+
@@ -66,7 +64,7 @@ const DemoTailwind = () => {
-
+
diff --git a/frontend/src/tw-components/Buttons.tsx b/frontend/src/tw-components/Buttons.tsx
index eab0bd47..17affc2e 100644
--- a/frontend/src/tw-components/Buttons.tsx
+++ b/frontend/src/tw-components/Buttons.tsx
@@ -1,100 +1,100 @@
import React from "react";
+import clsx from "clsx";
import Typography from "tw-components/Typography";
// size can only be one of:
// "small" | "small-long" | "medium" | "medium-long" | "large" | "large-long" | "icon-only"
type ButtonSize = keyof typeof buttonSizes;
-// state can only be "enabled" or "disabled"
-type ButtonState = keyof typeof buttonColors;
+// Button props
type ButtonProps = {
size?: ButtonSize;
- state?: ButtonState;
+ disabled?: boolean;
children?: React.ReactNode;
onClick?: () => void;
+ isIconButton?: boolean;
};
-type IconButtonProps = {
- state?: ButtonState;
- onClick?: () => void;
-};
-
+// Button size styles
const buttonSizes = {
- small: "px-[24px] h-[32px] flex items-center justify-center leading-none",
- "small-long":
- "px-[40px] h-[32px] flex items-center justify-center leading-none",
- medium: "px-[32px] h-[42px] flex items-center justify-center leading-none",
- "medium-long":
- "px-[48px] h-[42px] flex items-center justify-center leading-none",
- large: "px-[40px] h-[51px] flex items-center justify-center leading-none",
- "large-long":
- "px-[56px] h-[51px] flex items-center justify-center leading-none",
- "icon-only": "px-[24px] h-[42px] flex items-center justify-center",
-};
-
-const buttonColors = {
- enabled:
- "bg-blue-dark text-white dark:bg-white dark:text-blue-dark hover:bg-blue-dark-hover focus:bg-blue-dark-focused focus:outline-none active:bg-blue-dark-focused dark:hover:bg-grey-light dark:focus:bg-[#D9DBDF] dark:active:bg-[#D9DBDF]",
- disabled:
- "bg-grey text-white cursor-not-allowed dark:bg-grey dark:text-grey-light",
+ small: "px-[24px] h-[32px]",
+ "small-long": "px-[40px] h-[32px]",
+ medium: "px-[32px] h-[42px]",
+ "medium-long": "px-[48px] h-[42px]",
+ large: "px-[40px] h-[51px]",
+ "large-long": "px-[56px] h-[51px]",
+ "icon-only": "px-[24px] h-[42px]",
};
-const buttonTypography: Record
= {
+const buttonTypography: Record<
+ keyof typeof buttonSizes,
+ React.ElementType | null
+> = {
small: Typography.Title7,
"small-long": Typography.Title7,
medium: Typography.Title6,
"medium-long": Typography.Title6,
large: Typography.Title5,
"large-long": Typography.Title5,
- "icon-only": Typography.Title7, // Not sure about this one
+ "icon-only": null,
};
+// Shared base styles for all buttons
+const baseButtonStyles =
+ "transition-all duration-200 flex items-center justify-center bg-blue-dark text-white hover:bg-blue-dark-hover focus:bg-blue-dark-focused focus:outline-none active:bg-blue-dark-focused";
+
+const enabledDarkModeStyles =
+ "dark:bg-white dark:text-blue-dark dark:hover:bg-grey-light dark:focus:bg-[#D9DBDF] dark:active:bg-[#D9DBDF]";
+
+const disabledStyles = "pointer-events-none bg-grey text-grey-light";
+
+// Button component (handles both regular and icon buttons)
const Button: React.FC = ({
size = "medium",
- state = "enabled",
+ disabled = false,
children,
onClick,
+ isIconButton = false,
}) => {
const TextComponent = buttonTypography[size];
return (
);
};
-const IconButton: React.FC = ({
- state = "enabled",
- onClick,
-}) => {
- return (
-
- );
-};
+// Export separate IconButton
+const IconButton: React.FC> = (
+ props,
+) => ;
export { Button, IconButton };
From b91c9bd34d4cc2dec5695e93c35a3d3058ddad08 Mon Sep 17 00:00:00 2001
From: bzzz-coding <86077274+bzzz-coding@users.noreply.github.com>
Date: Mon, 24 Feb 2025 10:01:07 -0800
Subject: [PATCH 3/5] Refactored button components
---
frontend/src/pages/Demo/DemoTailwind.tsx | 6 +-
frontend/src/tw-components/Buttons.tsx | 133 +++++++++++++----------
2 files changed, 76 insertions(+), 63 deletions(-)
diff --git a/frontend/src/pages/Demo/DemoTailwind.tsx b/frontend/src/pages/Demo/DemoTailwind.tsx
index 4894a97c..652be178 100644
--- a/frontend/src/pages/Demo/DemoTailwind.tsx
+++ b/frontend/src/pages/Demo/DemoTailwind.tsx
@@ -42,8 +42,8 @@ const DemoTailwind = () => {
Disabled
-
-
@@ -64,7 +64,7 @@ const DemoTailwind = () => {
-
+
diff --git a/frontend/src/tw-components/Buttons.tsx b/frontend/src/tw-components/Buttons.tsx
index 17affc2e..8d0d3fc5 100644
--- a/frontend/src/tw-components/Buttons.tsx
+++ b/frontend/src/tw-components/Buttons.tsx
@@ -2,20 +2,6 @@ import React from "react";
import clsx from "clsx";
import Typography from "tw-components/Typography";
-// size can only be one of:
-// "small" | "small-long" | "medium" | "medium-long" | "large" | "large-long" | "icon-only"
-type ButtonSize = keyof typeof buttonSizes;
-
-// Button props
-type ButtonProps = {
- size?: ButtonSize;
- disabled?: boolean;
- children?: React.ReactNode;
- onClick?: () => void;
- isIconButton?: boolean;
-};
-
-// Button size styles
const buttonSizes = {
small: "px-[24px] h-[32px]",
"small-long": "px-[40px] h-[32px]",
@@ -26,75 +12,102 @@ const buttonSizes = {
"icon-only": "px-[24px] h-[42px]",
};
-const buttonTypography: Record<
- keyof typeof buttonSizes,
- React.ElementType | null
-> = {
- small: Typography.Title7,
- "small-long": Typography.Title7,
- medium: Typography.Title6,
- "medium-long": Typography.Title6,
- large: Typography.Title5,
- "large-long": Typography.Title5,
- "icon-only": null,
+type ButtonSize = keyof typeof buttonSizes;
+
+type BaseButtonProps = {
+ size?: ButtonSize;
+ disabled?: boolean;
+ className?: string;
+ children?: React.ReactNode;
+ onClick?: () => void;
};
-// Shared base styles for all buttons
+// Shared styles
const baseButtonStyles =
- "transition-all duration-200 flex items-center justify-center bg-blue-dark text-white hover:bg-blue-dark-hover focus:bg-blue-dark-focused focus:outline-none active:bg-blue-dark-focused";
+ "transition-all duration-200 flex items-center justify-center rounded-[64px] bg-blue-dark text-white hover:bg-blue-dark-hover focus:bg-blue-dark-focused focus:outline-none active:bg-blue-dark-focused disabled:bg-grey disabled:text-white disabled:cursor-not-allowed";
+// Dark mode styles for enabled buttons
const enabledDarkModeStyles =
- "dark:bg-white dark:text-blue-dark dark:hover:bg-grey-light dark:focus:bg-[#D9DBDF] dark:active:bg-[#D9DBDF]";
-
-const disabledStyles = "pointer-events-none bg-grey text-grey-light";
+ "dark:bg-white dark:text-blue-dark dark:hover:bg-grey-light dark:focus:bg-[#D9DBDF] dark:active:bg-[#D9DBDF] dark:disabled:bg-grey dark:disabled:text-grey-light";
-// Button component (handles both regular and icon buttons)
-const Button: React.FC