@schalkneethling/calavera-skill-css-tokens 0.2.0-next.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Schalk Neethling
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://calavera.schalkneethling.com/schemas/calavera-artifact.schema.json",
3
+ "schemaVersion": 1,
4
+ "id": "skill-css-tokens",
5
+ "type": "skill",
6
+ "displayName": "CSS tokens",
7
+ "payload": "payload/css-tokens",
8
+ "compatibility": {
9
+ "calavera": ">=2.2.0 <3"
10
+ }
11
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@schalkneethling/calavera-skill-css-tokens",
3
+ "version": "0.2.0-next.2",
4
+ "description": "CSS tokens artifact for Calavera.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+ssh://git@github.com/schalkneethling/create-project-calavera.git",
9
+ "directory": "packages/artifacts/skill-css-tokens"
10
+ },
11
+ "files": [
12
+ "calavera-artifact.json",
13
+ "payload"
14
+ ],
15
+ "type": "module",
16
+ "exports": {
17
+ ".": "./calavera-artifact.json",
18
+ "./package.json": "./package.json"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "provenance": true
23
+ }
24
+ }
@@ -0,0 +1,152 @@
1
+ # CSS Design Tokens
2
+
3
+ ## Quick Start
4
+
5
+ 1. Install the skill in your project (see [main repo README](https://github.com/schalkneethling/create-project-calavera#readme))
6
+ 2. Import `tokens.css` in your main stylesheet or HTML
7
+ 3. Start using tokens: `var(--color-primary)`, `var(--size-16)`, etc.
8
+
9
+ For the philosophy and detailed usage, read on below.
10
+
11
+ ## Philosophy
12
+
13
+ This token system embodies several key principles:
14
+
15
+ ### 1. Perceptual Uniformity
16
+
17
+ Colors use the `oklch()` color space rather than `hsl()` or `rgb()`. This ensures:
18
+
19
+ - Consistent perceived brightness across hues
20
+ - More predictable color manipulation
21
+ - Better accessibility through perceptual lightness control
22
+
23
+ ### 2. Semantic Naming
24
+
25
+ Tokens are named by their purpose or scale value, not their appearance:
26
+
27
+ - `--color-primary` not `--color-teal`
28
+ - `--size-16` (16px value) not `--spacing-small`
29
+ - `--text-xl` (size indicator) not `--heading-size`
30
+
31
+ ### 3. System Thinking
32
+
33
+ The design system is interconnected:
34
+
35
+ - Border radius values reference the spacing scale
36
+ - Typography sizes follow a modular scale
37
+ - Z-index uses named layers, not arbitrary numbers
38
+
39
+ ### 4. Dark Mode First-Class
40
+
41
+ Dark mode isn't an afterthought:
42
+
43
+ - Colors are redefined in `prefers-color-scheme: dark`
44
+ - Values are adjusted for optimal contrast in both modes
45
+ - The system maintains visual hierarchy in light and dark
46
+
47
+ ### 5. Scale Consistency
48
+
49
+ Both spacing and typography use consistent scales:
50
+
51
+ - Spacing: 4px base unit (0.25rem)
52
+ - Typography: Modular scale with clear relationships
53
+
54
+ ## Token Categories
55
+
56
+ ### Typography
57
+
58
+ - **Font Families**: System fonts with web-safe fallbacks
59
+ - **Weights**: Named weights from regular to bold
60
+ - **Sizes**: Modular scale from xs (12px) to 4xl (36px)
61
+
62
+ ### Spacing
63
+
64
+ - **Size Scale**: 4px increments from 4px to 96px
65
+ - Named by pixel value for clarity (`--size-16` = 1rem = 16px)
66
+
67
+ ### Colors
68
+
69
+ - **Surfaces**: Background colors for different elevation levels
70
+ - **Text**: Primary, muted, and inverted text colors
71
+ - **Brand**: Logo-specific colors
72
+ - **Interactive**: Primary and accent colors with hover states
73
+ - **Semantic**: Success, error, warning, info states
74
+ - **Borders**: Subtle and strong border options
75
+
76
+ ### Layout
77
+
78
+ - **Border Radius**: Five levels from small to full circle
79
+ - **Z-index**: Named layers for predictable stacking
80
+ - **Transitions**: Three timing options (fast, base, slow)
81
+
82
+ ## Usage Examples
83
+
84
+ ```css
85
+ /* Typography */
86
+ .heading {
87
+ font-family: var(--font-family-base);
88
+ font-size: var(--text-2xl);
89
+ font-weight: var(--font-weight-bold);
90
+ }
91
+
92
+ /* Spacing */
93
+ .card {
94
+ padding: var(--size-24);
95
+ margin-block-end: var(--size-32);
96
+ }
97
+
98
+ /* Colors */
99
+ .button {
100
+ background-color: var(--color-primary);
101
+ color: var(--color-text-inverted);
102
+ }
103
+
104
+ .button:hover {
105
+ background-color: var(--color-primary-hover);
106
+ }
107
+
108
+ /* Layout */
109
+ .modal {
110
+ border-radius: var(--radius-lg);
111
+ z-index: var(--layer-modal);
112
+ }
113
+ ```
114
+
115
+ ## Customization Guide
116
+
117
+ ### When to Keep as-is
118
+
119
+ - Working on a prototype or MVP
120
+ - Building internal tools where brand consistency isn't critical
121
+ - Learning design systems
122
+ - Quick experiments or proof-of-concepts
123
+
124
+ ### When to Customize
125
+
126
+ - Matching specific brand guidelines
127
+ - Projects with unique visual requirements
128
+ - Integrating with existing design systems
129
+ - Production applications with defined visual identity
130
+
131
+ **Remember**: The token _structure_ (semantic naming, scale consistency, system thinking) is more valuable than the specific values. Customize the values to fit your needs, but maintain the systematic approach.
132
+
133
+ ## Extending the System
134
+
135
+ These tokens provide a foundation. Projects can:
136
+
137
+ - Add component-specific tokens that reference these base tokens
138
+ - Create semantic aliases (e.g., `--button-bg: var(--color-primary)`)
139
+ - Extend the color palette while maintaining the `oklch()` approach
140
+ - Add new token categories (shadows, animations, grid systems, etc.)
141
+
142
+ The key is maintaining the system's consistency and semantic approach.
143
+
144
+ ## Browser Support
145
+
146
+ The `oklch()` color space is supported in:
147
+
148
+ - Chrome/Edge 111+
149
+ - Safari 15.4+
150
+ - Firefox 113+
151
+
152
+ For older browsers, consider using a PostCSS plugin to generate fallback colors, or use this as a progressive enhancement where supported browsers get optimal color fidelity.
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: css-tokens
3
+ description: Provides foundational CSS design tokens (custom properties) for typography, spacing, colors, borders, z-index, and transitions. Use when setting up a base token system for a web project.
4
+ ---
5
+
6
+ # CSS Design Tokens Skill
7
+
8
+ ## Purpose
9
+
10
+ This skill provides a comprehensive set of CSS design tokens (custom properties) to establish a consistent design foundation for web projects. Use this skill when the user requests a base token system or design tokens for their CSS.
11
+
12
+ ## When to Use This Skill
13
+
14
+ Use this skill when the user asks for:
15
+
16
+ - "Add design tokens to my project"
17
+ - "Set up CSS tokens"
18
+ - "Create a tokens file"
19
+ - "Add base CSS variables"
20
+ - Similar requests for foundational CSS custom properties
21
+
22
+ ## When NOT to Use This Skill
23
+
24
+ - User already has an existing design token system (suggest modifications instead)
25
+ - User specifically requests a framework-specific token system (e.g., Tailwind config, CSS-in-JS tokens)
26
+ - User only needs a subset of tokens (offer to extract specific categories)
27
+
28
+ ## What This Skill Provides
29
+
30
+ A complete `tokens.css` file with a comprehensive design token system:
31
+
32
+ - **Typography**: Font families, weights, and a modular size scale (xs to 4xl)
33
+ - **Spacing**: Consistent size scale from 4px to 96px, named by pixel value
34
+ - **Colors**: Using `oklch()` color space for perceptually uniform colors with light/dark mode variants for surfaces, text, brand, interactive elements, and semantic states
35
+ - **Borders**: Radius values derived from the size scale (sm to full)
36
+ - **Z-index**: Named layers for stacking context (dropdown, modal, toast, etc.)
37
+ - **Transitions**: Standard timing values (fast, base, slow)
38
+
39
+ Users can reference individual tokens using CSS custom property syntax: `var(--token-name)`
40
+
41
+ ## Token Content
42
+
43
+ The complete token definitions are located in `references/tokens.css` within this skill directory. This file contains all the CSS custom property declarations organized by category.
44
+
45
+ ## How to Use This Skill
46
+
47
+ ### 1. Detect CSS Directory
48
+
49
+ Search the project for common CSS directory names:
50
+
51
+ - `css/`
52
+ - `styles/`
53
+ - `assets/css/`
54
+ - `stylesheets/`
55
+ - `src/css/`
56
+ - `src/styles/`
57
+
58
+ Check directories at multiple levels (root, `src/`, `public/`, `assets/`).
59
+
60
+ ### 2. Confirm Location with User
61
+
62
+ **If a CSS directory is found:**
63
+
64
+ Present the discovered location and ask for confirmation:
65
+
66
+ ```text
67
+ I found a CSS directory at [path]. Should I add the design tokens to this directory in a file named `tokens.css`?
68
+
69
+ If you'd like a different location or filename, please specify both.
70
+ ```
71
+
72
+ **If no CSS directory is found:**
73
+
74
+ Ask the user directly:
75
+
76
+ ```text
77
+ I couldn't find an existing CSS directory in your project. Please specify:
78
+ 1. The directory path where you'd like the tokens file (I can create it if needed)
79
+ 2. The filename (e.g., `tokens.css`, `design-tokens.css`)
80
+ ```
81
+
82
+ ### 3. Write the Tokens File
83
+
84
+ Before writing, check whether the target file exists. If it does, show its current content or a diff and require an explicit decision to overwrite it or choose a new file. Once that decision is confirmed, write the complete tokens file using the exact content from `references/tokens.css` in this skill directory.
85
+
86
+ ### 4. Inform User About Import
87
+
88
+ After successfully writing the file, inform the user:
89
+
90
+ ✓ Design tokens written to [full-path]
91
+
92
+ To use these tokens in your project, import this file in your main CSS file or HTML:
93
+
94
+ **In CSS:**
95
+
96
+ ```css
97
+ @import url("path/to/tokens.css");
98
+ ```
99
+
100
+ **In HTML:**
101
+
102
+ ```html
103
+ <link rel="stylesheet" href="path/to/tokens.css" />
104
+ ```
105
+
106
+ The tokens are now available as CSS custom properties throughout your project (e.g., `var(--color-primary)`, `var(--size-16)`).
107
+
108
+ ## Customization
109
+
110
+ These tokens provide a solid foundation but are meant to be customized for your project:
111
+
112
+ - Adjust color values to match your brand
113
+ - Modify the spacing scale to fit your design system
114
+ - Add project-specific tokens as needed
115
+ - Extend categories with additional tokens (animations, shadows, etc.)
116
+
117
+ This is a **scaffolding skill** - it sets up the initial structure but doesn't handle ongoing modifications.
118
+
119
+ ## Important Notes
120
+
121
+ - **Do NOT make assumptions** about directory structure or filename if the user hasn't specified
122
+ - **Always confirm** the location before writing
123
+ - **Create directories** if needed and confirmed by user
124
+ - The tokens file includes both light and dark mode color schemes using `prefers-color-scheme`
125
+ - The `oklch()` color space provides perceptually uniform colors for better accessibility and consistency
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "CSS Tokens"
3
+ short_description: "Create a foundational CSS token system."
4
+ default_prompt: "Use $css-tokens to add a CSS token foundation to this project."
@@ -0,0 +1,158 @@
1
+ :root {
2
+ /* ========================================
3
+ * Typography - Font Families
4
+ * ======================================== */
5
+ --font-family-base:
6
+ inter, "Source Sans 3", "IBM Plex Sans", -apple-system, blinkmacsystemfont, "Segoe UI", roboto,
7
+ helvetica, arial, sans-serif;
8
+ --font-family-mono:
9
+ ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", "Liberation Mono", menlo, monaco,
10
+ consolas, monospace;
11
+
12
+ /* ========================================
13
+ * Typography - Font Weights
14
+ * ======================================== */
15
+ --font-weight-regular: 400;
16
+ --font-weight-medium: 500;
17
+ --font-weight-semibold: 600;
18
+ --font-weight-bold: 700;
19
+
20
+ /* ========================================
21
+ * Typography - Font Sizes
22
+ * Token name = approximate pixel value
23
+ * ======================================== */
24
+ --text-xs: 0.75rem; /* 12px */
25
+ --text-sm: 0.875rem; /* 14px */
26
+ --text-base: 1rem; /* 16px */
27
+ --text-lg: 1.125rem; /* 18px */
28
+ --text-xl: 1.25rem; /* 20px */
29
+ --text-2xl: 1.5rem; /* 24px */
30
+ --text-3xl: 1.875rem; /* 30px */
31
+ --text-4xl: 2.25rem; /* 36px */
32
+
33
+ /* ========================================
34
+ * Spacing / Size Scale
35
+ * Token name = pixel value (--size-16 = 16px = 1rem)
36
+ * ======================================== */
37
+ --size-4: 0.25rem; /* 4px */
38
+ --size-8: 0.5rem; /* 8px */
39
+ --size-12: 0.75rem; /* 12px */
40
+ --size-16: 1rem; /* 16px */
41
+ --size-20: 1.25rem; /* 20px */
42
+ --size-24: 1.5rem; /* 24px */
43
+ --size-32: 2rem; /* 32px */
44
+ --size-40: 2.5rem; /* 40px */
45
+ --size-48: 3rem; /* 48px */
46
+ --size-64: 4rem; /* 64px */
47
+ --size-80: 5rem; /* 80px */
48
+ --size-96: 6rem; /* 96px */
49
+
50
+ /* ========================================
51
+ * Border Radius (uses size tokens)
52
+ * ======================================== */
53
+ --radius-sm: var(--size-4);
54
+ --radius-md: var(--size-8);
55
+ --radius-lg: var(--size-12);
56
+ --radius-xl: var(--size-16);
57
+ --radius-full: 9999px;
58
+
59
+ /* ========================================
60
+ * Z-Index Layers
61
+ * ======================================== */
62
+ --layer-send-to-back: -1;
63
+ --layer-dropdown: 100;
64
+ --layer-modal: 300;
65
+ --layer-toast: 400;
66
+ --layer-bring-to-front: 9999;
67
+
68
+ /* ========================================
69
+ * Transitions
70
+ * ======================================== */
71
+ --transition-fast: 150ms ease;
72
+ --transition-base: 250ms ease;
73
+ --transition-slow: 400ms ease;
74
+
75
+ /* ========================================
76
+ * Colors - Light Mode (Default)
77
+ * Using oklch() for perceptual uniformity
78
+ * ======================================== */
79
+
80
+ /* Surfaces */
81
+ --color-surface: oklch(98% 0.005 250deg); /* Near white */
82
+ --color-surface-raised: oklch(100% 0 0deg); /* Pure white */
83
+ --color-surface-sunken: oklch(95% 0.01 250deg); /* Slightly darker */
84
+
85
+ /* Text */
86
+ --color-text: oklch(25% 0.02 250deg); /* Dark slate */
87
+ --color-text-muted: oklch(50% 0.015 250deg); /* Medium gray */
88
+ --color-text-inverted: oklch(98% 0.005 250deg); /* Light for dark backgrounds */
89
+
90
+ /* Logo Colors - derived from brand */
91
+ --color-logo-maker: oklch(40% 0.025 220deg); /* Dark slate-blue */
92
+ --color-logo-bench: oklch(55% 0.15 185deg); /* Teal */
93
+
94
+ /* Primary - Teal (matches logo "Bench") */
95
+ --color-primary: oklch(50% 0.14 185deg);
96
+ --color-primary-hover: oklch(45% 0.14 185deg);
97
+ --color-primary-active: oklch(40% 0.14 185deg);
98
+
99
+ /* Accent - Coral/Orange for CTAs */
100
+ --color-accent: oklch(65% 0.18 35deg);
101
+ --color-accent-hover: oklch(60% 0.18 35deg);
102
+
103
+ /* Borders */
104
+ --color-border: oklch(88% 0.01 250deg);
105
+ --color-border-strong: oklch(75% 0.015 250deg);
106
+
107
+ /* States */
108
+ --color-success: oklch(55% 0.15 145deg);
109
+ --color-error: oklch(55% 0.2 25deg);
110
+ --color-warning: oklch(70% 0.15 80deg);
111
+ --color-info: oklch(55% 0.12 240deg);
112
+
113
+ /* Focus ring */
114
+ --color-focus-ring: oklch(55% 0.15 185deg / 50%);
115
+ }
116
+
117
+ /* ========================================
118
+ * Colors - Dark Mode
119
+ * ======================================== */
120
+ @media (prefers-color-scheme: dark) {
121
+ :root {
122
+ /* Surfaces */
123
+ --color-surface: oklch(18% 0.015 250deg); /* Deep charcoal */
124
+ --color-surface-raised: oklch(22% 0.015 250deg); /* Elevated dark */
125
+ --color-surface-sunken: oklch(14% 0.015 250deg); /* Deeper */
126
+
127
+ /* Text */
128
+ --color-text: oklch(92% 0.01 250deg); /* Light gray */
129
+ --color-text-muted: oklch(65% 0.01 250deg); /* Muted gray */
130
+ --color-text-inverted: oklch(18% 0.015 250deg); /* Dark for light backgrounds */
131
+
132
+ /* Logo Colors - brighter for dark mode */
133
+ --color-logo-maker: oklch(75% 0.02 220deg); /* Lighter slate */
134
+ --color-logo-bench: oklch(65% 0.15 185deg); /* Brighter teal */
135
+
136
+ /* Primary - Brighter teal for dark mode */
137
+ --color-primary: oklch(60% 0.14 185deg);
138
+ --color-primary-hover: oklch(65% 0.14 185deg);
139
+ --color-primary-active: oklch(55% 0.14 185deg);
140
+
141
+ /* Accent */
142
+ --color-accent: oklch(70% 0.16 35deg);
143
+ --color-accent-hover: oklch(75% 0.16 35deg);
144
+
145
+ /* Borders */
146
+ --color-border: oklch(30% 0.015 250deg);
147
+ --color-border-strong: oklch(40% 0.015 250deg);
148
+
149
+ /* States */
150
+ --color-success: oklch(60% 0.15 145deg);
151
+ --color-error: oklch(60% 0.18 25deg);
152
+ --color-warning: oklch(75% 0.15 80deg);
153
+ --color-info: oklch(60% 0.12 240deg);
154
+
155
+ /* Focus ring */
156
+ --color-focus-ring: oklch(60% 0.15 185deg / 50%);
157
+ }
158
+ }