Skip to content

kevintyj/design

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Design System Core

Design System Generation Monorepo

Blog post

Figma plugin

A comprehensive design system with color and spacing generation based on Radix UI colors, built as a modular TypeScript monorepo with Bun.

โœจ Features

Terminal Demo

Youtube Demo

๐ŸŽจ Color System

  • 12-step color progressions for each color using Radix UI methodology
  • Alpha channel variants for transparency effects
  • Wide gamut P3 support for modern displays
  • Gray scale variants contextual to each color
  • Special colors (contrast, surface, indicator)

๐Ÿ“ Spacing System

  • 26 spacing values from 0px to 80px with 4px base multiplier
  • Pixel and REM variants for flexible sizing
  • Utility classes for margin, padding, and gap
  • Tailwind-compatible naming conventions

๐Ÿ›  Generation Options

  • Multiple output formats: CSS custom properties, JSON, design tokens, Tailwind config
  • CLI tool for easy generation from any project
  • TypeScript support with full type safety
  • Configurable output directories and options
  • Organized folder structure (colors/, spacing/, combined/)

๐Ÿ“ฆ Packages

Core Packages

Package Description Status
@kevintyj/design-color-core Core color generation logic โœ… Complete
@kevintyj/design-spacing-core Core spacing generation logic โœ… Complete

Generation Packages

Package Description Status
@kevintyj/design-color-css CSS generation utilities โœ… Complete
@kevintyj/design-color-json JSON format generation โœ… Complete
@kevintyj/design-spacing-css Spacing CSS utilities โœ… Complete
@kevintyj/design-spacing-json Spacing JSON formats โœ… Complete

Application Packages

Package Description Status
@kevintyj/design/cli Command-line interface โœ… Complete
@kevintyj/design/figma-plugin Figma plugin for design system management โœ… Complete
@kevintyj/design/figma-json Export Figma variables to JSON โœ… Complete
@kevintyj/design/examples Usage examples and demos โœ… Complete

๐Ÿš€ Quick Start

1. Install Dependencies

bun install

2. Build the System

# Build all packages in dependency order
bun run build

3. Validate Your Definitions

Your base.ts file is already set up with 9 beautiful colors and 26 spacing values:

# Validate color definitions
bun run colors:validate

# List all available colors
bun run colors:list

# Validate spacing definitions
bun run spacing:validate

4. Generate Design System

# Quick generation with all features
bun run system:quick

# Generate colors only
bun run colors:quick

# Generate spacing only
bun run spacing:quick

# Custom output directory
bun run system:quick --output ./dist

# Full control with all options
bun run system:generate --verbose --output ./styles

๐ŸŽฏ Available Colors

Your base.ts currently includes:

  • ๐Ÿ”ฅ blaze - Vibrant orange-red (#FC4B32 / #FD563D)
  • ๐Ÿ‚ autumn - Warm brown (#311318 / #30181B)
  • ๐ŸŒธ pink - Bright pink (#F9486F / #F55776)
  • ๐ŸŒŠ teal - Blue-green (#00A77F / #17AD85)
  • ๐Ÿ’™ blue - Primary blue (#286EDC / #3A80E0)
  • โค๏ธ red - Classic red (#DA3132 / #DE393A)
  • ๐Ÿ’› yellow - Bright yellow (#FBB919 / #FFBD3B)
  • ๐Ÿ’š green - Fresh green (#28B450 / #51B251)
  • ๐Ÿ’œ violet - Purple-blue (#5B5BD6 / #5B5BD6)

Each color generates 12-step progressions for light and dark modes with alpha variants, wide gamut P3 colors, and contextual gray scales.

๐Ÿ“ Available Spacing

Your base.ts includes 26 spacing values following a 4px multiplier system:

  • Core values: 0, 1 (4px), 2 (8px), 3 (12px), 4 (16px), 5 (20px)
  • Extended values: 6 through 20 for larger spacing needs
  • Pixel variants: px (1px), 2px, 3px, 5px, 6px, 10px, 14px
  • REM equivalents: Auto-generated for all values (e.g., 1rem = 16px)

๐Ÿ“š CLI Commands

Quick Commands

Command Description Example
bun run system:quick Generate complete design system bun run system:quick --output ./dist
bun run colors:quick Quick color generation (all features) bun run colors:quick
bun run spacing:quick Quick spacing generation bun run spacing:quick

Validation Commands

Command Description Example
bun run system:validate Validate both colors and spacing bun run system:validate
bun run colors:validate Validate color definitions bun run colors:validate
bun run spacing:validate Validate spacing definitions bun run spacing:validate

List Commands

Command Description Example
bun run colors:list List all available colors bun run colors:list
bun run spacing:list List all spacing values bun run spacing:list

Generation Commands

Command Description Example
bun run system:generate Full system generation bun run system:generate --verbose
bun run colors:generate Full control color generation bun run colors:generate --formats css,json
bun run spacing:generate Full spacing generation bun run spacing:generate --formats css

Figma Integration

Command Description Example
bun run system:figma Generate complete Figma JSON bun run system:figma
bun run colors:figma Generate Figma color JSON bun run colors:figma
bun run spacing:figma Generate Figma spacing JSON bun run spacing:figma

Advanced Generation Options

# Generate specific formats
bun run colors:generate --formats css,json --output ./assets

# Exclude alpha channels (smaller output)
bun run colors:generate --no-alpha --output ./minimal

# Only wide gamut colors
bun run colors:generate --no-alpha --no-gray-scale --output ./p3

# Custom CSS prefix
bun run colors:generate --css-prefix "--theme" --formats css

# Pretty JSON with specific format
bun run colors:generate --json-format tokens --json-pretty --formats json

# Verbose output to see all generated files
bun run system:generate --verbose

๐ŸŽฏ Generated Output Structure

output/
โ”œโ”€โ”€ css/
โ”‚   โ”œโ”€โ”€ colors/
โ”‚   โ”‚   โ”œโ”€โ”€ colors-light.css
โ”‚   โ”‚   โ”œโ”€โ”€ colors-dark.css
โ”‚   โ”‚   โ”œโ”€โ”€ colors-combined.css
โ”‚   โ”‚   โ””โ”€โ”€ colors-full-*.css
โ”‚   โ”œโ”€โ”€ spacing/
โ”‚   โ”‚   โ”œโ”€โ”€ spacing.css
โ”‚   โ”‚   โ”œโ”€โ”€ spacing-px.css
โ”‚   โ”‚   โ”œโ”€โ”€ spacing-rem.css
โ”‚   โ”‚   โ””โ”€โ”€ spacing-combined.css
โ”‚   โ””โ”€โ”€ combined/           # ๐Ÿšง Coming soon
โ”‚       โ””โ”€โ”€ design-system.css
โ”œโ”€โ”€ json/
โ”‚   โ”œโ”€โ”€ colors/
โ”‚   โ”‚   โ”œโ”€โ”€ colors-flat.json
โ”‚   โ”‚   โ”œโ”€โ”€ colors-nested.json
โ”‚   โ”‚   โ”œโ”€โ”€ colors-tokens.json
โ”‚   โ”‚   โ””โ”€โ”€ colors-tailwind.json
โ”‚   โ”œโ”€โ”€ spacing/
โ”‚   โ”‚   โ”œโ”€โ”€ spacing-flat.json
โ”‚   โ”‚   โ”œโ”€โ”€ spacing-nested.json
โ”‚   โ”‚   โ”œโ”€โ”€ spacing-tokens.json
โ”‚   โ”‚   โ”œโ”€โ”€ spacing-tailwind.json
โ”‚   โ”‚   โ””โ”€โ”€ spacing-collections.json
โ”‚   โ””โ”€โ”€ combined/           # ๐Ÿšง Coming soon
โ”‚       โ””โ”€โ”€ design-system.json
โ””โ”€โ”€ figma/
    โ”œโ”€โ”€ colors-figma.json
    โ”œโ”€โ”€ spacing-figma.json
    โ””โ”€โ”€ system-figma.json   # ๐Ÿšง Coming soon

๐Ÿ’ป Programmatic Usage

Color Generation

import {
  loadColorDefinitions,
  generateColorSystem
} from '@kevintyj/design-color-core';
import { generateCSSFiles } from '@kevintyj/design-color-css';
import { generateJSONFiles } from '@kevintyj/design-color-json';

// Load from base.ts
const colorInput = await loadColorDefinitions('./base.ts');
const colorSystem = generateColorSystem(colorInput);

// Generate CSS files
const cssFiles = generateCSSFiles(colorSystem, {
  includeAlpha: true,
  includeWideGamut: true
});

// Generate JSON files
const jsonFiles = generateJSONFiles(colorSystem, {
  format: 'all'
});

Spacing Generation

import {
  loadSpacingDefinitions,
  generateSpacingSystem
} from '@kevintyj/design-spacing-core';
import { generateCSSFiles } from '@kevintyj/design-spacing-css';
import { generateJSONFiles } from '@kevintyj/design-spacing-json';

// Load from base.ts
const spacingInput = await loadSpacingDefinitions('./base.ts');
const spacingSystem = generateSpacingSystem(spacingInput);

// Generate CSS files
const cssFiles = generateCSSFiles(spacingSystem, {
  variant: 'full',
  generateUtilityClasses: true
});

// Generate JSON files
const jsonFiles = generateJSONFiles(spacingSystem, {
  format: 'tailwind'
});

Combined System Generation

import {
  loadColorDefinitions,
  loadSpacingDefinitions,
  generateColorSystem,
  generateSpacingSystem
} from '@kevintyj/design-color-core';

// Load definitions
const colorInput = await loadColorDefinitions('./base.ts');
const spacingInput = await loadSpacingDefinitions('./base.ts');

// Generate systems
const colorSystem = generateColorSystem(colorInput);
const spacingSystem = generateSpacingSystem(spacingInput);

// Generate combined output
const designSystem = {
  colors: colorSystem,
  spacing: spacingSystem,
  metadata: {
    generatedAt: new Date().toISOString(),
    version: '1.0.0'
  }
};

๐ŸŽจ Examples

Generated CSS Output

Color Custom Properties:

:root {
  /* Color scale */
  --color-blue-1: #fcfdff;
  --color-blue-2: #f6f9ff;
  --color-blue-12: #113161;

  /* Alpha variants */
  --color-blue-a1: rgba(40, 110, 220, 0.05);
  --color-blue-a12: rgba(40, 110, 220, 0.95);

  /* Wide gamut P3 */
  --color-blue-p3-1: oklch(99.4% 0.0025 259.5);

  /* Special colors */
  --color-blue-contrast: #ffffff;
  --color-blue-surface: rgba(40, 110, 220, 0.1);
}

Spacing Custom Properties:

:root {
  /* Pixel values */
  --spacing-0: 0px;
  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-4: 16px;

  /* REM values */
  --spacing-1-rem: 0.25rem;
  --spacing-2-rem: 0.5rem;
  --spacing-4-rem: 1rem;
}

/* Utility classes */
.m-1 { margin: 4px; }
.p-2 { padding: 8px; }
.gap-4 { gap: 16px; }

Generated JSON Output

Tailwind Colors:

{
  "theme": {
    "colors": {
      "blue": {
        "50": "#fcfdff",
        "500": "#286edc",
        "950": "#113161"
      }
    }
  }
}

Tailwind Spacing:

{
  "theme": {
    "spacing": {
      "0": "0px",
      "1": "4px",
      "2": "8px",
      "4": "16px",
      "px": "1px"
    }
  }
}

Run Examples

# Basic color and spacing generation example
bun run example:basic

# Advanced usage patterns
bun run example:advanced

๐Ÿ›  Development

Build Commands

# Install dependencies
bun install

# Build all packages in dependency order
bun run build

# Build specific package
bun run build:package cli

# Clean build artifacts
bun run build:clean

# List available packages
bun run build:list

Development Scripts

# Run linting
bun run lint

# Format code
bun run precommit

# Run tests
bun run test

# Clean everything
bun run clean

Adding New Colors

  1. Edit your base.ts file to add new colors:
export const light = {
  // ... existing colors
  brand: '#FF6B35',      // Add new color
  accent: '#4ECDC4'
};

export const dark = {
  // ... existing colors
  brand: '#FF7F59',      // Add dark variant
  accent: '#45B7B8'
};
  1. Validate and generate:
bun run colors:validate
bun run colors:quick

Adding New Spacing Values

  1. Edit the spacing object in base.ts:
export const spacing = {
  // ... existing values
  "24": 96,    // 24 * 4px = 96px
  "32": 128    // 32 * 4px = 128px
};
  1. Generate spacing using the CLI:
bun run spacing:validate
bun run spacing:quick

Project Structure

design/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ color-generation-core/     # Core color generation
โ”‚   โ”œโ”€โ”€ color-generation-css/      # Color CSS output
โ”‚   โ”œโ”€โ”€ color-generation-json/     # Color JSON output
โ”‚   โ”œโ”€โ”€ spacing-generation-core/   # Core spacing generation
โ”‚   โ”œโ”€โ”€ spacing-generation-css/    # Spacing CSS output
โ”‚   โ”œโ”€โ”€ spacing-generation-json/   # Spacing JSON output
โ”‚   โ”œโ”€โ”€ cli/                       # Command-line interface
โ”‚   โ”œโ”€โ”€ figma-plugin/              # Figma integration
โ”‚   โ”œโ”€โ”€ figma-to-json/             # Figma variable export
โ”‚   โ””โ”€โ”€ examples/                  # Usage examples
โ”œโ”€โ”€ base.ts                        # Your design definitions
โ”œโ”€โ”€ package.json                   # Monorepo configuration
โ”œโ”€โ”€ build.ts                       # Custom build system
โ””โ”€โ”€ output/                        # Generated files

๐ŸŽจ Design System Methodology

Color Scale (Radix UI)

  • Steps 1-2: Backgrounds, subtle borders
  • Steps 3-5: UI component backgrounds
  • Steps 6-8: Borders, separators
  • Steps 9-10: Solid backgrounds, primary actions
  • Steps 11-12: High contrast text, active states

Spacing Scale (4px Base)

  • Micro spacing (0-4px): 0, px, 2px, 3px, 1
  • Small spacing (4-16px): 1, 5px, 6px, 2, 10px, 3, 14px, 4
  • Medium spacing (16-48px): 4, 5, 6, 7, 8, 9, 10, 11, 12
  • Large spacing (48px+): 13, 14, 15, 16, 18, 20

๐Ÿ“– Package APIs

Color Generation

  • Core: createColorInput(), generateColorSystem(), validateColorInput()
  • CSS: generateCSSFiles(), generateCSSForColorSystem()
  • JSON: generateJSONFiles(), generateFlatJSON(), generateTailwindJSON()

Spacing Generation

  • Core: createSpacingInput(), generateSpacingSystem(), validateSpacingInput()
  • CSS: generateCSSFiles(), generateSpacingUtilityClasses()
  • JSON: generateJSONFiles(), generateTailwindSpacingJSON()

๐ŸŽฏ Figma Integration

Figma Plugin

  • Import/export design system configurations
  • Generate color scales directly in Figma
  • Manage design system variables
  • Export to multiple formats

Figma Variable Export

  • Export Figma variables to JSON
  • Convert to design system format
  • Support for color and spacing variables
# Develop Figma plugin
bun run figma:dev

# Build Figma plugin for production
bun run figma:build

๐Ÿ—๏ธ Build System

This project uses a custom TypeScript build system with advanced features:

Build Process

  1. Core Packages: Color and spacing generation cores
  2. Extension Packages: CSS, JSON, and Figma integrations
  3. Application Packages: CLI and examples

Build Features

  • ๐Ÿ” Environment validation with Bun version checking
  • ๐Ÿ“ฆ Dependency-aware ordering prevents build failures
  • ๐ŸŽจ Rich console output with colors and progress
  • ๐Ÿš€ Parallel execution within build groups
  • ๐Ÿ“Š Build statistics with timing and performance data
  • ๐Ÿงน Smart cleanup and artifact management

Build Statistics

The build system provides detailed statistics:

  • Individual package build times
  • Group build summaries
  • Performance rankings
  • Total build time and package counts

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Build and test: bun run build && bun run test
  5. Run linting: bun run lint
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Open a Pull Request

๐Ÿ“„ License

BSD 3-Clause License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Radix UI for the color methodology
  • Bun for the fast JavaScript runtime and build tools
  • Tailwind CSS for spacing and utility inspiration
  • All contributors to this project

๐Ÿ”ฎ Roadmap

  • โœ… Complete color generation system
  • โœ… Complete spacing generation system
  • โœ… CLI integration for colors
  • โœ… CLI integration for spacing
  • โœ… Combined system generation
  • ๐Ÿšง Typography scale generation
  • ๐Ÿšง Component primitive generation
  • ๐Ÿšง Enhanced Figma plugin with spacing support
  • ๐Ÿšง Web-based design system editor
  • ๐Ÿšง Design token standard compliance
  • ๐Ÿšง Advanced utility class generation
  • ๐Ÿšง Design system documentation site
  • ๐Ÿšง VS Code extension for design system management

๐ŸŽจ Ready to build beautiful, consistent design systems with automated color and spacing generation!

About

Design utils for Kevin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages