Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChakraV3によるCommonButtonコンポーネント #171

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pkgs/frontend/app/components/CommonButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Button, ButtonProps } from "~/components/ui/button";

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

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

export default CommonButton;
138 changes: 71 additions & 67 deletions pkgs/frontend/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,79 +1,83 @@
import {
Box,
Button,
Checkbox,
ClientOnly,
HStack,
Heading,
Progress,
RadioGroup,
Skeleton,
VStack,
} from "@chakra-ui/react"
import type { MetaFunction } from "@remix-run/node"
import { ColorModeToggle } from "../components/color-mode-toggle"
Box,
Button,
Checkbox,
ClientOnly,
HStack,
Heading,
Progress,
RadioGroup,
Skeleton,
VStack,
} from "@chakra-ui/react";
import type { MetaFunction } from "@remix-run/node";
import { ColorModeToggle } from "../components/color-mode-toggle";
import { CommonButton } from "~/components/CommonButton";

export const meta: MetaFunction = () => {
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
]
}
return [
{ title: "New Remix App" },
{ name: "description", content: "Welcome to Remix!" },
];
};

export default function Index() {
return (
<Box textAlign="center" fontSize="xl" pt="30vh">
<VStack gap="8">
<img alt="chakra logo" src="/static/logo.svg" width="80" height="80" />
<Heading size="2xl" letterSpacing="tight">
Welcome to Chakra UI v3 + Remix
</Heading>
return (
<Box textAlign="center" fontSize="xl" pt="30vh">
<CommonButton width="full" backgroundColor="red" size="lg" color="blue">
<>Click me</>
</CommonButton>
<VStack gap="8">
<img alt="chakra logo" src="/static/logo.svg" width="80" height="80" />
<Heading size="2xl" letterSpacing="tight">
Welcome to Chakra UI v3 + Remix
</Heading>

<HStack gap="10">
<Checkbox.Root defaultChecked>
<Checkbox.HiddenInput />
<Checkbox.Control>
<Checkbox.Indicator />
</Checkbox.Control>
<Checkbox.Label>Checkbox</Checkbox.Label>
</Checkbox.Root>
<HStack gap="10">
<Checkbox.Root defaultChecked>
<Checkbox.HiddenInput />
<Checkbox.Control>
<Checkbox.Indicator />
</Checkbox.Control>
<Checkbox.Label>Checkbox</Checkbox.Label>
</Checkbox.Root>

<RadioGroup.Root display="inline-flex" defaultValue="1">
<RadioGroup.Item value="1" mr="2">
<RadioGroup.ItemHiddenInput />
<RadioGroup.ItemControl>
<RadioGroup.ItemIndicator />
</RadioGroup.ItemControl>
<RadioGroup.ItemText lineHeight="1">Radio</RadioGroup.ItemText>
</RadioGroup.Item>
<RadioGroup.Root display="inline-flex" defaultValue="1">
<RadioGroup.Item value="1" mr="2">
<RadioGroup.ItemHiddenInput />
<RadioGroup.ItemControl>
<RadioGroup.ItemIndicator />
</RadioGroup.ItemControl>
<RadioGroup.ItemText lineHeight="1">Radio</RadioGroup.ItemText>
</RadioGroup.Item>

<RadioGroup.Item value="2">
<RadioGroup.ItemHiddenInput />
<RadioGroup.ItemControl>
<RadioGroup.ItemIndicator />
</RadioGroup.ItemControl>
<RadioGroup.ItemText lineHeight="1">Radio</RadioGroup.ItemText>
</RadioGroup.Item>
</RadioGroup.Root>
</HStack>
<RadioGroup.Item value="2">
<RadioGroup.ItemHiddenInput />
<RadioGroup.ItemControl>
<RadioGroup.ItemIndicator />
</RadioGroup.ItemControl>
<RadioGroup.ItemText lineHeight="1">Radio</RadioGroup.ItemText>
</RadioGroup.Item>
</RadioGroup.Root>
</HStack>

<Progress.Root width="300px" value={65} striped animated>
<Progress.Track>
<Progress.Range />
</Progress.Track>
</Progress.Root>
<Progress.Root width="300px" value={65} striped animated>
<Progress.Track>
<Progress.Range />
</Progress.Track>
</Progress.Root>

<HStack>
<Button>Lets go</Button>
<Button variant="outline">bun install @chakra-ui/react</Button>
</HStack>
</VStack>
<HStack>
<Button>Lets go</Button>
<Button variant="outline">bun install @chakra-ui/react</Button>
</HStack>
</VStack>

<Box pos="absolute" top="4" right="4">
<ClientOnly fallback={<Skeleton w="10" h="10" rounded="md" />}>
<ColorModeToggle />
</ClientOnly>
</Box>
</Box>
)
<Box pos="absolute" top="4" right="4">
<ClientOnly fallback={<Skeleton w="10" h="10" rounded="md" />}>
<ColorModeToggle />
</ClientOnly>
</Box>
</Box>
);
}