Skip to content

Commit

Permalink
refactor: rename CommonButton
Browse files Browse the repository at this point in the history
  • Loading branch information
yawn-c111 committed Nov 25, 2024
1 parent c8be9de commit fe7754e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
import {
Button as ChakraButton,
ButtonProps as ChakraButtonProps,
} from "@chakra-ui/react";
import { Button, ButtonProps } from "@chakra-ui/react";

interface ButtonProps extends Omit<ChakraButtonProps, "width"> {
interface CommonButtonProps extends Omit<ButtonProps, "width"> {
children: React.ReactNode;
width?: "full" | number;
size?: "sm" | "md" | "lg";
backgroundColor?: string;
color?: string;
}

export const Button = ({
export const CommonButton = ({
children,
width = "full",
size = "md",
backgroundColor,
color,
...props
}: ButtonProps) => {
}: CommonButtonProps) => {
return (
<ChakraButton
<Button
w={width === "full" ? "100%" : width}
size={size}
backgroundColor={backgroundColor}
color={color}
{...props}
>
{children}
</ChakraButton>
</Button>
);
};

export default Button;
export default CommonButton;
7 changes: 4 additions & 3 deletions pkgs/frontend/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Box,
Button,
Checkbox,
ClientOnly,
HStack,
Expand All @@ -11,7 +12,7 @@ import {
} from "@chakra-ui/react";
import type { MetaFunction } from "@remix-run/node";
import { ColorModeToggle } from "../components/color-mode-toggle";
import { Button } from "~/components/button";
import { CommonButton } from "~/components/CommonButton";

export const meta: MetaFunction = () => {
return [
Expand All @@ -23,9 +24,9 @@ export const meta: MetaFunction = () => {
export default function Index() {
return (
<Box textAlign="center" fontSize="xl" pt="30vh">
<Button width="full" backgroundColor="red" size="lg" color="blue">
<CommonButton width="full" backgroundColor="red" size="lg" color="blue">
<>Click me</>
</Button>
</CommonButton>
<VStack gap="8">
<img alt="chakra logo" src="/static/logo.svg" width="80" height="80" />
<Heading size="2xl" letterSpacing="tight">
Expand Down

0 comments on commit fe7754e

Please sign in to comment.