Skip to content

Skeleton fix #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/few-olives-like.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"notion-to-jsx": patch
---

add loading state to image skeleton component
2 changes: 1 addition & 1 deletion packages/notion-to-jsx/src/components/Cover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Cover = ({ src, alt }: Props) => {
return (
<div className={coverContainer}>
<div className={skeletonWrapper({ isLoaded })}>
<Skeleton variant="image" />
<Skeleton variant="image" isLoading={!isLoaded} />
</div>
<img
src={src}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Image = ({
<div className={imageContainer}>
<div className={imageWrapper} style={getImageStyles(format, isColumn)}>
<div className={skeletonWrapper({ isLoaded })}>
<Skeleton variant="image" />
<Skeleton variant="image" isLoading={!isLoaded} />
</div>
<img
className={imageStyle({
Expand Down
9 changes: 9 additions & 0 deletions packages/notion-to-jsx/src/components/Skeleton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type SkeletonProps = {
* 추가 CSS 클래스명
*/
className?: string;
/**
* 로딩 상태
*/
isLoading?: boolean;
};

/**
Expand All @@ -29,6 +33,7 @@ const Skeleton = ({
width,
height,
className,
isLoading = true,
}: SkeletonProps) => {
const getVariantClass = () => {
switch (variant) {
Expand All @@ -42,6 +47,10 @@ const Skeleton = ({
}
};

if (!isLoading) {
return null;
}

return (
<div
className={`${styles.skeleton} ${getVariantClass()} ${className || ''}`}
Expand Down