Skip to content

Commit

Permalink
feat: add usePlaceholder to allow users to not use the blurred plac…
Browse files Browse the repository at this point in the history
…eholder
  • Loading branch information
dbismut committed Jan 2, 2022
1 parent 795dcd1 commit 4e8dbce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type ImagePropTypes = {
explicitWidth?: boolean;
/** Triggered when the image finishes loading */
onLoad?(): void;
/** Whether the image should use a blurred image placeholder */
usePlaceholder?: boolean;
};

type State = {
Expand Down Expand Up @@ -116,6 +118,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
explicitWidth,
data,
onLoad,
usePlaceholder = true,
},
ref
) => {
Expand Down Expand Up @@ -170,7 +173,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
const transition =
fadeInDuration > 0 ? `opacity ${fadeInDuration}ms` : undefined;

const placeholder = (
const placeholder = usePlaceholder ? (
<div
style={{
backgroundImage: data.base64 ? `url(${data.base64})` : undefined,
Expand All @@ -181,7 +184,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
...absolutePositioning,
}}
/>
);
) : null;

const { width, aspectRatio } = data;
const height = data.height || width / aspectRatio;
Expand Down

0 comments on commit 4e8dbce

Please sign in to comment.