-
-
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
4 changed files
with
90 additions
and
1 deletion.
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,49 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { userEvent } from "@storybook/test"; | ||
|
||
import { ButtonSecondary } from "./ButtonSecondary"; | ||
|
||
const meta = { | ||
component: ButtonSecondary, | ||
} satisfies Meta<typeof ButtonSecondary>; | ||
|
||
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"> | ||
<ButtonSecondary>Focused</ButtonSecondary> | ||
<ButtonSecondary disabled>Disabled</ButtonSecondary> | ||
</div> | ||
), | ||
play: async () => { | ||
await userEvent.tab(); | ||
}, | ||
} satisfies Story; | ||
|
||
export const Sizes = { | ||
render: () => ( | ||
<div className="flex flex-col items-start gap-4"> | ||
<ButtonSecondary size="sm">Small</ButtonSecondary> | ||
<ButtonSecondary size="md">Medium</ButtonSecondary> | ||
<ButtonSecondary size="lg">Large</ButtonSecondary> | ||
</div> | ||
), | ||
} satisfies Story; | ||
|
||
export const Sentiments = { | ||
render: () => ( | ||
<div className="flex flex-wrap gap-4"> | ||
<ButtonSecondary sentiment="neutral">Neutral</ButtonSecondary> | ||
<ButtonSecondary sentiment="danger">Danger</ButtonSecondary> | ||
</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,35 @@ | ||
import { clsx } from "clsx/lite"; | ||
import { forwardRef } from "react"; | ||
|
||
import { Button, type ButtonProps } from "./Button"; | ||
|
||
export interface ButtonSecondaryProps extends ButtonProps { | ||
size?: "sm" | "md" | "lg"; | ||
sentiment?: "neutral" | "danger"; | ||
} | ||
|
||
export const ButtonSecondary = forwardRef(function ButtonSecondary( | ||
{ | ||
size = "md", | ||
sentiment = "neutral", | ||
className, | ||
...props | ||
}: ButtonSecondaryProps, | ||
ref: React.ForwardedRef<HTMLButtonElement>, | ||
) { | ||
return ( | ||
<Button | ||
ref={ref} | ||
size={size} | ||
className={clsx( | ||
className, | ||
"bg-ui-neutral-50 font-medium ring-1 ring-inset", | ||
sentiment === "neutral" && | ||
"text-ui-primary-700 ring-ui-primary-600 active:bg-ui-primary-100", | ||
sentiment === "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
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