Skip to content

Commit 2cb2f8e

Browse files
authored
Merge pull request #219 from buildo/link-button-add-props
Add icon to LinkButton + fix onPress type
2 parents d872b75 + 04d9b0f commit 2cb2f8e

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

packages/bento-design-system/src/Button/ButtonLink.tsx

+16-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { buttonRecipe } from "../Button/Button.css";
33
import { useLinkComponent } from "../util/link";
44
import { ButtonProps } from "./createButton";
55
import { Label } from "..";
6-
import { Box } from "../internal";
6+
import { Box, Column, Columns } from "../internal";
77
import { useLink } from "@react-aria/link";
88
import { element } from "../reset.css";
99
import { ButtonConfig } from "./Config";
10+
import { IconProps } from "../Icons";
1011

1112
type Props = {
1213
href: string;
@@ -16,6 +17,7 @@ type Props = {
1617
isDisabled?: ButtonProps["isDisabled"];
1718
size?: ButtonProps["size"];
1819
active?: boolean;
20+
icon?: (props: IconProps) => JSX.Element;
1921
} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "color">;
2022

2123
export function createButtonLink(config: ButtonConfig) {
@@ -57,9 +59,19 @@ export function createButtonLink(config: ButtonConfig) {
5759
paddingY={config.paddingY[size]}
5860
borderRadius={config.radius}
5961
>
60-
<Label as="span" size={config.labelSize}>
61-
{label}
62-
</Label>
62+
<Columns space={config.internalSpacing} alignY="center">
63+
{props.icon && (
64+
<Column width="content">
65+
{props.icon({
66+
size: config.iconSize[size],
67+
color: "inherit",
68+
})}
69+
</Column>
70+
)}
71+
<Label as="span" size={config.labelSize} uppercase={config.uppercaseLabel}>
72+
{label}
73+
</Label>
74+
</Columns>
6375
</Box>
6476
);
6577
};

packages/bento-design-system/src/Button/createButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Props = {
1818
isDisabled?: boolean;
1919
size?: ButtonSize;
2020
icon?: (props: IconProps) => JSX.Element;
21-
} & AriaButtonProps<"button">;
21+
} & Omit<AriaButtonProps<"button">, "onPress">;
2222

2323
/**
2424
* A button

packages/storybook/stories/Components/ButtonLink.stories.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createComponentStories, formatMessage, textArgType } from "../util";
22
import { ButtonLink } from "../";
3+
import { IconCheck } from "@buildo/bento-design-system";
34

45
const { defaultExport, createStory } = createComponentStories({
56
component: ButtonLink,
@@ -25,3 +26,9 @@ export const Active = createStory({
2526
hierarchy: "primary",
2627
active: true,
2728
});
29+
30+
export const WithIcon = createStory({
31+
kind: "solid",
32+
hierarchy: "primary",
33+
icon: IconCheck,
34+
});

0 commit comments

Comments
 (0)