Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
--color-rule: var(--rule);
--color-brand: var(--brand);
--color-charge: var(--charge);
--color-on-brand: var(--on-brand);
--color-chrome: var(--chrome);
--color-chrome-fg: var(--chrome-fg);
--color-chrome-mid: var(--chrome-mid);
--color-sidebar-ring: var(--sidebar-ring);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
Expand Down Expand Up @@ -59,7 +63,8 @@
--radius-4xl: calc(var(--radius) * 2.6);
}

:root {
:root,
.light {
/* HoverUI homepage tokens */
--paper: #e7e9e4; /* page — pale grey-green, a lab bench, not cream */
--surface: #f4f5f2; /* tile surface */
Expand All @@ -86,6 +91,23 @@
*/
--brand: #ff5400;
--charge: #b83a00;
/* Text on a --brand fill. Fixed in both themes: --ink inverts, and light ink on the
brand orange drops to ~2.7:1. #14150F on #FF5400 is 5.70:1. */
--on-brand: #14150f;

/*
* The pills in the header bezel and the solid badges. They are dark in BOTH themes — a
* dark control on a pale bench in light mode, a raised one in dark mode — so --brand can
* be the hover text colour on them everywhere (5.70:1 on #14150F, 5.32:1 on #1B1C17).
* --chrome-mid is 7.49:1 / 7.00:1 respectively.
*/
--chrome: #14150f;
--chrome-fg: #e7e9e4;
--chrome-mid: #a3a79d;

/* The charge field's alpha. A 9% radial reads as a field on the pale bench; on the dark
one the same alpha is closer to a torch, so it drops there (docs/DESIGN.md § Signature). */
--charge-alpha: 9%;

--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
Expand Down Expand Up @@ -121,7 +143,28 @@
--sidebar-ring: oklch(0.708 0 0);
}

/*
* Dark theme. The same bench with the lights down: still green-shifted, still achromatic at
* rest. Measured (docs/DESIGN.md § Dark theme):
* --ink #ECEDE8 16.34:1 on --paper, 15.17:1 on --surface
* --mid #8D9187 5.98:1 on --paper, 5.55:1 on --surface
* --charge #FF7A3D 7.42:1 on --paper, 6.89:1 on --surface, and --paper on it 7.42:1
* --brand keeps its value; on this bench it could carry text (5.97:1), but it still only
* appears under the pointer.
*/
.dark {
--paper: #0e0f0c;
--surface: #171813;
--ink: #ecede8;
--mid: #8d9187;
--rule: #2a2c25;
--charge: #ff7a3d;
--chrome: #1b1c17;
--chrome-fg: #ecede8;
--chrome-mid: #a3a79d;
--charge-alpha: 7%;
color-scheme: dark;

--background: oklch(0.145 0 0);
--foreground: oklch(0.985 0 0);
--card: oklch(0.205 0 0);
Expand Down Expand Up @@ -220,6 +263,45 @@
scroll-behavior: auto;
}
}
/* The effect sheet is a modal <dialog>; the page behind it must not scroll under it. */
html:has(dialog[open]) {
overflow: hidden;
}
}

/*
* The effect sheet (components/gallery/effect-sheet.tsx). Opens on the out-curve inside the
* enter band; the backdrop fades with it. @starting-style gives the open state a "from"
* value without a JS frame. Closing is instant on purpose: the visitor has already decided
* to leave, and a release animation would hold the page they are returning to.
*/
.effect-sheet {
opacity: 1;
transform: translateY(0) scale(1);
transition:
opacity 220ms cubic-bezier(0.23, 1, 0.32, 1),
transform 220ms cubic-bezier(0.23, 1, 0.32, 1);
}
.effect-sheet::backdrop {
background: color-mix(in oklch, var(--paper) 72%, transparent);
backdrop-filter: blur(6px);
}
@starting-style {
.effect-sheet[open] {
opacity: 0;
transform: translateY(12px) scale(0.985);
}
}
@media (prefers-reduced-motion: reduce) {
.effect-sheet {
transition: opacity 160ms linear;
transform: none;
}
@starting-style {
.effect-sheet[open] {
transform: none;
}
}
}

/*
Expand Down
13 changes: 13 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,25 @@ export const metadata: Metadata = {
// app/favicon.ico is picked up by the file convention; nothing to declare here.
};

/*
* Runs before first paint, so a returning dark-theme visitor never sees a light frame. The
* stored choice wins; with none, the OS preference decides. Kept tiny and inline because an
* external file would arrive after the paint it exists to prevent. The toggle that writes
* the key is components/site/theme-toggle.tsx.
*/
const THEME_SCRIPT = `try{var t=localStorage.getItem("hoverui-theme");if(t!=="light"&&t!=="dark")t=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";if(t==="dark")document.documentElement.classList.add("dark")}catch(e){}`;

export default function RootLayout({ children }: LayoutProps<"/">) {
return (
<html
lang="en"
// The theme script edits this element's class before React hydrates it.
suppressHydrationWarning
className={`${geistSans.variable} ${geistMono.variable} ${bricolage.variable} h-full antialiased`}
>
<head>
<script dangerouslySetInnerHTML={{ __html: THEME_SCRIPT }} />
</head>
<body className="min-h-full flex flex-col font-sans">{children}</body>
</html>
);
Expand Down
11 changes: 5 additions & 6 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { SiteHeader, SkipLink } from "@/components/site/site-header";
* The whole site is this one page (SCOPE.md), so this file is deliberately only its running
* order. Each region owns its own markup, its own copy and the reasoning behind its layout:
*
* components/site/site-header.tsx the bezel, the nav menu and the skip link
* components/site/site-header.tsx the pills, the nav, the theme toggle and the skip link
* components/hero/hero.tsx the headline, the install command, the logotype
* components/gallery/gallery.tsx a section per group, mapped from lib/registry.ts
* components/gallery/effect-sheet.tsx each effect's preview, code, install and motion
* components/site/site-footer.tsx the two closing lines
*
* `main` sets the measure every one of them lines up against — max-w-6xl and px-6. The header
* repeats that box rather than nesting inside it, because it sits outside `main` and has to
* arrive at the same edges on its own.
* repeats that box rather than nesting inside it, because it is sticky outside `main` and has
* to arrive at the same edges on its own.
*/
export default function Home() {
return (
Expand All @@ -24,9 +25,7 @@ export default function Home() {
<ChargeField />

<SkipLink />
<div className="mx-auto w-full max-w-6xl px-6">
<SiteHeader />
</div>
<SiteHeader />
<main className="mx-auto w-full max-w-6xl flex-1 px-6">
<Hero />
<Gallery />
Expand Down
2 changes: 1 addition & 1 deletion components/gallery/charge-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function ChargeField() {
// boundary, so the contrast floor that forces --charge to be the darker tone does not
// apply, and the field gets to be the actual brand orange.
background:
"radial-gradient(560px circle at var(--px) var(--py), color-mix(in oklch, var(--brand) 9%, transparent), transparent 62%)",
"radial-gradient(560px circle at var(--px) var(--py), color-mix(in oklch, var(--brand) var(--charge-alpha), transparent), transparent 62%)",
}}
/>
);
Expand Down
74 changes: 74 additions & 0 deletions components/gallery/copy-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"use client";

import * as React from "react";

/**
* One copy control, used by the tile footer and every panel of the effect sheet. It confirms
* in place — the glyph becomes a tick and the accessible name says so — rather than raising a
* toast somewhere else on the screen.
*/
export function CopyButton({
text,
label,
className = "",
children,
}: {
text: string;
/** What is being copied, for the accessible name: "Copy {label}". */
label: string;
className?: string;
/** Optional visible text beside the glyph. */
children?: React.ReactNode;
}) {
const [copied, setCopied] = React.useState(false);
const timer = React.useRef<number | undefined>(undefined);

React.useEffect(() => () => window.clearTimeout(timer.current), []);

const copy = async () => {
try {
await navigator.clipboard.writeText(text);
setCopied(true);
window.clearTimeout(timer.current);
timer.current = window.setTimeout(() => setCopied(false), 1600);
} catch {
// Clipboard blocked (insecure context / denied). The text is on screen to select.
}
};

return (
<button
type="button"
onClick={copy}
aria-label={copied ? `${label} copied` : `Copy ${label}`}
className={[
"inline-flex shrink-0 items-center justify-center gap-1.5 text-[var(--mid)]",
"[transition:color_200ms_cubic-bezier(0.23,1,0.32,1),background-color_200ms_cubic-bezier(0.23,1,0.32,1),transform_140ms_cubic-bezier(0.23,1,0.32,1)]",
"hover:bg-[color-mix(in_oklch,var(--charge)_9%,transparent)] hover:text-[var(--charge)] active:[transform:scale(0.94)]",
"focus-visible:text-[var(--charge)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--charge)]",
className,
].join(" ")}
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={1.6}
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden
className="size-4"
>
{copied ? (
<polyline points="4 12 10 18 20 6" />
) : (
<>
<rect x="8.5" y="8.5" width="12" height="12" rx="2.5" />
<path d="M15.5 8.5V6a2.5 2.5 0 0 0-2.5-2.5H6A2.5 2.5 0 0 0 3.5 6v7A2.5 2.5 0 0 0 6 15.5h2.5" />
</>
)}
</svg>
{children ? <span aria-hidden>{copied ? "Copied" : children}</span> : null}
</button>
);
}
Loading
Loading