Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
337 changes: 337 additions & 0 deletions .agents/skills/fyrst-ui-0.5-migration/SKILL.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Lint
run: bun run lint

- name: Typecheck
run: bun run typecheck

- name: Build
run: bun run build

Expand Down
11 changes: 0 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# reset build folders
/packages/preset/css
/packages/preset/jsx
/packages/preset/patterns
/packages/preset/tokens
/packages/preset/types
/packages/preset/recipes
/packages/preset/helpers.js
/packages/preset/helpers.d.ts
/packages/preset/helpers.mjs

# dotenv environment variable files
.env
.env.development.local
Expand Down
72 changes: 37 additions & 35 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Workspace packages (private, not published):

Uses Bun as package manager and build tool, full TypeScript support.

First-party agent skills live in `.agents/skills/<name>/SKILL.md`. Consumer apps on `@fyrst/ui` 0.2.x (`panda.buildinfo.json` in `include`) or still on Panda CSS 1.x should follow [`.agents/skills/panda-v2-migration/SKILL.md`](.agents/skills/panda-v2-migration/SKILL.md).
First-party agent skills live in `.agents/skills/<name>/SKILL.md`. Consumer apps on `@fyrst/ui` 0.2.x (`panda.buildinfo.json` in `include`) or still on Panda CSS 1.x should follow [`.agents/skills/panda-v2-migration/SKILL.md`](.agents/skills/panda-v2-migration/SKILL.md). Consumer apps on 0.3.x / 0.4.x upgrading to 0.5.x should follow [`.agents/skills/fyrst-ui-0.5-migration/SKILL.md`](.agents/skills/fyrst-ui-0.5-migration/SKILL.md). Every breaking change to the public API needs a matching section in a migration skill.

## Package Structure

```
packages/
├── preset/ # @fyrst/design-preset - Panda CSS Preset
│ └── src/
│ ├── index.ts # Main preset export
│ ├── index.ts # Token preset (`@fyrst/ui/design-preset`)
│ └── tokens/ # Base & semantic tokens
├── components/ # @fyrst/ui-components - Vue 3 UI Components
└── nuxt/ # @fyrst/ui-nuxt - Nuxt Module
Expand All @@ -39,13 +39,14 @@ bun run dev:components # Components dev server
bun run dev:nuxt # Link @fyrst/ui, panda lib, then Nuxt module playground
bun run dev:nuxt:prepare # Link @fyrst/ui, panda lib, then stub/prepare the Nuxt module + playground
bun run dev:nuxt:build # Link @fyrst/ui, then build the Nuxt playground (dev check, not publish)
bun run typecheck # tsc on the preset, vue-tsc on the components
bun run clean # Clean all dist folders
```

## Lint Commands

```bash
bun run lint # Run ESLint on all packages
bun run lint # ESLint on sources, tests, and build scripts
bun run lint:fix # Auto-fix lint issues
bun run --filter='@fyrst/ui-nuxt' lint # Lint specific package
```
Expand Down Expand Up @@ -110,67 +111,68 @@ bun run --filter='@fyrst/ui-nuxt' test:types # Type checking
- Use Panda CSS for styling
- Follow patterns in `packages/components/src/`

### CVA/SVA Styling Pattern
### Component Styling (CVA/SVA)

New components using CVA (or SVA for multi-slot) must follow this pattern:
Component styles are `cva` (one element) or `sva` (several slots) definitions in the component's folder. Panda extracts them from the published JS and generates every variant.

**1. Create component folder** (e.g., `packages/components/src/components/Badge/`):
**1. Component folder** (e.g. `packages/components/src/components/Badge/`):
```
Badge/
├── BadgeRoot.vue
├── styles.ts
└── index.ts
```
Standalone exceptions (`Button`, `Loader`) keep those public names (not `ButtonRoot` / `LoaderRoot`) but still use a folder + `styles.ts`. Internal controls keep their styles next to them in `src/internal/controls/` (`controlStyles.ts`, `choiceStyles.ts`, …).

Standalone exceptions (`Button`, `Loader`) keep those public names (not `ButtonRoot` / `LoaderRoot`) but still use a folder + `styles.ts`:
```
Button/
├── Button.vue
├── styles.ts
└── index.ts
```

**2. styles.ts** - Define CVA/SVA with slots if needed:
**2. styles.ts** — a static object literal. Panda reads it at build time, so do not build variants with loops, spreads of shared constants, or `Object.fromEntries`; write them out.
```typescript
import { cva } from 'styled-system/css'
// or for multi-slot: import { sva } from 'styled-system/css'
import { sva } from 'styled-system/css'

export const badgeStyles = cva({
base: { ... },
variants: { ... },
defaultVariants: { ... },
export const badgeStyles = sva({
slots: ['root', 'icon'],
base: { root: { ... } },
variants: { size: { sm: { root: { ... } } } },
defaultVariants: { size: 'md' },
})
```

**3. Component.vue** - Use computed with `.raw()` (typically wrapped in `css(...)`):
```typescript
**3. Component** — every component takes a `css` prop typed `CssMap<…>`; `root` is always the outermost element. For each slot that accepts an override, take the style object with `.raw()` and merge the override with `withCss`:
```vue
<script setup lang="ts">
import { computed } from 'vue'
import { css } from 'styled-system/css'
import { withCss, type CssMap } from '../../internal/css'
import { badgeStyles } from './styles'

const props = defineProps<{ ... }>()
export type BadgeCss = CssMap<'root' | 'icon'>

const badgeClass = computed(() => css(
badgeStyles.raw({ color: props.color, size: props.size }),
))
```
const props = defineProps<{ size?: 'sm' | 'md' | 'lg', css?: BadgeCss }>()
const styles = computed(() => badgeStyles.raw({ size: props.size }))
</script>

```vue
<template>
<span :class="badgeClass">...</span>
<span :class="withCss(styles.root, props.css?.root)">…</span>
</template>
```

**4. index.ts** - Named parts plus default namespace `{ Root, … }`:
- `withCss(style, override)` is `css(style, override)`: one class per property, the override wins. Never append an override class to a finished class string; both atomic classes would stay on the element and stylesheet order would decide.
- Parts without an override (internal chrome) may call the definition directly: `fieldStyles().footer`.
- Share style objects between parts through a typed `createInjectionKey` context (see `Card/types.ts`), never string keys.
- Calling `.raw()` with runtime variants in another file triggers Panda's `imported_recipe_raw_dynamic` warning. It is expected: the definition itself still generates every variant.
- Prefer semantic tokens (`surface`, `border`, `text.muted`, `neutral`) over `_light` overrides. Keep a `_light` block only when state selectors must beat light-mode colors on specificity (see `switchStyles.ts`).

**4. Content.** Content props (labels, titles, descriptions, item content, field message / error) render with `v-html`, as documented in the README. Sanitizing untrusted strings is the consuming app's job, not the library's; `vue/no-v-html` is off for that reason. Where practical, offer a slot for the same content so apps can pass escaped text or their own nodes.

**5. index.ts** — named parts plus default namespace `{ Root, … }`, and export the component's `*Css` types:
```typescript
import BadgeRoot from './BadgeRoot.vue'
export { BadgeRoot }
export type { BadgeCss } from './BadgeRoot.vue'
export default { Root: BadgeRoot }
```

Register the same named exports in `vue-components.ts` and `vue-entries.ts` (`vueLibEntries` and `nuxtComponents` are 1:1; no alias table). `Button` / `Loader` export the SFC by those names and do not use a `{ Root }` namespace.
Register the entry in `vue-entries.ts` (`vueLibEntries`; `nuxtComponents` is derived) and the named export in `vue-components.ts`. `Button` / `Loader` export the SFC by those names and do not use a `{ Root }` namespace.

Do not export `Control*` from `@fyrst/ui`. Bare controls stay under `src/internal/controls/` for Field/Switch. Public form API is `Field.*` / `FyrstField*`. Re-export `FieldOption` from Field.
Do not export `Control*` from `@fyrst/ui`. Bare controls stay under `src/internal/controls/` and share `useFieldControl()` (id, ARIA links, validity from the Field context). Public form API is `Field.*` / `FyrstField*`; composed fields use `FieldSharedProps` and `FieldFooter`. Re-export `FieldOption` from Field.

### Panda CSS

Expand Down Expand Up @@ -236,4 +238,4 @@ describe('ssr', async () => {
3. Build order: Nuxt module requires preset built first (automatic)
4. Peer dependencies: `vue`, `reka-ui`, and `@pandacss/dev` are required. `@pandacss/preset-base` is a published `dependency` (the design-system preset inlines the module; apps on `designSystem` do not install it). `nuxt` and `@nuxt/kit` are optional (only `@fyrst/ui/nuxt`). Do not put `@nuxt/kit` in published `dependencies`.
5. No Prettier: ESLint used for formatting (stylistic rules)
6. Do not ship compiled Panda CSS (`panda cssgen`, `styles.css`, `panda.css`). Publish only the root `@fyrst/ui` package. Consuming apps must depend on `@pandacss/dev`, keep their own `panda.config.ts`, and set `designSystem: '@fyrst/ui'` (no fyrst preset, no `include` into the package). The library build runs `panda lib --outdir dist --files './**/*.{js,mjs}' --panda '^2.4.0'` after assembling `dist/`. That command owns `./panda/*`, `./css`, `./tokens`, `./types`, and other generated subpaths — do not hand-edit them. Custom exports (`./design-preset`, `./preset`, `./nuxt`, `./vue/*`, `./style.css`) stay in `package.json`. `@fyrst/ui/style.css` is Iconify icons only. Pack root `dist/` only (assembled from workspace build outputs, including `dist/panda/` and `dist/styled-system/`) — do not include nested `packages/*/dist`.
6. Do not ship compiled Panda CSS (`panda cssgen`, `styles.css`, `panda.css`). Publish only the root `@fyrst/ui` package. Consuming apps must depend on `@pandacss/dev`, keep their own `panda.config.ts`, and set `designSystem: '@fyrst/ui'` (no fyrst preset, no `include` into the package). The library build runs `panda lib --outdir dist --files './**/*.{js,mjs}' --panda '^2.4.0'` after assembling `dist/`. That command owns `./panda/*`, `./css`, `./tokens`, `./types`, and other generated subpaths — do not hand-edit them. Custom exports (`./design-preset`, `./preset`, `./nuxt`, `./vue/*`, `./style.css`) stay in `package.json`. `@fyrst/ui/style.css` is Iconify icons only: do not add `<style>` blocks to components. The root `panda.config.ts` sets `forceImportExtension: true` so the published runtime loads in plain Node. Pack root `dist/` only (assembled from workspace build outputs, including `dist/panda/` and `dist/styled-system/`) — do not include nested `packages/*/dist`.
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.0] - 2026-10-31

Breaking minor (0.x semver) for apps on 0.3.x / 0.4.x. The Panda contract is unchanged (`designSystem: '@fyrst/ui'`, Panda `^2.4`). Follow [`.agents/skills/fyrst-ui-0.5-migration/SKILL.md`](.agents/skills/fyrst-ui-0.5-migration/SKILL.md). Details: [`changelog/2026-10-31-0.5.0-overrides-and-cleanup.md`](changelog/2026-10-31-0.5.0-overrides-and-cleanup.md).

### Breaking

- **One `css` override prop.** `AlertRoot` `classRoot` / `classIcon` / `classContent` / `classClose`, `CardRoot` `classRoot`, `AccordionRoot` `classes`, `CarouselRoot` `classWrapper` / `classCarousel`, and `FlyoutRoot` `classTrigger` are replaced by `css` (slot-keyed style objects; `root` is the outermost element). Every component now accepts `css`, and merges it into its own style object, so an overridden property gets one class and the override wins (`classRoot` and friends were appended as extra classes and could lose). Values must go through `css.raw()`; bare objects never generated CSS.
- `CardRoot` `borderColor` (no-op since 0.3.0) is removed.
- `useFormData` returns `getFormData()` / `getJson()` (read on each call) instead of cached `formData` / `jsonData` refs, and accepts an element, ref, or getter.
- `useCarousel(options, carousel)` drops the `slots` argument; `carouselItems` is `HTMLElement[]`.
- Carousel children use `inject(CarouselContextKey)` instead of string keys.
- Carousel wheel navigation is off by default (`wheel-navigation` turns it on). It used to block page scrolling.
- `FlyoutRoot` is built on Reka Popover: Escape and outside click close it, a click while hover-open pins it, and focus moves correctly. The `#trigger` slot must render one element (it becomes the trigger). Keep `#dropdown` content inside `FlyoutDropdown`; the `flyout-enter` / `flyout-leave` transition classes are gone.
- Removed types: `SwitchCssMap`, `ProgressCssMap`, `SwitchStyles`, `ProgressStyles`, `ListStyles`, `PricingCardStyles`. Use `CssMap<K>` and the per-component `*Css` types.
- Component `name` options: `FyButton` / `FyLoader` → `FyrstButton` / `FyrstLoader`.
- A disabled `Button` link renders without `href` and with `aria-disabled="true"`.

### Added

- Semantic colors `surface`, `surface.raised`, `border`, `border.hover`, `border.subtle`, `text.muted`; base `brand.50` and `brand.200` (replacing hex literals in `Button`).
- `CssMap` and `*Css` types for every component, `CarouselContextKey`, `CarouselContext`, `FieldSharedProps`.
- `FlyoutRoot` `direction` and `openOnHover`; `CarouselNavigation` `prevLabel` / `nextLabel`.
- Migration skill `.agents/skills/fyrst-ui-0.5-migration`.

### Fixed

- The package loads in plain Node (ESM and CJS). The published Panda runtime used extensionless imports (`forceImportExtension: true`).
- `require('@fyrst/ui/vue/<Name>')` resolves the `.cjs` build.
- `useFormData` no longer returns stale or `null` data.
- `@fyrst/ui/style.css` is icons only again (Flyout's transition CSS had leaked into it).
- Overrides passed to `PricingCardBody` and similar now produce CSS when passed through `css.raw()`; the body's default padding is generated.
- `ListItem` `size` / `state` / `icon` are respected inside `ListRoot`.
- `FieldError` no longer sets both `role="alert"` and `aria-live="polite"`; the required asterisk is `aria-hidden`.
- `Button` `title` is the label without HTML tags (it showed raw markup before).
- Carousel no longer logs `console.warn` at either end; its default buttons have `type="button"`.

### Changed

- Field helper text in light mode uses `text.muted` (`grey.600`, was `grey.500`). Checkbox and radio hover borders in light mode use `border.hover` (`grey.300`, was `grey.400`). Everything else measures identical to 0.4.1 in the playground (dark and light, rest / hover / focus).
- Component styles stay atomic `cva` / `sva`; class names only change where a color now uses a semantic token (for example `bg-c_surface` instead of `bg-c_grey.black` plus `light:bg-c_white`). Styles that lived inline in controls, the prompt form, the carousel, and the flyout moved into `styles.ts` definitions, so runtime ternaries inside `css()` are gone.
- Panda build warnings dropped from 50 to 14. The remaining `imported_recipe_raw_dynamic` warnings are expected (see the Panda v2 skill). Lint now covers tests and build scripts; `bun run typecheck` runs in CI. Component tests no longer need a prior preset build.

## [0.4.1] - 2026-10-31

Patch on 0.4.0. Font tokens, `font-family: inherit`, `Button` `fullWidth`, `AlertRoot` `hideIcon`, the required-field asterisk (`color: 'danger'`), and the inlined `@pandacss/preset-base` dependency are unchanged.
Expand Down
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ fyrst.dev design system. One npm package with subpath exports:

This library does **not** ship compiled Panda CSS. Consuming apps depend on `@pandacss/dev`, keep their own `panda.config.ts`, and set `designSystem: '@fyrst/ui'`. `panda lib` writes `@fyrst/ui/panda/*` (`lib.json`, `preset.mjs`, `buildinfo.json`) and the generated `./css`, `./tokens`, `./types`, … subpaths. Do not hand-edit those generated exports.

Upgrading from 0.4.x? 0.5.0 has breaking changes. Follow [`.agents/skills/fyrst-ui-0.5-migration/SKILL.md`](.agents/skills/fyrst-ui-0.5-migration/SKILL.md) (it is in the git repository, not in the npm tarball).

## Install

Required peers: `vue`, `reka-ui`, `@pandacss/dev`. `@pandacss/preset-base` is a normal dependency: `panda lib` inlines it into the design-system preset, so apps that set `designSystem: '@fyrst/ui'` do not install it. `nuxt` and `@nuxt/kit` are optional and only needed for `@fyrst/ui/nuxt` (a Nuxt app already provides both).
Expand Down Expand Up @@ -88,6 +90,35 @@ You can also import from `@fyrst/ui/components` if you want the subpath to be ex

`createInjectionKey` is exported from `@fyrst/ui` but is not auto-imported by the Nuxt module.

## Styling components

Component styles are atomic Panda classes from `cva` / `sva` definitions inside the package. They reach the app through `designSystem: '@fyrst/ui'`; Panda generates every variant of each definition, so the app does not need to render a variant for its CSS to exist.

**Per-instance overrides.** Every component takes a `css` prop: style objects keyed by slot, where `root` is always the outermost element. Wrap each value in `css.raw()` from the app's own `styled-system/css`. Panda only generates CSS for objects it can see at build time; a bare object literal compiles but produces no CSS.

```vue
<script setup lang="ts">
import { css } from 'styled-system/css'
</script>

<template>
<FyrstAlertRoot
:messages="messages"
:css="{ root: css.raw({ maxWidth: 'md' }), title: css.raw({ fontSize: 'xl' }) }"
/>
</template>
```

The component merges the override into its own style object before generating classes, so an overridden property gets one class and the override wins.

**Semantic colors.** Besides `primary`, `neutral`, and the status colors, the preset has `surface`, `surface.raised`, `border`, `border.hover`, `border.subtle`, and `text.muted`. They switch between dark (default) and `.light` on their own, so app styles rarely need `_light`.

## Text and HTML content

Content props render as **HTML** (`v-html`): `Button` `label`, `CardHeader` `title` / `subtitle`, `HeroLead` `headline` / `description`, list items and `PricingCard` features, accordion item `title` / `content`, tab labels, `FlyoutRoot` `label`, and field `message` / `error`. Markup such as `Build <mark>faster</mark>` works as written.

The library does not sanitize these strings. **The app is responsible**: sanitize anything that can contain user input, server responses (including validation messages), CMS content, or external translations before passing it, for example with [DOMPurify](https://github.com/cure53/DOMPurify). Where a component has a slot for the same content (`CardHeader` `#title` / `#subtitle`, `HeroLead` `#headline` / `#description`, `AccordionRoot` `#content`, `ListItem` and `TabItem` default slots, `FlyoutRoot` `#trigger-label`), text passed through the slot is escaped by Vue. `Button` `label`, accordion item `title`, and field `message` / `error` have no slot; sanitize those strings.

## Component names

Nuxt auto-imports Vue components with a `Fyrst` prefix (`FyrstButton`, `FyrstAlertRoot`, `FyrstCardRoot`) as named exports of `@fyrst/ui`. Per-component files remain available at `@fyrst/ui/vue/*` for direct imports (for example `@fyrst/ui/vue/Button`).
Expand Down Expand Up @@ -137,14 +168,19 @@ This repo is a Bun workspace. Internal package names (`@fyrst/design-preset`, `@
```bash
bun install
bun run build
bun run typecheck
bun run test
bun run dev:nuxt
```

`bun run build` and `bun run dev:nuxt` link the root package at `node_modules/@fyrst/ui` and run `panda lib`, so the playground can set `designSystem: '@fyrst/ui'` the same way consumers do.

See `AGENTS.md` for lint, test, and package scripts.

Apps on `@fyrst/ui` 0.2.x (`panda.buildinfo.json` in `include`) or still on Panda CSS 1.x should follow [`.agents/skills/panda-v2-migration/SKILL.md`](.agents/skills/panda-v2-migration/SKILL.md). That skill lives in the git repository (not in the npm tarball).
Migration skills live in the git repository (not in the npm tarball):

- Apps on `@fyrst/ui` 0.2.x (`panda.buildinfo.json` in `include`) or still on Panda CSS 1.x: [`.agents/skills/panda-v2-migration/SKILL.md`](.agents/skills/panda-v2-migration/SKILL.md).
- Apps on `@fyrst/ui` 0.3.x / 0.4.x: [`.agents/skills/fyrst-ui-0.5-migration/SKILL.md`](.agents/skills/fyrst-ui-0.5-migration/SKILL.md).

## Publishing

Expand Down
Loading
Loading