Skip to content

Commit

Permalink
Add chevron to ButtonAction
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelArestad committed Aug 3, 2023
1 parent f132a89 commit b5a48f5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
18 changes: 18 additions & 0 deletions src/components/ButtonAction.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ export const WithLabelActive: Story = {
},
};

export const IconOnlyIsSelect: Story = {
args: {
children: '',
icon: 'starhollow',
isActive: false,
isSelect: true,
},
};

export const WithLabelIsSelect: Story = {
args: {
children: 'Hello World',
icon: 'starhollow',
isActive: false,
isSelect: true,
},
};

export const IconOnlyWithTooltip: Story = {
args: {
icon: 'starhollow',
Expand Down
17 changes: 15 additions & 2 deletions src/components/ButtonAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ interface ButtonActionProps {
icon: IconType;
children?: string;
isActive?: boolean;
isSelect?: boolean;
tooltip?: string;
}

interface ButtonStylingProps {
isActive?: boolean;
isSelect?: boolean;
}

const StyledButton = styled.button<ButtonStylingProps>`
Expand Down Expand Up @@ -54,10 +56,20 @@ const StyledButton = styled.button<ButtonStylingProps>`
}
`;

const Chevron = (
<svg viewBox="0 0 8 8" width="8px" height="8px">
<path
fill="#73828C"
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"
/>
</svg>
);

export const ButtonAction = ({
children,
icon,
isActive = false,
isSelect = false,
tooltip,
...rest
}: ButtonActionProps) => {
Expand All @@ -69,16 +81,17 @@ export const ButtonAction = ({
delayShow={600}
{...rest}
>
<StyledButton isActive={isActive} as="div">
<StyledButton isActive={isActive} isSelect={isSelect} as="div">
{icon && <Icon icon={icon} />}
{children}
</StyledButton>
</WithTooltip>
);
return (
<StyledButton isActive={isActive} {...rest}>
<StyledButton isActive={isActive} isSelect={isSelect} {...rest}>
{icon && <Icon icon={icon} />}
{children}
{isSelect ? Chevron : null}
</StyledButton>
);
};

0 comments on commit b5a48f5

Please sign in to comment.