Skip to content

Commit

Permalink
feat(*): added skeleton component
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Dec 9, 2021
1 parent 3702310 commit 1137649
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Components/Skeleton/shimmer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import './skeleton.css';

const Shimmer = () => {
return (
<div className="shimmer-wrapper">
<div className="shimmer">

</div>
</div>
)
}

export default Shimmer;
79 changes: 79 additions & 0 deletions src/Components/Skeleton/skeleton.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.skeleton {
background: #ddd;
margin: 10px 0;
border-radius: 4px;
}

.skeleton-wrapper {
margin: 20px auto;
padding: 10px 15px;
position: relative;
background: #f2f2f2;
border-radius: 1%;
animation: loading 2.5s infinite;
}

.skeleton-wrapper.profile {
height: 100vh;
}

.skeleton-wrapper.profile .skeleton-card {
padding: 5%;
}

.skeleton-profile .skeleton.avatar {
width: 300px;
height: 300px;
padding-bottom: 5%;
}

.skeleton.text {
width: 100%;
height: 12px;
}

.skeleton.title {
width: 50%;
height: 20px;
margin-bottom: 15px;
}

.skeleton.avatar {
width: 100px;
height: 100px;
border-radius: 50%;
}

.skeleton.thumbnail {
width: 100px;
height: 100px;
}

.shimmer-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
/* overflow: hidden; */
}

.shimmer {
width: 50%;
height: 100%;
background-color: rgba(255, 255, 255, 0.2);
transform: skewX(-20deg);
box-shadow: 0 0 30px 30px rgba(255, 255, 255, 0.05);
}

@keyframes loading {
0% {
transition: translateX(-150%);
}
50% {
transition: translateX(-60%);
}
100% {
transition: translateX(150%);
}
}
19 changes: 19 additions & 0 deletions src/Components/Skeleton/skeletonCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import SkeletonElement from './skeletonElement';
import Shimmer from './shimmer';

const SkeletonCard = () => {
return (
<div className="skeleton-wrapper col-lg-5 ">
<div className="skeleton-card">
<SkeletonElement type="avatar"/>
<SkeletonElement type="title" />
<SkeletonElement type="text" />
<SkeletonElement type="text" />
</div>
<Shimmer/>
</div>
)
}

export default SkeletonCard;
12 changes: 12 additions & 0 deletions src/Components/Skeleton/skeletonElement.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import './skeleton.css';

const SkeletonElement = ({type}) => {
const classes = `skeleton ${type}`;

return (
<div className={classes}></div>
)
}

export default SkeletonElement;

0 comments on commit 1137649

Please sign in to comment.