fix skeletons

This commit is contained in:
keyan 2021-04-28 17:52:03 -05:00
parent eb329f4cae
commit 2da1ee1a4b
7 changed files with 32 additions and 14 deletions

View File

@ -97,30 +97,34 @@ export default function Comment ({ item, children, replyOpen, includeParent, cac
} }
export function CommentSkeleton ({ skeletonChildren }) { export function CommentSkeleton ({ skeletonChildren }) {
const comments = skeletonChildren ? new Array(2).fill(null) : [] const comments = skeletonChildren > 0 ? new Array(skeletonChildren).fill(null) : []
return ( return (
<> <div className={styles.comment}>
<div className={`${itemStyles.item} ${itemStyles.skeleton} ${styles.item} ${styles.skeleton}`}> <div className={`${itemStyles.item} ${itemStyles.skeleton} ${styles.item} ${styles.skeleton}`}>
<UpVote className={styles.upvote} /> <UpVote className={styles.upvote} />
<div className={`${itemStyles.hunk} ${styles.hunk}`}> <div className={`${itemStyles.hunk} ${styles.hunk}`}>
<div className={itemStyles.other}> <div className={itemStyles.other}>
<span className={`${itemStyles.otherItem} ${itemStyles.otherItemLonger} clouds`} /> <span className={`${itemStyles.otherItem} clouds`} />
<span className={`${itemStyles.otherItem} clouds`} />
<span className={`${itemStyles.otherItem} clouds`} /> <span className={`${itemStyles.otherItem} clouds`} />
<span className={`${itemStyles.otherItem} ${itemStyles.otherItemLonger} clouds`} /> <span className={`${itemStyles.otherItem} ${itemStyles.otherItemLonger} clouds`} />
</div> </div>
<div className={`${styles.text} clouds`} /> <div className={`${styles.text} clouds`} />
</div> </div>
</div> </div>
<div className={`${itemStyles.children} ${styles.children}`}> <div className={`${itemStyles.children} ${styles.children} ${styles.skeleton}`}>
<div className={styles.comments}> <div className={styles.replyPadder}>
<div className={`${itemStyles.other} ${styles.reply} clouds`} />
</div>
<div className={`${styles.comments} ml-sm-1 ml-md-3`}>
{comments {comments
? comments.map((_, i) => ( ? comments.map((_, i) => (
<CommentSkeleton key={i} /> <CommentSkeleton key={i} skeletonChildren={skeletonChildren - 1} />
)) ))
: null} : null}
</div> </div>
</div> </div>
</> </div>
) )
} }

View File

@ -8,6 +8,7 @@
.text { .text {
margin-top: .1rem; margin-top: .1rem;
padding-right: .75rem;
} }
.reply { .reply {
@ -29,8 +30,20 @@
} }
.skeleton .text { .skeleton .text {
height: 100px; height: 80px;
border-radius: .4rem; border-radius: .4rem;
margin-right: .75rem;
}
.skeleton .reply {
width: 45px;
height: 10px;
border-radius: .2rem;
}
.replyPadder {
padding: .25rem 0;
padding-bottom: .5rem;
} }
.comment { .comment {

View File

@ -8,10 +8,10 @@ export default function Comments ({ comments, ...props }) {
} }
export function CommentsSkeleton () { export function CommentsSkeleton () {
const comments = new Array(3).fill(null) const comments = new Array(1).fill(null)
return comments.map((_, i) => ( return comments.map((_, i) => (
<CommentSkeleton key={i} skeletonChildren /> <CommentSkeleton key={i} skeletonChildren={2} />
)) ))
} }

View File

@ -18,7 +18,7 @@ export default function Header () {
if (session) { if (session) {
return ( return (
<NavDropdown eventKey={'/' + session.user.name} title={`@${session.user.name}`} alignRight> <NavDropdown title={`@${session.user.name}`} alignRight>
<Link href={'/' + session.user.name} passHref> <Link href={'/' + session.user.name} passHref>
<NavDropdown.Item>profile</NavDropdown.Item> <NavDropdown.Item>profile</NavDropdown.Item>
</Link> </Link>

View File

@ -64,6 +64,7 @@ export function ItemSkeleton ({ rank, children }) {
<span className={`${styles.link} clouds`} /> <span className={`${styles.link} clouds`} />
</div> </div>
<div className={styles.other}> <div className={styles.other}>
<span className={`${styles.otherItem} clouds`} />
<span className={`${styles.otherItem} clouds`} /> <span className={`${styles.otherItem} clouds`} />
<span className={`${styles.otherItem} ${styles.otherItemLonger} clouds`} /> <span className={`${styles.otherItem} ${styles.otherItemLonger} clouds`} />
<span className={`${styles.otherItem} ${styles.otherItemLonger} clouds`} /> <span className={`${styles.otherItem} ${styles.otherItemLonger} clouds`} />

View File

@ -67,7 +67,7 @@
height: 14px; height: 14px;
background-color: grey; background-color: grey;
width: 800px; width: 800px;
border-radius: .4rem; border-radius: .3rem;
margin: 3px 0px; margin: 3px 0px;
} }
@ -75,7 +75,7 @@
display: inline-flex; display: inline-flex;
width: 42px; width: 42px;
height: 70%; height: 70%;
border-radius: .4rem; border-radius: .27rem;
background-color: grey; background-color: grey;
margin-right: .5rem; margin-right: .5rem;
} }

View File

@ -48,7 +48,7 @@ function LoadItem ({ query }) {
<ItemSkeleton> <ItemSkeleton>
<ReplySkeleton /> <ReplySkeleton />
</ItemSkeleton> </ItemSkeleton>
<div className='mt-5'> <div className={styles.comments}>
<CommentsSkeleton /> <CommentsSkeleton />
</div> </div>
</div> </div>