Add web-frontend, web-project-audit and web-project-scaffold-containerized-python skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
59fc08fa5f
commit
5201aa9bd5
63 changed files with 3042 additions and 0 deletions
113
skills/web-frontend/references/components.md
Normal file
113
skills/web-frontend/references/components.md
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
# Components
|
||||
|
||||
Recipes in plain CSS on the tokens. Port them to CSS Modules, Tailwind (`tailwind.md`) or a component library's styling API as the project requires. Every interactive element has hover, active, `:focus-visible` and disabled states.
|
||||
|
||||
## Buttons
|
||||
|
||||
Three variants and two sizes cover almost everything. One primary button per view.
|
||||
|
||||
```css
|
||||
.btn {
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
|
||||
height: 2.5rem; padding-inline: var(--space-4);
|
||||
font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1;
|
||||
border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer;
|
||||
transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
.btn:active { transform: translateY(1px); }
|
||||
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
|
||||
.btn-primary { background: var(--accent); color: var(--accent-fg); }
|
||||
.btn-primary:hover { background: var(--accent-hover); }
|
||||
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
|
||||
.btn-secondary:hover { background: var(--surface-2); }
|
||||
.btn-ghost { background: transparent; color: var(--fg-muted); }
|
||||
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }
|
||||
.btn-danger { background: var(--danger); color: var(--accent-fg); }
|
||||
.btn-sm { height: 2rem; padding-inline: var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
|
||||
```
|
||||
Icon-only buttons are square (`width` = `height`) and need `aria-label`.
|
||||
|
||||
## Inputs
|
||||
|
||||
```css
|
||||
.field { display: grid; gap: var(--space-2); }
|
||||
.field > label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
|
||||
.field > .hint { font-size: var(--text-xs); color: var(--fg-muted); }
|
||||
.field > .error { font-size: var(--text-xs); color: var(--danger); display: flex; gap: var(--space-1); }
|
||||
.input {
|
||||
height: 2.5rem; padding-inline: var(--space-3); width: 100%;
|
||||
background: var(--surface); color: var(--fg);
|
||||
border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
|
||||
transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
.input::placeholder { color: var(--fg-subtle); }
|
||||
.input:hover { border-color: var(--fg-subtle); }
|
||||
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
|
||||
.input[aria-invalid="true"] { border-color: var(--danger); }
|
||||
textarea.input { height: auto; min-height: 6rem; padding-block: var(--space-2); resize: vertical; }
|
||||
```
|
||||
Placeholders show an example value, never the label.
|
||||
|
||||
## Cards and surfaces
|
||||
|
||||
Use a card only when the thing is a separate object (an item in a collection, a self-contained panel). A section of a page is not a card.
|
||||
|
||||
```css
|
||||
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-5); }
|
||||
.card-interactive { transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
|
||||
.card-interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-raised); }
|
||||
.well { background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-4); }
|
||||
```
|
||||
In a row of cards: same padding, title in the same place, actions pinned to the same edge (`display: flex; flex-direction: column` with `margin-top: auto` on the footer).
|
||||
|
||||
## Badges, pills, status
|
||||
|
||||
```css
|
||||
.badge { display: inline-flex; align-items: center; gap: var(--space-1); height: 1.375rem; padding-inline: var(--space-2);
|
||||
font-size: var(--text-xs); font-weight: var(--weight-medium); border-radius: var(--radius-full);
|
||||
background: var(--surface-2); color: var(--fg-muted); }
|
||||
.badge-ok { background: var(--ok-soft); color: var(--ok); }
|
||||
.badge-warn { background: var(--warn-soft); color: oklch(from var(--warn) calc(l - 0.15) c h); }
|
||||
.badge-danger { background: var(--danger-soft); color: var(--danger); }
|
||||
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
|
||||
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
|
||||
```
|
||||
Status always pairs color with a word or icon.
|
||||
|
||||
## Tables
|
||||
|
||||
```css
|
||||
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
|
||||
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
|
||||
th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: var(--weight-medium);
|
||||
color: var(--fg-muted); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
|
||||
td { padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
|
||||
tr:last-child td { border-bottom: 0; }
|
||||
tbody tr:hover { background: var(--surface-2); }
|
||||
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
```
|
||||
No zebra stripes and borders together; pick one. Truncate long cells with a tooltip rather than letting a row explode.
|
||||
|
||||
## Navigation
|
||||
|
||||
- Top nav: logo/name left, 3 to 6 links, one action right. Active link marked by weight or color plus `aria-current="page"`, not just an underline that is hard to see.
|
||||
- Side nav: items 2.25rem tall, icon + label, active item `background: var(--accent-soft); color: var(--accent-text)`. Group headings use `.label`.
|
||||
- Tabs: underline style (2px `--accent` bar under the active tab) for page sections; segmented control (pill group on `--surface-2`) for view switches.
|
||||
|
||||
## Overlays
|
||||
|
||||
- Popovers/menus: `--surface`, `--shadow-popover`, `--radius-md`, 4px inner padding, items 2rem tall. Animate opacity + 4px translate in `--dur-base`.
|
||||
- Modals: max-width 32rem (forms) or 48rem (content), `--shadow-modal`, `--radius-lg`, backdrop `oklch(0 0 0 / 0.4)`. Focus trapped, Escape closes, title in an `h2`. Use the native `<dialog>` or Radix Dialog.
|
||||
- Toasts: bottom-right on desktop, bottom-center on phones; short past-tense message ("Invoice sent"); an Undo action for destructive operations instead of a confirm dialog where possible.
|
||||
|
||||
## States
|
||||
|
||||
- **Loading:** skeletons shaped like the real content (`--surface-2` blocks with a subtle shimmer that stops under reduced motion) for page loads; inline spinners only inside buttons.
|
||||
- **Empty:** say what will appear here and how to add the first one, with the primary action. A small icon at most, no large illustration unless the product has an illustration style.
|
||||
- **Error:** what failed, why if known, and a retry. Keep the rest of the page usable.
|
||||
|
||||
## Data display details
|
||||
|
||||
- Numbers: `tabular-nums`, right-aligned in columns, units in `--fg-muted`, thousands separators via `Intl.NumberFormat`.
|
||||
- Dates: relative for recent ("3 min ago") with the absolute date in a `title`/tooltip; absolute in tables.
|
||||
- Code and IDs: `--font-mono`, `--surface-2` background, copy button on hover.
|
||||
85
skills/web-frontend/references/layout.md
Normal file
85
skills/web-frontend/references/layout.md
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
# Layout
|
||||
|
||||
Rules first, then patterns to copy. All values come from `assets/tokens.css`.
|
||||
|
||||
## Rules
|
||||
|
||||
- Spacing between siblings comes from `gap` on a flex/grid parent. Margins only for one-off offsets.
|
||||
- One side gutter, set once on the outer wrapper: `padding-inline: var(--gutter)`. Use `padding-block` for vertical padding so the sides never get zeroed by a shorthand.
|
||||
- Design at ~400px and ~1280px, then check 768px. Rows wrap or stack to one column on phones.
|
||||
- Flex/grid children that hold text, code or tables get `min-width: 0`.
|
||||
- Only tables, code blocks and diagrams may be wider than the screen, each inside an `overflow-x: auto` wrapper.
|
||||
- Size heroes to their content, never `100vh`. For full-screen apps, use `height: 100dvh` on the shell (or `100%` from `html`/`body`), not `100vh`.
|
||||
- Let content set heights. Don't stretch cards over empty space. Choose column counts the items fill.
|
||||
- Left-align by default. Center only short, self-contained things (an empty state, a one-line hero on a launch page).
|
||||
- Vertical rhythm: inside a component `--space-2` to `--space-4`; between components `--space-6` to `--space-8`; between page sections `--space-12` to `--space-24`.
|
||||
|
||||
## Page container
|
||||
|
||||
```css
|
||||
.page { padding-inline: var(--gutter); padding-block: var(--space-8) var(--space-16); }
|
||||
.container { max-width: var(--content-max); margin-inline: auto; }
|
||||
.prose { max-width: var(--prose-max); }
|
||||
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
|
||||
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-3)); }
|
||||
```
|
||||
|
||||
## Auto-fitting grid (cards, galleries)
|
||||
|
||||
```css
|
||||
.grid-auto {
|
||||
display: grid; gap: var(--space-6);
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
|
||||
}
|
||||
```
|
||||
|
||||
## Sidebar + content (docs, settings)
|
||||
|
||||
```css
|
||||
.with-sidebar { display: grid; gap: var(--space-8); grid-template-columns: 1fr; }
|
||||
@media (min-width: 900px) { .with-sidebar { grid-template-columns: 15rem minmax(0, 1fr); } }
|
||||
.with-sidebar > aside { position: sticky; top: var(--space-6); align-self: start; }
|
||||
```
|
||||
|
||||
## App shell (tools, dashboards)
|
||||
|
||||
```css
|
||||
.app { display: grid; height: 100dvh; grid-template-rows: auto 1fr; grid-template-columns: 1fr; }
|
||||
@media (min-width: 900px) {
|
||||
.app { grid-template-columns: 15rem minmax(0, 1fr); grid-template-areas: "nav top" "nav main"; }
|
||||
.app > nav { grid-area: nav; border-right: 1px solid var(--border); }
|
||||
.app > header { grid-area: top; }
|
||||
.app > main { grid-area: main; }
|
||||
}
|
||||
.app > header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--gutter);
|
||||
border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: var(--z-sticky); }
|
||||
.app > main { overflow: auto; padding: var(--space-6) var(--gutter); }
|
||||
```
|
||||
On phones the nav becomes a top bar with a menu button or a bottom tab bar (max 5 items).
|
||||
|
||||
## Dashboard
|
||||
|
||||
- Order: page title and time range → the 3 to 5 numbers that matter → the main chart → supporting tables.
|
||||
- KPI row: `grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr))`. Each tile shows label, value (`tabular-nums`), change vs. previous period with a semantic color, and optionally a sparkline.
|
||||
- Status shown in form: a colored dot or pill plus a word, never color alone.
|
||||
- Tables: sticky header, right-aligned numbers, muted secondary columns, row hover in `--surface-2`.
|
||||
|
||||
## Editorial / landing page
|
||||
|
||||
- The hero states the thesis: the subject's most characteristic thing (a headline set big, a live demo, a striking image), sized to content.
|
||||
- Break the grid on purpose once: an oversized type moment, a full-bleed band, an asymmetric 7/5 split. Keep the rest on a calm 12-column grid:
|
||||
```css
|
||||
.grid-12 { display: grid; gap: var(--space-6); grid-template-columns: repeat(12, minmax(0, 1fr)); }
|
||||
.span-7 { grid-column: span 7; } .span-5 { grid-column: span 5; }
|
||||
@media (max-width: 800px) { .grid-12 > * { grid-column: 1 / -1; } }
|
||||
```
|
||||
- Full-bleed bands keep the gutter on their inner wrapper, not the band itself.
|
||||
- Section headings are left-aligned with a short lead paragraph. No eyebrow on every section; use one only when it encodes something (a category, a step).
|
||||
- End with one clear call to action, not three.
|
||||
|
||||
## Forms
|
||||
|
||||
- One column. Labels above inputs. Group related fields with a heading, not a box around each.
|
||||
- Inputs width by expected content (a ZIP code field is short), max ~32rem for text fields.
|
||||
- Primary action at the end, left-aligned with the fields; secondary actions as quieter buttons next to it.
|
||||
- Validate on blur and on submit; inline errors under the field in `--danger` with an icon and text.
|
||||
44
skills/web-frontend/references/libraries.md
Normal file
44
skills/web-frontend/references/libraries.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# Libraries
|
||||
|
||||
Reach for few dependencies, each doing real work. If the project already has a choice for a role, keep it. Install current stable versions (`npm view <pkg> version`). Don't add a library for something CSS or the platform already does well.
|
||||
|
||||
## Pick a base by project type
|
||||
|
||||
| Project | Stack |
|
||||
|---|---|
|
||||
| Static page, single landing page, prototype | Plain HTML + `tokens.css` + a little vanilla JS. No framework. |
|
||||
| Content site, blog, docs, marketing site | **Astro** (static by default, islands where needed). MDX for content. |
|
||||
| Interactive SPA, internal tool, dashboard (no SEO needs) | **Vite + React + TypeScript**. |
|
||||
| Product with SEO, auth, server data, many routes | **Next.js (App Router) + TypeScript**. |
|
||||
| Team already on Vue / Svelte | **Nuxt** or **SvelteKit**; map the roles below to their equivalents. |
|
||||
|
||||
## Roles (React defaults)
|
||||
|
||||
| Role | Default | Notes |
|
||||
|---|---|---|
|
||||
| Styling | `tokens.css` + **CSS Modules** or **Tailwind v4** | Tailwind only with tokens mapped into `@theme` (`tailwind.md`). Never a second color system alongside the tokens. |
|
||||
| Accessible primitives | **Radix UI** primitives (or **shadcn/ui** for copy-in components) | shadcn's stock look is a known AI tell: always restyle it to the tokens (radius, colors, fonts, shadows). |
|
||||
| Icons | **Lucide** (`lucide-react`) | One icon set per project. 16px in dense UI, 20px default, `stroke-width` 1.75. Never emoji as icons. |
|
||||
| Fonts | `@fontsource/<family>` or `next/font/google` | Self-host to avoid layout shift; set `font-display: swap`. |
|
||||
| Routing | Framework router; **TanStack Router** or **React Router** for Vite SPAs | Type-safe routes when available. |
|
||||
| Server state | **TanStack Query** | Caching, retries, loading/error states. Don't hand-roll fetch-in-`useEffect`. |
|
||||
| Client state | React state/context first; **Zustand** when shared state grows | No Redux unless the project has it. |
|
||||
| Forms + validation | **React Hook Form** + **Zod** | Zod schemas double as API types. |
|
||||
| Tables | **TanStack Table** | Headless; style with tokens. |
|
||||
| Charts | **Recharts** for standard charts; **visx** or **D3** for custom | Color from tokens; load the `dataviz` skill if present. |
|
||||
| Motion | CSS transitions first; **Motion** (`motion/react`) for orchestrated sequences, layout and gestures | Always honor reduced motion. |
|
||||
| Toasts | **Sonner** | Restyle to tokens. |
|
||||
| Command palette | **cmdk** | |
|
||||
| Dates | **date-fns** (or `Intl` alone for formatting) | Format with `Intl.DateTimeFormat`/`NumberFormat` for locale-aware output. |
|
||||
| Markdown | **react-markdown** + **remark-gfm** | |
|
||||
| Syntax highlighting | **Shiki** | Pick a theme pair that matches both color themes. |
|
||||
| Testing | **Vitest** + **Testing Library**; **Playwright** for e2e and screenshots | Playwright also gives the one rendered check before shipping. |
|
||||
| Lint/format | ESLint (flat config) + Prettier, or **Biome** | Match the project. |
|
||||
|
||||
## Don't reach for
|
||||
|
||||
- Full UI kits with a strong look of their own (Material UI, Ant Design, Chakra default theme, Bootstrap) unless the project already uses one. They fight the tokens.
|
||||
- Animation libraries for hover states.
|
||||
- jQuery, Moment.js, Lodash as a whole (import single functions or use the platform).
|
||||
- CSS-in-JS runtimes (styled-components, Emotion) in new projects. They cost runtime and clash with server components.
|
||||
- Icon fonts.
|
||||
68
skills/web-frontend/references/tailwind.md
Normal file
68
skills/web-frontend/references/tailwind.md
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# Tailwind with the tokens
|
||||
|
||||
Tailwind is fine as long as the tokens stay the single source of truth. Never use Tailwind's stock palette (`bg-blue-600`, `text-gray-500`) in components. Map the tokens into the theme and use only those names.
|
||||
|
||||
## Tailwind v4 (CSS-first config)
|
||||
|
||||
```css
|
||||
/* src/styles/app.css */
|
||||
@import "tailwindcss";
|
||||
@import "./tokens.css"; /* the file from assets/tokens.css */
|
||||
|
||||
/* Explicit toggle. System dark mode needs no variant: the tokens already switch. */
|
||||
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
|
||||
|
||||
@theme inline {
|
||||
--color-*: initial; /* drop the stock palette */
|
||||
--color-bg: var(--bg);
|
||||
--color-surface: var(--surface);
|
||||
--color-surface-2: var(--surface-2);
|
||||
--color-border: var(--border);
|
||||
--color-border-strong: var(--border-strong);
|
||||
--color-fg: var(--fg);
|
||||
--color-fg-muted: var(--fg-muted);
|
||||
--color-fg-subtle: var(--fg-subtle);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-hover: var(--accent-hover);
|
||||
--color-accent-fg: var(--accent-fg);
|
||||
--color-accent-soft: var(--accent-soft);
|
||||
--color-accent-text: var(--accent-text);
|
||||
--color-ring: var(--ring);
|
||||
--color-ok: var(--ok); --color-ok-soft: var(--ok-soft);
|
||||
--color-warn: var(--warn); --color-warn-soft: var(--warn-soft);
|
||||
--color-danger: var(--danger); --color-danger-soft: var(--danger-soft);
|
||||
--color-info: var(--info); --color-info-soft: var(--info-soft);
|
||||
--color-transparent: transparent;
|
||||
--color-current: currentColor;
|
||||
|
||||
/* Names must differ from the token they read, or the variable refers to itself and becomes invalid. */
|
||||
--font-heading: var(--font-display); /* class: font-heading */
|
||||
--font-sans: var(--font-body);
|
||||
--shadow-card: var(--shadow-raised); /* class: shadow-card */
|
||||
--shadow-menu: var(--shadow-popover);
|
||||
--shadow-dialog: var(--shadow-modal);
|
||||
/* --radius-sm/md/lg, --font-mono and --ease-out need no mapping: tokens.css declares them
|
||||
with Tailwind's own names, unlayered, so they override Tailwind's defaults. */
|
||||
}
|
||||
```
|
||||
|
||||
Because the colors resolve through CSS variables that already switch with the theme, components rarely need `dark:` variants at all: `bg-surface text-fg border-border` is correct in both themes.
|
||||
|
||||
Usage examples:
|
||||
```html
|
||||
<button class="inline-flex h-10 items-center gap-2 rounded-md bg-accent px-4 text-sm font-medium text-accent-fg hover:bg-accent-hover focus-visible:outline-2 focus-visible:outline-ring">Save changes</button>
|
||||
<div class="rounded-md border border-border bg-surface p-5">…</div>
|
||||
<span class="text-xs font-semibold uppercase tracking-[0.06em] text-fg-muted">Revenue</span>
|
||||
```
|
||||
|
||||
## Tailwind v3 projects
|
||||
|
||||
Put the same mapping in `tailwind.config` under `theme.extend.colors` (`bg: 'var(--bg)'`, `fg: 'var(--fg)'`, …), plus `fontFamily`, `borderRadius` and `boxShadow`. Set `darkMode: ['selector', '[data-theme="dark"]']` for the toggle. As in v4, the variables already follow the system theme, so `dark:` classes are rarely needed.
|
||||
|
||||
## Habits to avoid in Tailwind output
|
||||
|
||||
- `rounded-xl shadow-lg` as the default on every container.
|
||||
- `bg-gradient-to-r from-purple-500 to-blue-500` anywhere.
|
||||
- `text-center` on whole sections.
|
||||
- Arbitrary values (`p-[13px]`, `text-[#333]`) instead of tokens.
|
||||
- Very long class strings repeated across files: extract a component instead.
|
||||
Loading…
Add table
Add a link
Reference in a new issue