Skip to content

Commit 6b14135

Browse files
authored
Jh/button specs (#1631)
* Adjust button spacing when icons are present * Remove unused sizes * Remove unused import * Switch to rem from px
1 parent 2f52658 commit 6b14135

File tree

16 files changed

+164
-48
lines changed

16 files changed

+164
-48
lines changed

packages/components/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- Vertical cadence of `ActionList` reduced to a minimum of `36px`
3131
- `Popover`, `Menu`, and `Select` no longer cancel the first click outside by default (use `cancelClickOutside` to override this)
3232
- `DialogContent` no longer has `py` unless it overflows the available space (acting as `overflow: scroll`)
33+
- Padding in `Button`'s has been updated to have better visual balance when icons are used
3334

3435
### Fixed
3536

4 Bytes
Loading
0 Bytes
Loading
-10 Bytes
Loading
-1 Bytes
Loading
-2 Bytes
Loading

packages/components/src/Button/ButtonBase.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
ButtonSizes,
4848
ButtonSizeProps,
4949
buttonIconSizeMap,
50+
buttonPadding,
5051
} from './size'
5152
import { ButtonIcon, buttonIcon, ButtonIconProps } from './icon'
5253

@@ -146,6 +147,7 @@ const ButtonJSX = forwardRef(
146147
onKeyUp={handleOnKeyUp}
147148
onBlur={handleOnBlur}
148149
ref={ref}
150+
px={buttonPadding(!!(iconBefore || iconAfter), size)}
149151
>
150152
{iconBefore && <ButtonIcon name={iconBefore} size={iconSize} />}
151153
{children}

packages/components/src/Button/ButtonTransparent.tsx

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,14 @@
2525
*/
2626

2727
import styled from 'styled-components'
28-
import { variant } from 'styled-system'
2928
import { ButtonBase } from './ButtonBase'
3029

3130
/* eslint-disable sort-keys-fix/sort-keys-fix */
32-
const transparentButtonPadding = variant({
33-
prop: 'size',
34-
variants: {
35-
xxsmall: {
36-
px: 'xsmall',
37-
},
38-
xsmall: {
39-
px: 'xsmall',
40-
},
41-
small: {
42-
px: 'small',
43-
},
44-
medium: {
45-
px: 'large',
46-
},
47-
large: {
48-
px: 'large',
49-
},
50-
},
51-
})
52-
5331
export const ButtonTransparent = styled(ButtonBase)`
5432
background: transparent;
5533
border: 1px solid transparent;
5634
color: ${({ theme, color = 'key' }) => theme.colors[color]};
57-
${(props) =>
58-
props.iconBefore || props.iconAfter
59-
? transparentButtonPadding
60-
: `padding: 0 ${props.theme.space.xsmall};`}
35+
padding: 0 ${(props) => props.theme.space.xsmall};
6136
6237
&:hover,
6338
&:focus,

packages/components/src/Button/__snapshots__/Button.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ exports[`Button Focus: renders outline when tabbing into focus, but not when cli
2727
white-space: nowrap;
2828
font-size: 0.875rem;
2929
height: 36px;
30-
padding-left: 24px;
31-
padding-right: 24px;
30+
padding-left: 1.5rem;
31+
padding-right: 1.5rem;
3232
}
3333
3434
.c0[disabled] {
@@ -74,7 +74,7 @@ exports[`Button Focus: renders outline when tabbing into focus, but not when cli
7474

7575
exports[`Button Focus: renders outline when tabbing into focus, but not when clicking 2`] = `
7676
<button
77-
class="ButtonBase__ButtonOuter-sc-1bpio6j-0 cFuMRs ButtonBase-sc-1bpio6j-1 Button-sc-18euc9m-0 dXZmpP"
77+
class="ButtonBase__ButtonOuter-sc-1bpio6j-0 iARsUm ButtonBase-sc-1bpio6j-1 Button-sc-18euc9m-0 dXZmpP"
7878
>
7979
focus
8080
</button>

packages/components/src/Button/__snapshots__/ButtonOutline.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ exports[`ButtonOutline Focus: renders outline when tabbing into focus, but not w
2727
white-space: nowrap;
2828
font-size: 0.875rem;
2929
height: 36px;
30-
padding-left: 24px;
31-
padding-right: 24px;
30+
padding-left: 1.5rem;
31+
padding-right: 1.5rem;
3232
}
3333
3434
.c0[disabled] {
@@ -76,7 +76,7 @@ exports[`ButtonOutline Focus: renders outline when tabbing into focus, but not w
7676

7777
exports[`ButtonOutline Focus: renders outline when tabbing into focus, but not when clicking 2`] = `
7878
<button
79-
class="ButtonBase__ButtonOuter-sc-1bpio6j-0 cFuMRs ButtonBase-sc-1bpio6j-1 ButtonOutline-ncggc7-0 iADMFt"
79+
class="ButtonBase__ButtonOuter-sc-1bpio6j-0 iARsUm ButtonBase-sc-1bpio6j-1 ButtonOutline-ncggc7-0 iADMFt"
8080
>
8181
focus
8282
</button>

0 commit comments

Comments
 (0)