Skip to content

Commit 2eeb5fb

Browse files
Merge pull request #425 from storybookjs/update/button-action-with-chevron
Add chevron to ButtonAction
2 parents 51227f4 + b5a48f5 commit 2eeb5fb

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

src/components/ButtonAction.stories.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ export const WithLabelActive: Story = {
4343
},
4444
};
4545

46+
export const IconOnlyIsSelect: Story = {
47+
args: {
48+
children: '',
49+
icon: 'starhollow',
50+
isActive: false,
51+
isSelect: true,
52+
},
53+
};
54+
55+
export const WithLabelIsSelect: Story = {
56+
args: {
57+
children: 'Hello World',
58+
icon: 'starhollow',
59+
isActive: false,
60+
isSelect: true,
61+
},
62+
};
63+
4664
export const IconOnlyWithTooltip: Story = {
4765
args: {
4866
icon: 'starhollow',

src/components/ButtonAction.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ interface ButtonActionProps {
1010
icon: IconType;
1111
children?: string;
1212
isActive?: boolean;
13+
isSelect?: boolean;
1314
tooltip?: string;
1415
}
1516

1617
interface ButtonStylingProps {
1718
isActive?: boolean;
19+
isSelect?: boolean;
1820
}
1921

2022
const StyledButton = styled.button<ButtonStylingProps>`
@@ -54,10 +56,20 @@ const StyledButton = styled.button<ButtonStylingProps>`
5456
}
5557
`;
5658

59+
const Chevron = (
60+
<svg viewBox="0 0 8 8" width="8px" height="8px">
61+
<path
62+
fill="#73828C"
63+
d="M.85 1.9a.5.5 0 1 0-.7.7l3.5 3.5c.2.2.5.2.7 0l3.5-3.5a.5.5 0 1 0-.7-.7L4 5.04.85 1.9Z"
64+
/>
65+
</svg>
66+
);
67+
5768
export const ButtonAction = ({
5869
children,
5970
icon,
6071
isActive = false,
72+
isSelect = false,
6173
tooltip,
6274
...rest
6375
}: ButtonActionProps) => {
@@ -69,16 +81,17 @@ export const ButtonAction = ({
6981
delayShow={600}
7082
{...rest}
7183
>
72-
<StyledButton isActive={isActive} as="div">
84+
<StyledButton isActive={isActive} isSelect={isSelect} as="div">
7385
{icon && <Icon icon={icon} />}
7486
{children}
7587
</StyledButton>
7688
</WithTooltip>
7789
);
7890
return (
79-
<StyledButton isActive={isActive} {...rest}>
91+
<StyledButton isActive={isActive} isSelect={isSelect} {...rest}>
8092
{icon && <Icon icon={icon} />}
8193
{children}
94+
{isSelect ? Chevron : null}
8295
</StyledButton>
8396
);
8497
};

0 commit comments

Comments
 (0)