Skip to content

Commit 8dabdc7

Browse files
authored
fix(flat-button): fully support theming (#1056)
1 parent 569d347 commit 8dabdc7

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

src/components/buttons/flat-button/flat-button.js

+35-33
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ const getIconElement = props => {
2323
});
2424
};
2525

26-
const getTextColor = (tone, isHover = false, theme) => {
27-
const overwrittenVars = {
28-
...vars,
29-
...theme,
30-
};
31-
26+
const getTextColor = (tone, isHover = false, overwrittenVars) => {
3227
switch (tone) {
3328
case 'primary':
3429
return isHover
@@ -54,42 +49,49 @@ export const FlatButton = props => {
5449
label={props.label}
5550
onClick={props.onClick}
5651
isDisabled={props.isDisabled}
57-
css={theme => css`
58-
display: flex;
59-
align-items: center;
60-
font-size: 1rem;
61-
border: none;
62-
background: none;
63-
padding: 0;
64-
min-height: initial;
65-
66-
p {
67-
color: ${props.isDisabled
68-
? vars.colorNeutral
69-
: getTextColor(props.tone, false, theme)};
70-
}
52+
css={theme => {
53+
const overwrittenVars = {
54+
...vars,
55+
...theme,
56+
};
7157

72-
svg * {
73-
fill: ${props.isDisabled
74-
? vars.colorNeutral
75-
: getTextColor(props.tone, false, theme)};
76-
}
58+
return css`
59+
display: flex;
60+
align-items: center;
61+
font-size: 1rem;
62+
border: none;
63+
background: none;
64+
padding: 0;
65+
min-height: initial;
7766
78-
&:hover,
79-
&:focus {
8067
p {
8168
color: ${props.isDisabled
82-
? vars.colorNeutral
83-
: getTextColor(props.tone, true, theme)};
69+
? overwrittenVars.colorNeutral
70+
: getTextColor(props.tone, false, overwrittenVars)};
8471
}
8572
8673
svg * {
8774
fill: ${props.isDisabled
88-
? vars.colorNeutral
89-
: getTextColor(props.tone, true, theme)};
75+
? overwrittenVars.colorNeutral
76+
: getTextColor(props.tone, false, overwrittenVars)};
77+
}
78+
79+
&:hover,
80+
&:focus {
81+
p {
82+
color: ${props.isDisabled
83+
? overwrittenVars.colorNeutral
84+
: getTextColor(props.tone, true, overwrittenVars)};
85+
}
86+
87+
svg * {
88+
fill: ${props.isDisabled
89+
? overwrittenVars.colorNeutral
90+
: getTextColor(props.tone, true, overwrittenVars)};
91+
}
9092
}
91-
}
92-
`}
93+
`;
94+
}}
9395
buttonAttributes={dataProps}
9496
>
9597
<Spacings.Inline scale="xs" alignItems="center">

0 commit comments

Comments
 (0)