@pivotable/design-system
v0.1.19
Published
Cross-platform design tokens for Pivotable iOS and Web applications
Maintainers
Readme
Pivotable Design System
Cross-platform design tokens for Pivotable iOS and Web applications.
Overview
This package serves as the single source of truth for all design tokens, generating platform-specific outputs:
- iOS: Swift constants and extensions
- Web: CSS custom properties and TypeScript types
All tokens are defined in JSON format and automatically generate platform outputs via GitHub Actions.
Installation
iOS (Swift Package Manager)
Add the package dependency in Xcode:
- File → Add Package Dependencies
- Enter the repository URL:
https://github.com/pivotable-ai/design-system - Select the version range (e.g.,
from: "0.1.0")
Or add to your Package.swift:
dependencies: [
.package(url: "https://github.com/pivotable-ai/design-system", from: "0.1.0")
]Then import in your Swift files:
import PivotableDesignSystemWeb (npm)
npm install @pivotable/design-systemImport CSS in your globals.css:
@import "@pivotable/design-system/build/web/tokens.css";Import TypeScript types:
import { tokens, tokenValues } from "@pivotable/design-system/build/web/tokens";Token Reference
Colors
Adaptive Colors (change per theme)
background- Primary background colorforeground- Primary text colorprimary- Primary brand color for CTAs
Static Colors (same in both themes)
border- Default border colorcard- Card background colorbadge- Badge background color
Semantic Colors (all static)
success- Success state color (#4ADEB5)error- Error state color (#E73E3E)warning- Warning state color (#FFC857)interviewing- Interviewing status color (#EA580C)accepted- Accepted status color (#16A34A)
Spacing
Spacing values use a 4pt base unit. Common values:
extraSmall- 4ptsmall- 6ptmedium- 16ptlarge- 24ptextraLarge- 32pt
Component-specific spacing tokens are also available (e.g., buttonHorizontalPadding, cardPadding, standardPadding).
Typography
Font sizes match iOS Dynamic Type text styles:
largeTitle- 34pttitle- 28pttitle2- 22pttitle3- 20ptheadline- 17pt (semibold)body- 17ptcallout- 16ptsubheadline- 15ptfootnote- 13ptcaption- 12ptcaption2- 11pt
Font weights: regular (400), medium (500), semibold (600), bold (700)
Radius
cornerRadius- 16pt (standard corner radius for cards and buttons)
Platform Examples
iOS Swift
import SwiftUI
import PivotableDesignSystem
struct MyView: View {
var body: some View {
VStack(spacing: PivotSpacing.medium) {
Text("Hello")
.foregroundColor(.foreground)
.padding(PivotSpacing.standardPadding)
Button("Click me") {
// Action
}
.background(Color.primary)
.foregroundColor(.background)
.cornerRadius(PivotRadius.cornerRadius)
}
.background(Color.background)
}
}Web CSS
.my-component {
background-color: var(--colorBackground);
color: var(--colorForeground);
padding: var(--spacingStandardPadding);
border-radius: var(--radiusCornerRadius);
}
.primary-button {
background-color: var(--colorPrimary);
color: var(--colorBackground);
}Web TypeScript/React
import { tokens, tokenValues } from "@pivotable/design-system/build/web/tokens";
// Use CSS variables
const styles = {
backgroundColor: tokens.color.background,
padding: tokens.spacing.standardPadding,
};
// Use actual hex values for calculations
const primaryHex = tokenValues.color.light.primary; // '#153243'Architecture
Token Structure
Tokens are organized by category:
tokens/src/
├── colors/
│ ├── light.json # Light theme colors
│ └── dark.json # Dark theme colors
├── spacing/
│ └── scale.json # Spacing scale
├── typography/
│ ├── font-families.json
│ ├── font-sizes.json
│ ├── font-weights.json
│ └── line-heights.json
└── radius/
└── scale.jsonBuild Process
- Style Dictionary processes token JSON files
- Custom transforms convert tokens to platform-specific formats
- Formats generate Swift, CSS, and TypeScript outputs
- GitHub Actions runs build on every push to main
Generated Outputs
- iOS:
Sources/PivotableDesignSystem/*.swift - Web:
build/web/tokens.css,build/web/tokens.ts
Contributing
Adding New Tokens
- Edit the appropriate JSON file in
tokens/src/ - Follow existing naming conventions (camelCase)
- Add descriptions for all new tokens
- Run
npm run validateto check for issues - Submit a pull request
Modifying Existing Tokens
- Update the token value in the JSON file
- Ensure adaptive colors have both light and dark values
- Run validation to check contrast ratios
- Update any affected documentation
Pull Request Process
- Create a feature branch
- Make your changes
- Run
npm run validateandnpm run build - Ensure all tests pass
- Submit PR with clear description
Migration Guide
From Old Colors.swift
Old:
Color.appPrimary
Color.appBackground
Constants.standardPaddingNew:
import PivotableDesignSystem
Color.primary
Color.background
PivotSpacing.standardPaddingFrom Old CSS Variables
Old:
var(--primary)
var(--background)New:
var(--colorPrimary)
var(--colorBackground)See the Migration Strategy section for detailed migration steps.
Troubleshooting
iOS: "No such module 'PivotableDesignSystem'"
- Ensure the package is added to your project dependencies
- Check that the version in Package.swift matches the available versions
- Clean build folder (Product → Clean Build Folder)
Web: CSS variables not working
- Ensure
tokens.cssis imported in yourglobals.css - Check that CSS variables are prefixed with
--(e.g.,--colorPrimary) - Verify the package is installed:
npm list @pivotable/design-system
TypeScript: Types not found
- Ensure
tokens.tsis imported from the correct path - Check that TypeScript can resolve the module
- Try reinstalling:
npm install @pivotable/design-system
Versioning
We use semantic versioning:
- Minor Version (0.x.0): New tokens added, non-breaking changes
- Major Version (x.0.0): Tokens removed or renamed
Breaking Changes
Breaking changes are announced in release notes and require team approval. A deprecation period of at least 2 minor versions is provided before removal.
License
MIT
Support
For issues, questions, or contributions, please open an issue on GitHub.
