Skip to content

Commit

Permalink
[EmptyState] Manually set height
Browse files Browse the repository at this point in the history
  • Loading branch information
laurkim committed Mar 29, 2024
1 parent 2d121d1 commit afc2eb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
4 changes: 4 additions & 0 deletions polaris-react/src/components/EmptyState/EmptyState.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.Image {
height: 226px;
}

.imageContained {
@media (--p-breakpoints-md-up) {
position: initial;
Expand Down
15 changes: 2 additions & 13 deletions polaris-react/src/components/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState, useEffect} from 'react';
import React from 'react';

import {classNames} from '../../utilities/css';
import type {ComplexAction} from '../../types';
Expand Down Expand Up @@ -46,19 +46,8 @@ export function EmptyState({
secondaryAction,
footerContent,
}: EmptyStateProps) {
const [imageLoaded, setImageLoaded] = useState<boolean>(false);

useEffect(() => {
const img: HTMLImageElement = new window.Image(0, 0);
img.src = largeImage || image;
img.onload = () => {
setImageLoaded(true);
};
}, [largeImage, image]);

if (!imageLoaded) return null;

const imageContainedClass = classNames(
styles.Image,
imageContained && styles.imageContained,
);

Expand Down

0 comments on commit afc2eb1

Please sign in to comment.