Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 59e40d5

Browse files
ahmehrimontezume
authored andcommittedJun 18, 2019
style(flat-button): implement inverted tone (#869)
feat(flat-button): implement inverted tone
1 parent 7db6786 commit 59e40d5

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed
 

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@ const getIconElement = props => {
1616
});
1717
};
1818

19-
const getTextColor = (tone, isHover = false) => {
19+
const getTextColor = (tone, isHover = false, theme) => {
20+
const overwrittenVars = {
21+
...vars,
22+
...theme,
23+
};
24+
2025
switch (tone) {
2126
case 'primary':
22-
return isHover ? vars.colorPrimary25 : vars.colorPrimary;
27+
return isHover
28+
? overwrittenVars.colorPrimary25
29+
: overwrittenVars.colorPrimary;
2330
case 'secondary':
24-
return vars.colorSolid;
31+
return overwrittenVars.colorSolid;
2532
default:
2633
return 'inherit';
2734
}
@@ -40,38 +47,39 @@ export const FlatButton = props => {
4047
label={props.label}
4148
onClick={props.onClick}
4249
isDisabled={props.isDisabled}
43-
css={css`
50+
css={theme => css`
4451
display: flex;
4552
align-items: center;
4653
font-size: 1rem;
4754
border: none;
4855
background: none;
4956
padding: 0;
5057
min-height: initial;
58+
5159
p {
5260
color: ${props.isDisabled
5361
? vars.colorNeutral
54-
: getTextColor(props.tone)};
62+
: getTextColor(props.tone, false, theme)};
5563
}
5664
5765
svg * {
5866
fill: ${props.isDisabled
5967
? vars.colorNeutral
60-
: getTextColor(props.tone, false)};
68+
: getTextColor(props.tone, false, theme)};
6169
}
6270
6371
&:hover,
6472
&:focus {
6573
p {
6674
color: ${props.isDisabled
6775
? vars.colorNeutral
68-
: getTextColor(props.tone, true)};
76+
: getTextColor(props.tone, true, theme)};
6977
}
7078
7179
svg * {
7280
fill: ${props.isDisabled
7381
? vars.colorNeutral
74-
: getTextColor(props.tone, true)};
82+
: getTextColor(props.tone, true, theme)};
7583
}
7684
}
7785
`}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
2+
import { ThemeProvider } from 'emotion-theming';
23
import { FlatButton, InformationIcon } from 'ui-kit';
34
import { Suite, Spec } from '../../../../test/percy';
45

56
export const routePath = '/flat-button';
67

7-
export const component = () => (
8+
export const component = ({ themes }) => (
89
<Suite>
910
<Spec label="regular">
1011
<FlatButton tone="primary" label="A label text" onClick={() => {}} />
@@ -42,5 +43,15 @@ export const component = () => (
4243
icon={<InformationIcon />}
4344
/>
4445
</Spec>
46+
<ThemeProvider theme={themes.darkTheme}>
47+
<Spec label="secondary">
48+
<FlatButton
49+
tone="secondary"
50+
label="Inverted"
51+
onClick={() => {}}
52+
icon={<InformationIcon />}
53+
/>
54+
</Spec>
55+
</ThemeProvider>
4556
</Suite>
4657
);

0 commit comments

Comments
 (0)