This commit is contained in:
Shusui MOYATANI
2023-03-18 02:45:14 +09:00
parent 3f19aa120d
commit f1cd3f85aa
7 changed files with 85 additions and 10 deletions

View File

@@ -106,6 +106,53 @@ const DateFormatConfig = () => {
);
};
const ToggleButton = (props: {
value: boolean;
onClick: JSX.EventHandler<HTMLButtonElement, MouseEvent>;
}) => {
return (
<button
class="flex h-[24px] w-[48px] items-center rounded-full border border-primary px-1"
classList={{
'bg-white': !props.value,
'justify-start': !props.value,
'bg-rose-300': props.value,
'justify-end': props.value,
}}
area-label={props.value}
onClick={props.onClick}
>
<span class="m-[-2px] inline-block h-5 w-5 rounded-full border border-primary bg-white shadow" />
</button>
);
};
const OtherConfig = () => {
const { config, setConfig } = useConfig();
const toggleKeepOpenPostForm = () => {
setConfig((current) => ({
...current,
keepOpenPostForm: !(current.keepOpenPostForm ?? false),
}));
};
return (
<div>
<h3 class="font-bold"></h3>
<div class="flex flex-col justify-evenly gap-2 sm:flex-row">
<div class="flex w-full">
<div class="flex-1">稿</div>
<ToggleButton
value={config().keepOpenPostForm}
onClick={() => toggleKeepOpenPostForm()}
/>
</div>
</div>
</div>
);
};
const ConfigUI = (props: ConfigProps) => {
let containerRef: HTMLDivElement | undefined;
@@ -131,6 +178,7 @@ const ConfigUI = (props: ConfigProps) => {
</div>
<RelayConfig />
<DateFormatConfig />
<OtherConfig />
</div>
</div>
);