Skip to content

[Design] add the ThinkRail design-system library — live foundations - #951

Open
Julia Shilova (juliashilovaa) wants to merge 7 commits into
mainfrom
ui-usage-rules
Open

Julia Shilova (juliashilovaa) wants to merge 7 commits into
mainfrom
ui-usage-rules

Conversation

@juliashilovaa

@juliashilovaa Julia Shilova (juliashilovaa) commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

There is no single maintained place where designers, developers, and AI agents can see ThinkRail's actual components, usage rules, working code, and the design system behind them.

Design guidance is scattered across multiple specs (COLOR, TYPOGRAPHY, SPACING, NOTIFICATIONS, UI-TERMINOLOGY, and module specs). Token values are repeated manually, component previews can drift from production, and the external designer prompt references outdated fonts and colors.

Goal

The long-term goal is to build an AI designer that can review new features against the existing design system, identify inconsistencies, and suggest improvements.

The first step is to establish a single, reliable source of design knowledge that stays synchronized with production and can be used by both humans and AI agents.

Solution

A design-system library inside the existing ThinkRail frontend, covering foundations, components, patterns, and vocabulary.

The library uses actual production components and tokens, maintains design rules in one place, and generates Markdown documentation from the same sources.

1. Architecture

  • apps/web/library is a second Vite entry of apps/web, using the existing React, React Compiler, Tailwind, and @/ alias setup.
  • No additional dependencies and no impact on the application bundle.
  • Components are imported directly from @thinkrail/ui/*, themes from @/themes.
  • library.css imports the application's index.css, so the library renders with the exact production styles and tokens.
  • Component changes hot-reload into the library.
  • No duplicated components, copied styles, or manually recreated states.

2. Single source of truth

Token values remain in their original sources:

  • colors.json, typography.json, spacing.json
  • tokens.css and theme manifests

Design rules, descriptions, and component documentation live in apps/web/library/content/.

Instead of repeating token values in documentation, :::live blocks render directly from production sources.

15 live blocks cover color roles, alpha values, palettes across themes, typography, spacing, radius, icons, and themes.

The blocks reuse the existing token generators' logic (typographyModel.ts, colorsModel.ts) rather than introducing separate calculations.

3. Component documentation

Button and IconButton are the first fully documented components.

Each component page includes:

  • Purpose, when to use, and alternatives.
  • Live variants, sizes, tones, and states.
  • Interactive playground with generated code.
  • Copyable examples using actual production components.
  • Anatomy, props, defaults, and accessibility.
  • Keyboard behavior and usage rules.
  • References to real production usage.

Component API documentation is type-checked against the actual TypeScript props, preventing documented variants, sizes, tones, and properties from drifting out of sync.

4. Library interface

The library is organized into five sections:

  • Guides: component reuse and extension rules, design iteration prompt.
  • Foundations: Color, Typography, Spacing, Radius, Icons, Themes.
  • Components: searchable overview and individual component pages.
  • Patterns: Notices, Loading.
  • Vocabulary: shared UI terminology.

The interface includes a grouped sidebar, sticky page outline, live previews, collapsible code examples, and a theme switcher supporting all six production themes.

It uses ThinkRail's own typography, tokens, and components, with responsive navigation and a mobile drawer.

5. Generated documentation for AI agents

library/scripts/generate-md.ts generates documentation directly from library content:

  • COLOR.md
  • TYPOGRAPHY.md
  • SPACING.md
  • NOTIFICATIONS.md
  • UI-TERMINOLOGY.md
  • packages/ui/COMPONENTS.md
  • Root DESIGN.md

Existing specs retain their paths, frontmatter, and identifiers, so existing references continue working.

DESIGN.md consolidates the design prompt with current themes, fonts, typography, spacing, radius, and available components. It replaces the outdated external designer prompt.

AGENTS.md identifies the library as the source of design rules, while existing specs link to the relevant library documentation instead of duplicating it.

6. Validation

Added automated checks to keep the library synchronized with production:

  • Generated documentation is up to date.
  • All authored Markdown pages and live blocks are registered.
  • Internal links and source references resolve.
  • Examples match their documentation.
  • Referenced production usages still exist.
  • Documented defaults match rendered defaults.
  • Component API documentation passes TypeScript checks.

library:verify runs browser verification in Chromium, covering navigation, live blocks, search, themes, component states, accessibility behavior, code copying, and responsive layouts.

Verification results:

  • 57/57 library browser checks passed.
  • Library build and generated documentation checks passed.
  • Typecheck passed (25/25).
  • Application CSS verified against main: no new classes, only unused Markdown-derived classes removed.
  • No shipped runtime changes.

7. Commands

bun run library:dev
bun run library:build
bun run library:md
bun run --cwd apps/web library:verify [url]

Screenshots

Guides

Using the library Design iteration prompt
Using the library Design iteration prompt

Foundations

Color Typography
Color Typography
Spacing Radius
Spacing Radius
Icons Themes
Icons Themes

Components

Components overview Button
Components overview Button
IconButton
IconButton

Patterns

Notices Loading
Notices Loading

Vocabulary

UI vocabulary
UI vocabulary

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🌐 Website preview

Preview https://pr-951.thinkrail-website.pages.dev
Routes Landing · Blog · Vibecoding · Agentic development · Agentic IDE
Commit fd8a0bd

This comment updates in place on every push that touches the website or shared build inputs.

@juliashilovaa Julia Shilova (juliashilovaa) changed the title docs(ui): define component usage and extension rules feat(web): add the ThinkRail component library with Button and IconButton Oct 27, 2026

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

Comment thread apps/web/library/examples/button/long-label.tsx
Base automatically changed from button-system to main October 27, 2026 21:22
Julia.Shilova added 3 commits October 29, 2026 14:54
…ources

index.css scans apps/web/src plus the TS/TSX of packages/ui, the renderers and extension web halves, so Markdown specs, generated references and the component library never add classes to the app's CSS. The app CSS only loses classes parsed from Markdown prose.
…tton

apps/web/library is a second Vite entry that renders production components from source with the production stylesheet and every bundled theme: navigation, a Using the library guide, and complete Button and IconButton pages (variants, sizes, tone, live states, playground, copyable examples, anatomy, props, accessibility, rules, production usages). One typed content source feeds both the site and the generated packages/ui/COMPONENTS.md; library.test.ts keeps the reference, examples, usages and defaults in sync, and library:verify drives the site in Chromium. AGENTS.md and packages/ui/SPEC.md link to it.
A header with Guides / Components and the theme menu, a grouped sidebar, a Components overview with a name search and live, inert preview cards, and component pages with Import / Source / Docs rows, When to use, examples as a two-column grid of cards with show-code, and a sticky On this page outline. All in ThinkRail tokens, type classes and components.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@juliashilovaa Julia Shilova (juliashilovaa) changed the title feat(web): add the ThinkRail component library with Button and IconButton feat(web): add the ThinkRail design-system library — live foundations, Button and IconButton Oct 29, 2026
@juliashilovaa Julia Shilova (juliashilovaa) changed the title feat(web): add the ThinkRail design-system library — live foundations, Button and IconButton [Design] add the ThinkRail design-system library — live foundations Oct 29, 2026

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — ready to merge.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant