-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5177bee
commit 2f6d981
Showing
3 changed files
with
92 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script lang="ts"> | ||
import { cn } from '$lib/utils'; | ||
import { Command } from 'bits-ui'; | ||
type Props = Command.InputProps & { | ||
class?: string; | ||
}; | ||
let { class: class_name = undefined, ...rest }: Props = $props(); | ||
</script> | ||
|
||
<Command.Input | ||
placeholder="Search..." | ||
class={cn( | ||
'inline-flex w-full truncate rounded-[inherit] bg-transparent px-4 text-lg transition-colors placeholder:text-gray-700 focus:outline-none focus:ring-0', | ||
class_name | ||
)} | ||
{...rest} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,78 @@ | ||
<script lang="ts"> | ||
import { Icons } from '$lib/assets/icons'; | ||
import { Badge } from '$lib/components/ui/badge'; | ||
import * as Command from '$lib/components/ui/command'; | ||
import { aside_items } from '$lib/config/sitemap'; | ||
import { command_open_state } from '$lib/stores'; | ||
import { cn } from '$lib/utils'; | ||
import { Command } from 'bits-ui'; | ||
type Props = { | ||
search: string; | ||
type Props = Command.ListProps & { | ||
class?: string; | ||
}; | ||
let { search, class: class_name = undefined, ...rest }: Props = $props(); | ||
let { class: class_name = undefined, ...rest }: Props = $props(); | ||
</script> | ||
|
||
<Command.List class={cn('px-1 pb-1', class_name)} {...rest}> | ||
<Command.Empty class="text-gray-600"> | ||
No results found for | ||
<span class="font-semibold text-gray-1000"> | ||
"{search}" | ||
</span>. | ||
</Command.Empty> | ||
{#each Object.entries(aside_items) as item} | ||
{@const [group, links] = item} | ||
<Command.Group | ||
class="[&_[data-cmdk-group-heading]]:py-3 [&_[data-cmdk-group-heading]]:capitalize [&_[data-cmdk-group-heading]]:text-gray-700" | ||
> | ||
<Command.GroupHeading> | ||
{group} | ||
</Command.GroupHeading> | ||
{#each links as link} | ||
{@const disabled = link.status == 'soon'} | ||
<Command.Item | ||
value={link.title} | ||
{disabled} | ||
class="flex place-items-center gap-3 rounded-md py-3 hover:cursor-pointer hover:bg-gray-100 aria-selected:bg-gray-100" | ||
> | ||
{#snippet child({ props })} | ||
<a href={link.href} {...props}> | ||
{#if link.icon} | ||
{@const Icon = link.icon} | ||
<span class="text-gray-1000"> | ||
<Icon aria-hidden="true" width="16" height="16" /> | ||
</span> | ||
{:else} | ||
<span class="text-gray-1000"> | ||
<Icons.ArrowRight | ||
width="16" | ||
height="16" | ||
class="text-gray-600" | ||
aria-hidden="true" | ||
/> | ||
</span> | ||
{/if} | ||
<span>{link.title}</span> | ||
{#if link.status === 'new'} | ||
<Badge variant="blue" size="sm">New</Badge> | ||
{/if} | ||
{#if link.status === 'soon'} | ||
<Badge variant="gray-subtle" size="sm">Soon</Badge> | ||
{/if} | ||
{#if link.status === 'draft'} | ||
<Badge variant="purple-subtle" size="sm">Draft</Badge> | ||
{/if} | ||
</a> | ||
{/snippet} | ||
</Command.Item> | ||
{/each} | ||
</Command.Group> | ||
{/each} | ||
<Command.List | ||
class={cn('overflow-y-auto overflow-x-hidden border-t px-2 pb-2', class_name)} | ||
{...rest} | ||
> | ||
<Command.Viewport> | ||
<Command.Empty class="flex w-full items-center justify-center pb-6 pt-8 text-sm text-gray-700"> | ||
No results found. | ||
</Command.Empty> | ||
{#each Object.entries(aside_items) as item} | ||
{@const [group, links] = item} | ||
<Command.Group> | ||
<Command.GroupHeading class="px-3 pb-2 pt-4 text-xs font-medium capitalize text-gray-700"> | ||
{group} | ||
</Command.GroupHeading> | ||
<Command.GroupItems> | ||
{#each links as link} | ||
{@const disabled = link.status == 'soon'} | ||
<Command.Item | ||
onSelect={command_open_state.toggle} | ||
{disabled} | ||
value={link.title} | ||
class={cn( | ||
'flex h-10 cursor-pointer select-none items-center gap-2 px-3 py-2.5 text-sm outline-none data-[selected]:rounded-lg data-[selected]:bg-gray-alpha-100', | ||
// disabled | ||
'data-[disabled]:pointer-events-none data-[disabled]:opacity-50' | ||
)} | ||
> | ||
{#snippet child({ props })} | ||
<a href={disabled ? undefined : link.href} {...props}> | ||
{#if link.icon} | ||
{@const Icon = link.icon} | ||
<span class="text-gray-1000"> | ||
<Icon aria-hidden="true" width="16" height="16" /> | ||
</span> | ||
{:else} | ||
<span class="text-gray-1000"> | ||
<Icons.ArrowRight | ||
width="16" | ||
height="16" | ||
class="text-gray-600" | ||
aria-hidden="true" | ||
/> | ||
</span> | ||
{/if} | ||
<span>{link.title}</span> | ||
{#if link.status === 'new'} | ||
<Badge variant="blue" size="sm">New</Badge> | ||
{/if} | ||
{#if link.status === 'soon'} | ||
<Badge variant="gray-subtle" size="sm">Soon</Badge> | ||
{/if} | ||
{#if link.status === 'draft'} | ||
<Badge variant="purple-subtle" size="sm">Draft</Badge> | ||
{/if} | ||
</a> | ||
{/snippet} | ||
</Command.Item> | ||
{/each} | ||
</Command.GroupItems> | ||
</Command.Group> | ||
{/each} | ||
</Command.Viewport> | ||
</Command.List> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters