From 4bbbbe4952a0430e014f57d23d5f327783ecbc18 Mon Sep 17 00:00:00 2001 From: Ole Stangeland Date: Mon, 28 Sep 2026 12:57:02 +0200 Subject: [PATCH 01/10] 2 set up global styles and design tokens (#3) * feat: add design tokens and cascade layers * feat: add global reset and base styles * feat: add shared style utilities and wire global styles * test: add visual style verification pages * docs: document styling structure and usage * fix: apply Prettier formatting for CI --- apps/web/src/main.tsx | 8 +- apps/web/src/styles.css | 19 - apps/web/src/styles/base.css | 102 +++ apps/web/src/styles/layers.css | 2 + apps/web/src/styles/resets.css | 74 ++ apps/web/src/styles/style_guide/SKILL.md | 467 ++++++++++++ .../src/styles/style_guide/StylesGuide.tsx | 341 +++++++++ .../styles/style_tests/ColorAndStateTest.tsx | 504 +++++++++++++ .../style_tests/FoundationStressTest.tsx | 666 ++++++++++++++++++ .../style_tests/LayoutUtilitiesTest.tsx | 383 ++++++++++ .../src/styles/style_tests/StyleTestSuite.tsx | 18 + .../src/styles/style_tests/TypographyTest.tsx | 248 +++++++ apps/web/src/styles/tokens.css | 219 ++++++ apps/web/src/styles/utilities.css | 205 ++++++ 14 files changed, 3236 insertions(+), 20 deletions(-) delete mode 100644 apps/web/src/styles.css create mode 100644 apps/web/src/styles/base.css create mode 100644 apps/web/src/styles/layers.css create mode 100644 apps/web/src/styles/resets.css create mode 100644 apps/web/src/styles/style_guide/SKILL.md create mode 100644 apps/web/src/styles/style_guide/StylesGuide.tsx create mode 100644 apps/web/src/styles/style_tests/ColorAndStateTest.tsx create mode 100644 apps/web/src/styles/style_tests/FoundationStressTest.tsx create mode 100644 apps/web/src/styles/style_tests/LayoutUtilitiesTest.tsx create mode 100644 apps/web/src/styles/style_tests/StyleTestSuite.tsx create mode 100644 apps/web/src/styles/style_tests/TypographyTest.tsx create mode 100644 apps/web/src/styles/tokens.css create mode 100644 apps/web/src/styles/utilities.css diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index 2d61927..ad07e99 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -1,8 +1,14 @@ import { StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; + +import './styles/layers.css'; +import './styles/resets.css'; +import './styles/tokens.css'; +import './styles/base.css'; +import './styles/utilities.css'; + import { App } from './App'; -import './styles.css'; createRoot(document.getElementById('root')!).render( diff --git a/apps/web/src/styles.css b/apps/web/src/styles.css deleted file mode 100644 index 837c4bb..0000000 --- a/apps/web/src/styles.css +++ /dev/null @@ -1,19 +0,0 @@ -:root { - font-family: system-ui; - color-scheme: light dark; -} -body { - margin: 0; -} -header, -nav { - display: flex; - gap: 1rem; -} -header, -main { - padding: 1rem; -} -a { - color: inherit; -} diff --git a/apps/web/src/styles/base.css b/apps/web/src/styles/base.css new file mode 100644 index 0000000..c4b3761 --- /dev/null +++ b/apps/web/src/styles/base.css @@ -0,0 +1,102 @@ +@layer base { + /* Global page defaults */ + html { + color-scheme: light; + } + + body { + font-family: var(--font-family-base); + font-size: var(--font-size-md); + font-weight: var(--font-weight-regular); + line-height: var(--line-height-normal); + color: var(--color-text-primary); + background-color: var(--color-bg-page); + } + + /* Headings */ + h1, + h2, + h3, + h4, + h5, + h6 { + font-family: var(--font-family-heading); + font-weight: var(--font-weight-semibold); + line-height: var(--line-height-tight); + } + + h1, + h2, + h3 { + letter-spacing: var(--letter-spacing-tight); + } + + h1 { + font-size: var(--font-size-4xl); + } + + h2 { + font-size: var(--font-size-3xl); + } + + h3 { + font-size: var(--font-size-2xl); + } + + h4 { + font-size: var(--font-size-xl); + } + + h5 { + font-size: var(--font-size-lg); + } + + h6 { + font-size: var(--font-size-md); + } + + /* Links */ + a { + color: var(--color-text-accent); + text-decoration-thickness: from-font; + text-underline-offset: 0.15em; + } + + a:hover { + color: var(--color-brand-primary-hover); + } + + /* Keyboard focus */ + :focus-visible { + outline: var(--border-width-medium) solid var(--color-focus-ring); + outline-offset: 2px; + } + + /* Placeholder text */ + ::placeholder { + color: var(--color-text-muted); + opacity: 1; + } + + /* Text emphasis */ + strong, + b { + font-weight: var(--font-weight-semibold); + } + + small { + font-size: var(--font-size-sm); + } + + /* Text selection */ + ::selection { + color: var(--color-selection-text); + background-color: var(--color-selection-bg); + } + + /* Dividers */ + hr { + border: 0; + border-top: var(--border-width-thin) solid var(--color-border-divider); + } +} diff --git a/apps/web/src/styles/layers.css b/apps/web/src/styles/layers.css new file mode 100644 index 0000000..d42cf6b --- /dev/null +++ b/apps/web/src/styles/layers.css @@ -0,0 +1,2 @@ +/* Cascade order: later layers take priority over earlier layers. */ +@layer reset, base, components, utilities; diff --git a/apps/web/src/styles/resets.css b/apps/web/src/styles/resets.css new file mode 100644 index 0000000..13cebc5 --- /dev/null +++ b/apps/web/src/styles/resets.css @@ -0,0 +1,74 @@ +@layer reset { + /* Use predictable box sizing */ + *, + *::before, + *::after { + box-sizing: border-box; + } + + /* Ensure the page can fill the viewport */ + html { + min-height: 100%; + } + + body { + margin: 0; + min-height: 100dvh; + } + + /* Keep media within its container */ + img, + picture, + video, + canvas { + display: block; + max-width: 100%; + } + + /* Preserve media aspect ratio */ + img, + picture, + video { + height: auto; + } + + /* Remove inline SVG baseline spacing */ + svg { + display: block; + } + + /* Inherit surrounding form typography */ + button, + input, + select, + textarea { + font: inherit; + color: inherit; + } + + /* Prevent long text from overflowing */ + p, + h1, + h2, + h3, + h4, + h5, + h6 { + overflow-wrap: anywhere; + } + + /* Remove default content margins */ + h1, + h2, + h3, + h4, + h5, + h6, + p, + figure, + blockquote, + dl, + dd { + margin: 0; + } +} diff --git a/apps/web/src/styles/style_guide/SKILL.md b/apps/web/src/styles/style_guide/SKILL.md new file mode 100644 index 0000000..44143b9 --- /dev/null +++ b/apps/web/src/styles/style_guide/SKILL.md @@ -0,0 +1,467 @@ +# Project CSS Style System + +Use this file as the reference for understanding and extending the project's `/styles` foundation. + +## Files and responsibilities + +- `layers.css` — declares the cascade order. +- `tokens.css` — global design tokens only: colors, spacing, type scales, radii, shadows, control sizes, layout values, motion, and z-index values. +- `resets.css` — browser normalization and predictable low-level behavior. +- `base.css` — default styling for plain HTML elements. +- `utilities.css` — small opt-in layout and helper classes. +- Component CSS — component-specific styling, wrapped in `@layer components`. + +Global cascade order: + +```css +@layer reset, base, components, utilities; +``` + +Later layers have higher priority for normal declarations. + +Important: ordinary unlayered author CSS outranks normal layered CSS. Keep application rules inside the appropriate layer. + +## Global import order + +Load the global files in this order: + +```ts +import './styles/layers.css'; +import './styles/tokens.css'; +import './styles/resets.css'; +import './styles/base.css'; +import './styles/utilities.css'; +``` + +`tokens.css` is intentionally unlayered because it mainly defines custom properties. + +## General styling rules + +1. Use existing tokens instead of hard-coded values when an appropriate token exists. +2. Use utilities for composition and small explicit overrides. +3. Put component appearance in component CSS, not in `utilities.css`. +4. Wrap component CSS in `@layer components`. +5. Prefer component classes over broad HTML selectors inside component styles. +6. Add a new global token only when the value represents a reusable design-system decision. +7. Add a new utility only when the pattern is broadly reusable across multiple components. +8. Do not recreate a large utility framework manually. Prefer normal component CSS for most visual styling. + +## Important token groups + +### Colors + +Use semantic color tokens rather than raw hex values. + +Common examples: + +```css +var(--color-bg-page) +var(--color-surface) +var(--color-surface-raised) +var(--color-text-primary) +var(--color-text-secondary) +var(--color-text-muted) +var(--color-text-accent) +var(--color-border-default) +var(--color-border-divider) +``` + +Brand states: + +```css +var(--color-brand-primary) +var(--color-brand-primary-hover) +var(--color-brand-primary-active) +``` + +Generic interactive surfaces: + +```css +var(--color-surface-hover) +var(--color-surface-selected) +var(--color-surface-pressed) +``` + +Do not invent `--color-surface-active`; generic surface interaction uses hover / selected / pressed. + +Feedback: + +```css +var(--color-feedback-success) +var(--color-feedback-warning) +var(--color-feedback-error) +var(--color-feedback-info) +``` + +Each feedback color has matching `-surface` and `-border` tokens. + +For longer alert body text, prefer normal readable text colors where appropriate; semantic feedback colors are especially useful for headings, icons, and short labels. + +Backdrop: + +```css +var(--color-backdrop) +``` + +Use the backdrop token in modal/dialog/drawer component CSS rather than adding a generic `.backdrop` utility. + +### Spacing + +Use the spacing scale: + +```css +var(--space-1) +var(--space-2) +var(--space-3) +var(--space-4) +var(--space-5) +var(--space-6) +var(--space-8) +var(--space-10) +var(--space-12) +var(--space-16) +``` + +Example: + +```css +.card { + padding: var(--space-5); + gap: var(--space-3); +} +``` + +Do not add component-specific global spacing tokens such as `--card-padding` unless repeated usage proves they are useful. + +### Typography + +Use: + +```css +var(--font-family-base) +var(--font-family-heading) + +var(--font-size-xs) +var(--font-size-sm) +var(--font-size-md) +var(--font-size-lg) +var(--font-size-xl) +var(--font-size-2xl) +var(--font-size-3xl) +var(--font-size-4xl) + +var(--font-weight-regular) +var(--font-weight-medium) +var(--font-weight-semibold) +var(--font-weight-bold) + +var(--line-height-tight) +var(--line-height-snug) +var(--line-height-normal) +var(--line-height-relaxed) +``` + +The larger font sizes are fluid. Do not add breakpoint-specific heading sizes unless the existing scale is insufficient. + +Heading defaults already come from `base.css`; components should override them only when the component has a real need. + +### Radius, borders, and shadows + +```css +var(--radius-sm) +var(--radius-md) +var(--radius-lg) +var(--radius-xl) +var(--radius-full) + +var(--border-width-thin) +var(--border-width-medium) +var(--border-width-thick) + +var(--shadow-sm) +var(--shadow-md) +var(--shadow-lg) +``` + +Typical card example: + +```css +.card { + background: var(--color-surface); + border: var(--border-width-thin) solid var(--color-border-default); + border-radius: var(--radius-lg); + box-shadow: var(--shadow-sm); +} +``` + +### Layout + +Use: + +```css +var(--page-padding-inline) +var(--container-max-width) +``` + +The `.container` utility already applies both. + +```tsx +
...
+``` + +Do not create another page-wrapper abstraction unless a genuinely different layout is needed. + +### Controls and targets + +```css +var(--control-height-sm) +var(--control-height-md) +var(--control-height-lg) +var(--target-size-min) +``` + +Control height and target size are not the same concept. A compact visual control may be smaller than the desired touch target. + +For icon buttons and touch-oriented controls, explicitly respect `--target-size-min`. + +### Icons + +```css +var(--icon-size-sm) +var(--icon-size-md) +var(--icon-size-lg) +var(--icon-size-xl) +``` + +UI icons inside flex layouts often need `.shrink-0` so they keep their intended size. + +### Motion + +```css +var(--duration-fast) +var(--duration-normal) +var(--duration-slow) + +var(--ease-standard) +var(--ease-in) +var(--ease-out) +``` + +Apply motion intentionally in components. Do not add global transitions. + +### Layering + +Expected semantic order: + +```css +var(--z-sticky) +var(--z-dropdown) +var(--z-overlay) +var(--z-modal) +``` + +Use the semantic token that matches the UI role rather than arbitrary large numbers. + +## Current utilities + +### Container + +```tsx +
...
+``` + +### Display + +```text +.block +.flex +.inline-flex +.grid +.hidden +``` + +### Flex direction / behavior + +```text +.flex-row +.flex-col +.flex-wrap +.flex-1 +.shrink-0 +.grow +``` + +### Alignment + +```text +.items-start +.items-center +.items-end + +.justify-start +.justify-center +.justify-between +.justify-end +``` + +### Gaps + +```text +.gap-1 +.gap-2 +.gap-3 +.gap-4 +.gap-6 +.gap-8 +``` + +Use component CSS with `var(--space-*)` when a specific gap is part of a component's design rather than general composition. + +### Sizing / overflow + +```text +.w-full +.h-full +.min-w-0 +.min-h-0 +.overflow-hidden +.overflow-auto +``` + +`min-w-0` is especially useful for text/content inside flex and grid layouts that must be allowed to shrink. + +`min-h-0` is useful for scrollable children inside constrained flex/grid layouts. + +### Text utilities + +```text +.text-left +.text-center +.text-right + +.text-default +.text-secondary +.text-muted +.text-accent + +.font-medium +.font-semibold +.font-bold +``` + +`.text-default` maps to `--color-text-primary`. + +### Accessibility + +```text +.sr-only +``` + +Use `.sr-only` for content that should remain available to assistive technology while being visually hidden. + +## Component CSS pattern + +Recommended: + +```css +@layer components { + .recipe-card { + padding: var(--space-5); + color: var(--color-text-primary); + background: var(--color-surface); + border: var(--border-width-thin) solid var(--color-border-default); + border-radius: var(--radius-lg); + box-shadow: var(--shadow-sm); + } + + .recipe-card:hover { + background: var(--color-surface-hover); + } +} +``` + +React: + +```tsx +import './RecipeCard.css'; + +export function RecipeCard() { + return
...
; +} +``` + +Avoid broad selectors inside component CSS: + +```css +/* Avoid */ +button { ... } +input { ... } +``` + +Prefer: + +```css +.recipe-card__button { ... } +.recipe-search__input { ... } +``` + +## Utility vs component CSS + +Use a utility when the intent is generic: + +```tsx +
+``` + +Use component CSS when the rule defines the component's appearance: + +```css +.recipe-card { + padding: var(--space-5); + border-radius: var(--radius-lg); +} +``` + +Do not add utilities such as `.card-padding`, `.dialog-width`, or `.recipe-gap` unless they become broadly reusable concepts. + +## Accessibility notes + +- Preserve the global `:focus-visible` behavior unless a component provides an equally visible or better focus treatment. +- Use semantic text colors rather than lowering opacity for readable text. +- Disabled text should remain readable; disabled appearance should not depend on near-invisibility. +- Do not use white text on the primary orange automatically for small normal text; verify contrast for the actual component treatment. +- Use `--target-size-min` where touch/click target size matters. +- Use `.sr-only` for accessible hidden labels. +- The reset prevents long paragraph/heading text from forcing overflow; component layouts should still use `min-w-0` when needed. + +## Adding new tokens + +Before adding a token, ask: + +1. Is this value reused across multiple components? +2. Does it represent a design-system concept rather than one component's implementation? +3. Is there already an existing token that expresses the same role? +4. Is a local component custom property more appropriate? + +Good global token: + +```css +--color-feedback-error +``` + +Usually not a global token initially: + +```css +--recipe-card-padding +``` + +## Adding new utilities + +Before adding a utility, ask: + +1. Is it generic? +2. Will it be reused in multiple unrelated components? +3. Is it clearer than simply writing the property in component CSS? +4. Will adding it encourage a large hand-built utility framework? + +Prefer keeping `utilities.css` small and intentional. diff --git a/apps/web/src/styles/style_guide/StylesGuide.tsx b/apps/web/src/styles/style_guide/StylesGuide.tsx new file mode 100644 index 0000000..561a10c --- /dev/null +++ b/apps/web/src/styles/style_guide/StylesGuide.tsx @@ -0,0 +1,341 @@ +import type { CSSProperties } from 'react'; + +const sampleCard: CSSProperties = { + padding: 'var(--space-5)', + backgroundColor: 'var(--color-surface)', + border: 'var(--border-width-thin) solid var(--color-border-default)', + borderRadius: 'var(--radius-lg)', + boxShadow: 'var(--shadow-sm)', +}; + +const tokenRows = [ + ['Spacing', '--space-1 … --space-16', 'Padding, gaps, and component spacing'], + [ + 'Typography', + '--font-size-*, --font-weight-*, --line-height-*', + 'Text hierarchy and readable defaults', + ], + [ + 'Colors', + '--color-*', + 'Use semantic colors instead of hard-coded hex values', + ], + ['Radius', '--radius-*', 'Cards, controls, pills, and surfaces'], + ['Shadows', '--shadow-*', 'Raised surfaces and overlays'], + [ + 'Controls', + '--control-height-*, --target-size-min', + 'Consistent controls and interactive targets', + ], + [ + 'Layout', + '--page-padding-inline, --container-max-width', + 'Responsive page gutters and content width', + ], + ['Motion', '--duration-*, --ease-*', 'Transitions and animations'], + ['Layering', '--z-*', 'Sticky UI, dropdowns, overlays, and modals'], +]; + +function StylesGuide() { + return ( +
+
+
+

Styles Guide

+

+ A practical reference for the global tokens, utilities, and cascade + rules in /styles. +

+
+ +
+

1. Start with the global foundation

+ +
+

+ Plain HTML already receives the base typography, page colors, + focus treatment, placeholder styling, and heading hierarchy. +

+ +
+ Example link + Secondary text + Muted text + Accent text +
+
+
+ +
+

2. Use utilities for composition

+ +

+ Utilities are best for layout and small opt-in overrides. Component + appearance should normally live in component CSS. +

+ +
+
+
+ +
+ Recipe title + 20 min · 4 servings +
+
+ + Saved +
+ +
+            {`
+
+ +
...
+
+
`} +
+
+ +
+

3. Use tokens inside component CSS

+ +

+ Prefer semantic tokens over raw values when styling a reusable + component. +

+ +
+            {`@layer components {
+  .card {
+    padding: var(--space-5);
+    color: var(--color-text-primary);
+    background: var(--color-surface);
+    border: var(--border-width-thin) solid var(--color-border-default);
+    border-radius: var(--radius-lg);
+    box-shadow: var(--shadow-sm);
+  }
+
+  .card:hover {
+    background: var(--color-surface-hover);
+  }
+}`}
+          
+
+ +
+

4. Common token groups

+ +
+ + + + + + + + + + + {tokenRows.map(([category, tokens, use]) => ( + + + + + + ))} + +
CategoryTokensUse
+ {category} + + {tokens} + {use}
+
+
+ +
+

5. Common patterns

+ +
+ ...
`} + /> + + ...
`} + /> + + ...`} + /> + + ...`} + /> + + ...`} + /> + + Save recipe`} + /> + + + +
+

6. Component styling rules

+ +
+

+ Put component-specific selectors in the components{' '} + cascade layer. +

+ +
+              {`@layer components {
+  .button {
+    min-height: var(--control-height-md);
+    padding-inline: var(--space-4);
+    border-radius: var(--radius-md);
+  }
+}`}
+            
+ +

+ Avoid broad selectors such as button or{' '} + input inside component CSS. Prefer a component class. +

+
+
+ +
+

7. Cascade priority

+ +
+ reset < base < components < utilities + +

+ Utilities intentionally win over component styles. Keep normal + application rules inside a declared layer; unlayered author CSS + has higher priority than normal layered CSS. +

+
+
+ +
+

8. Prefer semantic states

+ +
+ + + +
+ +

+ Brand controls separately use{' '} + --color-brand-primary-hover and{' '} + --color-brand-primary-active. +

+
+ +
+

9. Accessibility defaults

+ +
+

+ The base layer supplies :focus-visible, readable text + selection, and placeholder styling. +

+ + + +

+ Use --target-size-min when an interactive target must + stay comfortably clickable, especially for icon buttons. +

+
+
+ + + ); +} + +const cellStyle: CSSProperties = { + padding: 'var(--space-3)', + textAlign: 'left', + verticalAlign: 'top', + borderBottom: 'var(--border-width-thin) solid var(--color-border-divider)', +}; + +function Example({ title, code }: { title: string; code: string }) { + return ( +
+ {title} + {code} +
+ ); +} + +function StateSample({ + label, + background, +}: { + label: string; + background: string; +}) { + return ( +
+ {label} +
+ ); +} + +export default StylesGuide; diff --git a/apps/web/src/styles/style_tests/ColorAndStateTest.tsx b/apps/web/src/styles/style_tests/ColorAndStateTest.tsx new file mode 100644 index 0000000..890695b --- /dev/null +++ b/apps/web/src/styles/style_tests/ColorAndStateTest.tsx @@ -0,0 +1,504 @@ +const palette = [ + { + name: 'Brand Primary', + token: '--color-brand-primary', + }, + { + name: 'Brand Primary Hover', + token: '--color-brand-primary-hover', + }, + { + name: 'Brand Primary Active', + token: '--color-brand-primary-active', + }, + { + name: 'Brand Accent Soft', + token: '--color-brand-accent-soft', + }, + { + name: 'Page Background', + token: '--color-bg-page', + }, + { + name: 'Subtle Background', + token: '--color-bg-subtle', + }, + { + name: 'Surface', + token: '--color-surface', + }, + { + name: 'Raised Surface', + token: '--color-surface-raised', + }, + { + name: 'Muted Surface', + token: '--color-surface-muted', + }, +]; + +const interactiveStates = [ + { + name: 'Hover', + token: '--color-surface-hover', + }, + { + name: 'Selected', + token: '--color-surface-selected', + }, + { + name: 'Pressed', + token: '--color-surface-pressed', + }, +]; + +const feedbackStates = [ + { + name: 'Success', + color: '--color-feedback-success', + surface: '--color-feedback-success-surface', + border: '--color-feedback-success-border', + }, + { + name: 'Warning', + color: '--color-feedback-warning', + surface: '--color-feedback-warning-surface', + border: '--color-feedback-warning-border', + }, + { + name: 'Error', + color: '--color-feedback-error', + surface: '--color-feedback-error-surface', + border: '--color-feedback-error-border', + }, + { + name: 'Info', + color: '--color-feedback-info', + surface: '--color-feedback-info-surface', + border: '--color-feedback-info-border', + }, +]; + +const borders = [ + { + name: 'Subtle', + token: '--color-border-subtle', + }, + { + name: 'Default', + token: '--color-border-default', + }, + { + name: 'Strong', + token: '--color-border-strong', + }, + { + name: 'Divider', + token: '--color-border-divider', + }, + { + name: 'Input', + token: '--color-border-input', + }, + { + name: 'Input Hover', + token: '--color-border-input-hover', + }, +]; + +function ColorAndStateTest() { + return ( +
+
+
+

Color & State Test

+ +

+ Tests the application palette, semantic states, borders, focus, + disabled colors, and common text/background combinations. +

+
+ + {/* Core palette */} +
+

Core Palette

+ +
+ {palette.map(({ name, token }) => ( +
+
+ +
+ {name} + {token} +
+
+ ))} +
+
+ +
+ + {/* Common text pairings */} +
+

Text & Surface Pairings

+ +

+ These combinations are closer to how colors will actually appear in + the interface. +

+ +
+
+ Page background +

Primary text

+

Secondary text

+

Muted text

+
+ +
+ Standard surface +

Primary text

+

Secondary text

+

Muted text

+
+ +
+ Raised surface +

Primary text

+

Secondary text

+

Muted text

+
+
+
+ + {/* Brand contrast */} +
+

Brand Contrast

+ +

+ Inspect inverse text carefully here, especially at smaller text + sizes. +

+ +
+

Primary Brand Surface

+ +

+ This is ordinary inverse body text displayed against the primary + brand color. +

+ + + This smaller text makes insufficient contrast easier to notice. + +
+
+ +
+ + {/* Interactive states */} +
+

Interactive Surfaces

+ +
+ {interactiveStates.map(({ name, token }) => ( +
+ {name} + {token} +
+ ))} +
+
+ + {/* Feedback */} +
+

Feedback States

+ +
+ {feedbackStates.map(({ name, color, surface, border }) => ( +
+ {name} + +

+ This is an example {name.toLowerCase()} message with normal + body text. +

+ + + Check the text, surface, and border as a complete state. + +
+ ))} +
+
+ + {/* Borders */} +
+

Borders & Outlines

+ +
+ {borders.map(({ name, token }) => ( +
+ {name} + {token} +
+ ))} + +
+ Soft outline + --color-outline-soft +
+ +
+ Strong outline + --color-outline-strong +
+
+
+ + {/* Icons */} +
+

Icon Colors

+ +
+ + + + + + + +
+
+ + {/* Disabled */} +
+

Disabled State

+ +
+ Disabled example +
+
+ + {/* Focus */} +
+

Keyboard Focus

+ +

+ Use Tab rather than clicking so that the global{' '} + :focus-visible treatment appears. +

+ +
+ + + + + Focusable link +
+ +
+ Focus ring token + --color-focus-ring +
+
+
+
+ ); +} + +function IconSample({ label, color }: { label: string; color: string }) { + return ( +
+ + + {label} +
+ ); +} + +export default ColorAndStateTest; diff --git a/apps/web/src/styles/style_tests/FoundationStressTest.tsx b/apps/web/src/styles/style_tests/FoundationStressTest.tsx new file mode 100644 index 0000000..8bf36c0 --- /dev/null +++ b/apps/web/src/styles/style_tests/FoundationStressTest.tsx @@ -0,0 +1,666 @@ +import { useState, type CSSProperties } from 'react'; + +const panelStyle: CSSProperties = { + padding: 'var(--space-4)', + backgroundColor: 'var(--color-surface)', + border: 'var(--border-width-thin) solid var(--color-border-default)', + borderRadius: 'var(--radius-md)', +}; + +function FoundationStressTest() { + const [moved, setMoved] = useState(false); + + return ( +
+
+
+

Foundation Stress Test

+ +

+ Tests responsive behavior, reset edge cases, token scales, native + controls, layering, and motion. +

+ +

+ Resize from a narrow mobile viewport to a wide desktop while + reviewing this page. +

+
+ + {/* Responsive typography */} +
+

Responsive Foundation

+ +

+ Large type and page padding use clamp(). They should + scale smoothly without becoming too small or too large. +

+ +
+
+ 2XL responsive text +
+ +
+ 3XL responsive text +
+ +
+ 4XL responsive text +
+
+ +
+ This box should remain inside the responsive page container at all + viewport widths. +
+
+ +
+ + {/* Responsive media */} +
+

Responsive Media

+ +

+ The image is much wider than the page and should scale down without + overflowing. +

+ +
+ Orange responsive media test +
+ +
+

SVG as a UI icon

+ +

+ Unlike responsive media, a UI icon normally keeps its intended + size rather than shrinking with surrounding flex content. +

+ +
+ + + + + + +

+ This icon should stay the same size even when the viewport + becomes narrow. +

+
+
+
+ +
+ + {/* Text overflow */} +
+

Extreme Text Wrapping

+ +
+

+ This ordinary sentence should wrap naturally inside a narrow + container. +

+ +

+ extraordinarilylongcontinuousstringdesignedtotestwhethertheresetpreventstextfromoverflowingitscontainer +

+
+
+ +
+ + {/* Native controls */} +
+

Native Controls

+ +

+ These are intentionally mostly unstyled. They should inherit the + global font and text color without the reset breaking native + behavior. +

+ +
+ + + + + + + +