-
-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add doc search & modernize docs (#411)
- Loading branch information
Showing
17 changed files
with
271 additions
and
90 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,115 @@ | ||
<script lang="ts"> | ||
import { Circle, File, Laptop, Moon, Sun } from "radix-icons-svelte"; | ||
import * as Command from "@/registry/new-york/ui/command"; | ||
import { Button } from "@/registry/new-york/ui/button"; | ||
import { onMount } from "svelte"; | ||
import { cn } from "@/utils"; | ||
import { docsConfig } from "@/config/docs"; | ||
import { goto } from "$app/navigation"; | ||
import { resetMode, setMode } from "mode-watcher"; | ||
let open = false; | ||
onMount(() => { | ||
function handleKeydown(e: KeyboardEvent) { | ||
if (e.key === "k" && (e.metaKey || e.ctrlKey)) { | ||
e.preventDefault(); | ||
open = true; | ||
} | ||
} | ||
document.addEventListener("keydown", handleKeydown); | ||
return () => { | ||
document.removeEventListener("keydown", handleKeydown); | ||
}; | ||
}); | ||
function runCommand(cmd: () => void) { | ||
open = false; | ||
cmd(); | ||
} | ||
const mainNav = docsConfig.mainNav.filter((item) => !item.external); | ||
const sidebarNav = docsConfig.sidebarNav; | ||
</script> | ||
|
||
<Button | ||
variant="outline" | ||
class={cn( | ||
"relative w-full justify-start text-sm text-muted-foreground sm:pr-12 md:w-40 xl:w-64" | ||
)} | ||
on:click={() => (open = true)} | ||
{...$$restProps} | ||
> | ||
<span class="hidden lg:inline-flex"> Search documentation... </span> | ||
<span class="inline-flex lg:hidden">Search...</span> | ||
<kbd | ||
class="pointer-events-none absolute right-1.5 top-1.5 hidden h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex" | ||
> | ||
<span class="text-xs">⌘</span>K | ||
</kbd> | ||
</Button> | ||
<Command.Dialog bind:open> | ||
<Command.Input placeholder="Type a command or search" /> | ||
<Command.List> | ||
<Command.Empty>No results found.</Command.Empty> | ||
<Command.Group heading="Links"> | ||
{#each mainNav as navItem} | ||
<Command.Item | ||
value={navItem.title} | ||
onSelect={() => | ||
runCommand(() => { | ||
navItem.href && goto(navItem.href); | ||
})} | ||
> | ||
<File class="mr-2 h-4 w-4" /> | ||
{navItem.title} | ||
</Command.Item> | ||
{/each} | ||
</Command.Group> | ||
{#each sidebarNav as group} | ||
<Command.Group heading={group.title}> | ||
{#each group.items as navItem} | ||
<Command.Item | ||
value={navItem.title} | ||
onSelect={() => | ||
runCommand(() => { | ||
navItem.href && goto(navItem.href); | ||
})} | ||
> | ||
<div | ||
class="mr-2 flex h-4 w-4 items-center justify-center" | ||
> | ||
<Circle class="h-3 w-3" /> | ||
</div> | ||
{navItem.title} | ||
</Command.Item> | ||
{/each} | ||
</Command.Group> | ||
{/each} | ||
<Command.Separator /> | ||
<Command.Group heading="Theme"> | ||
<Command.Item | ||
value="light" | ||
onSelect={() => runCommand(() => setMode("light"))} | ||
> | ||
<Sun class="mr-2 h-4 w-4" /> | ||
Light | ||
</Command.Item> | ||
<Command.Item | ||
value="dark" | ||
onSelect={() => runCommand(() => setMode("dark"))} | ||
> | ||
<Moon class="mr-2 h-4 w-4" /> | ||
Dark | ||
</Command.Item> | ||
<Command.Item | ||
value="system" | ||
onSelect={() => runCommand(() => resetMode())} | ||
> | ||
<Laptop class="mr-2 h-4 w-4" /> | ||
System | ||
</Command.Item> | ||
</Command.Group> | ||
</Command.List> | ||
</Command.Dialog> |
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
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,12 @@ | ||
<svg | ||
height="23" | ||
viewBox="0 0 1200 1227" | ||
width="23" | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="currentColor" | ||
{...$$restProps} | ||
> | ||
<path | ||
d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z" | ||
/> | ||
</svg> |
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
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
apps/www/src/lib/components/docs/light-switch/light-switch.svelte
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
<script lang="ts"> | ||
import { Moon, Sun } from "radix-icons-svelte"; | ||
import { Button } from "@/registry/new-york/ui/button"; | ||
import * as DropdownMenu from "@/registry/new-york/ui/dropdown-menu"; | ||
import { resetMode, setMode } from "mode-watcher"; | ||
</script> | ||
|
||
<DropdownMenu.Root positioning={{ placement: "bottom-end" }}> | ||
<DropdownMenu.Trigger asChild let:builder> | ||
<Button builders={[builder]} variant="ghost" class="w-9 px-0"> | ||
<Sun | ||
class="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-roate-90 dark:scale-0" | ||
/> | ||
<Moon | ||
class="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" | ||
/> | ||
<span class="sr-only">Toggle theme</span> | ||
</Button> | ||
</DropdownMenu.Trigger> | ||
<DropdownMenu.Content> | ||
<DropdownMenu.Item on:click={() => setMode("light")}> | ||
Light | ||
</DropdownMenu.Item> | ||
<DropdownMenu.Item on:click={() => setMode("dark")}> | ||
Dark | ||
</DropdownMenu.Item> | ||
<DropdownMenu.Item on:click={() => resetMode()}> | ||
System | ||
</DropdownMenu.Item> | ||
</DropdownMenu.Content> | ||
</DropdownMenu.Root> |
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
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
Oops, something went wrong.
8e5d90b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shadcn-svelte – ./
shadcn-svelte-git-main-huntabyte.vercel.app
shadcn-svelte-huntabyte.vercel.app
shadcn-svelte.vercel.app
www.shadcn-svelte.com
shadcn-svelte.com