关于 design
design 是用于管理设计令牌和维护界面一致性的设计技能,面向设计师与开发者。它涵盖颜色、排版、间距和组件令牌,并提供审查与导出示例。
主要功能
- 01管理 CSS、JSON 和 Tailwind 设计令牌
- 02生成颜色、排版与间距尺度
- 03检查颜色对比度并转换格式
- 04审查颜色与排版系统
- 05导出 CSS、JavaScript 和 SCSS 令牌
适用场景
- 01为 SaaS 仪表板建立颜色调色板
- 02检查文本与背景的颜色对比度
- 03将令牌导出为项目所需格式
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ johnlindquist/ claude --skill design安装后在 Claude Code 中输入/design确认已加载。
详细介绍
设计系统管理器
管理设计令牌并保持设计一致性。
设计令牌格式
CSS 变量
:root {
/* Colors */
--color-primary: #3b82f6;
--color-primary-dark: #2563eb;
--color-secondary: #64748b;
--color-success: #22c55e;
--color-warning: #f59e0b;
--color-error: #ef4444;
/* Typography */
--font-sans: 'Inter', system-ui, sans-serif;
--font-mono: 'JetBrains Mono', monospace;
--text-xs: 0.75rem;
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.125rem;
--text-xl: 1.25rem;
--text-2xl: 1.5rem;
/* Spacing */
--space-1: 0.25rem;
--space-2: 0.5rem;
--space-3: 0.75rem;
--space-4: 1rem;
--space-6: 1.5rem;
--space-8: 2rem;
/* Border Radius */
--radius-sm: 0.25rem;
--radius-md: 0.375rem;
--radius-lg: 0.5rem;
--radius-full: 9999px;
/* Shadows */
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}
JSON 令牌
{
"color": {
"primary": { "value": "#3b82f6" },
"primary-dark": { "value": "#2563eb" },
"secondary": { "value": "#64748b" }
},
"font": {
"family": {
"sans": { "value": "'Inter', system-ui, sans-serif" },
"mono": { "value": "'JetBrains Mono', monospace" }
},
"size": {
"xs": { "value": "0.75rem" },
"sm": { "value": "0.875rem" },
"base": { "value": "1rem" },
"lg": { "value": "1.125rem" }
}
},
"spacing": {
"1": { "value": "0.25rem" },
"2": { "value": "0.5rem" },
"4": { "value": "1rem" }
}
}
Tailwind 配置
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#3b82f6',
dark: '#2563eb',
},
secondary: '#64748b',
},
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
},
},
};
颜色操作
生成调色板
gemini -m pro -o text -e "" "Generate a color palette for:
Base color: #3b82f6 (blue)
Purpose: SaaS dashboard
Provide:
1. 10-step shade scale (50-900)
2. Semantic colors (success, warning, error)
3. Neutral grays
4. CSS custom properties format
5. Ensure WCAG AA contrast ratios"
检查颜色对比度
gemini -m pro -o text -e "" "Check contrast ratios:
Foreground: #ffffff
Backgrounds:
- #3b82f6
- #2563eb
- #1d4ed8
For each:
1. Calculate contrast ratio
2. WCAG AA compliance (4.5:1 normal, 3:1 large)
3. WCAG AAA compliance (7:1 normal, 4.5:1 large)
4. Suggest adjustments if needed"
转换颜色格式
gemini -m pro -o text -e "" "Convert this color to all formats:
Input: #3b82f6
Output:
- HEX
- RGB
- RGBA
- HSL
- HSLA
- CSS custom property"
字体排印
字体比例
gemini -m pro -o text -e "" "Generate a type scale:
Base: 16px
Ratio: 1.25 (major third)
Steps: 8 (xs to 4xl)
Provide:
1. Sizes in rem
2. Corresponding line-heights
3. Letter-spacing recommendations
4. CSS custom properties"
字体搭配
gemini -m pro -o text -e "" "Suggest font pairings for:
Style: Modern, professional SaaS
Needs: Headings, body text, code
For each pairing:
1. Heading font
2. Body font
3. Code font
4. Google Fonts links
5. Fallback stack"
间距系统
生成比例
gemini -m pro -o text -e "" "Generate a spacing scale:
Base: 4px
Approach: 4-point grid
Provide:
1. Scale from 0 to 96
2. Named tokens (xs, sm, md, lg, etc.)
3. Use cases for each size
4. CSS custom properties"
组件令牌
按钮令牌
:root {
/* Button Base */
--btn-padding-x: var(--space-4);
--btn-padding-y: var(--space-2);
--btn-font-size: var(--text-sm);
--btn-font-weight: 500;
--btn-border-radius: var(--radius-md);
/* Button Primary */
--btn-primary-bg: var(--color-primary);
--btn-primary-text: white;
--btn-primary-hover-bg: var(--color-primary-dark);
/* Button Secondary */
--btn-secondary-bg: transparent;
--btn-secondary-text: var(--color-primary);
--btn-secondary-border: var(--color-primary);
}
输入框令牌
:root {
--input-padding-x: var(--space-3);
--input-padding-y: var(--space-2);
--input-font-size: var(--text-base);
--input-border-width: 1px;
--input-border-color: var(--color-gray-300);
--input-border-radius: var(--radius-md);
--input-focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.3);
}
导出令牌
导出为 CSS
cat tokens.json | jq -r '
to_entries | .[] |
"--\(.key): \(.value.value);"
' > tokens.css
导出为 JavaScript
cat tokens.json | jq '
to_entries | map({(.key): .value.value}) | add
' > tokens.js
导出为 SCSS 变量
cat tokens.json | jq -r '
to_entries | .[] |
"$\(.key): \(.value.value);"
' > _tokens.scss
设计审查
审查颜色
gemini -m pro -o text -e "" "Audit this color system:
$(cat src/styles/tokens.css)
Check:
1. Sufficient contrast ratios
2. Consistent naming
3. Complete semantic colors
4. Dark mode compatibility
5. Accessibility issues"
审查字体排印
gemini -m pro -o text -e "" "Audit this typography system:
$(cat src/styles/typography.css)
Check:
1. Readable line heights
2. Appropriate scale ratio
3. Responsive considerations
4. Font loading strategy
5. Accessibility"
最佳实践
- 使用语义化名称 - 用
--color-error而非--color-red - 为令牌编写文档 - 说明每个令牌的使用场景
- 保持一致性 - 不要创建一次性令牌
- 测试无障碍性 - 检查所有对比度
- 对令牌进行版本管理 - 跟踪变更
- 单一事实来源 - 从一个文件生成
- 定期审查 - 审查是否存在偏移
评论
支持 Markdown