Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chevron to ButtonAction #425

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
};
Loading