Skip to content

Commit

Permalink
fix; improve skeleton achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Oct 2, 2023
1 parent def996c commit 447d1ca
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 34 deletions.
49 changes: 24 additions & 25 deletions components/skeletons/achievementSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
import React, { FunctionComponent } from "react";
import { Skeleton, useMediaQuery } from "@mui/material";
import { Skeleton } from "@mui/material";
import styles from "../../styles/achievements.module.css";

const AchievementSkeleton: FunctionComponent = () => {
const isMobile = useMediaQuery("(max-width:768px)");
return (
<>
<Skeleton
variant="rounded"
width={1000}
height={isMobile ? 400 : 245}
sx={{
bgcolor: "grey.900",
marginBottom: "40px",
borderRadius: "30px",
maxWidth: `${isMobile ? "100%" : "min(1500px, calc(100% - 32px))"}`,
margin: "0 auto 40px",
}}
/>
<Skeleton
variant="rounded"
width={1000}
height={isMobile ? 400 : 245}
sx={{
bgcolor: "grey.900",
borderRadius: "30px",
maxWidth: `${isMobile ? "100%" : "min(1500px, calc(100% - 32px))"}`,
margin: "0 auto",
}}
/>
<div className={styles.achievementSkeleton}>
<Skeleton
variant="rounded"
className={styles.achievementLoading}
sx={{
bgcolor: "grey.900",
borderRadius: "30px",
margin: "40px auto 0",
}}
/>
</div>
<div className={styles.achievementSkeleton}>
<Skeleton
variant="rounded"
className={styles.achievementLoading}
sx={{
bgcolor: "grey.900",
borderRadius: "30px",
margin: "10px auto 0",
}}
/>
</div>
</>
);
};
Expand Down
18 changes: 9 additions & 9 deletions pages/achievements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ const Achievements: NextPage = () => {
Complete achievements and grow your Starknet on-chain reputation
</p>
</div>
<div className={styles.cardWrapper}>
<div className={styles.cards}>
{userAchievements.length > 0 ? (
userAchievements.map(
{userAchievements.length > 0 ? (
<div className={styles.cardWrapper}>
<div className={styles.cards}>
{userAchievements.map(
(achievementCategory: AchievementsDocument, index: number) => {
return (
<Achievement
Expand All @@ -117,12 +117,12 @@ const Achievements: NextPage = () => {
/>
);
}
)
) : (
<AchievementSkeleton />
)}
)}
</div>
</div>
</div>
) : (
<AchievementSkeleton />
)}
</div>
</div>
);
Expand Down
15 changes: 15 additions & 0 deletions styles/achievements.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,21 @@ background: linear-gradient(
opacity: 0.8;
}

.achievementSkeleton {
height: 250px;
position: relative;
overflow: hidden;
width: 100%;
}

.achievementLoading {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 80%;
}

@media (max-width: 768px) {
.container {
padding: 0;
Expand Down

0 comments on commit 447d1ca

Please sign in to comment.