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
2 changes: 2 additions & 0 deletions site/src/layouts/Base.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import Analytics from '@vercel/analytics/astro';
import { site } from '../data/site.config';
import { appTokenCss } from '../lib/app-tokens/app-tokens';
import '../styles/index.css';

interface Props { title?: string; description?: string; noindex?: boolean }
Expand Down Expand Up @@ -35,6 +36,7 @@ const jsonLd = {
{noindex && <meta name="robots" content="noindex" />}
<meta name="theme-color" content={site.themeColor} />
<meta name="color-scheme" content="dark" />
<style is:inline set:html={appTokenCss()} />
<link rel="icon" href="/logo.svg" type="image/svg+xml" />
<link rel="icon" href="/favicon.ico" sizes="48x48" />
<link rel="sitemap" href="/sitemap-index.xml" />
Expand Down
11 changes: 11 additions & 0 deletions site/src/lib/app-tokens/app-tokens.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Which of the app's palettes paints the embedded demos. The landing page is dark only, so the
* demos use the app's default palette in its dark variant.
*/
export const APP_TOKENS = {
selector: ".oi-app",
palette: "default",
scheme: "dark",
chartPrefix: "chart",
wearPrefix: "wear",
} as const;
24 changes: 24 additions & 0 deletions site/src/lib/app-tokens/app-tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { CHART_PALETTE } from "~/lib/theme/chart-palette.config";
import { PALETTES } from "~/lib/theme/palettes.config";
import { THEME_DOM, THEME_TOKENS } from "~/lib/theme/theme.config";
import { APP_TOKENS } from "./app-tokens.config";

const declaration = (name: string, value: string): string =>
`${THEME_DOM.tokenPrefix}${name}: ${value};`;

const numbered = (prefix: string, values: readonly string[]): string[] =>
values.map((value, index) => declaration(`${prefix}-${index + 1}`, value));

/**
* The app's palette and chart colours as one CSS rule for the demo scope, read straight from the
* app's config at build time so the demos can never drift from the app.
*/
export function appTokenCss(): string {
const variant = PALETTES[APP_TOKENS.palette][APP_TOKENS.scheme];
const declarations = [
...THEME_TOKENS.map((token) => declaration(token, variant[token])),
...numbered(APP_TOKENS.chartPrefix, CHART_PALETTE.categorical[APP_TOKENS.scheme]),
...numbered(APP_TOKENS.wearPrefix, CHART_PALETTE.wear[APP_TOKENS.scheme]),
];
return `${APP_TOKENS.selector}{${declarations.join("")}}`;
}
65 changes: 40 additions & 25 deletions site/src/mock/demo/items-demo.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChevronsUpDown } from "lucide-react";
import { useDeferredValue, useMemo, useState } from "react";
import { ItemTable } from "~/components/item-table/item-table.component";
import { PageHeader } from "~/components/page-header/page-header.component";
Expand All @@ -11,8 +12,16 @@ import { useDemoInventory } from "./use-demo-inventory";
const ALL = "all";
/** The demo shows only the first matches; the real app lists everything. */
const ROW_CAP = 12;
/**
* Native selects dressed as the app's Select trigger. The app's own Select places its list with
* `position: fixed`, which lands in the wrong spot inside the scaled demo panels.
*/
const SELECT_WRAP_CLASS = "relative min-w-0 flex-1 sm:w-48 sm:flex-none";
const SELECT_CLASS =
"h-8 min-w-0 flex-1 rounded-md border border-input bg-card px-2.5 outline-none sm:flex-none";
"h-8 w-full appearance-none rounded-md border border-control bg-background pl-2.5 pr-7 text-foreground transition-colors hover:bg-muted";
const SELECT_ICON_CLASS =
"pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground";
const SELECT_ICON_SIZE = 14;

/** The real Items page body: search, filters, sortable table and the move bar, on sample data. */
export default function ItemsDemo() {
Expand Down Expand Up @@ -56,30 +65,36 @@ export default function ItemsDemo() {
aria-label={COPY.common.searchPlaceholder}
className="h-8 w-full rounded-md border border-input bg-card px-2.5 outline-none placeholder:text-muted-foreground focus:border-primary sm:w-44"
/>
<select
value={location}
onChange={(e) => setLocation(e.target.value)}
className={SELECT_CLASS}
aria-label={COPY.itemColumns.location}
>
<option value={ALL}>{COPY.items.allLocations}</option>
{locations.map(([id, name]) => (
<option key={id} value={id}>
{name}
</option>
))}
</select>
<select
value={type}
onChange={(e) => setType(e.target.value)}
className={SELECT_CLASS}
aria-label={COPY.itemColumns.type}
>
<option value={ALL}>{COPY.items.allTypes}</option>
{types.map((t) => (
<option key={t}>{t}</option>
))}
</select>
<div className={SELECT_WRAP_CLASS}>
<select
value={location}
onChange={(e) => setLocation(e.target.value)}
className={SELECT_CLASS}
aria-label={COPY.itemColumns.location}
>
<option value={ALL}>{COPY.items.allLocations}</option>
{locations.map(([id, name]) => (
<option key={id} value={id}>
{name}
</option>
))}
</select>
<ChevronsUpDown size={SELECT_ICON_SIZE} className={SELECT_ICON_CLASS} aria-hidden />
</div>
<div className={SELECT_WRAP_CLASS}>
<select
value={type}
onChange={(e) => setType(e.target.value)}
className={SELECT_CLASS}
aria-label={COPY.itemColumns.type}
>
<option value={ALL}>{COPY.items.allTypes}</option>
{types.map((t) => (
<option key={t}>{t}</option>
))}
</select>
<ChevronsUpDown size={SELECT_ICON_SIZE} className={SELECT_ICON_CLASS} aria-hidden />
</div>
</PageHeader>
<DemoTransferStatus transfer={transfer} onDismiss={dismiss} />
{selectedItems.length > 0 && (
Expand Down
2 changes: 1 addition & 1 deletion site/src/mock/demo/storage-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function StorageDemo() {
<div className="oi-app flex h-[640px] flex-col gap-3 p-4">
<PageHeader title={copy.title} description={copy.description} />
<div className="flex min-h-0 flex-1 flex-col gap-3 md:flex-row">
<div className="flex shrink-0 gap-2 overflow-hidden md:w-60 md:flex-col">
<div className="flex shrink-0 gap-2 overflow-hidden md:w-72 md:flex-col">
{units.map((unit) => (
<UnitCard
key={unit.id}
Expand Down
65 changes: 23 additions & 42 deletions site/src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@
--color-border: var(--border);
--color-input: var(--input);
--color-accent: var(--accent);
--color-accent-strong: var(--accent-strong);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-success: var(--success);
--color-destructive: var(--destructive);
--color-destructive-solid: var(--destructive-solid);
/* Hovered solid buttons darken, so their dark or white text only gains contrast. */
--color-primary-hover: color-mix(in oklab, var(--primary) 88%, black);
--color-destructive-solid-hover: color-mix(in oklab, var(--destructive-solid) 88%, black);
--color-warning: var(--warning);
/* Tokens the app's spec-sheet components use; values sit on .oi-app below. */
--color-accent-foreground: var(--accent-foreground);
Expand All @@ -60,51 +65,20 @@

/* The vendored app: tokens scoped to its frame, plus a small reset (Tailwind's preflight stays off). */
.oi-app {
/* Palette and chart colours come from the app's own config: see src/lib/app-tokens. */
color-scheme: dark;
--background: #0a0a0a;
--foreground: #f5f5f5;
--card: color-mix(in srgb, #0a0a0a 97%, white);
--thumb-base-tint: 18%;
--thumb-dot-tint: 100%;
--thumb-art-tone: contrast(0.82) brightness(1.13);
--muted: rgb(255 255 255 / 0.03);
--muted-foreground: #8d8d8d;
--border: rgb(255 255 255 / 0.08);
--input: rgb(255 255 255 / 0.1);
--accent: rgb(255 255 255 / 0.04);
--primary: oklch(57.1% 0.21 264);
--primary-foreground: #ffffff;
--success: #10b981;
--destructive: #f87171;
--warning: #fbbf24;
--skeleton: rgb(255 255 255 / 0.06);
--skeleton-highlight: rgb(255 255 255 / 0.1);
--accent-foreground: var(--foreground);
--accent-ink: var(--primary);
--accent-edge: transparent;
--primary-edge: transparent;
--border-strong: rgb(255 255 255 / 0.12);
--control-border: #636363;
--fill-1: #f5f5f5;
--fill-2: #9a9a9a;
--fill-3: #5c5c5c;
--fill-4: #3a3a3a;
--fill-5: #262626;
--slot-empty: rgb(255 255 255 / 0.1);
/* Data-visualisation palette, dark values from the app's src/index.css. */
--chart-1: #87bafd;
--chart-2: #c97409;
--chart-3: #2bd2c2;
--chart-4: #d8559b;
--chart-5: #b385fb;
--chart-6: #f3c935;
--chart-7: #0f99c9;
--chart-8: #fd968f;
--wear-1: #b5e2fd;
--wear-2: #74ccfe;
--wear-3: #33b4f2;
--wear-4: #109bd5;
--wear-5: #0481b3;
/* Derived exactly as the app's src/index.css derives them. */
--accent-ink: var(--accent-strong);
--border-strong: color-mix(in srgb, var(--foreground) 12%, transparent);
--fill-1: var(--foreground);
--fill-2: color-mix(in srgb, var(--foreground) 61%, var(--background));
--fill-3: color-mix(in srgb, var(--foreground) 35%, var(--background));
--fill-4: color-mix(in srgb, var(--foreground) 20%, var(--background));
--fill-5: color-mix(in srgb, var(--foreground) 12%, var(--background));
--slot-empty: color-mix(in srgb, var(--foreground) 10%, transparent);
}

/* The landing's global `button { border: 0 }` (layer site) resets border colour to currentColor and outranks the app reset below; restore the app's token. */
Expand Down Expand Up @@ -207,10 +181,17 @@
outline-offset: -2px;
}
.oi-app :focus-visible {
outline: 2px solid var(--primary);
outline: 2px solid var(--accent-ink);
outline-offset: 2px;
border-radius: 4px;
}
.oi-app .no-focus-ring:focus-visible {
outline: none;
}
.oi-app input[type="checkbox"],
.oi-app input[type="radio"] {
accent-color: var(--accent-ink);
}
}

@keyframes skeleton-shimmer {
Expand Down
2 changes: 1 addition & 1 deletion site/src/styles/sections/bento.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
letter-spacing: 0.02em;
}

/* ── Shared: the app's own UI vocabulary, rebuilt with tokens (Tailwind never scans this folder, and the vendored .oi-app scope would paint the primary blue, so the app's measurements are copied here and its primary maps to the lime accent) ── */
/* ── Shared: the app's own UI vocabulary, rebuilt with tokens (Tailwind never scans this folder, so the app's measurements are copied here and its primary maps to the lime accent) ── */
.bento__ui {
--ui-fg: var(--c-fg);
--ui-muted: #8d8d8d;
Expand Down
Loading