@@ -16,14 +16,10 @@ export type ButtonProps = React.HTMLAttributes<
16
16
} ;
17
17
18
18
export const Button = ( props : ButtonProps ) => {
19
- const { variant, accent } = props ;
20
- const ButtonElement = createButtonElement ( props ) ;
21
- return < ButtonElement { ...props } /> ;
19
+ return < ButtonElement as = { props . href ? "a" : "button" } { ...props } /> ;
22
20
} ;
23
21
24
- const createButtonElement = ( props : ButtonProps ) => styled (
25
- props . href ? "a" : "button"
26
- ) < ButtonProps > `
22
+ const ButtonElement = styled . button < ButtonProps > `
27
23
font-size: ${ ( props ) => {
28
24
if ( props . size === "small" ) return "0.75em" ;
29
25
if ( props . size === "large" ) return "1.25em" ;
@@ -66,17 +62,24 @@ const createButtonElement = (props: ButtonProps) => styled(
66
62
border: ${ ( props ) => {
67
63
if ( props . variant !== "outlined" ) return "none" ;
68
64
return `1px solid ${
69
- props . theme [ props . accent || "info" ] ?? getThemeValue ( props . accent || "info" )
65
+ props . theme [ props . accent || "info" ] ??
66
+ getThemeValue ( props . accent || "info" )
70
67
} `;
71
68
} } ;
72
69
background-color: ${ ( props ) => {
73
70
if ( props . variant === "contained" )
74
- return props . theme [ props . accent || "info" ] ?? getThemeValue ( props . accent || "info" ) ;
71
+ return (
72
+ props . theme [ props . accent || "info" ] ??
73
+ getThemeValue ( props . accent || "info" )
74
+ ) ;
75
75
return "transparent" ;
76
76
} } ;
77
77
color: ${ ( props ) => {
78
78
if ( props . variant === "contained" ) return "#fff" ;
79
- return props . theme [ props . accent || "info" ] ?? getThemeValue ( props . accent || "info" ) ;
79
+ return (
80
+ props . theme [ props . accent || "info" ] ??
81
+ getThemeValue ( props . accent || "info" )
82
+ ) ;
80
83
} } ;
81
84
82
85
&:disabled {
@@ -99,15 +102,17 @@ const createButtonElement = (props: ButtonProps) => styled(
99
102
filter: drop-shadow(
100
103
0em 0.125em 0.625em
101
104
${ ( props ) =>
102
- props . theme [ props . accent || "info" ] ?? getThemeValue ( props . accent || "info" ) } 80
105
+ props . theme [ props . accent || "info" ] ??
106
+ getThemeValue ( props . accent || "info" ) } 80
103
107
)
104
108
brightness(110%);
105
109
}
106
110
&:active:not(:disabled) {
107
111
filter: drop-shadow(
108
112
0em 0.0625em 0.3125em
109
113
${ ( props ) =>
110
- props . theme [ props . accent || "info" ] ?? getThemeValue ( props . accent || "info" ) } 80
114
+ props . theme [ props . accent || "info" ] ??
115
+ getThemeValue ( props . accent || "info" ) } 80
111
116
)
112
117
brightness(80%);
113
118
}
0 commit comments