@times-design-system/theme-ios
v2.9.3
Published
Times Design System theme package - iOS xcassets theme files
Maintainers
Readme
@times-design-system/theme-ios
Times Design System theme package for iOS with Swift color definitions, typography tokens, and Xcode asset catalog support.
Installation
yarn add @times-design-system/theme-iosContents
Swift Color Files
Pre-generated Swift files for iOS color assets:
src/Colors/
├── DarkCoreColors.swift
├── LightCoreColors.swift
├── DarkBrandColors.swift
├── LightBrandColors.swift
├── DarkChannelsColors.swift
├── LightChannelsColors.swift
└── ... (30+ color definition files)Xcode Asset Catalog
Complete color asset catalog ready for Xcode projects:
src/TDS[Theme]/Colors/[ColorName].colorset/
├── Contents.json # RGBA + dark mode appearance
└── ... (2,700+ color definitions)Spacing and Typography
src/
├── TDSSpacing.swift # Spacing token definitions (CGFloat)
└── TDSTypography.swift # Typography token definitionsUsage
In Your Xcode Project
- Copy the generated files to your iOS project:
cp -r node_modules/@times-design-system/theme-ios/src/* YourProject/DesignTokens/Add to Xcode by dragging the folders into your project navigator
Use in Swift code:
import UIKit
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Use color tokens
view.backgroundColor = UIColor(named: "SurfaceCanvas")
// Use brand colors
button.backgroundColor = UIColor(named: "BrandHome500")
// Use spacing
label.text = "Hello"
label.font = UIFont.systemFont(ofSize: CGFloat.TdsSpacing100)
}
}Swift Color Definitions
Each color file contains semantic and brand color definitions:
class DarkCoreColors: TDSColors {
override val surfaceCanvas = UIColor(hex: 0xFF000000)
override val surfaceLevel1 = UIColor(hex: 0xFF0D0D0D)
override val textPrimary = UIColor(hex: 0xFFFFFFFF)
override val textSecondary = UIColor(hex: 0xFFD9D9D9)
// ... 200+ color properties
}Using with SwiftUI
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Heading")
.font(.system(size: 2.25 * 16)) // Use TdsTypography.swift values
.foregroundColor(Color(UIColor(named: "TextPrimary")!))
Text("Body text")
.font(.system(.body))
.padding(CGFloat.TdsSpacing100)
.background(Color(UIColor(named: "SurfaceCanvas")!))
}
}
}Token Categories
Colors (2,700+)
Semantic Colors
SurfaceCanvas, SurfaceLevel1-4, SurfaceInverse
TextPrimary, TextSecondary, TextTertiary
BorderPrimary, BorderSecondary
InteractivePrimary, InteractiveSecondaryBrand & Channel Colors
BrandHome500, BrandBusiness500, BrandSport500
BrandMoney500, BrandComment500, etc.
ChannelWorld500, ChannelUk500, etc.Feedback Colors
FeedbackError, FeedbackSuccess, FeedbackWarning, FeedbackInfo
InputBorder*, InputFill*, InputText*Spacing (20 values)
CGFloat.TdsSpacing025 // 0.25rem (4pt)
CGFloat.TdsSpacing050 // 0.5rem (8pt)
CGFloat.TdsSpacing100 // 1rem (16pt)
CGFloat.TdsSpacing200 // 1.5rem (24pt)
// ... up to TdsSpacing400Typography
// Font sizes
TdsTypography.fontSize025 // 0.75rem
TdsTypography.fontSize100 // 2.25rem
// Line heights
TdsTypography.lineHeightTight
TdsTypography.lineHeightNormal
// Font families
TdsTypography.fontFamilySans
TdsTypography.fontFamilySerifDark Mode Support
All colors are automatically configured with dynamic appearance support:
// Automatically switches between light and dark
let color = UIColor(named: "TextPrimary")
// In SwiftUI
Color(UIColor(named: "SurfaceCanvas")!)The colors use Xcode's dynamic appearance feature to switch based on:
- System appearance settings
- Trait collection (light/dark)
File Structure
dist/
├── TDSCoreColors.swift # Core color definitions
├── TDSSpacing.swift # Spacing tokens
├── TDSTypography.swift # Typography tokens
└── TDS[Theme]/Colors/ # Xcode asset catalogs
├── TDSBrandColors.colorset/
├── TDSSemanticColors.colorset/
└── ... (2,700+ color sets)Compatibility
- iOS: 12.0+
- Swift: 5.0+
- Xcode: 12.0+
- macOS: 10.15+
- tvOS: 12.0+
- watchOS: 5.0+
Building
To rebuild after token changes:
npm run buildThis generates:
- Swift color class definitions
- Xcode asset catalog with Contents.json files
- Dynamic appearance setup for dark mode
License
ISC
Palette Tokens (Pre-resolved Colors)
tokens.brand.primary; // Color ramp with 19 steps (100-1000)
tokens.channels.comment; // Channel-specific colors
tokens.dataVisualisation.data01; // Data visualization colorsSemantic Tokens
tokens.semanticColor.surface.default; // "rgba(255, 255, 255, 1.00)"
tokens.semanticColor.text.primary; // "rgba(26, 26, 26, 1.00)"
tokens.semanticColor.interactive.primary; // Brand color for interactive elementsBrowser Support
All CSS custom properties (--tds-*) are supported in modern browsers (Chrome, Firefox, Safari, Edge).
For older browsers, use the JavaScript tokens with fallback values:
const fontSize = tokens.Foundation.fontSize100 || '2.25rem';Building
To rebuild the package after modifying tokens:
npm run buildThis will:
- Clean the
dist/directory - Build ESM and CJS JavaScript modules
- Copy CSS variables to dist/
Publishing
npm publishThe package is configured with public access and will publish to the public npm registry.
License
ISC
