6.5 KiB
Design Tokens Package Agent
Module Information
Package: @picture/design-tokens
Version: 0.1.0
Type: Shared design system tokens
Location: /apps/picture/packages/design-tokens
Identity
I am the Design Tokens Agent for the Picture app. I maintain the centralized design system that provides consistent colors, spacing, typography, and theming across all Picture app platforms (web, mobile, landing).
Purpose
This package provides framework-agnostic design tokens that ensure visual consistency across:
- Mobile apps (React Native/Expo) via native theme helpers
- Web apps (SvelteKit) via Tailwind CSS preset
- Landing pages (Astro) via Tailwind CSS preset
The design system supports multiple theme variants (default, sunset, ocean) with both light and dark color modes.
Expertise
Design Token Categories
-
Colors (
src/colors.ts)- Base color palette (blacks, whites, grays, brand colors)
- Semantic colors for light/dark modes (background, surface, text, borders)
- Status colors (success, warning, error, info)
- Theme-specific colors (indigo/violet, orange/pink, sky/emerald)
-
Spacing (
src/spacing.ts)- Standardized spacing scale (0px to 128px)
- Border radius values (sm, md, lg, xl, 2xl, 3xl, full)
-
Typography (
src/typography.ts)- Font size scale (xs to 8xl)
- Font weights (regular, medium, semibold, bold)
-
Shadows (
src/shadows.ts)- Box shadow definitions for web
- Platform-appropriate shadow styles
-
Themes (
src/themes/)- Default theme: Indigo/violet color scheme
- Sunset theme: Orange/pink color scheme
- Ocean theme: Sky/emerald color scheme
- Each theme supports light/dark modes
Platform-Specific Exports
Tailwind CSS Preset (tailwind/preset.js)
- Complete Tailwind configuration with design tokens
- Color utilities for dark/light modes
- Spacing, typography, and shadow utilities
- Import in
tailwind.config.jsto apply tokens
React Native Helpers (native/theme.ts)
getThemeColors(variant, mode): Get colors for a themecreateNativeTheme(variant, mode): Create complete theme objectgetThemeVariants(): List available themesisValidThemeVariant(variant): Validate theme names
Code Structure
design-tokens/
├── src/
│ ├── index.ts # Main export (all tokens)
│ ├── colors.ts # Base & semantic colors
│ ├── spacing.ts # Spacing & border radius
│ ├── typography.ts # Font sizes & weights
│ ├── shadows.ts # Shadow definitions
│ └── themes/
│ ├── index.ts # Theme registry
│ ├── default.ts # Indigo/violet theme
│ ├── sunset.ts # Orange/pink theme
│ └── ocean.ts # Sky/emerald theme
├── tailwind/
│ └── preset.js # Tailwind CSS preset
├── native/
│ └── theme.ts # React Native helpers
└── package.json
Key Patterns
Design Token Usage
Web (Tailwind CSS):
// tailwind.config.js
module.exports = {
presets: [require('@picture/design-tokens/tailwind/preset')],
// Use tokens: bg-primary, text-dark-bg, p-4, text-lg
}
Mobile (React Native):
import { createNativeTheme } from '@picture/design-tokens/native';
const theme = createNativeTheme('default', 'dark');
// Access: theme.colors.primary.default, theme.spacing[4], theme.fontSize.lg
Direct Import:
import { semanticColors, spacing, fontSize } from '@picture/design-tokens';
const darkColors = semanticColors.dark;
const padding = spacing[4]; // 16px
const textSize = fontSize.lg; // 18px
Theme Structure
Each theme provides:
colors: Semantic color mappings for light/dark modesshadows: Platform-appropriate shadow stylesopacity: Standard opacity values (disabled, overlay, hover, pressed)
Color Semantic Naming
- Backgrounds:
background,surface,elevated,overlay - Borders:
border,divider - Inputs:
input.background,input.border,input.text,input.placeholder - Text:
text.primary,text.secondary,text.tertiary,text.disabled,text.inverse - Brand:
primary.*,secondary.* - Status:
success,warning,error,info - UI:
skeleton,shimmer,favorite,like,tag
Integration Points
Consumers
This package is consumed by:
@picture/mobile- React Native mobile app@picture/mobile-ui- Mobile UI component library@picture/web- SvelteKit web app@picture/landing- Astro landing page
Build System
- Build tool:
tsupfor TypeScript compilation - Outputs:
dist/- Compiled JS/types for main exportnative/- React Native helper with typestailwind/preset.js- Tailwind preset (no build needed)
- Build command:
pnpm build - Dev mode:
pnpm dev(watch mode)
Design System Principles
- Single source of truth: All visual tokens defined once
- Framework agnostic: Tokens work across web and native
- Theme support: Multiple color schemes with light/dark modes
- Semantic naming: Intent-based naming (not color-based)
- Type safety: Full TypeScript support with exported types
Common Operations
Adding a New Color
- Add base color to
src/colors.tsbaseColorsobject - Map to semantic color in
semanticColors.darkandsemanticColors.light - Update Tailwind preset in
tailwind/preset.jsif needed - Run
pnpm buildto regenerate outputs
Creating a New Theme
- Create
src/themes/mytheme.tsfollowing existing theme structure - Export from
src/themes/index.ts - Add to
themesobject insrc/themes/index.ts - Update Tailwind preset if theme-specific utilities needed
- Run
pnpm build
Modifying Spacing Scale
- Update
spacingobject insrc/spacing.ts - Update Tailwind preset
theme.extend.spacing - Run
pnpm build - Verify no breaking changes in consuming apps
Type Exports
Key exported types:
BaseColors,SemanticColors,ColorModeSpacing,BorderRadiusFontSize,FontWeightThemeVariant,ThemeMode,ThemeNativeTheme(from native helpers)
Notes
- Package is private (not published to npm)
- Peer dependency:
tailwindcss >=3.0.0(optional) - Build generates both CJS and ESM formats for maximum compatibility
- Colors use hex values for broad platform support
- Shadow values are platform-specific (web uses box-shadow, native uses elevation)