Skip to content

Commit

Permalink
Created basic documentation site as a placeholder (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshjoshi authored Dec 6, 2024
1 parent faaca6c commit 984c4d6
Show file tree
Hide file tree
Showing 19 changed files with 221 additions and 59 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"devDependencies": {
"@playwright/test": "^1.49.0",
"@sveltejs/adapter-auto": "^3.3.1",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.9.0",
"@sveltejs/package": "^2.3.7",
"@sveltejs/vite-plugin-svelte": "^5.0.1",
Expand Down
13 changes: 6 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html class="h-full bg-black" lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
Expand Down
9 changes: 6 additions & 3 deletions src/lib/field/Field.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import type { Component, Snippet } from "svelte";
import { useId } from "../../hooks/use-id";
import { getAllContexts, getContext } from "svelte";
import { getAllContexts, getContext, setContext } from "svelte";
const contexts = getAllContexts();
console.log(contexts);
// const contexts = getAllContexts();
// console.log(contexts);
type Props = {
/** The element or component the checkbox should render as. */
Expand All @@ -21,6 +21,7 @@
};
let providedDisabled = getContext<boolean>("headlessui-disabled-context");
console.log("Field: Incoming disabled context:", providedDisabled);
let {
id = `headlessui-control-${useId()}`,
Expand All @@ -43,6 +44,8 @@
let dataAttributes: DataAttributes<SnippetProps> = {
"data-disabled": disabled,
};
setContext("headlessui-disabled-context", disabled);
</script>

{#if typeof as === "string"}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/fieldset/Fieldset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
};
let providedDisabled = getContext<boolean>("headlessui-disabled-context");
console.log("Fieldset: Incoming disabled context:", providedDisabled);
let {
as = "fieldset",
disabled = providedDisabled || false,
Expand Down Expand Up @@ -43,6 +44,9 @@
};
setContext("headlessui-disabled-context", disabled);
let value = $state({ count: 0 });
setContext("counter", value);
</script>

{#if typeof as === "string"}
Expand Down
25 changes: 25 additions & 0 deletions src/routes/(main)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script lang="ts">
import Nav from "./nav.svelte";
let { children } = $props();
import "../../app.css";
</script>

<div>
<div class="relative">
<main class="bg-black/80 px-4 sm:px-6">
<div class="mx-auto flex max-w-7xl">
<div class="sticky top-0 hidden h-screen w-[17rem] shrink-0 lg:block lg:pr-px xl:pr-[2px]">
<div class="h-full overflow-y-auto pb-[calc(80px+4rem)]">
<Nav />
</div>
</div>
<main class="flex min-w-0 flex-1 pt-16">
<div class="mx-auto max-w-[46rem] min-w-0 flex-1 px-2 md:px-8">
{@render children()}
</div>
</main>
</div>
</main>
</div>
</div>
8 changes: 8 additions & 0 deletions src/routes/(main)/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script lang="ts">
import Nav from "./nav.svelte";
</script>

<div class="prose"><h1>HeadlessUI Svelte</h1></div>
<div class="lg:hidden">
<Nav />
</div>
27 changes: 27 additions & 0 deletions src/routes/(main)/[component]/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts">
import { page } from "$app/stores";
import Nav from "../nav.svelte";
const pageName = $derived($page.url.pathname.replace(/^\/|\/$/g, ""));
</script>

<div class="prose text-white"><h1>{pageName}</h1></div>
<div class="prose mt-4 mb-6">
<p class="text-base/7"></p>
</div>

<div
class="relative mt-8 mb-12 flex flex-col items-center justify-center overflow-hidden"
style="height: 400px"
>
<div class="size-full bg-white/5">
<iframe
src="examples/{pageName}"
class="size-full [color-scheme:auto]"
title="Button example"
></iframe>
</div>
</div>

<div class="lg:hidden">
<Nav />
</div>
21 changes: 21 additions & 0 deletions src/routes/(main)/nav.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script lang="ts">
import { page } from "$app/stores";
const components = ["button", "checkbox", "fieldset", "input", "switch"];
</script>

<nav>
<div class="border-t border-white/[7.5%] py-7">
<h3 class="px-4 pb-4 font-mono text-xs font-semibold uppercase tracking-widest text-white/50">
Forms
</h3>
<div class="flex flex-col gap-4 px-4">
{#each components as component}
<!-- data-active={$page.url.pathname === component} -->
<a
class="group block whitespace-nowrap py-2 px-6 text-white/80 transition-colors duration-200 hover:text-white data-active:font-semibold data-active:text-white lg:py-0 lg:px-0 lg:text-sm"
href="/{component}"
>{component}</a>
{/each}
</div>
</div>
</nav>
1 change: 1 addition & 0 deletions src/routes/+error.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Womp womp</h1>
1 change: 1 addition & 0 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const prerender = true;
38 changes: 0 additions & 38 deletions src/routes/+page.svelte

This file was deleted.

12 changes: 12 additions & 0 deletions src/routes/examples/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import "../../app.css";
let { children } = $props();
</script>

<div class="relative bg-white/5">
<div class="absolute inset-[35%] block rounded-full bg-white/15 blur-2xl"></div>
<div class="relative flex min-h-screen w-full flex-col items-center justify-center">
{@render children()}
</div>
</div>
8 changes: 8 additions & 0 deletions src/routes/examples/button/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script lang="ts">
import Button from "$lib/button/Button.svelte";
</script>

<Button
class="inline-flex items-center gap-2 rounded-md bg-gray-700 py-1.5 px-3 text-sm/6 font-semibold text-white shadow-inner shadow-white/10 focus:outline-none data-[hover]:bg-gray-600 data-[open]:bg-gray-700 data-[focus]:outline-1 data-[focus]:outline-white"
>Save changes
</Button>
15 changes: 15 additions & 0 deletions src/routes/examples/checkbox/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script lang="ts">
import Checkbox from "$lib/checkbox/Checkbox.svelte";
</script>

<p class="text-white">TODO</p>

<!-- <Checkbox
checked={enabled}
onChange={setEnabled}
className="group size-6 rounded-md bg-white/10 p-1 ring-1 ring-white/15 ring-inset data-[checked]:bg-white"
>
<CheckIcon
className="hidden size-4 fill-black group-data-[checked]:block"
/>
</Checkbox> -->
54 changes: 54 additions & 0 deletions src/routes/examples/fieldset/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script lang="ts">
import Field from "$lib/field/Field.svelte";
import Fieldset from "$lib/fieldset/Fieldset.svelte";
import Input from "$lib/input/Input.svelte";
</script>

<div class="w-full max-w-lg px-4">
<Fieldset class="space-y-6 rounded-xl bg-white/5 p-6 sm:p-10">
<p class="text-base/7 font-semibold text-white">Shipping details</p>
<Field>
<p class="text-sm/6 font-medium text-white">Street address</p>
<Input
class="mt-3 block w-full rounded-lg border-none bg-white/5 py-1.5 px-3 text-sm/6 text-white focus:outline-none data-[focus]:outline-2 data-[focus]:-outline-offset-2 data-[focus]:outline-white/25"
/>
</Field>
[TODO Select]
<!-- <Field>
<p class="text-sm/6 font-medium text-white">Country</p>
<p class="text-sm/6 text-white/50">We currently only ship to North America.</p>
<div class="relative">
<Select
class={clsx(
'mt-3 block w-full appearance-none rounded-lg border-none bg-white/5 py-1.5 px-3 text-sm/6 text-white',
'focus:outline-none data-[focus]:outline-2 data-[focus]:-outline-offset-2 data-[focus]:outline-white/25',
// Make the text of each option black on Windows
'*:text-black'
)}
>
<option>Canada</option>
<option>Mexico</option>
<option>United States</option>
</Select>
<ChevronDownIcon
class="group pointer-events-none absolute top-2.5 right-2.5 size-4 fill-white/60"
aria-hidden="true"
/>
</div>
</Field> -->
<Field>
<p class="text-sm/6 font-medium text-white">Delivery notes</p>
<p class="text-sm/6 text-white/50">
If you have a tiger, we'd like to know about it.
</p>
[TODO: TextArea]
<!-- <Textarea
class={clsx(
'mt-3 block w-full resize-none rounded-lg border-none bg-white/5 py-1.5 px-3 text-sm/6 text-white',
'focus:outline-none data-[focus]:outline-2 data-[focus]:-outline-offset-2 data-[focus]:outline-white/25'
)}
rows={3}
/> -->
</Field>
</Fieldset>
</div>
16 changes: 16 additions & 0 deletions src/routes/examples/input/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script lang="ts">
import Field from "$lib/field/Field.svelte";
import Input from "$lib/input/Input.svelte";
</script>

<div class="w-full max-w-md px-4">
<Field>
<p class="text-sm/6 font-medium text-white">Name</p>
<p class="text-sm/6 text-white/50">
Use your real name so people will recognize you.
</p>
<Input
class="mt-3 block w-full rounded-lg border-none bg-white/5 py-1.5 px-3 text-sm/6 text-white focus:outline-none data-[focus]:outline-2 data-[focus]:-outline-offset-2 data-[focus]:outline-white/25"
/>
</Field>
</div>
14 changes: 14 additions & 0 deletions src/routes/examples/switch/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang="ts">
import Switch from "$lib/switch/Switch.svelte";
</script>

<!-- checked={enabled}
onChange={setEnabled} -->
<Switch
class="group relative flex h-7 w-14 cursor-pointer rounded-full bg-white/10 p-1 transition-colors duration-200 ease-in-out focus:outline-none data-[focus]:outline-1 data-[focus]:outline-white data-[checked]:bg-white/10"
>
<span
aria-hidden="true"
class="pointer-events-none inline-block size-5 translate-x-0 rounded-full bg-white ring-0 shadow-lg transition duration-200 ease-in-out group-data-[checked]:translate-x-7"
/>
</Switch>
10 changes: 1 addition & 9 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import adapter from "@sveltejs/adapter-auto";
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";

/** @type {import('@sveltejs/kit').Config} */
const config = {
// TODO: Need to investigate whether accessors and/or dev are necessary
// compilerOptions: {
// accessors: true,
// dev: true,
// discloseVersion: false,
// runes: true,
// },
compilerOptions: {
runes: true,
},

kit: {
adapter: adapter(),
},
Expand Down

0 comments on commit 984c4d6

Please sign in to comment.