Skip to content

Commit

Permalink
Refactor: 스켈레톤 로딩 CSS 변수화
Browse files Browse the repository at this point in the history
  • Loading branch information
soulchicken committed Oct 26, 2023
1 parent ed2aa64 commit 3377083
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 41 deletions.
27 changes: 5 additions & 22 deletions src/components/common/skeleton/RecommendBoxSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { loadingCSS } from '@/styles/GlobalStyles';
import color from '@/styles/color';
import { css } from '@emotion/react';

Expand Down Expand Up @@ -25,24 +26,6 @@ const recommendsCSS = css`
grid-template-columns: repeat(2, 1fr);
`;

const load = css`
@keyframes loading {
0% {
background-position: 0;
}
100% {
background-position: 480px;
}
}
animation: loading 10s infinite;
background: linear-gradient(
to right,
rgba(246, 247, 248, 0.8), rgba(204, 207, 208, 0.7) 50%, rgba(246, 247, 248, 0.8) 100%
);
background-size: 200% 100%;
`;

const boxCSS = css`
margin: 0.5rem;
padding: 1rem;
Expand All @@ -60,22 +43,22 @@ const imageWrapperCSS = css`
position: relative;
margin: 0.25rem;
border-radius: 50%;
${load}
${loadingCSS}
`;

const characterNameCSS = css`
width: 5rem;
height: 1rem;
border-radius: 1rem;
${load};
${loadingCSS};
`;

const hashTagCSS = css`
height: 0.75rem;
margin: 0.375rem;
width: 8rem;
border-radius: 0.75rem;
${load}
${loadingCSS}
`;

const statusMessageCSS = css`
Expand All @@ -85,5 +68,5 @@ const statusMessageCSS = css`
margin: 0.375rem;
border-radius: 0.875rem;
${load}
${loadingCSS}
`;
23 changes: 4 additions & 19 deletions src/components/common/skeleton/SkeletonList.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { loadingCSS } from '@/styles/GlobalStyles';
import { css } from '@emotion/react';

const SkeletonList = () => (
Expand All @@ -19,22 +20,6 @@ const SingleSkeleton = () => (
</div>
);

const load = css`
@keyframes loading {
0% {
background-position: 0;
}
100% {
background-position: 480px;
}
}
animation: loading 10s infinite;
background: linear-gradient(to right, #f2f2f2, #ddd, #f2f2f2);
background-size: 200% 100%;
`;

const friendCSS = css`
display:flex;
flex-direction:row;
Expand All @@ -47,7 +32,7 @@ const imageWrapperCSS = css`
position: relative;
margin: 0.375rem;
border-radius: 50%;
${load};
${loadingCSS};
`;

const textWrapperCSS = css`
Expand All @@ -63,12 +48,12 @@ const characterNameCSS = css`
width: 5rem;
height: 1rem;
border-radius: 1rem;
${load};
${loadingCSS};
`;

const messageCSS = css`
width: 15rem;
height: 0.75rem;
border-radius: 0.75rem;
${load};
${loadingCSS};
`;
20 changes: 20 additions & 0 deletions src/styles/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,23 @@ const GlobalStyles = () => (
);

export default GlobalStyles;

export const loadingCSS = css`
@keyframes loading {
0% {
background-position: 100% 0;
}
100% {
background-position: -100% 0;
}
}
animation: loading 4s infinite;
background: linear-gradient(
to right,
rgba(230, 233, 238, 0.9),
rgba(215, 218, 224, 0.95) 50%,
rgba(230, 233, 238, 0.9) 100%
);
background-size: 200% 100%;
`;

0 comments on commit 3377083

Please sign in to comment.