Skip to content

Commit 3c1ee86

Browse files
Merge pull request #368 from storybookjs/update/button-icon-size
Make Icon size in Buttons smaller
2 parents 3d82fae + e086f4a commit 3c1ee86

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

src/components/Button.stories.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,35 @@ export const Sizes = () => (
4343
</>
4444
);
4545

46+
export const ContainsSVG = () => (
47+
<>
48+
<Button appearance="secondary">
49+
<Icon icon="lock" />
50+
Default
51+
</Button>
52+
<Button appearance="secondary" size="small">
53+
<Icon icon="lock" />
54+
Small
55+
</Button>
56+
<Button appearance="secondary">
57+
<Icon icon="check" />
58+
Default
59+
</Button>
60+
<Button appearance="secondary" size="small">
61+
<Icon icon="check" />
62+
Small
63+
</Button>
64+
<Button appearance="secondary">
65+
<Icon icon="grid" />
66+
Default
67+
</Button>
68+
<Button appearance="secondary" size="small">
69+
<Icon icon="grid" />
70+
Small
71+
</Button>
72+
</>
73+
);
74+
4675
export const Loading = () => (
4776
<>
4877
<Button appearance="primary" isLoading>

src/components/Button.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ export const StyledButton = styled.button<StylingProps & { children: ReactElemen
8888
}
8989
9090
svg {
91-
height: ${(props) => (props.size === SIZES.SMALL ? '14' : '16')}px;
92-
width: ${(props) => (props.size === SIZES.SMALL ? '14' : '16')}px;
91+
height: ${(props) => (props.size === SIZES.SMALL ? '12' : '14')}px;
92+
width: ${(props) => (props.size === SIZES.SMALL ? '12' : '14')}px;
9393
vertical-align: top;
9494
margin-right: ${(props) => (props.size === SIZES.SMALL ? '4' : '6')}px;
95-
margin-top: ${(props) => (props.size === SIZES.SMALL ? '-1' : '-2')}px;
96-
margin-bottom: ${(props) => (props.size === SIZES.SMALL ? '-1' : '-2')}px;
95+
margin-top: ${(props) => (props.size === SIZES.SMALL ? '0' : '-1')}px;
96+
margin-bottom: ${(props) => (props.size === SIZES.SMALL ? '0' : '-1')}px;
9797
9898
/* Necessary for js mouse events to not glitch out when hovering on svgs */
9999
pointer-events: none;
@@ -147,6 +147,8 @@ export const StyledButton = styled.button<StylingProps & { children: ReactElemen
147147
svg {
148148
display: block;
149149
margin: 0;
150+
height: ${props.size === SIZES.SMALL ? '14' : '16'}px;
151+
width: ${props.size === SIZES.SMALL ? '14' : '16'}px;
150152
}
151153
padding: ${props.size === SIZES.SMALL ? '7' : '12'}px;
152154
`}

0 commit comments

Comments
 (0)