diff --git a/CLAUDE.md b/CLAUDE.md index 2d1f10048..aef843e74 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -50,10 +50,12 @@ Pages that are not migrated yet are named `_index.astro` so Astro skips them. Mi - Select elements by their own class, never by structure or tag (`> *`, `> div`, `:first-child`, bare `svg`, `[data-x] > *`). If an element needs styling, give it a class and nest that class under its parent. The exception is content a component renders internally that has no `className` to pass, like the icon inside an `IconButton` (`.swatch svg`). - Nest CSS to mirror the markup: a child's rules go inside its parent's block (`.marker { .bar { } }`), so the stylesheet reads like the HTML tree. - Fully rounded corners use `var(--radius-max)`, never `var(--max-size)`. -- `z-index` stays at `1` unless a real overlap needs more. +- Avoid `z-index: 2` or above unless nothing else works. Resolve overlaps first by DOM order (a later sibling at the same `z-index` paints on top, so put overlays and curtains before what must sit above them) or by leveling the field (give competing siblings the same `position: relative`/`z-index: 1`, or `isolation: isolate` a container so its children's layers stay inside it). ## Components +- Don't copy the same markup or styles across files. As soon as a block repeats, extract it into a component and use that everywhere it appeared. + - Dialog-like surfaces (`Dialog`, `AlertDialog`, `Popover`) share their extra parts, which live as their own top-level components: `DialogHeader`, `DialogBody`, `DialogActions` and `DialogField` (a labeled control, taking a `label` prop). Each surface attaches them as `X.Header`, `X.Body`, `X.Actions` and `X.Field`; none defines its own copy. Fix their spacing in the part's own CSS module. - Other extra non-Radix parts of a composed component are local functions in that component's `index.tsx`, `function Name({ className, ...props }: ComponentProps<"div">)` using `classNames(styles["kebab-class"], className)`, spread in with `{ ...composeRadixComponents(_, styles), Name }`. Once a part is shared by several components, it moves out into its own top-level component instead, like the `Dialog*` parts. A part shared across menus (`Discriminator` in DropdownMenu) is styled through a data attribute, since CSS modules re-hash classes per importing file. diff --git a/packages/website/src/components/BaseStyles.astro b/packages/website/src/components/BaseStyles.astro index 2f9eb10d9..8c90c53f7 100644 --- a/packages/website/src/components/BaseStyles.astro +++ b/packages/website/src/components/BaseStyles.astro @@ -73,6 +73,10 @@ styles += "}"; --duration-brief: 200ms; --duration-subtle: 2s; --duration-spinner: 1s; + /* Gap between consecutive items in a staggered entrance */ + --duration-stagger: 20ms; + + --easing-standard: cubic-bezier(0.4, 0, 0.6, 1); --tank-card-min-width: 8rem; --drop-down-min-width: 16rem; @@ -81,6 +85,11 @@ styles += "}"; -