feat(config): update page layout

This commit is contained in:
kunish 2023-09-16 23:55:42 +08:00
parent d059ea85b3
commit 2be357e73c
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
2 changed files with 63 additions and 72 deletions

View File

@ -36,7 +36,7 @@ import {
setFavDayTheme, setFavDayTheme,
setFavNightTheme, setFavNightTheme,
setSelectedEndpoint, setSelectedEndpoint,
setTwemoji, setUseTwemoji,
useRequest, useRequest,
useTwemoji, useTwemoji,
} from '~/signals' } from '~/signals'
@ -250,13 +250,27 @@ const ConfigForm = () => {
const ConfigForXd = () => { const ConfigForXd = () => {
const [t, { locale }] = useI18n() const [t, { locale }] = useI18n()
const autoSwitchThemeSubChild = () => ( return (
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-4">
<div>
<ConfigTitle>{t('autoSwitchTheme')}</ConfigTitle>
<input
type="checkbox"
class="toggle"
checked={autoSwitchTheme()}
onChange={(e) => setAutoSwitchTheme(e.target.checked)}
/>
</div>
<Show when={autoSwitchTheme()}> <Show when={autoSwitchTheme()}>
<div class="flex flex-col gap-4">
<div class="flex flex-col"> <div class="flex flex-col">
<ConfigTitle>{t('favDayTheme')}</ConfigTitle> <ConfigTitle>{t('favDayTheme')}</ConfigTitle>
<select <select
class="select select-bordered w-full max-w-xs" class="select select-bordered"
onChange={(e) => setFavDayTheme(e.target.value)} onChange={(e) => setFavDayTheme(e.target.value)}
> >
<For each={themes}> <For each={themes}>
@ -268,11 +282,12 @@ const ConfigForXd = () => {
</For> </For>
</select> </select>
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col">
<ConfigTitle>{t('favNightTheme')}</ConfigTitle> <ConfigTitle>{t('favNightTheme')}</ConfigTitle>
<select <select
class="select select-bordered w-full max-w-xs" class="select select-bordered"
onChange={(e) => setFavNightTheme(e.target.value)} onChange={(e) => setFavNightTheme(e.target.value)}
> >
<For each={themes}> <For each={themes}>
@ -284,44 +299,20 @@ const ConfigForXd = () => {
</For> </For>
</select> </select>
</div> </div>
</div>
</Show> </Show>
) </div>
const checkboxList = [ <div>
{ <ConfigTitle>{t('useTwemoji')}</ConfigTitle>
label: t('autoSwitchTheme'),
value: autoSwitchTheme,
onChange: (value: boolean) => setAutoSwitchTheme(value),
subChild: autoSwitchThemeSubChild,
},
{
label: t('useTwemoji'),
value: useTwemoji,
onChange: setTwemoji,
},
]
return (
<div class="grid gap-4">
<For each={checkboxList}>
{(checkbox) => (
<>
<div class="flex flex-col">
<ConfigTitle>{checkbox.label}</ConfigTitle>
<input <input
type="checkbox" type="checkbox"
class="toggle" class="toggle"
checked={checkbox.value()} checked={useTwemoji()}
onChange={(e) => { onChange={(e) => setUseTwemoji(e.target.checked)}
checkbox.onChange(e.target.checked)
}}
/> />
</div> </div>
{checkbox.subChild?.()}
</>
)}
</For>
<div> <div>
<Button <Button
@ -357,7 +348,7 @@ const Versions = () => {
export default () => { export default () => {
return ( return (
<div class="mx-auto flex w-full max-w-screen-md flex-col gap-4"> <div class="mx-auto flex max-w-screen-md flex-col gap-4">
<DNSQueryForm /> <DNSQueryForm />
<ConfigForm /> <ConfigForm />
<ConfigForXd /> <ConfigForXd />

View File

@ -40,7 +40,7 @@ export const [autoCloseConns, setAutoCloseConns] = makePersisted(
createSignal(false), createSignal(false),
{ name: 'autoCloseConns', storage: localStorage }, { name: 'autoCloseConns', storage: localStorage },
) )
export const [useTwemoji, setTwemoji] = makePersisted(createSignal(true), { export const [useTwemoji, setUseTwemoji] = makePersisted(createSignal(true), {
name: 'useTwemoji', name: 'useTwemoji',
storage: localStorage, storage: localStorage,
}) })