Skip to content

Commit

Permalink
feat: skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
wkylin committed Dec 26, 2024
1 parent 5df95d1 commit 55900e3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/components/stateless/AnimateWave/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
opacity: 0;
position: absolute;
top: 2px;
box-shadow: 0 60px 25px -20px rgb(0 0 0 / 50%);
}

.droppingTexts > div:nth-child(1) {
Expand Down
17 changes: 17 additions & 0 deletions src/components/stateless/SkeletonFix/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'

Check failure on line 1 in src/components/stateless/SkeletonFix/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: Install the 'eslint' package
import styles from './index.module.less'

const SkeletonFix = () => {
return (
<div className={`${styles.placeholder} ${styles.shimmer}`}>
<div className={styles['faux-image-wrapper']}>
<div className={styles['faux-image']}></div>
</div>
<div className={styles['faux-text']}></div>
<div className={`${styles['faux-text']} ${styles.short}`}></div>
<div className={`${styles['faux-text']} ${styles['min-short']}`}></div>
</div>
)
}

export default SkeletonFix
63 changes: 63 additions & 0 deletions src/components/stateless/SkeletonFix/index.module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.placeholder {
width: 100%;
}

.faux-image-wrapper {
margin-bottom: 10px;
position: relative;
width: 100px;
height: 100px;
}

.faux-image {
background: #ddd;
border-radius: 4px;
position: absolute;
height: 100%;
width: 100%;
}

.faux-text {
background: #ddd;
border-radius: 4px;
height: 20px;
margin-bottom: 5px;
}

.faux-text.short {
width: 75%;
}

.faux-text.min-short {
width: 45%;
}

.shimmer {
overflow: hidden;
position: relative;
}

.shimmer::before {
content: '';
position: absolute;
background: linear-gradient(
90deg,
rgb(255 255 255 / 0%) 0%,
rgb(255 255 255 / 40%) 50%,
rgb(255 255 255 / 0%) 100%
);
height: 100%;
width: 100%;
z-index: 1;
animation: shimmer 1s infinite;
}

@keyframes shimmer {
0% {
transform: translateX(-100%);
}

100% {
transform: translateX(100%);
}
}
4 changes: 4 additions & 0 deletions src/pages/home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import ShiCode from '@stateless/ShiCode'
// import Masonry from '@container/masonryContainer'
import DynamicBackground from '@stateless/DynamicBackground'
import ContentPlaceholder from '@stateless/ContentPlaceholder'
import SkeletonFix from '@stateless/SkeletonFix'
import { oneApiChat, prettyObject, randomNum } from '@utils/aidFn'

Check warning on line 39 in src/pages/home/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import specifier randomNum
import { fireConfetti } from '@utils/confetti'

Expand Down Expand Up @@ -385,6 +386,9 @@ const Home = () => {
<section style={{ position: 'relative' }}>
<AnimateWave />
</section>
<section style={{ margin: 20 }}>
<SkeletonFix />
</section>
<section style={{ margin: 20 }}>
<ResponsiveMasonry columnsCountBreakPoints={{ 350: 1, 750: 2, 900: 6 }}>
<Masonry gutter="10px">
Expand Down

0 comments on commit 55900e3

Please sign in to comment.