Skip to content

Commit 793018f

Browse files
authored
Merge pull request #511 from buildo/expand_icon_button_padding
Allow separate config of paddingX and paddingY for IconButton
2 parents a4b9635 + 4d6559c commit 793018f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/bento-design-system/src/IconButton/Config.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ import { BentoSprinkles } from "../internal";
33

44
export type IconButtonConfig = {
55
radius: BentoSprinkles["borderRadius"];
6-
padding: Record<IconProps["size"], BentoSprinkles["padding"]>;
6+
padding: Record<
7+
IconProps["size"],
8+
| BentoSprinkles["padding"]
9+
| { paddingX: BentoSprinkles["paddingX"]; paddingY: BentoSprinkles["paddingY"] }
10+
>;
711
};

packages/bento-design-system/src/IconButton/IconButton.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export function IconButton(props: Props) {
3737
},
3838
ref
3939
);
40+
41+
const paddingConfig = config.padding[props.size];
42+
4043
return (
4144
<Box
4245
as="button"
@@ -56,9 +59,13 @@ export function IconButton(props: Props) {
5659
alignItems="center"
5760
justifyContent="center"
5861
borderRadius={config.radius}
59-
padding={match(props.kind)
60-
.with("solid", "outline", () => config.padding[props.size])
61-
.with("transparent", () => undefined)
62+
{...match(props.kind)
63+
.with("solid", "outline", () =>
64+
paddingConfig && typeof paddingConfig === "object" && "paddingX" in paddingConfig
65+
? paddingConfig
66+
: { padding: paddingConfig }
67+
)
68+
.with("transparent", () => {})
6269
.exhaustive()}
6370
>
6471
{props.icon({ size: props.size, color: "inherit" })}

0 commit comments

Comments
 (0)