Skip to content

Commit

Permalink
Merge pull request #228 from jim-deriv/jim/feq-2472/add-border-width-…
Browse files Browse the repository at this point in the history
…prop-and-variants

[FEQ] Jim/FEQ-2472/add border width prop and variants
  • Loading branch information
shayan-deriv authored Jul 15, 2024
2 parents 8fb37dc + cc06340 commit d2bf5a9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/Button/Button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,19 @@ $black-outline-hover: rgba(0, 0, 0, 0.08);
}
}

&__border-width {
&--none {
border-width: 0;
}
&--sm {
border-width: 1px;
}
&--md {
border-width: 2px;
}
&--lg {
border-width: 3px;
}
}

}
11 changes: 11 additions & 0 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import "./Button.scss";

type TVariant = "contained" | "ghost" | "outlined";
type TColor = "black" | "primary-light" | "primary" | "white";
type TBorderWidth = Extract<TGenericSizes, 'md' | 'sm' | 'lg'> | 'none';

interface ButtonProps extends ComponentProps<"button"> {
borderWidth?: TBorderWidth;
color?: TColor;
icon?: ReactElement | ReactNode;
isFullWidth?: boolean;
Expand Down Expand Up @@ -58,7 +60,15 @@ const LoaderColor = {
white: "#85ACB0",
} as const;

const BorderWidth = {
none: "deriv-button__border-width--none",
sm: "deriv-button__border-width--sm",
md: "deriv-button__border-width--md",
lg: "deriv-button__border-width--lg",
} as const;

export const Button = ({
borderWidth = 'md',
className,
color = "primary",
icon,
Expand All @@ -80,6 +90,7 @@ export const Button = ({
ButtonColor[color],
ButtonSize[size],
ButtonRounded[rounded],
BorderWidth[borderWidth],
{
"deriv-button__full-width": isFullWidth,
"deriv-button__hover--disabled": hideHoverStyles,
Expand Down
5 changes: 5 additions & 0 deletions stories/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const meta = {
},
tags: ["autodocs"],
args: {
borderWidth: "md",
variant: "contained",
children: "Click Me!",
color: "primary",
Expand All @@ -23,6 +24,10 @@ const meta = {
},

argTypes: {
borderWidth: {
options: ["none", "sm", "md", "lg"],
control: { type: "radio" },
},
variant: {
options: ["contained", "outlined", "ghost"],
control: { type: "radio" },
Expand Down

0 comments on commit d2bf5a9

Please sign in to comment.