mirror of
https://github.com/youwen5/site.git
synced 2024-11-28 10:53:50 -08:00
feat: make theme picker dropdown wide on mobile
This commit is contained in:
parent
a40b96329c
commit
925dc0dcb8
2 changed files with 13 additions and 3 deletions
|
@ -74,7 +74,7 @@
|
||||||
>
|
>
|
||||||
</Drawer.Close>
|
</Drawer.Close>
|
||||||
<Separator class="h-1 rounded-3xl mt-1 dark:bg-zinc-500 my-2" />
|
<Separator class="h-1 rounded-3xl mt-1 dark:bg-zinc-500 my-2" />
|
||||||
<ThemePicker let:builder>
|
<ThemePicker let:builder hideLabel wide>
|
||||||
<Button variant="outline" size="lg" builders={[builder]}>
|
<Button variant="outline" size="lg" builders={[builder]}>
|
||||||
<Sun class="mr-4 dark:hidden" />
|
<Sun class="mr-4 dark:hidden" />
|
||||||
<Moon class="mr-4 hidden dark:block" />
|
<Moon class="mr-4 hidden dark:block" />
|
||||||
|
|
|
@ -5,12 +5,17 @@
|
||||||
change the color theme of the website.
|
change the color theme of the website.
|
||||||
|
|
||||||
@slot builder - A slot for the button that triggers the dropdown menu.
|
@slot builder - A slot for the button that triggers the dropdown menu.
|
||||||
|
|
||||||
|
@prop hideLabel - A boolean that determines whether to show the label
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
|
||||||
import { setMode } from 'mode-watcher';
|
import { setMode } from 'mode-watcher';
|
||||||
|
|
||||||
|
export let hideLabel: boolean = true;
|
||||||
|
export let wide: boolean = false;
|
||||||
|
|
||||||
let modes = [
|
let modes = [
|
||||||
{ value: 'light', label: 'Light' },
|
{ value: 'light', label: 'Light' },
|
||||||
{ value: 'dark', label: 'Dark' },
|
{ value: 'dark', label: 'Dark' },
|
||||||
|
@ -26,10 +31,15 @@
|
||||||
<DropdownMenu.Trigger asChild let:builder>
|
<DropdownMenu.Trigger asChild let:builder>
|
||||||
<slot {builder} />
|
<slot {builder} />
|
||||||
</DropdownMenu.Trigger>
|
</DropdownMenu.Trigger>
|
||||||
<DropdownMenu.Content>
|
<DropdownMenu.Content class={wide ? 'w-[80%]' : ''}>
|
||||||
|
{#if hideLabel}
|
||||||
|
<DropdownMenu.Label>Color Theme</DropdownMenu.Label>
|
||||||
|
{/if}
|
||||||
<DropdownMenu.Group>
|
<DropdownMenu.Group>
|
||||||
{#each modes as { value, label } (value)}
|
{#each modes as { value, label } (value)}
|
||||||
<DropdownMenu.Item on:click={() => changeMode(value)}>{label}</DropdownMenu.Item>
|
<DropdownMenu.Item on:click={() => changeMode(value)} class={wide ? 'text-md' : ''}>
|
||||||
|
{label}</DropdownMenu.Item
|
||||||
|
>
|
||||||
{/each}
|
{/each}
|
||||||
</DropdownMenu.Group>
|
</DropdownMenu.Group>
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
|
|
Loading…
Reference in a new issue