Skip to content

Latest commit

 

History

History
115 lines (79 loc) · 5.33 KB

CLAUDE.md

File metadata and controls

115 lines (79 loc) · 5.33 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Overview

Faency is a React component library and design system for Traefik Labs, built with React, TypeScript, vanilla-extract, and Radix UI Primitives. It provides accessible, themed components with light/dark mode support.

All components are styled with vanilla-extract (Stitches was removed in v14). See CONTRIBUTING.md for the contribution workflow, docs/COMPONENT_REFERENCE.md for the component rules, and docs/MIGRATION.md for the v13 → v14 upgrade guide.

Development Commands

Core Development

  • yarn install - Install dependencies
  • yarn storybook - Start Storybook development server at http://localhost:6006
  • yarn build - Build the library for production
  • yarn lint - Lint TypeScript/React files in components and styles directories
  • yarn lint:fix - Auto-fix linting issues
  • yarn typecheck - Type-check the whole project with tsc (also runs in CI)
  • yarn test - Run Jest tests in watch mode
  • yarn test:ci - Run tests in CI mode (silent, non-watch)

Release

Releases are automated. .github/workflows/release.yaml runs yarn semantic-release on every push to master; there is no local release command.

Architecture

Styling System

  • vanilla-extract: Build-time styling with design tokens, recipes and a css prop (see docs/COMPONENT_REFERENCE.md)
  • Build Tool: Vite with vanilla-extract plugin
  • Design Tokens: Theme contract in styles/tokens.css.ts, light/dark implementations in styles/themes.css.ts
  • Theme Support: Light/dark themes with customizable primary colors
  • Component Themes: Components with their own tokens have a ComponentName.theme.ts file (e.g., Button.theme.ts), merged in styles/themes.css.ts

Component Structure

Components follow a consistent pattern:

  • ComponentName.tsx - Main component implementation
  • ComponentName.css.ts - Styles and recipes
  • ComponentName.stories.tsx - Storybook stories
  • ComponentName.test.tsx - Jest tests
  • ComponentName.theme.ts - Component theme tokens for light/dark modes (if needed)
  • index.ts - Exports

Key Files

  • styles/tokens.css.ts - Theme contract (design tokens)
  • styles/themes.css.ts - Light/dark theme classes per primary color
  • styles/themeContext.tsx - FaencyProvider root provider and useFaencyTheme hook
  • colors/ - Color palette definitions (light/dark variants)
  • index.ts - Main library exports (explicit named exports)

Colors and Theming

  • Primary colors: neon, blue, orange, red, green, deepBlue, grayBlue
  • Dynamic theme generation based on primary color selection
  • Component themes support both light and dark variants
  • Colors are defined in /colors/ with systematic naming

Component Dependencies

  • Built on Radix UI Primitives for accessibility
  • Uses vanilla-extract for build-time styling
  • React 18+ and TypeScript 5+ required

Development Workflow

Code Style

  • No Unnecessary Comments: Do not add obvious or redundant comments. Code should be self-explanatory through clear naming and structure. Only add comments when explaining complex logic, non-obvious decisions, or documenting public APIs.
  • No Unnecessary Emojis: OK for console warnings/errors, but avoid in code comments or commit messages.

Adding New Components

  1. Create component directory in /components/
  2. Add ComponentName.css.ts and ComponentName.tsx (with css prop support)
  3. If needed, add ComponentName.theme.ts and register its tokens in styles/tokens.css.ts and styles/themes.css.ts
  4. Add Storybook stories with all variants
  5. Write Jest tests
  6. Export from the component's index.ts and the main index.ts

Working with Themes

  • Component theme files export light and dark token objects (e.g. buttonLightTheme, buttonDarkTheme)
  • Add new tokens to the colors contract in styles/tokens.css.ts and spread the objects into the light and dark colors in styles/themes.css.ts
  • Use semantic color tokens for consistency

Testing Strategy

  • Jest with React Testing Library configured
  • jsdom environment for DOM testing
  • Focus on accessibility and component behavior
  • Run tests before submitting changes
  • Test coverage is currently being developed

Dependency Policy

  • Pin all versions: All dependencies must use exact pinned versions (no ^ or ~). This applies to both dependencies and devDependencies.
  • 3-day rule: When updating or adding dependencies, only use versions released more than 3 days ago. Check the npm release date before pinning a version.

Important Notes

  • Node Version: Use the version in .nvmrc, kept up to date by Renovate. engines.node in package.json is the minimum for apps that install Faency and is raised by hand
  • Conventional Commits: Follow conventional commit format for semantic releases
  • Accessibility: All components must be accessible and support keyboard navigation
  • Storybook: Every component requires comprehensive stories showing all variants

Component Rules

Follow docs/COMPONENT_REFERENCE.md when writing or changing a component: css prop support, variant typing with RecipeVariantProps and splitVariants, polymorphic as and Radix parts, state layers, theme tokens, required test coverage and known test pitfalls.