11import styled from "styled-components" ;
2- import loaderGif from "../assets/gif/ajax-loader.gif" ;
32
43const 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 ;
0 commit comments