Skip to content

Commit 673e772

Browse files
authored
Merge pull request #89 from iranpsc/feat/Skeleton
2 parents 7dca73f + 8fed8a4 commit 673e772

56 files changed

Lines changed: 2425 additions & 633 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 77 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Button.jsx

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import styled from "styled-components";
2-
import loaderGif from "../assets/gif/ajax-loader.gif";
32

43
const ButtonElement = styled.button`
54
border-radius: 10px;
65
white-space: nowrap;
76
background-color: ${(props) =>
87
props.color
9-
? props.disabled
10-
? `${props.color}80` // Add 50% transparency when disabled
11-
: props.color
8+
? props.disabled === "pending"
9+
? props.color // همان رنگ اصلی، فقط مات میشه
10+
: props.disabled
11+
? `${props.color}80`
12+
: props.color
1213
: props.grayTheme
1314
? props.theme.colors.newColors.otherColors.garyBtn
1415
: props.disabled === "pending"
15-
? "#3B3B3B"
16-
: props.theme.colors.primary};
16+
? props.theme.colors.primary // رنگ اصلی، فقط مات میشه
17+
: props.disabled
18+
? `${props.theme.colors.primary}80`
19+
: props.theme.colors.primary};
1720
border: none;
1821
padding: ${(props) => (props.large ? "0 20px" : "10px 22px")};
1922
width: ${(props) =>
@@ -32,7 +35,7 @@ const ButtonElement = styled.button`
3235
cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
3336
color: ${(props) =>
3437
props.disabled === "pending"
35-
? "#949494"
38+
? props.theme.colors.newColors.primaryText
3639
: props.grayTheme
3740
? props.theme.colors.newColors.otherColors.grayBtnText
3841
: props.theme.colors.newColors.primaryText};
@@ -41,8 +44,10 @@ const ButtonElement = styled.button`
4144
display: flex;
4245
align-items: center;
4346
justify-content: center;
44-
opacity: ${(props) => (props.disabled ? "0.5" : "1")};
47+
gap: 8px;
48+
opacity: ${(props) => (props.disabled === "pending" ? "0.6" : props.disabled ? "0.5" : "1")};
4549
pointer-events: ${(props) => (props.disabled ? "none" : "auto")};
50+
4651
@media (max-width: 840px) {
4752
width: ${(props) => (props.row ? "55px" : props.full && "100%")};
4853
height: ${(props) => props.row && "35px"};
@@ -52,10 +57,21 @@ const ButtonElement = styled.button`
5257
@media (min-width: 998px) {
5358
height: ${(props) => (props.large ? "40px" : "50px")};
5459
}
55-
& img {
56-
width: 25px;
57-
height: 25px;
58-
margin: 0 3px;
60+
`;
61+
62+
// اسپینر دایره‌ای
63+
const Spinner = styled.span`
64+
width: 18px;
65+
height: 18px;
66+
border: 2px solid rgba(255, 255, 255, 0.5);
67+
border-top: 2px solid white;
68+
border-radius: 50%;
69+
animation: spin 0.8s linear infinite;
70+
display: inline-block;
71+
72+
@keyframes spin {
73+
0% { transform: rotate(0deg); }
74+
100% { transform: rotate(360deg); }
5975
}
6076
`;
6177

@@ -91,9 +107,9 @@ const Button = ({
91107
style={style}
92108
>
93109
{label}
94-
{disabled === "pending" && <img src={loaderGif} alt="Loading..." />}
110+
{disabled === "pending" && <Spinner />}
95111
</ButtonElement>
96112
);
97113
};
98114

99-
export default Button;
115+
export default Button;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import styled, { keyframes } from "styled-components";
2+
import Container from "./Container";
3+
4+
const shimmer = keyframes`
5+
0% { background-position: -1000px 0; }
6+
100% { background-position: 1000px 0; }
7+
`;
8+
9+
const LoadingContainer = styled(Container)`
10+
display: flex;
11+
gap: 20px;
12+
13+
`;
14+
15+
const SkeletonCard = styled.div`
16+
flex: 1;
17+
height: 66px;
18+
border-radius: 4px;
19+
background: linear-gradient(
20+
90deg,
21+
${(props) => props.theme.colors.newColors.shades.bg02},
22+
${(props) => props.theme.colors.newColors.shades.bg002},
23+
${(props) => props.theme.colors.newColors.shades.bg0002}
24+
);
25+
background-size: 1000px 100%;
26+
animation: ${shimmer} 1.2s infinite linear;
27+
`;
28+
29+
const SkeletonGrid = ({ count = 2 }) => {
30+
return (
31+
<LoadingContainer>
32+
{Array.from({ length: count }).map((_, i) => (
33+
<SkeletonCard key={i} />
34+
))}
35+
</LoadingContainer>
36+
);
37+
};
38+
39+
export default SkeletonGrid;

0 commit comments

Comments
 (0)