mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +00:00
✨ feat: Skeleton Common
This commit is contained in:
parent
2656c56a6f
commit
8d463e537d
@ -1,6 +1,6 @@
|
|||||||
@import '../../../../styles/utilities';
|
@import '../../../../styles/utilities';
|
||||||
|
|
||||||
.skeletonImage:empty {
|
.skeletonImage {
|
||||||
@apply relative;
|
@apply relative;
|
||||||
background: #DDDBDD;
|
background: #DDDBDD;
|
||||||
|
|
||||||
|
@ -5,16 +5,14 @@ import s from './SkeletonImage.module.scss'
|
|||||||
interface SkeletonImageProps {
|
interface SkeletonImageProps {
|
||||||
align?: "left" | "center"
|
align?: "left" | "center"
|
||||||
size?: "small" | "default" | "large"
|
size?: "small" | "default" | "large"
|
||||||
children?: React.ReactNode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkeletonImage = ({ align="center", size="default", children }: SkeletonImageProps) => {
|
const SkeletonImage = ({ align="center", size="default" }: SkeletonImageProps) => {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(s.skeletonImage, {
|
<div className={classNames(s.skeletonImage, {
|
||||||
[s[size]] : size,
|
[s[size]] : size,
|
||||||
[s[align]] : align
|
[s[align]] : align
|
||||||
})}>
|
})}>
|
||||||
{children}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
@import '../../../../styles/utilities';
|
@import '../../../../styles/utilities';
|
||||||
|
|
||||||
.skeletonParagraph {
|
.skeletonParagraph {
|
||||||
|
margin: 0 1.6rem;
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
|
@ -1,23 +1,15 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React from "react";
|
||||||
import s from './SkeletonParagraph.module.scss'
|
import s from './SkeletonParagraph.module.scss'
|
||||||
|
|
||||||
interface SkeletonParagraphProps {
|
interface SkeletonParagraphProps {
|
||||||
rows?: number // number of rows in paragraph
|
rows?: number // number of rows in paragraph
|
||||||
children?: React.ReactNode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkeletonParagraph = ({ rows=2, children }: SkeletonParagraphProps) => {
|
const SkeletonParagraph = ({ rows=2 }: SkeletonParagraphProps) => {
|
||||||
|
|
||||||
const [isChildLoaded, setIsChildLoaded] = useState(false)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setIsChildLoaded(true);
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={s.skeletonParagraph}>
|
<div className={s.skeletonParagraph}>
|
||||||
{
|
{
|
||||||
isChildLoaded ? children : [...Array(rows)].map((e, i) => {
|
[...Array(rows)].map((e, i) => {
|
||||||
if (i === rows-1) {
|
if (i === rows-1) {
|
||||||
return <div key={i} className={s.lastRow}></div>
|
return <div key={i} className={s.lastRow}></div>
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user