diff --git a/skills/animate/SKILL.md b/skills/animate/SKILL.md new file mode 100644 index 0000000..7c3b20c --- /dev/null +++ b/skills/animate/SKILL.md @@ -0,0 +1,207 @@ +--- +name: animate +description: Build an animation from scratch, making the decisions in the order that determines whether it feels right — should it animate at all, what purpose, which tool, which properties, which curve and duration, how it interrupts, how it exits. Writes the implementation. Use when asked to animate something, add motion, make a component feel alive, or build a transition. For critiquing existing motion use review-animations; for auditing a whole codebase use improve-animations. +--- + +# Building Animations + +## Initial Response + +When this skill is first invoked without a specific question, respond only with: + +> I'm ready to build animations that feel right, my knowledge comes from Emil Kowalski's animation philosophy. + +Do not provide any other information until the user asks a question. + +A construction skill. It does ONE thing: turn a request for motion into an implementation that would survive a strict review. It does not audit a codebase (that's `improve-animations`), critique a diff (that's `review-animations`), hunt for places that could animate (that's `find-animation-opportunities`), or build for React Native (that's `animate-expo`). + +## Operating Posture + +You are a senior design engineer building the animation yourself. The bar is Emil Kowalski's animation philosophy — the same bar `review-animations` enforces. Write it so it passes that review the first time. + +Two failure modes, and the first is worse: + +1. **Animating something that shouldn't animate.** The gate below exists to produce zero lines of code sometimes. That's a success, not a dodge. +2. **Animating the right thing with the wrong ingredients** — `ease-in` on an entrance, `scale(0)`, keyframes on a toast, a duration that makes a dropdown feel sluggish. + +Never present motion options as a menu. Make the call, state the reasoning in one line, write the code. + +## Hard Rules + +1. **Run the sequence in order.** Steps 1 and 2 gate everything. Don't reach for a curve before you know whether it animates at all. +2. **No approximated values.** Every curve, duration, and spring config comes from the tables below. Never invent `cubic-bezier(0.4, 0, 0.2, 1)` because it looks familiar. +3. **Extend the codebase's tokens, don't fork them.** If `--ease-out` or a duration scale already exists, use it. Adding a parallel system is a defect. +4. **Reduced motion and hover gating ship with the animation**, not as a follow-up. +5. **Cheapest tool that works.** Don't install a motion library for a fade. + +## The Build Sequence + +### 1. Should this animate at all? + +| Frequency | Decision | +| --- | --- | +| 100+ times/day (keyboard shortcuts, command palette toggle) | **No animation. Ever.** Stop here. | +| Tens of times/day (hover effects, list navigation) | Near-imperceptible only — fast and subtle, or nothing | +| Occasional (modals, drawers, toasts) | Standard animation | +| Rare / first-time (onboarding, success, celebration) | The delight budget lives here | + +**Keyboard-initiated actions are a disqualifier, not a judgment call.** Raycast has no open/close animation — that is correct for something opened hundreds of times a day. + +If the request fails this gate, say so plainly and don't write the animation. Offer the non-motion alternative (instant state change, a static affordance) instead. + +### 2. What is the purpose? + +Name it in one of these words before continuing: + +- **Feedback** — confirming the interface heard the user +- **Spatial consistency** — showing where something came from or went +- **State indication** — making a state change legible +- **Preventing a jarring change** — bridging content that would otherwise teleport +- **Explanation** — demonstrating how something works (marketing/onboarding only) +- **Delight** — allowed *only* at the rare/first-time tier + +Can't name it? Don't build it. "It looks cool" on a frequently-seen element is a reason to stop. + +Also check **function**: data the user is reading or acting on should not move for style. A decorative mouse-tracking effect belongs on a marketing page, not on a graph in a banking app. + +### 3. Pick the tool — cheapest that works + +Walk down; stop at the first that fits. + +| Need | Tool | +| --- | --- | +| Hover, press, color, a state toggle you control with a class or attribute | **CSS transition** | +| Entry animation on mount, no JS state | **CSS `@starting-style`** | +| Predetermined motion that must stay smooth while the page is busy loading | **CSS animation** (runs off the main thread) | +| Programmatic control with CSS performance, no library | **WAAPI** (`element.animate()`) | +| Springs, layout animations, exit animations, gesture-driven values | **Motion** (`motion.dev`) | + +CSS animations beat JS under load — they run off the main thread, while `requestAnimationFrame`-based animation drops frames while the browser loads, scripts, or paints. Use CSS for predetermined motion, JS for dynamic and interruptible motion. + +If the task needs a *component* rather than an animation — a toast, a drawer, a command menu, a dropdown — stop and invoke `pick-ui-library`. Hand-rolling those is how you end up with a `
` dropdown and no focus management. + +### 4. Pick the properties + +- **`transform` and `opacity` only.** They skip layout and paint and run on the GPU. `width`/`height`/`margin`/`padding`/`top`/`left` trigger all three. (`clip-path` is the sanctioned fourth — see RECIPES.md. `height` is tolerated only for accordions, where there's no transform equivalent.) +- **Never `scale(0)`.** Start from `scale(0.9–0.97)` + `opacity: 0`. Nothing in the real world appears from nothing. +- **`transform-origin` at the trigger** for popovers, dropdowns, menus, tooltips — `var(--transform-origin)` in Base UI. **Modals are exempt**; they're not anchored to a trigger, so they stay centered. +- **Percentages in `translate()`** are relative to the element's own size — `translateY(100%)` moves by its own height whatever the content. Prefer over hardcoded pixels. +- **In Motion, use the full transform string.** `x`/`y`/`scale` shorthands are not hardware-accelerated and drop frames under load: + +```jsx + // drops frames under load + // hardware accelerated +``` + +- **Never drive a child's transform from a CSS variable on the parent** — it recalculates styles for every child. Set `transform` on the element directly. + +### 5. Easing and duration — or a spring + +**Easing**, in decision order: + +| Situation | Easing | +| --- | --- | +| Entering or exiting | `ease-out` | +| Moving / morphing on screen | `ease-in-out` | +| Hover / color change | `ease` | +| Constant motion (marquee, progress) | `linear` | +| Default | `ease-out` | + +**Never `ease-in` on UI.** It starts slow, delaying the exact moment the user is watching. `ease-out` at 200ms *feels* faster than `ease-in` at 200ms. + +Built-in CSS easings are too weak. Use these: + +```css +--ease-out: cubic-bezier(0.23, 1, 0.32, 1); /* strong ease-out for UI */ +--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1); /* strong ease-in-out for on-screen movement */ +--ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); /* iOS-like drawer curve (Ionic) */ +``` + +Need a curve that isn't here? Take it from [easing.dev](https://easing.dev/) or [easings.co](https://easings.co/). Don't hand-roll one. + +**Duration:** + +| Element | Duration | +| --- | --- | +| Button press feedback | 100–160ms | +| Tooltips, small popovers | 125–200ms | +| Dropdowns, selects | 150–250ms | +| Modals, drawers | 200–500ms | +| Marketing / explanatory | Can be longer | + +**UI animations stay under 300ms.** A 180ms dropdown feels more responsive than a 400ms one. + +**Reach for a spring instead** when the motion is drag with momentum, an element that should feel alive, a gesture the user can interrupt or reverse, or decorative mouse-tracking: + +```js +{ type: "spring", duration: 0.5, bounce: 0.2 } // Apple-style — easier to reason about +{ type: "spring", mass: 1, stiffness: 100, damping: 10 } // traditional physics — more control +``` + +Keep bounce at 0.1–0.3, and avoid bounce in most UI — reserve it for drag-to-dismiss and playful interactions. + +### 6. Interruption and exit + +- **Transitions, not keyframes, for anything triggered rapidly** — toasts, toggles, anything a user can fire twice in a second. Transitions retarget from the current value; keyframes restart from zero. +- **Springs for gestures**, because they carry velocity through an interruption. +- **Exit the way it entered.** A toast that slides in from the bottom leaves through the bottom. Symmetric paths are what make swipe-to-dismiss feel obvious. +- **Asymmetric timing where the user is deciding.** Slow on the deliberate phase (a hold-to-confirm press: 2s linear), snappy on the system response (release: 200ms ease-out). + +### 7. Reduced motion and pointer gating + +Ships with the animation, every time. + +```css +@media (prefers-reduced-motion: reduce) { + .element { animation: fade 0.2s ease; } /* keep opacity/color, drop transform-based motion */ +} + +@media (hover: hover) and (pointer: fine) { + .element:hover { transform: scale(1.05); } /* touch fires false hovers on tap */ +} +``` + +```jsx +const reduce = useReducedMotion(); +const closedX = reduce ? 0 : '-100%'; +``` + +Reduced motion means **fewer and gentler** animations, not zero — keep transitions that aid comprehension, remove movement and position changes. + +## Recipes + +For ready-to-build implementations of the common cases — button press, dropdown, tooltip, modal, drawer, toast, accordion, stagger, hold-to-confirm, tab indicator, scroll reveal, drag-to-dismiss — see [RECIPES.md](RECIPES.md). Load it whenever the request matches one of those components; start from the recipe rather than from a blank file. + +## Never Ship + +Self-check before you finish. Each of these is an automatic block in `review-animations`: + +| Never | Instead | +| --- | --- | +| `transition: all` | Name the exact properties | +| `transform: scale(0)` entrance | `scale(0.95)` + `opacity: 0` | +| `ease-in` on a UI element | `ease-out` or a strong custom curve | +| Built-in `ease-out` on a deliberate animation | `cubic-bezier(0.23, 1, 0.32, 1)` | +| Animation on a keyboard shortcut or 100+/day action | No animation | +| UI duration over 300ms with no reason | 150–250ms | +| `transform-origin: center` on a trigger-anchored popover | `var(--transform-origin)` (modals exempt) | +| Keyframes on toasts, toggles, rapidly-triggered elements | CSS transitions | +| Animating `width`/`height`/`margin`/`padding`/`top`/`left` | `transform` / `opacity` | +| Motion `x`/`y`/`scale` props under load | Full `transform` string | +| Ungated `:hover` motion | `@media (hover: hover) and (pointer: fine)` | +| Missing `prefers-reduced-motion` | Gentler variant, not zero | +| Everything entering at once | 30–80ms stagger | + +## Output + +Write the code. Then, in at most a few lines: + +- **The gate result** — frequency tier and the named purpose. If something in the request was rejected, say which and why. +- **The ingredients** — tool, properties, curve, duration or spring config, in one line each. +- **What to feel-check** — if the result depends on feel you can't judge from code (a crossfade, a spring's bounce, the opacity/height balance in an entering list), say so and point at the check: play it at 2–5× duration or in the DevTools animation inspector, step it frame by frame, test gestures on a real device, and look again the next day with fresh eyes. + +Don't pad this into a report. The code is the deliverable. + +## Tone + +Opinionated and brief. When the honest answer is "this shouldn't animate," give it — that answer is the reason this skill exists. When feel genuinely can't be settled from code, say so instead of guessing at a value. diff --git a/skills/better-colors/SKILL.md b/skills/better-colors/SKILL.md new file mode 100644 index 0000000..a68be0b --- /dev/null +++ b/skills/better-colors/SKILL.md @@ -0,0 +1,105 @@ +--- +name: better-colors +description: Helps you build a color system and answer anything about color in your project. You can generate palettes, use semantic tokens, convert between formats, check contrast and more. +--- + +# Colors + +A color system is a small set of ramps, named by role and verified against the backgrounds they actually render on. Most color bugs are system bugs. A value picked in isolation, a token borrowed because it looked right, a pair nobody measured. + +Never report a contrast value you did not measure, and never estimate a color you could compute. Colors are one of the few interface concerns with an exact answer, so produce the exact answer. + +Contrast requirements belong to `better-accessibility`. Surfaces, shadows and icon color belong to `better-ui`. + +## Match the project's color system + +Reuse the project's tokens and notation. A second representation added to fix one value makes the palette harder to reason about. A consistent hex system beats hex with `oklch()` scattered through it. + +For a new system, `oklch()` is the best default, because its numbers behave the way the ramp rules below describe. Everywhere else, a color library produces the same ramp in the project's own notation ([color-formats.md](color-formats.md)). + +## A system is ramps, not colors + +One neutral ramp, one accent ramp and only the status ramps the product actually renders. A `warning` ramp nothing imports is maintenance for zero pixels. A second accent hue earns its place only when two things must be distinguishable at a glance. + +## Every step has a job + +A ramp is not a gradient to pick from by eye. Each step exists because a role needs it: page background, component hover, border, solid fill, body text. Do not generate a step no role consumes. Both the Tailwind `50`–`950` and Radix `1`–`12` conventions map to those roles ([palette-structure.md](palette-structure.md)). + +## Name primitives by hue, semantics by role + +Primitives name a value (`--blue-500`) and are never applied in a component. Semantic tokens name a job (`--color-text-secondary`), point at a primitive and are the only tier components reference. + +That seam is what makes theming possible. Without it, dark mode means auditing every usage to work out which meant "the accent" and which just wanted blue ([token-naming.md](token-naming.md)). + +## Use a token only in its role + +Never borrow a token because its value is right today. A separator used as a text color works until borders get lighter, and then the text goes with them. If a role has no token, add the token. + +## Hold the hue across the ramp + +Four properties define a well-formed ramp: + +- Steps step evenly in *perceived* lightness, not in whatever the format calls lightness. +- Hue stays constant end to end. +- Vividness peaks mid-ramp and falls off at both ends. +- Steps sit denser at the light end than at the dark end. + +Both ends stop short of pure black and white, which cannot carry hue at all. Use a color library rather than eyeballing it ([palette-generation.md](palette-generation.md)). + +## One color, one meaning + +Use a color for one purpose across the whole interface, treating anything within `15°` of hue as the same color. If the accent means interactive, that hue on static text tells users to click something that is not clickable, and an interactive element rendered neutral misleads just as badly. Color is never the only carrier of meaning, which `better-accessibility` owns. + +## Fill exactly one action per view + +When filled color encodes primary emphasis, one primary action gets it and peers stay neutral. Put the color on the background, not the label. A filled button reads as primary across the room; accent-colored text on a neutral button reads as a link. + +Several colored backgrounds are fine when they encode distinct states or categories rather than competing as peers. + +## Measure the rendered pair, then report + +Measure a foreground against the background it actually renders on, not the page background. When a pair fails, report the pair, its measured value and the threshold it misses, then leave the colors alone. They are a design decision. Change them only when asked, and remeasure after ([contrast.md](contrast.md)). + +## Pick a gradient's interpolation space + +The space is a look, not a correctness setting. + +- **`in oklab`** is the best default: even brightness, no hue surprises. +- **`in oklch`** travels around the hue wheel rather than through the middle, staying vivid and sweeping every hue between the stops. Reach for it when a two-hue gradient goes gray in the middle. +- **The sRGB default** darkens and mutes the midpoint. It is what most interfaces already have, because it is what you get without asking. + +See [color-usage.md](color-usage.md). + +## Before you finish + +| Mistake | Fix | +| --- | --- | +| A raw value where the project has a token | Reuse or add the role token, in the project's notation | +| An isolated `oklch()` value dropped into a hex codebase | Keep the established notation unless a migration is in scope | +| A primitive like `--blue-500` used directly in a component | Point a semantic token at it | +| Token named for its appearance (`--color-blue-button`) or first use (`--color-sidebar-gray`) | Name it for its role: `--color-accent-solid`, `--color-bg-surface` | +| `--color-primary` meaning the brand and `--color-text-primary` meaning body text | Reserve `accent` for the brand; let `primary` mean "most prominent of its group" | +| Semantic token used outside its role (separator as text) | Add a token for the missing role; never borrow by value | +| Ramp built by varying HSL lightness | Rebuild against perceived lightness with a constant hue | +| Ramp spaced evenly across the full range | Tighten the light end until `50` and `100` read as two surfaces | +| Same saturation number reused across hues | Match the proportion of each hue's own maximum, not the raw value | +| Status hue that collides with the accent hue | Move it until destructive and primary read apart side by side | +| Dark mode made by mechanically reversing the light palette | Reverse as a starting point, then reduce vividness, widen the dark end and recheck every pair | +| `prefers-color-scheme` setting some tokens and a `.dark` class setting others | Pick one switching mechanism and use it throughout | +| Contrast fixed by changing hue | Change lightness, the channel contrast responds to | +| P3 color with no sRGB fallback | Declare the sRGB value first, then override inside `@media (color-gamut: p3)` | + +## Reporting + +**Severity.** `HIGH` makes content unreadable or assigns a misleading semantic color. `MEDIUM` is a noticeable theme, token, or gamut failure. `LOW` is isolated polish. + +**Verification.** Without a browser: token values, the gamut of every declared color, both theme blocks present and contrast computed from the declared token pair. With one: the background actually rendered behind the text, including opacity and any image beneath it, measured in both light and dark. A failing pair is reported, not repainted. Report every check you could not run as `Not verified`. + +**Format.** Group findings under the principle each violates, ordered by severity, one row per root cause listing every location it appears in: + +| Severity | Location | Before | After | Why | +| --- | --- | --- | --- | --- | + +`Location` is `path/to/file:line`. `Why` names the principle and the user impact. + +End with `Block` when any `HIGH` remains, `Approve` otherwise, leaving the rest in the table as work to do. Never `Approve` coverage you did not inspect. With nothing to report, state "No actionable color findings" and report verification. diff --git a/skills/better-layout/SKILL.md b/skills/better-layout/SKILL.md new file mode 100644 index 0000000..3701eb4 --- /dev/null +++ b/skills/better-layout/SKILL.md @@ -0,0 +1,81 @@ +--- +name: better-layout +description: Helps with grouping, alignment, reading order, progressive disclosure and other details that make a good layout. +--- + +# Layout + +Position, spacing and alignment carry hierarchy before a word is read. This skill builds that structure and stress-tests it: resize it, translate it, mirror it for RTL. + +Write every fix in the project's styling system. The numbers below are starting points for interfaces with no established density system, and where one applies, use it as written rather than a familiar-looking substitute. Keep deliberate platform chrome, compact professional tools and project tokens where they still pass the stress tests. + +Hit areas and focus behavior belong to `better-accessibility`. Radius, shadows and animation belong to `better-ui`. Line length and text spacing belong to `better-typography`. + +## Group with space, not lines + +Space groups first, background shapes second, separator lines last and only where space alone can't carry the structure. The gap between groups must be at least 2× the gap within one (`8px` intra-group to `16px`+ inter-group), or the grouping reads as noise. Alignment edges and importance ordering are in [grouping-and-alignment.md](grouping-and-alignment.md). + +## Keep controls distinct from content + +Give every interactive element a background shape, a border, or a consistent placement zone. A control styled like the static text beside it does not read as a control. + +## Align to shared edges + +Pick alignment edges and stick to them; every stray edge reads as noise. Use one project spacing step per level of subordination, where `16px` is a useful default. + +Use logical properties for direction-dependent layout: `padding-inline-start`, `margin-inline-end`. Reserve physical left and right for genuinely physical geometry. + +## Order by importance + +The most important content sits near the top and the leading edge. Reading order flows top-to-bottom, leading-to-trailing. Think in leading and trailing, not left and right. + +## Hint at hidden content + +Progressive disclosure needs a visible affordance. Use the project's established cue, or let the next item peek `16–32px` past the scroll edge, or show a disclosure control. Content hidden with zero cue may as well not exist. + +## Breathing room between targets + +Without an established density system, start with `12px` between adjacent bordered or filled controls and `24px` around borderless text- and icon-only ones. Compact layouts may use less, as long as `better-accessibility` hit areas don't overlap and the controls stay distinct. Layout margins and breakpoint recipes are in [spacing-and-adaptivity.md](spacing-and-adaptivity.md). + +## Inset buttons from the edges + +In content layouts, keep full-width buttons inside the layout margins with a visible radius, starting near `16px` inline on mobile. Edge-to-edge actions work when they follow established platform chrome, account for safe areas and stay distinguishable from system UI. + +## Content bleeds, controls float + +Backgrounds and media extend to the viewport edges. Controls and text stay inside the layout margins and safe areas (`env(safe-area-inset-*)`). Sticky chrome floats above the content layer rather than blocking it. + +## Hold structure until it breaks + +Breakpoints come from the content, not device presets. Keep the expanded layout as long as it genuinely fits and collapse late. Prefer container queries for component-level adaptation, and test the smallest and largest sizes first. + +## Plan for growth and clipping + +Translated strings grow, and short ones grow proportionally more, so a one-word button label is the riskiest thing on the screen. Put no fixed width or height on a text container, and let rows wrap. Test with pseudo-localization and one representative locale rather than budgeting a percentage. + +Never park a critical action where resizing or scrolling clips it. Keep it in the normal flow, or in stable chrome suited to the product. + +## Before you finish + +| Mistake | Fix | +| --- | --- | +| `margin-left` / `padding-right` in a localizable layout | `margin-inline-start` / `padding-inline-end` | +| Content-layout button touches the viewport edge | Inset within the project margins; keep intentional platform chrome | +| Breakpoints at 768/1024 because they're the defaults | Break where the content actually stops fitting | +| Fixed-width text container sized to one language | `max-width` and wrapping; test pseudo-localization | +| Primary action at the clip-prone bottom of a pane | Sticky positioning or stable chrome with safe-area padding | + +## Reporting + +**Severity.** `HIGH` blocks content or an action at a supported viewport. `MEDIUM` harms hierarchy, reading order, or adaptability. `LOW` is isolated alignment or spacing polish. + +**Verification.** Without a browser: logical properties in place of physical ones, container and media queries against the supported viewport list and DOM order against the intended reading order. With one: every supported width, 200% zoom and the RTL mirror. Report every check you could not run as `Not verified`. + +**Format.** Group findings under the principle each violates, ordered by severity, one row per root cause listing every location it appears in: + +| Severity | Location | Before | After | Why | +| --- | --- | --- | --- | --- | + +`Location` is `path/to/file:line`. `Why` names the principle and the user impact. + +End with `Block` when any `HIGH` remains, `Approve` otherwise, leaving the rest in the table as work to do. Never `Approve` coverage you did not inspect. With nothing to report, state "No actionable layout findings" and report verification. diff --git a/skills/better-typography/SKILL.md b/skills/better-typography/SKILL.md new file mode 100644 index 0000000..3334cc4 --- /dev/null +++ b/skills/better-typography/SKILL.md @@ -0,0 +1,162 @@ +--- +name: better-typography +description: Focuses on type scale, spacing, sizing, variable fonts, OpenType features, wrapping, truncation and other details that make typography feel great across your product. +--- + +# Typography + +Typography is mostly restraint: a sensible scale, comfortable spacing, enough contrast. A label, a table cell, a marketing headline and an article paragraph do not share one set of rules. + +When reviewing, read the rendered page instead of scanning the code. Bad wrapping, widows and truncation only show up at real content lengths. + +Write every fix in the project's styling system, and use the exact values below rather than familiar-looking equivalents. The [cheat sheet](css-cheat-sheet.md) maps each declaration to its Tailwind equivalent. + +The words themselves belong to `better-writing`. Semantic heading structure belongs to `better-accessibility`. Spatial RTL layout and logical properties belong to `better-layout`. Contrast measurement belongs to `better-colors`. This skill owns how text renders, wraps and behaves in mixed-direction content. + +## Serve the right format + +Use `.woff2` on the web, for Brotli compression and broad support. `.woff` is a fallback for very old browsers. `.ttf` and `.otf` are desktop formats with no web compression. How the files load is the project's concern. + +## Properties over raw tags + +When a CSS property exists, use it. `font-weight: 650` instead of `font-variation-settings: "wght" 650`. `font-optical-sizing: auto` instead of `"opsz"`. `font-variant-numeric: tabular-nums` instead of `font-feature-settings: "tnum" 1`. + +Properties keep working when a non-variable fallback renders. Reserve raw tags for custom axes (`"GRAD" 80`) and niche features (`"ss01" 1`) with no property of their own. Axes and feature tags are listed in [variable-fonts-and-opentype.md](variable-fonts-and-opentype.md). + +## Load intended weights and styles + +Browsers synthesize a weight or style the active family doesn't provide, distorting the real face. Load the faces the design uses. + +`font-synthesis: none` turns synthesis off, but it erases emphasis rather than reporting it. Set it only after checking every required bold, italic, small-cap, superscript and subscript form stays distinct across the fallback stack. + +## Fewer fonts, sizes and weights + +Rarely use more than three fonts. Weight and size define hierarchy; overusing them hurts readability fast. Pair for contrast, not similarity: a serif headline over a sans body reads as deliberate, two near-identical sans-serifs read as a mistake. + +Below `18px`, stay at weight `400` or heavier. Weights under `300` are display-only at `28px`+; they disappear at text sizes. Pairing guidance is in [choosing-fonts.md](choosing-fonts.md). + +## Use a type scale with semantic names + +Define a small set of sizes and deviate from it as little as possible. Hard-coded sizes with no system behind them break down at scale. + +Solo, default names like `text-sm` are fine when the usage rules are clear. On a team, name sizes by use (`text-body-sm`) so the rules survive other people. Scale construction is in [spacing-and-sizing.md](spacing-and-sizing.md). + +## Heading sizes descend with level + +Map heading levels to descending steps of the type scale, so a visually subordinate heading never overpowers its parent. Adjacent levels may share a size toward the small end of the scale, as long as weight or spacing keeps them distinct. The semantic element is `better-accessibility`'s; this skill sets only the visual treatment. + +## Line-height by role + +Headings tighter, around `1.1`. Body copy `1.5` to `1.6`. Prefer unitless values, so line-height scales with the font size; a fixed `24px` does not. + +Tight line-height is for short text. Anything that wraps to three or more lines needs at least `1.4`, even in a height-constrained row. + +## Letter-spacing by size + +Large headings often look better with slightly negative letter-spacing. Small uppercase labels need a little positive letter-spacing, or the letters feel crowded. Body copy at reading sizes needs neither. + +## Cap the measure + +Long lines make it hard for the eye to find the next one. Cap long-form text around 60–75 characters per line. Any unit works, as long as a cap exists and the line length lands in range. See [unit choices and the pixel equivalents](wrapping-and-punctuation.md#measure-line-length). + +## Wrap deliberately + +Four declarations, four jobs: + +- `text-wrap: balance` distributes text evenly across lines. Use it on headings. +- `text-wrap: pretty` stops a single short word landing on the final line. Use it on descriptions. +- `overflow-wrap: break-word` where a long word, link, or ID could escape the container. +- `white-space: nowrap` on labels and badges where a line break looks broken. + +Skip `balance` and `pretty` in long-form text. + +## Tabular numbers on changing values + +Digits have different widths by default, so timers, counters and prices shift the layout as they update. Apply `font-variant-numeric: tabular-nums` to any value that changes. + +## Truncate without losing content + +For a single line, `text-overflow: ellipsis` with `overflow: hidden` and `white-space: nowrap`. For several, `line-clamp`. Truncation hides content. When the missing text matters, keep the full value reachable in a tooltip or an expanded view. + +## Write copy naturally, style with CSS + +Store text in natural case and control presentation with `text-transform`, so a redesign never means rewriting copy. + +Use smart punctuation in rendered text: + +- Curly quotes in prose, straight quotes in code. +- An en dash for ranges: `2010–2020`. +- The single ellipsis character, not three periods. +- ` ` to hold `16 px` together across a line break. +- `­` to say where a long word may break. + +## Underlines from the font + +Default underlines sit wherever the browser decides. Pull position and thickness from the font's own metrics with `text-underline-position: from-font` and `text-decoration-thickness: from-font`. Tune by hand with `text-decoration-thickness`, `text-underline-offset` and `text-decoration-skip-ink`. + +`text-decoration-style` draws the line dotted, dashed, or wavy. A dotted underline is a common hint that a word carries extra information, such as an abbreviation or a defined term. + +Color is the only part of a real underline that animates reliably. So unless the only thing animating is the color, build the underline as a separate element rather than using `text-decoration`. + +## Inputs at 16px on mobile + +iOS Safari zooms the whole page when an input's text is smaller than `16px`. Two fixes hold the size at `16px` and look different, so ask which one the design wants: + +- Size the input up on mobile (`text-base sm:text-sm`). Changes how it looks on small screens. +- Keep `font-size: 16px` and render the intended size with `transform: scale()`, compensating width and `line-height`. Identical at every viewport, more code to maintain. + +Both recipes are in [details-and-accessibility.md](details-and-accessibility.md). + +## Size and contrast floors + +Start long-form body text at `16px`, the browser default. Move off it only for a reason you can name: the typeface runs small, the measure is narrow, or the product is a dense professional tool. + +UI text can go smaller. `14px` is a useful starting point for inputs and menus, `13px` for captions and rarely below `12px`. Inputs still need `16px` on mobile. + +When text looks low-contrast, use `better-colors` to measure the rendered pair and `better-accessibility` to classify the requirement. Leave the colors alone unless asked. + +## Font smoothing on the root + +On macOS, text renders heavier than intended. Apply `-webkit-font-smoothing: antialiased` and `-moz-osx-font-smoothing: grayscale` once on the root layout, never per component. Tailwind's `antialiased` covers both. + +## Language and bidi behavior + +Set `lang` so browsers and assistive technology pick the right pronunciation, quotes and hyphenation. Set `dir` at the document or at the content boundary where direction changes. Preserve digit order, and use `` to isolate a mixed-direction value. Spatial mirroring and logical CSS properties belong to `better-layout`. + +## Keep useful text selectable + +Keep text selectable by default. `::selection` can carry brand into the reading experience, as long as the selected combination stays legible. + +`user-select: none` belongs on a draggable or gesture-driven surface where accidental selection interferes. Never across the interface and never because a button label can be highlighted. + +## Before you finish + +| Mistake | Fix | +| --- | --- | +| Synthesized face differs from the design | Load the real face; disable only the verified synthesis mode | +| Child heading visually overpowers its parent | Map that section's hierarchy to descending scale steps | +| Heading element picked for its default size | Choose semantics first, then set the size in CSS | +| Orphan on the last line of a paragraph | `text-wrap: pretty` | +| Lopsided two-line heading | `text-wrap: balance` | +| Justified text in an interface | `text-align: start`; reserve justify for specific editorial layouts | +| Underline cuts through descenders | `text-decoration-skip-ink: auto`, `from-font` metrics | +| Mixed-direction value renders in the wrong order | Correct `lang`/`dir`; isolate the value with `` | +| Selection disabled across application chrome | Restore it; suppress only where it conflicts with a drag or gesture | +| Extra-info hint with no visual cue | Dotted underline via `text-decoration-style: dotted` | +| Thin/Light weight on `14px` UI text | Weight `400`+ below `18px`; thin weights are display-only | +| `leading-none` on a three-line card description | At least `1.4` on any text that wraps to 3+ lines | + +## Reporting + +**Severity.** `HIGH` makes text unreadable or truncates content with no way to recover it. `MEDIUM` breaks the type system or the heading hierarchy. `LOW` is isolated polish. + +**Verification.** Without a browser: computed size and weight for each heading level, checked descending; declared line-height and measure; truncation rules against realistic string lengths. With one: resize the viewport to catch wrapping, widows and truncation at real content lengths. Report every check you could not run as `Not verified`. + +**Format.** Group findings under the principle each violates, ordered by severity, one row per root cause listing every location it appears in: + +| Severity | Location | Before | After | Why | +| --- | --- | --- | --- | --- | + +`Location` is `path/to/file:line`. `Why` names the principle and the user impact. + +End with `Block` when any `HIGH` remains, `Approve` otherwise, leaving the rest in the table as work to do. Never `Approve` coverage you did not inspect. With nothing to report, state "No actionable typography findings" and report verification. diff --git a/skills/design-build/SKILL.md b/skills/design-build/SKILL.md index cf95210..179892a 100644 --- a/skills/design-build/SKILL.md +++ b/skills/design-build/SKILL.md @@ -1,11 +1,18 @@ --- name: design-build -description: Generate production-ready HTML/Tailwind code from design specifications and DESIGN.md design tokens. Use when the user has a clear design direction and wants to build. +description: Generate production-ready HTML/Tailwind code from design specifications and DESIGN.md design tokens. Uses design engineering principles, Tastemaker aesthetic rules, and modern layout/typography systems to build non-boring, stunning web interfaces. --- # /design-build -Generate code from a design spec and optional DESIGN.md tokens. Produces single-file HTML with Tailwind CSS via CDN (phase 1). Future versions will scaffold React projects. +Generate production-quality code from a design spec and optional DESIGN.md tokens. Produces single-file HTML with Tailwind CSS via CDN (phase 1) or React/UI components. + +Incorporates guidelines from installed design skills: +- **`tastemaker`**: Avoid generic AI slop (indigo/purple gradients, generic soft-shadow cards). +- **`landing-page-design`**: Structured hero section, headline/CTA hierarchy, conversion layout. +- **`emil-design-eng` & `animate`**: Micro-interactions, spring curves, component polish. +- **`better-colors`, `better-layout`, `better-typography`**: Whitespace, contrast, typographic scale. +- **`web-design-engineer`**: High-craft frontend design engineering standards. ## Flow @@ -15,51 +22,55 @@ Ask the user two questions: 1. **"What are we building?"** — Description of the page, component, or interface. Be specific about functionality, layout, content. -2. **"What style? Pick from awesome-design-md or describe it."** — Same as design-explore: URL to a DESIGN.md file, or free text description. If the user already explored in design-explore, they can reference the same DESIGN.md. +2. **"What style? Pick from awesome-design-md, describe it, or reference a vibe."** — URL to a DESIGN.md file, or free text description. If the user explored in `design-explore`, reference the same direction. -### Step 2: If DESIGN.md URL provided, download and extract +### Step 2: Extract tokens & design guidance + +If a DESIGN.md URL is provided, download it: ```bash curl -sL -o /tmp/design-tokens.md ``` -Read the file. Extract: -- Palette (colors) -- Typography (fonts, sizes) -- Spacing -- Border radius -- Shadows -- Identity/language notes +Extract: +- Palette (background, primary, accent, surface) +- Typography (font families, scales, weights) +- Spacing & Layout +- Border radius & Shadows +- Visual Identity notes + +Also inspect installed skills in `~/.agents/skills/` (such as `tastemaker`, `landing-page-design`, `better-typography`, `better-colors`) for applicable guidelines on the target component type. ### Step 3: Build the code prompt -Create a detailed prompt for the coder-pro sub-agent: +Create a detailed prompt for the `coder-pro` sub-agent: ``` -You are building a production-quality UI component/page. +You are a top-tier Web Design Engineer building a production-quality UI component/page. ## What to build {user's design description — what it is, what it does, layout, content} -## Design tokens (MUST follow exactly) -``` -{paste the extracted tokens directly} -``` +## Design tokens & rules (MUST follow strictly) +{extracted tokens or style requirements} + +## Aesthetic & Craft Principles (from Tastemaker & Design Engineering) +- NO "AI slop" or generic templates: avoid default indigo-to-purple gradients, generic soft-shadow cards, and cookie-cutter hero sections. +- Distinct Visual Vibe: choose an intentional aesthetic (e.g. brutalist, glass-morphism, warm editorial, high-contrast dark, Apple-like precision). +- Typography: strong typographic hierarchy with contrasting sizes and font weights (e.g., tight display headers, readable body). +- Whitespace & Padding: generous whitespace; group elements with padding rather than heavy border lines. +- Interactivity & Motion: subtle, polished hover transitions (`transition-all duration-200 ease-out`, hover elevation/scale). ## Technical requirements -- Single HTML file with Tailwind CSS via CDN () +- Custom