@cordagehq/ui-design-system 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # UI Design System — Components
2
+
3
+ A comprehensive design system built with React, Stitches CSS-in-JS, and Figma tokens.
4
+
5
+ ## Quick Start
6
+
7
+ ### Start Storybook
8
+ ```bash
9
+ npm run storybook
10
+ ```
11
+ Storybook will open at `http://localhost:6006`
12
+
13
+ ### Build Design System
14
+ ```bash
15
+ npm run build
16
+ ```
17
+
18
+ ### Run Tests
19
+ ```bash
20
+ npm run test
21
+ ```
22
+
23
+ ## Documentation
24
+
25
+ ### Getting Started
26
+ - **[Storybook Quick Start](./docs/getting-started/storybook-quickstart.md)** - Get started with Storybook
27
+ - **[Storybook Integration Guide](./docs/getting-started/storybook.md)** - Complete Storybook + Stitches setup
28
+ - **[Dark Theme Configuration](./docs/getting-started/dark-theme.md)** - Dark theme setup and usage
29
+
30
+ ### Font Awesome Pro Icons
31
+ - **[Font Awesome Pro README](./FONTAWESOME_README.md)** ⭐ **START HERE** - Overview and next steps
32
+ - **[Quick Reference](./FONTAWESOME_QUICK_REFERENCE.md)** - 30-second setup and API
33
+ - **[Complete Setup Guide](./FONTAWESOME_SETUP.md)** - Detailed configuration guide
34
+ - **[Token Configuration](./TOKEN_SETUP.md)** - How to configure FA_TOKEN (IMPORTANT!)
35
+ - **[Solution to Common Error](./SOLUTION_ERROR.md)** - If you get "Failed to replace env in config" error
36
+ - **[Troubleshooting](./TROUBLESHOOTING.md)** - Common problems and solutions
37
+ - **[Verification Checklist](./FONTAWESOME_VERIFICATION.md)** - Verify everything works
38
+ - **[Implementation Details](./FONTAWESOME_IMPLEMENTATION.md)** - Technical details
39
+
40
+ ### Theme & Configuration
41
+ - **[Dark Theme Setup Summary](./DARK_THEME_SETUP.md)** - Complete setup overview
42
+ - **[Storybook Configuration](./.storybook/README.md)** - Configuration details
43
+ - **[UI Contract](./contracts/ui-contract.md)** - Technical contract
44
+ - **[Component Guidelines](./docs/contributing/component-guidelines.md)** - How to create components
45
+
46
+ ## Tech Stack
47
+
48
+ - **React 18** - UI library
49
+ - **Stitches** - CSS-in-JS for React
50
+ - **Figma Tokens** - Design tokens automation
51
+ - **Font Awesome Pro** - Icon library (9400+ icons in 5 styles)
52
+ - **Storybook 8** - Component documentation
53
+ - **Vite** - Build tool
54
+ - **TypeScript** - Type safety
55
+ - **Vitest** - Testing framework
56
+
57
+ ## Scripts
58
+
59
+ ```bash
60
+ # Development
61
+ npm run dev # Start development server
62
+ npm run storybook # Start Storybook documentation
63
+ npm run build-storybook # Build static Storybook
64
+
65
+ # Quality
66
+ npm run typecheck # Type check with TypeScript
67
+ npm run lint # Lint code with ESLint
68
+ npm run format # Format code with Prettier
69
+
70
+ # Testing
71
+ npm run test # Run tests with Vitest
72
+ npm run test:ui # Run tests with UI
73
+ npm run test:coverage # Generate coverage report
74
+
75
+ # Build
76
+ npm run build # Build the package
77
+ npm run preview # Preview the built package
78
+
79
+ # Tokens
80
+ npm run tokens:transform # Transform Figma tokens to stitches config
81
+
82
+ # Components
83
+ npm run generate:component # Generate new component scaffold
84
+ ```
85
+
86
+ ## Project Structure
87
+
88
+ ```
89
+ packages/ui-design-system/
90
+ ├── .storybook/ # Storybook configuration
91
+ ├── src/
92
+ │ ├── atoms/ # Basic UI elements
93
+ │ ├── molecules/ # Composed components
94
+ │ ├── organisms/ # Complex components
95
+ │ ├── templates/ # Page templates
96
+ │ ├── stories/ # Storybook documentation
97
+ │ ├── stitches.config.ts # Stitches theme configuration
98
+ │ └── index.ts # Main entry point
99
+ ├── tokens/ # Design tokens (Figma)
100
+ ├── docs/ # Documentation
101
+ ├── contracts/ # Technical contracts
102
+ ├── scripts/ # Build and utility scripts
103
+ └── package.json
104
+ ```
105
+
106
+ ## Design Tokens
107
+
108
+ All design tokens are automatically generated from the `tokens/` directory:
109
+
110
+ ```bash
111
+ npm run tokens:transform
112
+ ```
113
+
114
+ Tokens include:
115
+ - **Colors** - Brand and semantic colors
116
+ - **Typography** - Font sizes, weights, line heights
117
+ - **Spacing** - Padding, margins, gaps
118
+ - **Border Radius** - Rounded corner sizes
119
+ - **Shadows** - Box shadows
120
+ - **Transitions** - Animation durations and timing functions
121
+
122
+ ## Consuming this Package
123
+
124
+ ### Installation
125
+
126
+ ```bash
127
+ npm install @cordage/ui-design-system
128
+ ```
129
+
130
+ ### Using Components
131
+
132
+ ```typescript
133
+ import { styled } from '@cordage/ui-design-system/stitches.config';
134
+
135
+ const Button = styled('button', {
136
+ padding: '$spacing-12 $spacing-16',
137
+ backgroundColor: '$color-primary',
138
+ borderRadius: '$borderRadius-md',
139
+ // ... more styles
140
+ });
141
+ ```
142
+
143
+ ### Using Tokens
144
+
145
+ ```typescript
146
+ import { getCssText, theme } from '@cordage/ui-design-system/stitches.config';
147
+
148
+ // Get CSS text for SSR
149
+ const styles = getCssText();
150
+
151
+ // Access theme tokens
152
+ const color = theme.colors['color-primary'];
153
+ ```
154
+
155
+ ## Dark Theme
156
+
157
+ The design system supports a comprehensive dark theme with 260+ tokens automatically generated from semantic token definitions.
158
+
159
+ ### Generate Dark Theme
160
+
161
+ To regenerate the dark theme configuration from tokens:
162
+
163
+ ```bash
164
+ node scripts/generate-dark-theme.js
165
+ ```
166
+
167
+ This generates `src/theme-dark.ts` with all dark theme colors resolved from Figma tokens.
168
+
169
+ ### Using Dark Theme
170
+
171
+ In your application:
172
+
173
+ ```typescript
174
+ import { darkTheme } from './theme-dark';
175
+
176
+ // Apply to root element
177
+ document.documentElement.classList.add(darkTheme);
178
+ ```
179
+
180
+ Or conditionally based on user preference:
181
+
182
+ ```typescript
183
+ import { darkTheme } from './theme-dark';
184
+
185
+ // Check system preference
186
+ const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
187
+ if (isDark) {
188
+ document.documentElement.classList.add(darkTheme);
189
+ }
190
+
191
+ // Listen for changes
192
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
193
+ if (e.matches) {
194
+ document.documentElement.classList.add(darkTheme);
195
+ } else {
196
+ document.documentElement.classList.remove(darkTheme);
197
+ }
198
+ });
199
+ ```
200
+
201
+ **[Full Dark Theme Documentation](./docs/getting-started/dark-theme.md)**
202
+
203
+ ## Contributing
204
+
205
+ See [Component Guidelines](./docs/contributing/component-guidelines.md) for guidelines on creating new components.
206
+
207
+ ## Consumed by
208
+
209
+ - `apps/frontend-app/`
210
+ - `apps/frontend-lovable/`
211
+
212
+ ## License
213
+
214
+ MIT
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ export type AvatarSize = '2xs' | 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
3
+ export interface AvatarProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ size?: AvatarSize;
5
+ src?: string;
6
+ alt?: string;
7
+ name?: string;
8
+ showBorder?: boolean;
9
+ showNotification?: boolean;
10
+ badgeIcon?: React.ReactNode;
11
+ onClick?: () => void;
12
+ }
13
+ export declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,15 @@
1
+ import { default as React } from 'react';
2
+ export type BadgeVariant = 'primary' | 'secondary' | 'tertiary' | 'teal' | 'slate' | 'sunset' | 'success' | 'warning' | 'danger' | 'info' | 'white' | 'pink' | 'fuchsia' | 'violet' | 'indigo' | 'cyan' | 'gray' | 'dark' | 'black' | 'skeleton' | 'default' | 'error';
3
+ export type BadgeSize = 'sm' | 'md' | 'lg';
4
+ export type BadgeStyleType = 'solid' | 'outline' | 'dot';
5
+ export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
6
+ variant?: BadgeVariant;
7
+ size?: BadgeSize;
8
+ styleType?: BadgeStyleType;
9
+ children?: React.ReactNode;
10
+ /** Icon rendered before the text. Accepts a ReactNode (e.g. FontAwesomeIcon or <i> element). */
11
+ iconLeft?: React.ReactNode;
12
+ /** Icon rendered after the text. Accepts a ReactNode (e.g. FontAwesomeIcon or <i> element). */
13
+ iconRight?: React.ReactNode;
14
+ }
15
+ export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,39 @@
1
+ import { default as React } from 'react';
2
+ export type FlagSize = 'sm' | 'md' | 'lg';
3
+ export interface FlagProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ /**
5
+ * ISO 3166-1 alpha-2 country code (e.g., 'US', 'MX', 'ES')
6
+ */
7
+ countryCode: string;
8
+ /**
9
+ * Size of the flag
10
+ * @default 'md'
11
+ */
12
+ size?: FlagSize;
13
+ /**
14
+ * Whether to show a badge indicating this is the main language
15
+ * @default false
16
+ */
17
+ mainLanguage?: boolean;
18
+ /**
19
+ * Custom className for additional styling
20
+ */
21
+ className?: string;
22
+ /**
23
+ * Accessible label for the flag
24
+ */
25
+ 'aria-label'?: string;
26
+ }
27
+ /**
28
+ * Flag Component
29
+ *
30
+ * Displays a country flag based on ISO 3166-1 alpha-2 country code.
31
+ * Optionally shows a badge to indicate the main language.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * <Flag countryCode="US" size="md" />
36
+ * <Flag countryCode="MX" size="sm" mainLanguage />
37
+ * ```
38
+ */
39
+ export declare const Flag: React.ForwardRefExoticComponent<FlagProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,72 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Icon component using Font Awesome Pro via CDN Kit
4
+ *
5
+ * Uses <i> tag with Font Awesome classes
6
+ * Supports 5 pro styles:
7
+ * - fas (Solid)
8
+ * - far (Regular)
9
+ * - fal (Light)
10
+ * - fat (Thin)
11
+ * - fad (Duotone)
12
+ */
13
+ export interface IconProps {
14
+ /**
15
+ * Icon prefix: 'fas' | 'far' | 'fal' | 'fat' | 'fad' | 'fab'
16
+ */
17
+ prefix?: 'fas' | 'far' | 'fal' | 'fat' | 'fad' | 'fab';
18
+ /**
19
+ * Icon name (e.g., 'heart', 'star', 'user')
20
+ * See: https://fontawesome.com/icons
21
+ */
22
+ name: string;
23
+ /**
24
+ * Icon size: 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl'
25
+ * @default 'base'
26
+ */
27
+ size?: 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl';
28
+ /**
29
+ * Icon color - uses design tokens
30
+ * @default 'inherit'
31
+ */
32
+ color?: string;
33
+ /**
34
+ * Custom className for additional styling
35
+ */
36
+ className?: string;
37
+ /**
38
+ * Rotate the icon
39
+ */
40
+ rotation?: 90 | 180 | 270;
41
+ /**
42
+ * Flip the icon
43
+ */
44
+ flip?: 'horizontal' | 'vertical' | 'both';
45
+ /**
46
+ * Spin the icon
47
+ */
48
+ spin?: boolean;
49
+ /**
50
+ * Pulse the icon
51
+ */
52
+ pulse?: boolean;
53
+ /**
54
+ * Border around the icon
55
+ */
56
+ border?: boolean;
57
+ }
58
+ /**
59
+ * Icon Component
60
+ *
61
+ * Uses Font Awesome CDN Kit with <i> tags
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * <Icon prefix="fas" name="heart" size="lg" />
66
+ * <Icon prefix="far" name="star" color="primary" />
67
+ * <Icon prefix="fal" name="user" size="xl" />
68
+ * <Icon prefix="fat" name="bell" />
69
+ * <Icon prefix="fad" name="shield" size="2xl" color="success" />
70
+ * ```
71
+ */
72
+ export declare const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Font Awesome Pro Integration
3
+ *
4
+ * This file provides utilities to use Font Awesome Pro icons
5
+ * Install via npm using the Font Awesome registry or use via CDN Kit
6
+ *
7
+ * NPM Setup in .npmrc:
8
+ * @fortawesome:registry=https://npm.fontawesome.com/
9
+ * //npm.fontawesome.com/:_authToken=${FA_TOKEN}
10
+ *
11
+ * Then install:
12
+ * - @fortawesome/fontawesome-pro
13
+ * - @fortawesome/fontawesome-svg-core
14
+ * - @fortawesome/react-fontawesome
15
+ */
16
+ declare let FontAwesomeIcon: any;
17
+ /**
18
+ * Register Font Awesome Pro icons globally
19
+ * Call this once at app initialization
20
+ *
21
+ * Example:
22
+ * import { fas } from '@fortawesome/pro-solid-svg-icons';
23
+ * initFontAwesome([fas]);
24
+ */
25
+ export declare function initFontAwesome(iconLibraries?: any[]): void;
26
+ /**
27
+ * Helper to find and use an icon
28
+ * Example: getIcon('fas', 'heart') returns the heart icon
29
+ */
30
+ export declare function getIcon(prefix: 'fas' | 'far' | 'fal' | 'fat' | 'fad' | 'fab', iconName: string): any;
31
+ export { FontAwesomeIcon };
32
+ /**
33
+ * Usage in components:
34
+ *
35
+ * Method 1: NPM Packages (Recommended)
36
+ * ====================================
37
+ * import { FontAwesomeIcon, initFontAwesome } from '@cordage/ui-design-system';
38
+ * import { fas } from '@fortawesome/pro-solid-svg-icons';
39
+ *
40
+ * // Initialize once in your app
41
+ * initFontAwesome([fas]);
42
+ *
43
+ * // Use in components
44
+ * <FontAwesomeIcon icon={['fas', 'heart']} />
45
+ *
46
+ * Method 2: CDN Kit (Alternative)
47
+ * ===============================
48
+ * Set VITE_FONTAWESOME_KIT_ID in .env.local
49
+ * Then use HTML classes:
50
+ * <i className="fa-solid fa-heart"></i>
51
+ */
@@ -0,0 +1,22 @@
1
+ <!--
2
+ Cordage Design System - Font Loading
3
+
4
+ This file contains the font loading links for the design system.
5
+ Copy these lines into your HTML file or use them in your bundler.
6
+ -->
7
+
8
+ <!-- Google Fonts Preconnect -->
9
+ <link rel="preconnect" href="https://fonts.googleapis.com">
10
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11
+
12
+ <!-- Satoshi - Primary UI Font (from Fontshare) -->
13
+ <!-- Weights: 300, 400, 500, 600, 700 -->
14
+ <link rel="stylesheet" href="https://api.fontshare.com/css?f[]=satoshi@300,400,500,600,700&display=swap">
15
+
16
+ <!-- Lora - Secondary Serif Font (from Google Fonts) -->
17
+ <!-- Weights: 400, 500, 600, 700 -->
18
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lora:wght@400;500;600;700&display=swap">
19
+
20
+ <!-- Font Awesome Icons (Optional - from CDN) -->
21
+ <!-- If you want to use Font Awesome icons, uncomment this line: -->
22
+ <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.0/css/all.min.css"> -->
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Fonts Configuration
3
+ *
4
+ * This file configures the typography system for the Cordage Design System.
5
+ * It defines @font-face rules for all fonts used in the design system.
6
+ *
7
+ * Fonts:
8
+ * - Satoshi: Primary UI font (sans-serif)
9
+ * - Lora: Secondary serif font
10
+ * - Font Awesome Pro: Icon font (via CDN Kit)
11
+ *
12
+ * Font Awesome Pro Configuration:
13
+ * Set your Kit ID in the environment variable: VITE_FONTAWESOME_KIT_ID
14
+ * The Kit ID is available at: https://fontawesome.com/account/kits
15
+ */
16
+ /**
17
+ * Font Awesome Pro Configuration
18
+ * Get your Kit ID from: https://fontawesome.com/account/kits
19
+ */
20
+ export declare const FONTAWESOME_KIT_ID: string;
21
+ export declare const FONTAWESOME_KIT_URL: string;
22
+ /**
23
+ * Import fonts from Google Fonts API and Font Awesome Pro
24
+ * This can be loaded via CDN link in HTML or via @import in CSS
25
+ */
26
+ /**
27
+ * Register fonts by providing the `globalCss` function from the stitches
28
+ * instance. This avoids importing the stitches instance here and therefore
29
+ * prevents circular module initialization.
30
+ */
31
+ export declare const registerFonts: (globalCss: (styles: any) => any) => any;
32
+ /**
33
+ * Font stack definitions for use in components
34
+ */
35
+ export declare const FONT_STACKS: {
36
+ ui: string;
37
+ serif: string;
38
+ mono: string;
39
+ icons: string;
40
+ };
41
+ /**
42
+ * Font weight values from tokens
43
+ */
44
+ export declare const FONT_WEIGHTS: {
45
+ light: number;
46
+ regular: number;
47
+ medium: number;
48
+ semibold: number;
49
+ bold: number;
50
+ };
51
+ /**
52
+ * Font size values from tokens (in px)
53
+ */
54
+ export declare const FONT_SIZES: {
55
+ '2xs': string;
56
+ xs: string;
57
+ sm: string;
58
+ md: string;
59
+ lg: string;
60
+ xl: string;
61
+ '2xl': string;
62
+ '3xl': string;
63
+ '4xl': string;
64
+ '5xl': string;
65
+ '6xl': string;
66
+ };
67
+ /**
68
+ * Line height values from tokens
69
+ */
70
+ export declare const LINE_HEIGHTS: {
71
+ tight: string;
72
+ normal: string;
73
+ relaxed: string;
74
+ };
75
+ /**
76
+ * Typography presets combining font, size, and weight
77
+ * Use these for consistent typography across components
78
+ */
79
+ export declare const TYPOGRAPHY_PRESETS: {
80
+ h1: {
81
+ fontSize: string;
82
+ fontWeight: number;
83
+ lineHeight: string;
84
+ fontFamily: string;
85
+ };
86
+ h2: {
87
+ fontSize: string;
88
+ fontWeight: number;
89
+ lineHeight: string;
90
+ fontFamily: string;
91
+ };
92
+ h3: {
93
+ fontSize: string;
94
+ fontWeight: number;
95
+ lineHeight: string;
96
+ fontFamily: string;
97
+ };
98
+ h4: {
99
+ fontSize: string;
100
+ fontWeight: number;
101
+ lineHeight: string;
102
+ fontFamily: string;
103
+ };
104
+ h5: {
105
+ fontSize: string;
106
+ fontWeight: number;
107
+ lineHeight: string;
108
+ fontFamily: string;
109
+ };
110
+ h6: {
111
+ fontSize: string;
112
+ fontWeight: number;
113
+ lineHeight: string;
114
+ fontFamily: string;
115
+ };
116
+ body: {
117
+ fontSize: string;
118
+ fontWeight: number;
119
+ lineHeight: string;
120
+ fontFamily: string;
121
+ };
122
+ 'body-small': {
123
+ fontSize: string;
124
+ fontWeight: number;
125
+ lineHeight: string;
126
+ fontFamily: string;
127
+ };
128
+ 'body-large': {
129
+ fontSize: string;
130
+ fontWeight: number;
131
+ lineHeight: string;
132
+ fontFamily: string;
133
+ };
134
+ label: {
135
+ fontSize: string;
136
+ fontWeight: number;
137
+ lineHeight: string;
138
+ fontFamily: string;
139
+ };
140
+ caption: {
141
+ fontSize: string;
142
+ fontWeight: number;
143
+ lineHeight: string;
144
+ fontFamily: string;
145
+ };
146
+ code: {
147
+ fontSize: string;
148
+ fontWeight: number;
149
+ lineHeight: string;
150
+ fontFamily: string;
151
+ };
152
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Cordage Design System
3
+ *
4
+ * Main entry point for the design system.
5
+ * Exports Stitches utilities (styled, css, etc.) and themes.
6
+ */
7
+ export { styled, css, globalCss, keyframes, getCssText, theme, createTheme, config, type CSS, type VariantProps, } from './stitches.config';
8
+ export { FONT_STACKS, FONT_WEIGHTS, FONT_SIZES, LINE_HEIGHTS, TYPOGRAPHY_PRESETS, FONTAWESOME_KIT_ID, FONTAWESOME_KIT_URL, } from './fonts';
9
+ export { initFontAwesome, getIcon, FontAwesomeIcon } from './fontawesome';
10
+ export { Badge, type BadgeProps, type BadgeVariant, type BadgeSize, type BadgeStyleType, } from './atoms/Badge';
11
+ export { Icon, type IconProps } from './atoms/Icon';
12
+ export { Avatar, type AvatarProps, type AvatarSize } from './atoms/Avatar';
13
+ export { Flag, type FlagProps, type FlagSize } from './atoms/Flag';
14
+ export { Card, type CardProps, type CardDensity, type CardSurface, type CardStatus, type CardHeaderProps, type CardBodyProps, type CardFooterProps, } from './molecules/Card';