Skip to content

Commit 9e9299b

Browse files
Merge pull request #381 from storybookjs/button-types
Add inverse and noChrome inverse button types
2 parents 5e13084 + 37c315f commit 9e9299b

2 files changed

Lines changed: 53 additions & 11 deletions

File tree

src/components/Button.stories.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ Basic.args = { children: 'Label' };
1616

1717
export const All = () => (
1818
<>
19-
<Button appearance="primary">Primary</Button>
20-
<Button appearance="secondary">Secondary</Button>
21-
<Button appearance="tertiary">Tertiary</Button>
22-
<Button appearance="outline">Outline</Button>
23-
<Button appearance="primaryOutline">Outline primary</Button>
24-
<Button appearance="secondaryOutline">Outline secondary</Button>
25-
<div style={{ background: 'grey', display: 'inline-block' }}>
26-
<Button appearance="inversePrimary">Primary inverse</Button>
19+
<div style={{ display: 'flex', gap: 16, padding: 32 }}>
20+
<Button appearance="primary">Primary</Button>
21+
<Button appearance="secondary">Secondary</Button>
22+
<Button appearance="tertiary">Tertiary</Button>
23+
<Button appearance="outline">Outline</Button>
24+
<Button appearance="primaryOutline">Outline primary</Button>
25+
<Button appearance="secondaryOutline">Outline secondary</Button>
2726
</div>
28-
<div style={{ background: 'grey', display: 'inline-block' }}>
27+
<div style={{ background: '#333333', display: 'flex', gap: 16, padding: 32 }}>
28+
<Button appearance="inversePrimary">Primary inverse</Button>
2929
<Button appearance="inverseSecondary">Secondary inverse</Button>
30-
</div>
31-
<div style={{ background: 'grey', display: 'inline-block' }}>
3230
<Button appearance="inverseOutline">Outline inverse</Button>
31+
<Button appearance="inverse">Inverse</Button>
32+
<Button appearance="inverseNoChrome">No Chrome Inverse</Button>
3333
</div>
3434
</>
3535
);

src/components/Button.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const APPEARANCES = {
3333
INVERSE_PRIMARY: 'inversePrimary',
3434
INVERSE_SECONDARY: 'inverseSecondary',
3535
INVERSE_OUTLINE: 'inverseOutline',
36+
INVERSE: 'inverse',
37+
INVERSE_NO_CHROME: 'inverseNoChrome',
3638
} as const;
3739

3840
const SIZES = {
@@ -330,6 +332,46 @@ export const StyledButton = styled.button<ButtonStylingProps & { children: React
330332
color: ${color.darkest};
331333
}
332334
`};
335+
336+
${(props) =>
337+
props.appearance === APPEARANCES.INVERSE &&
338+
`
339+
background: ${color.tr10};
340+
color: ${color.lightest};
341+
342+
${
343+
!props.isLoading &&
344+
`
345+
&:hover {
346+
background: ${color.tr10};
347+
box-shadow: none;
348+
}
349+
&:active {
350+
box-shadow: none;
351+
}
352+
`
353+
}
354+
`}
355+
356+
${(props) =>
357+
props.appearance === APPEARANCES.INVERSE_NO_CHROME &&
358+
`
359+
background: transparent;
360+
color: ${color.lightest};
361+
362+
${
363+
!props.isLoading &&
364+
`
365+
&:hover {
366+
background: transparent;
367+
box-shadow: none;
368+
}
369+
&:active {
370+
box-shadow: none;
371+
}
372+
`
373+
}
374+
`}
333375
`;
334376

335377
const ButtonLink = styled.a``;

0 commit comments

Comments
 (0)