-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { userEvent } from "@storybook/test"; | ||
|
||
import { ButtonTertiary } from "./ButtonTertiary"; | ||
|
||
const meta = { | ||
component: ButtonTertiary, | ||
} satisfies Meta<typeof ButtonTertiary>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic = { | ||
args: { | ||
children: "Click me", | ||
disabled: false, | ||
}, | ||
} satisfies Story; | ||
|
||
export const Interactivity = { | ||
render: () => ( | ||
<div className="flex flex-wrap gap-4"> | ||
<ButtonTertiary>Focused</ButtonTertiary> | ||
<ButtonTertiary disabled>Disabled</ButtonTertiary> | ||
</div> | ||
), | ||
play: async () => { | ||
await userEvent.tab(); | ||
}, | ||
} satisfies Story; | ||
|
||
export const Sizes = { | ||
render: () => ( | ||
<div className="flex flex-col items-start gap-4"> | ||
<ButtonTertiary size="sm">Small</ButtonTertiary> | ||
<ButtonTertiary size="md">Medium</ButtonTertiary> | ||
<ButtonTertiary size="lg">Large</ButtonTertiary> | ||
</div> | ||
), | ||
} satisfies Story; | ||
|
||
export const Colors = { | ||
render: () => ( | ||
<div className="flex flex-wrap gap-4"> | ||
<ButtonTertiary color="neutral">Neutral</ButtonTertiary> | ||
<ButtonTertiary color="accent">Accent</ButtonTertiary> | ||
<ButtonTertiary color="danger">Danger</ButtonTertiary> | ||
</div> | ||
), | ||
} satisfies Story; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { clsx } from "clsx/lite"; | ||
import { forwardRef } from "react"; | ||
|
||
import { Button, type ButtonProps } from "./Button"; | ||
|
||
export interface ButtonTertiaryProps extends ButtonProps { | ||
size?: "sm" | "md" | "lg"; | ||
color?: "neutral" | "accent" | "danger"; | ||
} | ||
|
||
export const ButtonTertiary = forwardRef(function ButtonTertiary( | ||
{ size = "md", color = "neutral", className, ...props }: ButtonTertiaryProps, | ||
ref: React.ForwardedRef<HTMLButtonElement>, | ||
) { | ||
return ( | ||
<Button | ||
ref={ref} | ||
size={size} | ||
className={clsx( | ||
className, | ||
"bg-ui-neutral-50 font-medium ring-1 ring-inset", | ||
color === "neutral" && | ||
"text-ui-neutral-950 ring-ui-neutral-600 active:bg-ui-neutral-100", | ||
color === "accent" && | ||
"text-ui-accent-700 ring-ui-accent-600 active:bg-ui-accent-100", | ||
color === "danger" && | ||
"text-ui-danger-700 ring-ui-danger-600 active:bg-ui-danger-100", | ||
)} | ||
{...props} | ||
/> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters