Skip to content

Commit

Permalink
refactor(Button): constrain color variants by level
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed Jul 13, 2024
1 parent da155e7 commit 2dc2be2
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 15 deletions.
1 change: 0 additions & 1 deletion src/components/ButtonPrimary.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const Colors = {
<div className="flex flex-wrap gap-4">
<ButtonPrimary color="neutral">Neutral</ButtonPrimary>
<ButtonPrimary color="accent">Accent</ButtonPrimary>
<ButtonPrimary color="danger">Danger</ButtonPrimary>
</div>
),
} satisfies Story;
4 changes: 1 addition & 3 deletions src/components/ButtonPrimary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button, type ButtonProps } from "./Button";

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

export const ButtonPrimary = forwardRef(function ButtonPrimary(
Expand All @@ -23,8 +23,6 @@ export const ButtonPrimary = forwardRef(function ButtonPrimary(
"bg-ui-neutral-900 text-ui-neutral-50 active:bg-ui-neutral-800",
color === "accent" &&
"bg-ui-accent-600 text-ui-accent-50 active:bg-ui-accent-700",
color === "danger" &&
"bg-ui-danger-600 text-ui-danger-50 active:bg-ui-danger-700",
)}
{...props}
/>
Expand Down
1 change: 0 additions & 1 deletion src/components/ButtonSecondary.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const Colors = {
render: () => (
<div className="flex flex-wrap gap-4">
<ButtonSecondary color="neutral">Neutral</ButtonSecondary>
<ButtonSecondary color="accent">Accent</ButtonSecondary>
<ButtonSecondary color="danger">Danger</ButtonSecondary>
</div>
),
Expand Down
4 changes: 1 addition & 3 deletions src/components/ButtonSecondary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button, type ButtonProps } from "./Button";

export interface ButtonSecondaryProps extends ButtonProps {
size?: "sm" | "md" | "lg";
color?: "neutral" | "accent" | "danger";
color?: "neutral" | "danger";
}

export const ButtonSecondary = forwardRef(function ButtonSecondary(
Expand All @@ -21,8 +21,6 @@ export const ButtonSecondary = forwardRef(function ButtonSecondary(
"font-medium",
color === "neutral" &&
"bg-ui-neutral-200 text-ui-neutral-950 active:bg-ui-neutral-300",
color === "accent" &&
"bg-ui-accent-200 text-ui-accent-950 active:bg-ui-accent-300",
color === "danger" &&
"bg-ui-danger-200 text-ui-danger-950 active:bg-ui-danger-300",
)}
Expand Down
1 change: 0 additions & 1 deletion src/components/ButtonTertiary.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const Sizes = {
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>
Expand Down
6 changes: 2 additions & 4 deletions src/components/ButtonTertiary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { Button, type ButtonProps } from "./Button";

export interface ButtonTertiaryProps extends ButtonProps {
size?: "sm" | "md" | "lg";
color?: "neutral" | "accent" | "danger";
color?: "accent" | "danger";
}

export const ButtonTertiary = forwardRef(function ButtonTertiary(
{ size = "md", color = "neutral", className, ...props }: ButtonTertiaryProps,
{ size = "md", color = "accent", className, ...props }: ButtonTertiaryProps,
ref: React.ForwardedRef<HTMLButtonElement>,
) {
return (
Expand All @@ -19,8 +19,6 @@ export const ButtonTertiary = forwardRef(function ButtonTertiary(
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" &&
Expand Down
2 changes: 0 additions & 2 deletions src/docs/sample.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Unstyled } from "@storybook/blocks";
import { Alert } from "../components/Alert";
import { ButtonPrimary } from "../components/ButtonPrimary";
import { ButtonSecondary } from "../components/ButtonSecondary";
import { ButtonTertiary } from "../components/ButtonTertiary";
import { Input } from "../components/Input";

<Unstyled>
Expand All @@ -16,7 +15,6 @@ import { Input } from "../components/Input";
<div className="flex flex-wrap gap-2">
<Input size="sm" placeholder="Placeholder" />
<ButtonPrimary size="sm">Ok</ButtonPrimary>
<ButtonTertiary size="sm">Cancel</ButtonTertiary>
</div>
</div>
</Alert>
Expand Down

0 comments on commit 2dc2be2

Please sign in to comment.