Skip to content

Commit 69dfbdf

Browse files
authored
Merge pull request #88 from 01-binary/skeleton-fix
Skeleton fix
2 parents 4f2d748 + 5cb32ae commit 69dfbdf

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

.changeset/few-olives-like.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"notion-to-jsx": patch
3+
---
4+
5+
add loading state to image skeleton component

packages/notion-to-jsx/src/components/Cover/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Cover = ({ src, alt }: Props) => {
1717
return (
1818
<div className={coverContainer}>
1919
<div className={skeletonWrapper({ isLoaded })}>
20-
<Skeleton variant="image" />
20+
<Skeleton variant="image" isLoading={!isLoaded} />
2121
</div>
2222
<img
2323
src={src}

packages/notion-to-jsx/src/components/Renderer/components/Image/Image.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const Image = ({
4747
<div className={imageContainer}>
4848
<div className={imageWrapper} style={getImageStyles(format, isColumn)}>
4949
<div className={skeletonWrapper({ isLoaded })}>
50-
<Skeleton variant="image" />
50+
<Skeleton variant="image" isLoading={!isLoaded} />
5151
</div>
5252
<img
5353
className={imageStyle({

packages/notion-to-jsx/src/components/Skeleton/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ type SkeletonProps = {
1818
* 추가 CSS 클래스명
1919
*/
2020
className?: string;
21+
/**
22+
* 로딩 상태
23+
*/
24+
isLoading?: boolean;
2125
};
2226

2327
/**
@@ -29,6 +33,7 @@ const Skeleton = ({
2933
width,
3034
height,
3135
className,
36+
isLoading = true,
3237
}: SkeletonProps) => {
3338
const getVariantClass = () => {
3439
switch (variant) {
@@ -42,6 +47,10 @@ const Skeleton = ({
4247
}
4348
};
4449

50+
if (!isLoading) {
51+
return null;
52+
}
53+
4554
return (
4655
<div
4756
className={`${styles.skeleton} ${getVariantClass()} ${className || ''}`}

0 commit comments

Comments
 (0)