diff --git a/src/app/App.tsx b/src/app/App.tsx index d735881..05006d9 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -13,6 +13,7 @@ import { Fragment, h } from "preact"; import { useEffect, useState } from "preact/hooks"; import styles from "./App.module.css"; import { + useCheckbox, useDiscussionCategories, useDiscussionLabels, useElementName, @@ -42,6 +43,7 @@ function Plugin() { const { title, setTitle, body, setBody, handleInputTitle, handleInputBody } = useFormState(); const [isLoading, setIsLoading] = useState(false); + const [value, handleChange] = useCheckbox(); const { selectedFiles, setSelectedFiles, fileToBase64, handleSelectedFiles } = useImageUpload(); const { contentRef, needsScroll } = useScrollDetection({ @@ -133,6 +135,8 @@ function Plugin() { isLoading={isLoading} disabled={!(elementName && body && category)} onClick={handleClick} + onChange={handleChange} + value={value} /> ); diff --git a/src/hooks/index.ts b/src/hooks/index.ts index ab08574..6d6d034 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,3 +1,4 @@ +export * from "./useCheckbox"; export * from "./useDiscussionCategories"; export * from "./useDiscussionLabels"; export * from "./useElementName"; diff --git a/src/hooks/useCheckbox.ts b/src/hooks/useCheckbox.ts new file mode 100644 index 0000000..51e6477 --- /dev/null +++ b/src/hooks/useCheckbox.ts @@ -0,0 +1,21 @@ +import { JSX } from "preact"; +import { useState } from "preact/hooks"; + +/** + * useCheckbox フック + * + * ActionFooter コンポーネントで使用されるチェックボックスの状態を管理します。 + * + * @return {[boolean, (event: JSX.TargetedEvent) => void]} - チェックボックスの状態と変更関数 + */ +export function useCheckbox(): [ + boolean, + (event: JSX.TargetedEvent) => void +] { + const [value, setValue] = useState(false); + function handleChange(event: JSX.TargetedEvent) { + const newValue = event.currentTarget.checked; + setValue(newValue); + } + return [value, handleChange]; +} diff --git a/src/ui/compositions/ActionFooter/actionfooter.tsx b/src/ui/compositions/ActionFooter/actionfooter.tsx index fc2769b..ad25fee 100644 --- a/src/ui/compositions/ActionFooter/actionfooter.tsx +++ b/src/ui/compositions/ActionFooter/actionfooter.tsx @@ -1,5 +1,12 @@ import { h } from "preact"; -import { Button, Container, VerticalSpace } from "@create-figma-plugin/ui"; +import { + Button, + Checkbox, + Container, + VerticalSpace, + Text, + Bold, +} from "@create-figma-plugin/ui"; import { JSX } from "preact"; import styles from "./actionfooter.module.css"; @@ -7,13 +14,27 @@ type ActionFooterProps = { isLoading: boolean; disabled: boolean; onClick: (event: JSX.TargetedMouseEvent) => void; + onChange: (event: JSX.TargetedEvent) => void; + value: boolean; }; -export function ActionFooter({ isLoading, disabled, onClick }: ActionFooterProps) { +export function ActionFooter({ + isLoading, + disabled, + onClick, + onChange, + value, +}: ActionFooterProps) { return (
- + + + + #Slack に投稿する + + +
); -} \ No newline at end of file +}