Skip to content

Commit

Permalink
Merge pull request #172 from hackdays-io/feature/input-and-textarea-c…
Browse files Browse the repository at this point in the history
…hakra

ChakraV3によるCommonInputとCommonTextareaコンポーネント
  • Loading branch information
yu23ki14 authored Nov 25, 2024
2 parents 0456a2f + 6d253fc commit 1dce97d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
13 changes: 13 additions & 0 deletions pkgs/frontend/app/components/Input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
Input as ChakraInput,
InputProps as ChakraInputProps,
} from "@chakra-ui/react";

interface InputProps extends Omit<ChakraInputProps, "value"> {
value: string | number;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
}

export const Input = ({ value, onChange }: InputProps) => {
return <ChakraInput value={value} onChange={onChange} />;
};
13 changes: 13 additions & 0 deletions pkgs/frontend/app/components/TextArea.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
Textarea as ChakraTextarea,
TextareaProps as ChakraTextareaProps,
} from "@chakra-ui/react";

interface TextAreaProps extends Omit<ChakraTextareaProps, "value"> {
value: string;
onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
}

export const TextArea = ({ value, onChange }: TextAreaProps) => {
return <ChakraTextarea value={value} onChange={onChange} />;
};
17 changes: 14 additions & 3 deletions pkgs/frontend/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react";
import {
Box,
Button,
Expand All @@ -12,6 +13,8 @@ import {
} from "@chakra-ui/react";
import type { MetaFunction } from "@remix-run/node";
import { ColorModeToggle } from "../components/color-mode-toggle";
import { Input } from "~/components/Input";
import { TextArea } from "~/components/TextArea";
import { CommonButton } from "~/components/CommonButton";

export const meta: MetaFunction = () => {
Expand All @@ -22,12 +25,20 @@ export const meta: MetaFunction = () => {
};

export default function Index() {
const [inputValue, setInputValue] = useState("Hello");
const [textareaValue, setTextareaValue] = useState("World");

return (
<Box textAlign="center" fontSize="xl" pt="30vh">
<CommonButton width="full" backgroundColor="red" size="lg" color="blue">
<>Click me</>
</CommonButton>
<VStack gap="8">
<Input
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
/>
<TextArea
value={textareaValue}
onChange={(e) => setTextareaValue(e.target.value)}
/>
<img alt="chakra logo" src="/static/logo.svg" width="80" height="80" />
<Heading size="2xl" letterSpacing="tight">
Welcome to Chakra UI v3 + Remix
Expand Down

0 comments on commit 1dce97d

Please sign in to comment.