Skip to content

Commit

Permalink
feat(config): update page layout
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Sep 16, 2023
1 parent d059ea8 commit 2be357e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 70 deletions.
129 changes: 60 additions & 69 deletions src/pages/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
setFavDayTheme,
setFavNightTheme,
setSelectedEndpoint,
setTwemoji,
setUseTwemoji,
useRequest,
useTwemoji,
} from '~/signals'
Expand Down Expand Up @@ -250,78 +250,69 @@ const ConfigForm = () => {
const ConfigForXd = () => {
const [t, { locale }] = useI18n()

const autoSwitchThemeSubChild = () => (
<Show when={autoSwitchTheme()}>
<div class="flex flex-col">
<ConfigTitle>{t('favDayTheme')}</ConfigTitle>
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>

<select
class="select select-bordered w-full max-w-xs"
onChange={(e) => setFavDayTheme(e.target.value)}
>
<For each={themes}>
{(theme) => (
<option selected={favDayTheme() === theme} value={theme}>
{theme}
</option>
)}
</For>
</select>
</div>
<div class="flex flex-col">
<ConfigTitle>{t('favNightTheme')}</ConfigTitle>
<Show when={autoSwitchTheme()}>
<div class="flex flex-col gap-4">
<div class="flex flex-col">
<ConfigTitle>{t('favDayTheme')}</ConfigTitle>

<select
class="select select-bordered"
onChange={(e) => setFavDayTheme(e.target.value)}
>
<For each={themes}>
{(theme) => (
<option selected={favDayTheme() === theme} value={theme}>
{theme}
</option>
)}
</For>
</select>
</div>

<select
class="select select-bordered w-full max-w-xs"
onChange={(e) => setFavNightTheme(e.target.value)}
>
<For each={themes}>
{(theme) => (
<option selected={favNightTheme() === theme} value={theme}>
{theme}
</option>
)}
</For>
</select>
<div class="flex flex-col">
<ConfigTitle>{t('favNightTheme')}</ConfigTitle>

<select
class="select select-bordered"
onChange={(e) => setFavNightTheme(e.target.value)}
>
<For each={themes}>
{(theme) => (
<option selected={favNightTheme() === theme} value={theme}>
{theme}
</option>
)}
</For>
</select>
</div>
</div>
</Show>
</div>
</Show>
)

const checkboxList = [
{
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>
<div>
<ConfigTitle>{t('useTwemoji')}</ConfigTitle>

<input
type="checkbox"
class="toggle"
checked={checkbox.value()}
onChange={(e) => {
checkbox.onChange(e.target.checked)
}}
/>
</div>
{checkbox.subChild?.()}
</>
)}
</For>
<input
type="checkbox"
class="toggle"
checked={useTwemoji()}
onChange={(e) => setUseTwemoji(e.target.checked)}
/>
</div>

<div>
<Button
Expand Down Expand Up @@ -357,7 +348,7 @@ const Versions = () => {

export default () => {
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 />
<ConfigForm />
<ConfigForXd />
Expand Down
2 changes: 1 addition & 1 deletion src/signals/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const [autoCloseConns, setAutoCloseConns] = makePersisted(
createSignal(false),
{ name: 'autoCloseConns', storage: localStorage },
)
export const [useTwemoji, setTwemoji] = makePersisted(createSignal(true), {
export const [useTwemoji, setUseTwemoji] = makePersisted(createSignal(true), {
name: 'useTwemoji',
storage: localStorage,
})
Expand Down

0 comments on commit 2be357e

Please sign in to comment.