Skip to content

Commit

Permalink
Rename role to variant in Button
Browse files Browse the repository at this point in the history
Role is an accessibility prop
  • Loading branch information
marcoacierno committed Feb 18, 2024
1 parent 56fb1e0 commit 917cfaa
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import clsx from "clsx";
import React, { ReactNode } from "react";
import { Color } from "../types";
import { Text } from "../text";
import { getBackgroundClasses } from "../colors-utils";
import { Text } from "../text";
import { Color } from "../types";

export const Button = ({
children,
onClick,
role = "primary",
variant = "primary",
icon = null,
size = "default",
fullWidth = false,
Expand All @@ -22,7 +22,7 @@ export const Button = ({
size?: "default" | "small";
children: ReactNode;
disabled?: boolean;
role?: "primary" | "secondary" | "alert";
variant?: "primary" | "secondary" | "alert";
onClick?: (
e: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLAnchorElement>
) => void;
Expand All @@ -41,15 +41,15 @@ export const Button = ({
{
"opacity-30": disabled,
// primary
"hover:bg-green": !disabled && role !== "alert",
"hover:bg-red/40": !disabled && role === "alert",
"hover:bg-green": !disabled && variant !== "alert",
"hover:bg-red/40": !disabled && variant === "alert",

// secondary
"bg-milk": role === "primary" && !background,
"bg-cream": (role === "alert" || role === "secondary") && !background,
"bg-milk": variant === "primary" && !background,
"bg-cream": (variant === "alert" || variant === "secondary") && !background,

"border-black": role !== "alert",
"border-red": role === "alert",
"border-black": variant !== "alert",
"border-red": variant === "alert",

"py-5 px-8": size === "small",
"py-5 px-8 lg:py-6 lg:px-12": size === "default",
Expand All @@ -69,7 +69,7 @@ export const Button = ({
noWrap
weight="strong"
size={size === "small" ? "label2" : "label1"}
color={role === "alert" ? "red" : "black"}
color={variant === "alert" ? "red" : "black"}
>
{children}
</Text>
Expand Down

0 comments on commit 917cfaa

Please sign in to comment.