Skip to content

Commit

Permalink
feat(ButtonPrimary): sentiment variants
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed Jul 12, 2024
1 parent 0aafd6e commit 78239dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/components/ButtonPrimary.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ export const Sizes = {
</Stack>
),
} satisfies Story;

export const Sentiments = {
render: () => (
<Stack>
<ButtonPrimary sentiment="neutral">Neutral</ButtonPrimary>
<ButtonPrimary sentiment="danger">Danger</ButtonPrimary>
</Stack>
),
} satisfies Story;
14 changes: 12 additions & 2 deletions src/components/ButtonPrimary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import { Button, type ButtonProps } from "./Button";

export interface ButtonPrimaryProps extends ButtonProps {
size?: "sm" | "md" | "lg";
sentiment?: "neutral" | "danger";
}

export const ButtonPrimary = forwardRef(function ButtonPrimary(
{ size = "md", className, ...props }: ButtonPrimaryProps,
{
size = "md",
sentiment = "neutral",
className,
...props
}: ButtonPrimaryProps,
ref: React.ForwardedRef<HTMLButtonElement>,
) {
return (
Expand All @@ -17,7 +23,11 @@ export const ButtonPrimary = forwardRef(function ButtonPrimary(
size={size}
className={clsx(
className,
"bg-ui-primary-600 font-medium text-ui-primary-50 active:bg-ui-primary-700",
"font-medium",
sentiment === "neutral" &&
"bg-ui-primary-600 text-ui-primary-50 active:bg-ui-primary-700",
sentiment === "danger" &&
"bg-ui-danger-600 text-ui-danger-50 active:bg-ui-danger-700",
)}
{...props}
/>
Expand Down

0 comments on commit 78239dc

Please sign in to comment.