@@ -11,114 +11,95 @@ export type OptionProps = {
1111} ;
1212
1313const getBackgroundColor = ( {
14- theme ,
15- disabled ,
16- red,
17- secondary ,
18- danger ,
14+ disabled = false ,
15+ secondary = false ,
16+ red = false ,
17+ danger = false ,
18+ theme = { } ,
1919} : OptionProps ) => {
20- if ( disabled )
21- return css `
22- background-color: ${ theme . light
20+ switch ( true ) {
21+ case disabled :
22+ return theme . light
2323 ? css `rgba(0, 0, 0, 0.4)`
24- : theme . background2 . darken ( 0.3 ) ( ) } ;
25- ` ;
26- if ( danger ) {
27- return css `
28- background-color: ${ theme . dangerBackground ( ) } ;
29- ` ;
30- }
31- if ( secondary ) {
32- return css `
33- background-color: transparent;
34- ` ;
24+ : theme . background2 . darken ( 0.3 ) ( ) ;
25+ case danger :
26+ return theme . dangerBackground ( ) ;
27+ case secondary :
28+ return css `transparent` ;
29+ case red :
30+ return theme . red . darken ( 0.2 ) ( ) ;
31+ case theme [ `button.background` ] :
32+ return theme [ `button.background` ] ;
33+ default :
34+ return css `#40a9f3; `;
3535 }
36- if ( red ) {
37- return css `
38- background-color: ${ theme . red . darken ( 0.2 ) ( ) } ;
39- ` ;
40- }
41- if ( theme [ `button.background` ] ) {
42- return css `
43- background-color: ${ theme [ `button.background` ] } ;
44- ` ;
45- }
46- return css `
47- background-color: #40a9f3;
48- ` ;
4936} ;
5037
5138const getBackgroundHoverColor = ( {
52- theme ,
53- disabled ,
54- red,
55- secondary ,
56- danger ,
39+ disabled = false ,
40+ secondary = false ,
41+ red = false ,
42+ danger = false ,
43+ theme = { } ,
5744} : OptionProps ) => {
58- if ( disabled )
59- return css `
60- background-color: ${ theme . light
45+ switch ( true ) {
46+ case disabled :
47+ return theme . light
6148 ? css `rgba(0, 0, 0, 0.4)`
62- : theme . background2 . darken ( 0.3 ) ( ) } ;
63- ` ;
64- if ( danger ) {
65- return css `
66- background-color: #e25d6a;
67- ` ;
68- }
69- if ( secondary ) {
70- return css `
71- background-color: #66b9f4;
72- ` ;
73- }
74- if ( red ) {
75- return css `
76- background-color: #f27777;
77- ` ;
49+ : theme . background2 . darken ( 0.3 ) ( ) ;
50+ case danger :
51+ return css ` #e25d6a;` ;
52+ case secondary :
53+ return css `#66b9f4;` ;
54+ case red :
55+ return css `#f27777; ` ;
56+ case theme [ `button.background` ] :
57+ return theme [ `button.hoverBackground` ] ;
58+ default :
59+ return css `#66b9f4;` ;
7860 }
79- if ( theme [ `button.hoverBackground` ] ) {
80- return css `
81- background-color: ${ theme [ `button.hoverBackground` ] } ;
82- ` ;
83- }
84- return css `
85- background-color: #66b9f4;
86- ` ;
8761} ;
8862
89- const getColor = ( { disabled, secondary, theme } : OptionProps ) => {
90- if ( disabled ) {
91- return theme . background2 . lighten ( 1.5 ) ( ) ;
92- }
93- if ( secondary ) {
94- return theme . light ? `rgba(0, 0, 0, 0.75)` : `rgba(255, 255, 255, 0.75)` ;
63+ const getColor = ( {
64+ disabled = false ,
65+ secondary = false ,
66+ theme = { } ,
67+ } : OptionProps ) => {
68+ switch ( true ) {
69+ case disabled :
70+ return theme . background2 . lighten ( 1.5 ) ( ) ;
71+ case secondary :
72+ return theme . light
73+ ? css `rgba(0, 0, 0, 0.75)`
74+ : css `rgba(255, 255, 255, 0.75)` ;
75+ default :
76+ return css `white` ;
9577 }
96- return `white` ;
9778} ;
9879
9980const getBorder = ( {
100- theme ,
101- secondary,
102- danger ,
103- red ,
104- disabled ,
81+ disabled = false ,
82+ secondary = false ,
83+ red = false ,
84+ danger = false ,
85+ theme = { } ,
10586} : OptionProps ) => {
106- if ( disabled ) {
107- return theme . light ? `2px solid rgba(0, 0, 0, 0.3)` : `2px solid #161A1C` ;
108- }
109- if ( secondary ) {
110- return `2px solid #66B9F4` ;
111- }
112- if ( red ) {
113- return `2px solid #F27777` ;
87+ switch ( true ) {
88+ case disabled :
89+ return theme . light
90+ ? css `2px solid rgba(0, 0, 0, 0.3)`
91+ : css `2px solid #161A1C` ;
92+ case secondary :
93+ return css `2px solid #66B9F4` ;
94+ case red :
95+ return css `2px solid #F27777` ;
96+ case danger :
97+ return css `2px solid #E25D6A` ;
98+ case theme [ `button.hoverBackground` ] :
99+ return css `2px solid ${ theme [ `button.hoverBackground` ] } ` ;
100+ default :
101+ return css `2px solid #66B9F4` ;
114102 }
115- if ( danger ) {
116- return `2px solid #E25D6A` ;
117- }
118- if ( theme && theme [ `button.hoverBackground` ] ) {
119- return `2px solid ${ theme [ `button.hoverBackground` ] } ` ;
120- }
121- return `2px solid #66B9F4` ;
122103} ;
123104
124105export interface IBaseProps {
@@ -137,36 +118,46 @@ export const buttonStyles = ({
137118 block = false ,
138119 small = false ,
139120} ) => css `
140- display: inline-flex;
121+ display: ${ block ? css `flex` : css ` inline-flex` } ;
141122 justify-content: center;
142123 align-items: center;
143- width: ${ block ? ' 100%' : ' inherit' } ;
144- padding: ${ small ? `0.5em 0.7em` : `0.65em 2.25em` } ;
124+ width: ${ block ? css ` 100%` : css ` inherit` } ;
125+ padding: ${ small ? css `0.5em 0.7em` : css `0.65em 2.25em` } ;
145126 border: ${ getBorder } ;
146127 border-radius: 4px;
147- ${ getBackgroundColor } ;
128+ background-color: ${ getBackgroundColor } ;
148129 box-sizing: border-box;
130+ overflow: hidden;
149131 color: ${ getColor } ;
150132 font-family: Poppins, Roboto, sans-serif;
151133 font-weight: 600;
152134 font-size: ${ small ? css `0.875em` : css `1.125em` } ;
153- line-height: 24px ;
135+ white-space: nowrap ;
154136 text-align: center;
155137 text-decoration: none;
156- white-space: nowrap ;
138+ text-overflow: ellipsis ;
157139 transition: 0.3s ease all;
158140 user-select: none;
159141 outline: none;
160- ${ ! disabled && `cursor: pointer;` } ;
142+ ${ ! disabled &&
143+ css `
144+ cursor: pointer;
145+ ` } ;
146+
147+ -webkit-appearance: inherit !important;
161148
162149 &:focus {
163150 outline: none;
164151 }
165152
166153 &:hover,
167154 &:focus {
168- ${ getBackgroundHoverColor } ;
169- ${ secondary ? `color: white` : `` } ;
155+ background-color: ${ getBackgroundHoverColor } ;
156+ ${ secondary
157+ ? css `
158+ color: white;
159+ `
160+ : `` } ;
170161 }
171162` ;
172163
0 commit comments