Skip to content

add bordered button variant #1900

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

Merged
merged 4 commits into from
Dec 12, 2024
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
2 changes: 1 addition & 1 deletion frontends/ol-components/src/components/Button/Button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as ButtonStories from "./Button.stories"

# Button

Use prop `variant="primary" | "secondary" | "tertiary" | "text"` to set the button variant:
Use prop `variant="primary" | "secondary" | "tertiary" | "bordered" | "noBorder" | "inverted" | "success" | "text"` to set the button variant:

<Canvas of={ButtonStories.VariantStory} />

Expand Down
43 changes: 36 additions & 7 deletions frontends/ol-components/src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ const meta: Meta<typeof Button> = {
"primary",
"secondary",
"tertiary",
"text",
"bordered",
"noBorder",
"inverted",
"text-secondary",
"success",
"text",
],
control: { type: "select" },
},
Expand Down Expand Up @@ -88,15 +90,21 @@ export const VariantStory: Story = {
<Button {...args} variant="tertiary">
Tertiary
</Button>
<Button {...args} variant="text">
Text
<Button {...args} variant="bordered">
Bordered
</Button>
<Button {...args} variant="noBorder">
Text Secondary
No Border
</Button>
<Button {...args} variant="inverted">
Inverted
</Button>
<Button {...args} variant="success">
Success
</Button>
<Button {...args} variant="text">
Text
</Button>
</Stack>
),
}
Expand Down Expand Up @@ -149,9 +157,21 @@ export const DisabledStory: Story = {
<Button {...args} disabled variant="secondary">
Secondary
</Button>
<Button {...args} variant="tertiary">
<Button {...args} disabled variant="tertiary">
Tertiary
</Button>
<Button {...args} disabled variant="bordered">
Bordered
</Button>
<Button {...args} disabled variant="noBorder">
No Border
</Button>
<Button {...args} disabled variant="inverted">
Inverted
</Button>
<Button {...args} disabled variant="success">
Success
</Button>
<Button {...args} disabled variant="text">
Text
</Button>
Expand Down Expand Up @@ -217,7 +237,16 @@ export const IconOnlyStory: Story = {

const EDGES = ["rounded", "circular", "none"] as const

const VARIANTS = ["primary", "secondary", "tertiary", "text"] as const
const VARIANTS = [
"primary",
"secondary",
"tertiary",
"bordered",
"noBorder",
"success",
"inverted",
"text",
] as const
const EXTRA_PROPS = [
{},
/**
Expand Down
30 changes: 19 additions & 11 deletions frontends/ol-components/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ type ButtonVariant =
| "primary"
| "secondary"
| "tertiary"
| "text"
| "bordered"
| "noBorder"
| "inverted"
| "success"
| "text"
type ButtonSize = "small" | "medium" | "large"
type ButtonEdge = "circular" | "rounded" | "none"

Expand Down Expand Up @@ -98,7 +99,7 @@ const buildStyles = (props: ButtonStyleProps & { theme: Theme }) => {
...props,
}
const { colors } = theme.custom
const hasBorder = variant === "secondary"
const hasBorder = variant === "secondary" || variant === "bordered"
return css([
{
color: theme.palette.text.primary,
Expand Down Expand Up @@ -142,11 +143,6 @@ const buildStyles = (props: ButtonStyleProps & { theme: Theme }) => {
boxShadow: "none",
},
},
hasBorder && {
backgroundColor: "transparent",
borderColor: "currentcolor",
borderStyle: "solid",
},
variant === "success" && {
backgroundColor: colors.darkGreen,
color: colors.white,
Expand All @@ -163,13 +159,11 @@ const buildStyles = (props: ButtonStyleProps & { theme: Theme }) => {
boxShadow: "none",
},
},
hasBorder && {
variant === "secondary" && {
color: colors.red,
backgroundColor: "transparent",
borderColor: "currentcolor",
borderStyle: "solid",
},
variant === "secondary" && {
color: colors.red,
":hover:not(:disabled)": {
backgroundColor: tinycolor(colors.brightRed).setAlpha(0.06).toString(),
},
Expand All @@ -188,6 +182,20 @@ const buildStyles = (props: ButtonStyleProps & { theme: Theme }) => {
color: colors.silverGray,
},
},
variant === "bordered" && {
backgroundColor: colors.white,
color: colors.silverGrayDark,
border: `1px solid ${colors.silverGrayLight}`,
":hover:not(:disabled)": {
backgroundColor: colors.lightGray1,
color: colors.darkGray2,
},
":disabled": {
backgroundColor: colors.lightGray2,
border: `1px solid ${colors.lightGray2}`,
color: colors.silverGrayDark,
},
},
variant === "noBorder" && {
backgroundColor: colors.white,
color: colors.darkGray2,
Expand Down
Loading