Skip to content

Commit 41fb6f5

Browse files
authored
Button - Fix padding (#588)
* Adjust button padding depending on label existence * Update test snapshots
1 parent d3b5eac commit 41fb6f5

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/components/button/__snapshots__/button.test.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ exports[`Button states renders only icon 1`] = `
223223
word-break: keep-all;
224224
cursor: pointer;
225225
pointer-events: auto;
226-
padding: 4px 12px;
226+
padding: 4px 6px;
227227
transition: all 150ms;
228228
background-color: rgba(255,255,255,0.0);
229229
color: #00AB44;
@@ -307,7 +307,7 @@ exports[`Button states renders only icon 1`] = `
307307
class="c0"
308308
colors="[object Object]"
309309
flavour="hollow"
310-
padding="1,3"
310+
padding="1,1.5"
311311
round="0.5"
312312
texttransform="firstLetter"
313313
>
@@ -342,7 +342,7 @@ exports[`Button states renders smaller only icon 1`] = `
342342
word-break: keep-all;
343343
cursor: pointer;
344344
pointer-events: auto;
345-
padding: 4px 12px;
345+
padding: 4px 6px;
346346
transition: all 150ms;
347347
background-color: rgba(255,255,255,0.0);
348348
color: #00AB44;
@@ -426,7 +426,7 @@ exports[`Button states renders smaller only icon 1`] = `
426426
class="c0"
427427
colors="[object Object]"
428428
flavour="hollow"
429-
padding="1,3"
429+
padding="1,1.5"
430430
round="0.5"
431431
texttransform="firstLetter"
432432
>

src/components/button/button.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const Button = ({
2424
flavour={flavour}
2525
textTransform={textTransform}
2626
hasIcon={!!icon || isLoading}
27+
hasLabel={!!children}
2728
onClick={isLoading ? undefined : onClick}
2829
ref={ref}
2930
iconColor={iconColor}

src/components/button/styled.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ const colorsByFlavour = ({ flavour = DEFAULT, danger, warning, iconColor }) => {
123123

124124
export const StyledButton = styled.button.attrs(
125125
({ groupFirst, groupLast, groupMiddle, ...props }) => ({
126-
padding: props.large ? [1.5, 4] : [1, 3],
126+
padding: props.large
127+
? !props.hasLabel
128+
? [1.5, 3]
129+
: [1.5, 4]
130+
: !props.hasLabel
131+
? [1, 1.5]
132+
: [1, 3],
127133
colors: colorsByFlavour(props),
128134
round: groupFirst
129135
? { side: "left", size: 0.5 }

0 commit comments

Comments
 (0)