feat: Skeleton Common

This commit is contained in:
sonnguyenkieio 2021-09-14 14:39:31 +07:00
parent 2656c56a6f
commit 8d463e537d
4 changed files with 8 additions and 16 deletions

View File

@ -1,6 +1,6 @@
@import '../../../../styles/utilities';
.skeletonImage:empty {
.skeletonImage {
@apply relative;
background: #DDDBDD;

View File

@ -5,16 +5,14 @@ import s from './SkeletonImage.module.scss'
interface SkeletonImageProps {
align?: "left" | "center"
size?: "small" | "default" | "large"
children?: React.ReactNode
}
const SkeletonImage = ({ align="center", size="default", children }: SkeletonImageProps) => {
const SkeletonImage = ({ align="center", size="default" }: SkeletonImageProps) => {
return (
<div className={classNames(s.skeletonImage, {
[s[size]] : size,
[s[align]] : align
})}>
{children}
</div>
)
}

View File

@ -1,6 +1,8 @@
@import '../../../../styles/utilities';
.skeletonParagraph {
.skeletonParagraph {
margin: 0 1.6rem;
.row {
display: inline-block;
height: 2rem;

View File

@ -1,23 +1,15 @@
import React, { useEffect, useState } from "react";
import React from "react";
import s from './SkeletonParagraph.module.scss'
interface SkeletonParagraphProps {
rows?: number // number of rows in paragraph
children?: React.ReactNode
}
const SkeletonParagraph = ({ rows=2, children }: SkeletonParagraphProps) => {
const [isChildLoaded, setIsChildLoaded] = useState(false)
useEffect(() => {
setIsChildLoaded(true);
}, [])
const SkeletonParagraph = ({ rows=2 }: SkeletonParagraphProps) => {
return (
<div className={s.skeletonParagraph}>
{
isChildLoaded ? children : [...Array(rows)].map((e, i) => {
[...Array(rows)].map((e, i) => {
if (i === rows-1) {
return <div key={i} className={s.lastRow}></div>
}