Skip to content

Commit be0f1bd

Browse files
chore: single component with shimmer animation
1 parent a849bc4 commit be0f1bd

File tree

2 files changed

+41
-32
lines changed

2 files changed

+41
-32
lines changed

src/features/Navigation/SlotsRenderer.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,20 +257,20 @@ export function SlotsPlaceholder({
257257
width={`${width - 1}px`}
258258
height={`${height}px`}
259259
overflow="hidden"
260+
className={styles.scrollSlotsPlaceholder}
260261
>
261-
{Array.from({ length: items }, (_, index) => (
262-
<MScrollPlaceholderItem key={index} />
263-
))}
262+
<div className={clsx(styles.absoluteFullSize, styles.shimmer)} />
263+
<div className={styles.absoluteFullSize}>
264+
{Array.from({ length: items }, (_, index) => (
265+
<MScrollPlaceholderItem key={index} />
266+
))}
267+
</div>
264268
</Box>
265269
);
266270
}
267271

268272
export const MScrollPlaceholderItem = memo(function ScrollPlaceholderItem() {
269-
return (
270-
<Box height="46px" className={styles.slotGroupContainer}>
271-
<div className={clsx(styles.slotGroup, styles.scrollPlaceholderItem)} />
272-
</Box>
273-
);
273+
return <div className={styles.scrollPlaceholderItem} />;
274274
});
275275

276276
function SlotIconName({

src/features/Navigation/slotsRenderer.module.css

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -168,33 +168,42 @@
168168
}
169169
}
170170

171-
.scroll-placeholder-item {
172-
position: relative;
173-
overflow: hidden;
174-
height: 100%;
175-
}
176-
177-
.scroll-placeholder-item::before {
178-
content: "";
179-
position: absolute;
180-
top: 0;
181-
left: -150%;
182-
width: 200%;
183-
height: 100%;
184-
background: linear-gradient(
185-
to right,
186-
rgba(255, 255, 255, 0) 0%,
187-
rgba(255, 246, 246, 0.05) 50%,
188-
rgba(255, 255, 255, 0) 100%
189-
);
190-
animation: shimmer 1.5s infinite;
191-
}
192-
193171
@keyframes shimmer {
194172
from {
195-
left: -100%;
173+
transform: translateX(0%);
196174
}
197175
to {
198-
left: 100%;
176+
transform: translateX(200%);
199177
}
200178
}
179+
180+
.scroll-slots-placeholder {
181+
background: var(--slots-list-slot-background-color);
182+
183+
.absolute-full-size {
184+
position: absolute;
185+
top: 0;
186+
left: 0;
187+
width: 100%;
188+
height: 100%;
189+
}
190+
191+
.shimmer {
192+
margin-left: -100%;
193+
will-change: transform;
194+
background: linear-gradient(
195+
to right,
196+
rgba(255, 255, 255, 0) 0%,
197+
rgba(255, 246, 246, 0.05) 50%,
198+
rgba(255, 255, 255, 0) 100%
199+
);
200+
animation: shimmer 1.5s infinite;
201+
}
202+
}
203+
204+
.scroll-placeholder-item {
205+
height: 46px;
206+
margin-bottom: 5px;
207+
border-radius: 5px;
208+
box-shadow: 0 0 0 4px var(--slot-nav-background-color);
209+
}

0 commit comments

Comments
 (0)