Skip to content

Commit 0917a96

Browse files
committed
fix: button height variations
1 parent 1ac3860 commit 0917a96

File tree

5 files changed

+50
-43
lines changed

5 files changed

+50
-43
lines changed

packages/components/base/src/button/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface ButtonProps<T extends HTMLTag = "button">
2727
/** Controls the button's size, affecting padding and overall dimensions.
2828
* @default "m"
2929
*/
30-
size?: "s" | "m" | "l" | "xs";
30+
size?: "xs" | "s" | "m" | "l" | "xl";
3131
/** Icon element to be displayed within the button.
3232
* Can be any valid React node (SVG, icon component, etc).
3333
*/

packages/components/base/src/button/styles/_variables.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,25 @@ $button-skins: (
105105
),
106106
);
107107
$button-sizes: (
108+
xl: (
109+
height: theme.get-spacing(7),
110+
padding-x: theme.get-spacing(3),
111+
),
108112
l: (
109-
padding-y: theme.get-spacing(2),
113+
height: theme.get-spacing(5),
110114
padding-x: theme.get-spacing(3),
111-
padding-icon: theme.get-spacing(1.5),
112115
),
113116
m: (
114117
// align with input height
115-
padding-y: theme.get-spacing(0.563),
118+
height: theme.get-spacing(4),
116119
padding-x: theme.get-spacing(2),
117-
padding-icon: theme.get-spacing(1),
118120
),
119121
s: (
120-
padding-y: theme.get-spacing(0.25),
122+
height: theme.get-spacing(3),
121123
padding-x: theme.get-spacing(1.25),
122-
padding-icon: theme.get-spacing(0.66),
123124
),
124125
xs: (
125-
padding-y: theme.get-spacing(0.063),
126+
height: theme.get-spacing(2.5),
126127
padding-x: theme.get-spacing(1),
127-
padding-icon: theme.get-spacing(0.5),
128128
),
129129
);

packages/components/base/src/button/styles/index.module.scss

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
box-sizing: border-box;
1616
align-items: center;
1717
justify-content: center;
18-
padding: scss-utils.get-css-var(button, padding-y) scss-utils.get-css-var(button, padding-x);
18+
min-height: scss-utils.get-css-var(button, height);
19+
padding: 0 scss-utils.get-css-var(button, padding-x);
1920
border-width: 1px;
2021
border-style: solid;
2122
border-color: scss-utils.get-css-var(button, border-color);
@@ -75,28 +76,17 @@
7576
padding-x,
7677
scss-utils.map-get-strict($props, padding-x)
7778
);
78-
@include scss-utils.define-css-var(
79-
button,
80-
padding-y,
81-
scss-utils.map-get-strict($props, padding-y)
82-
);
79+
@include scss-utils.define-css-var(button, height, scss-utils.map-get-strict($props, height));
8380

8481
&.icon-only {
85-
@include scss-utils.define-css-var(
86-
button,
87-
padding-x,
88-
scss-utils.map-get-strict($props, padding-icon)
89-
);
90-
@include scss-utils.define-css-var(
91-
button,
92-
padding-y,
93-
scss-utils.map-get-strict($props, padding-icon)
94-
);
82+
@include scss-utils.define-css-var(button, padding-x, 0);
9583
}
9684
}
9785
}
9886

9987
.size-xs {
88+
@include text.text-variation(small);
89+
10090
&.icon-only {
10191
// icon size
10292
> * {

packages/docs/stories/src/generic-button.stories.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,25 @@ export const Disabled: Story = {
8888
export const AllButtonVariations: Story = {
8989
decorators: [
9090
(): React.ReactElement =>
91-
generateAllVariations<ButtonProps>(Button, {
92-
skin: ["primary", "secondary", "negative"],
93-
skinVariation: ["default", "bordered", "muted", "ghost"],
94-
size: ["l", "m", "s", "xs"],
95-
children: [sentenceCase(faker.lorem.words({ min: 1, max: 2 }))],
96-
}),
91+
generateAllVariations<ButtonProps>(
92+
Button,
93+
{
94+
children: [sentenceCase(faker.lorem.word()), undefined],
95+
icon: [
96+
undefined,
97+
<Icon>
98+
<IconClose />
99+
</Icon>,
100+
],
101+
skin: ["primary", "secondary", "negative"],
102+
skinVariation: ["default", "bordered", "muted", "ghost"],
103+
size: ["xl", "l", "m", "s", "xs"],
104+
},
105+
{
106+
colSize: 2,
107+
align: "centered",
108+
filter: (props) => !!props.children || !!props.icon,
109+
},
110+
),
97111
],
98112
};

packages/docs/stories/src/utils/generate-all-variations.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const generateAllVariations = <T extends object>(
1313
render: (props: T) => React.ReactNode,
1414
data: PropsMap<T>,
1515
options?: {
16+
filter?: (props: T) => boolean;
1617
align?: GridProps["align"];
1718
colSize?: GridColumnProps["size"];
1819
},
@@ -34,19 +35,21 @@ export const generateAllVariations = <T extends object>(
3435
<Divider />
3536

3637
<Grid align={options?.align ?? "end"}>
37-
{generateDescribedCombinations<T>(data).map(({ combination, description }) => (
38-
<Grid.Column key={description} size={options?.colSize ?? 3} title={description}>
39-
{render(combination)}
38+
{generateDescribedCombinations<T>(data)
39+
.filter((i) => options?.filter?.(i.combination) ?? true)
40+
.map(({ combination, description }) => (
41+
<Grid.Column key={description} size={options?.colSize ?? 3} title={description}>
42+
{render(combination)}
4043

41-
{showInfo ? (
42-
<>
43-
<br />
44-
<br />
45-
<Snippet>{description}</Snippet>
46-
</>
47-
) : null}
48-
</Grid.Column>
49-
))}
44+
{showInfo ? (
45+
<>
46+
<br />
47+
<br />
48+
<Snippet>{description}</Snippet>
49+
</>
50+
) : null}
51+
</Grid.Column>
52+
))}
5053
</Grid>
5154
</>
5255
);

0 commit comments

Comments
 (0)