Skip to content

Commit 769ef6b

Browse files
committed
improve(NO-TASK): Standalone typography generation using cursor
1 parent 61432e5 commit 769ef6b

File tree

15 files changed

+2887
-211
lines changed

15 files changed

+2887
-211
lines changed

COLOR-PRESETS-GUIDE.md

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,132 @@ The plugin generates:
211211
- **Unexpected names**: Check your variable naming structure and hierarchy
212212
- **Empty color presets**: Verify that you have COLOR type variables in collections other than "Primitives"
213213

214-
For more information on WordPress color presets, see the [WordPress documentation](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/#color).
214+
For more information on WordPress color presets, see the [WordPress documentation](https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/#color).
215+
216+
# Color Presets Guide - Paint Style Integration
217+
218+
This guide explains how the Figma to WordPress Theme.json Exporter handles color presets with Paint Style integration for better labeling control.
219+
220+
## Overview
221+
222+
The plugin now uses **Paint Styles** for user-friendly display names while maintaining **Variables** for proper CSS variable references. This gives you the best of both worlds:
223+
224+
- **Paint Styles**: Provide human-readable, designer-friendly names
225+
- **Variables**: Ensure proper CSS variable references and maintain design system consistency
226+
227+
## How It Works
228+
229+
### 1. Variable-Based Colors with Paint Style Labels
230+
231+
When you have a Paint Style that references a Variable:
232+
233+
```
234+
Paint Style: "Midnight"
235+
↓ references
236+
Variable: "brand/primary"
237+
↓ generates
238+
WordPress Preset: {
239+
name: "Midnight", // From Paint Style
240+
slug: "brand-primary", // From Variable name
241+
color: "var(--wp--custom--brand--primary)" // From Variable
242+
}
243+
```
244+
245+
### 2. Standalone Paint Styles
246+
247+
When you have a Paint Style without bound variables:
248+
249+
```
250+
Paint Style: "Standalone Blue"
251+
↓ generates
252+
WordPress Preset: {
253+
name: "Standalone Blue", // From Paint Style
254+
slug: "standalone-blue", // From Paint Style name
255+
color: "#0000ff" // Direct hex value
256+
}
257+
```
258+
259+
### 3. Variables Without Paint Styles
260+
261+
When you have a Variable without a bound Paint Style:
262+
263+
```
264+
Variable: "brand/primary"
265+
↓ generates
266+
WordPress Preset: {
267+
name: "Brand Primary", // From Variable name
268+
slug: "brand-primary", // From Variable name
269+
color: "var(--wp--custom--brand--primary)" // From Variable
270+
}
271+
```
272+
273+
## Best Practices
274+
275+
### For Designers
276+
277+
1. **Create Paint Styles** for colors you want to appear in the UI with friendly names
278+
2. **Bind Paint Styles to Variables** for design system consistency
279+
3. **Use descriptive Paint Style names** like "Midnight", "Forest Green", "Sunset Orange"
280+
4. **Keep Variable names semantic** like "brand/primary", "brand/secondary", "accent/warning"
281+
282+
### For Developers
283+
284+
1. **CSS variables will always reference the Variable name**, not the Paint Style name
285+
2. **The slug in theme.json will match the Variable name** for consistency
286+
3. **Display names in the UI will use Paint Style names** when available
287+
4. **Fallback to Variable names** when no Paint Style is bound
288+
289+
## Example Workflow
290+
291+
1. **Create Variables** in Figma:
292+
- `brand/primary` (red color)
293+
- `brand/secondary` (green color)
294+
295+
2. **Create Paint Styles** and bind them to Variables:
296+
- Paint Style "Midnight" → bound to `brand/primary`
297+
- Paint Style "Forest Green" → bound to `brand/secondary`
298+
299+
3. **Export to WordPress**:
300+
```json
301+
{
302+
"settings": {
303+
"color": {
304+
"palette": [
305+
{
306+
"name": "Midnight",
307+
"slug": "brand-primary",
308+
"color": "var(--wp--custom--brand--primary)"
309+
},
310+
{
311+
"name": "Forest Green",
312+
"slug": "brand-secondary",
313+
"color": "var(--wp--custom--brand--secondary)"
314+
}
315+
]
316+
}
317+
}
318+
}
319+
```
320+
321+
4. **Use in WordPress**:
322+
```css
323+
.my-element {
324+
background-color: var(--wp--preset--color--brand-primary);
325+
}
326+
```
327+
328+
## Benefits
329+
330+
- **Better UX**: Users see friendly names like "Midnight" instead of "brand/primary"
331+
- **Consistent References**: CSS variables always reference the semantic Variable names
332+
- **Design System Integrity**: Variables maintain the design system structure
333+
- **Flexibility**: Can use Paint Styles for presentation while keeping Variables for logic
334+
335+
## Migration
336+
337+
If you're upgrading from the previous version:
338+
339+
- **Existing exports will continue to work** - the plugin maintains backward compatibility
340+
- **New exports will show Paint Style names** in the UI when available
341+
- **CSS variable references remain unchanged** - they still use Variable names
342+
- **No changes needed to existing WordPress themes** - the CSS variable structure is preserved

INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
If you're installing the plugin manually:
1414

15-
1. Download the plugin files from the repository
15+
1. Download the latest plugin release or clone this repository and run `npm install && npm run build`
1616
2. In Figma, go to Menu > Plugins > Development > Import plugin from manifest
1717
3. Select the manifest.json file from the downloaded files
1818

@@ -52,7 +52,7 @@ For the best results when using the WordPress Theme.json Exporter:
5252
2. Go to Menu > Plugins > WordPress Theme.json Export > Export to theme.json
5353
3. In the plugin UI, you can:
5454
- Choose to include typography presets (from text styles)
55-
- Generate color presets with customizable selection
55+
- Generate color presets with customizable selection (If adding/editing variables, you may need to close and reopen the plugin if color variables are msising)
5656
- Generate spacing presets from spacing variables
5757
- Upload an existing theme.json file to merge variables into it
5858
- Preview the generated theme.json and additional style files

export.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,15 +499,22 @@
499499
</div>
500500

501501
<div class="options">
502+
<div class="option-row">
503+
<input type="checkbox" id="generate-color-presets" />
504+
<label for="generate-color-presets">Generate color presets from color variables</label>
505+
<button type="button" class="customize-button" id="customize-colors" disabled>Customize</button>
506+
</div>
507+
502508
<div class="option-row">
503509
<input type="checkbox" id="generate-typography" />
504510
<label for="generate-typography">Generate typography presets from text styles <em>(10up tooling)</em></label>
505511
</div>
512+
506513
<div class="option-row">
507-
<input type="checkbox" id="generate-color-presets" />
508-
<label for="generate-color-presets">Generate color presets from color variables</label>
509-
<button type="button" class="customize-button" id="customize-colors" disabled>Customize</button>
514+
<input type="checkbox" id="generate-wordpress-typography" />
515+
<label for="generate-wordpress-typography">Generate WordPress-native typography structure <em>(fontFamilies, fontSizes, etc.)</em></label>
510516
</div>
517+
511518
<div class="option-row">
512519
<input type="checkbox" id="generate-spacing-presets" />
513520
<label for="generate-spacing-presets">Generate spacing presets from spacing variables</label>
@@ -776,6 +783,7 @@ <h3 class="modal-title">Customize Color Presets</h3>
776783
document.getElementById("export").addEventListener("click", () => {
777784
// Get the state of the checkboxes
778785
const generateTypography = document.getElementById("generate-typography").checked;
786+
const generateWordPressTypography = document.getElementById("generate-wordpress-typography").checked;
779787
const generateColorPresets = document.getElementById("generate-color-presets").checked;
780788
const generateSpacingPresets = document.getElementById("generate-spacing-presets").checked;
781789
const useRem = document.getElementById("use-rem").checked;
@@ -793,6 +801,7 @@ <h3 class="modal-title">Customize Color Presets</h3>
793801
type: "EXPORT",
794802
options: {
795803
generateTypography,
804+
generateWordPressTypography,
796805
generateColorPresets,
797806
generateSpacingPresets,
798807
baseTheme,

manifest.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
{
2-
"name": "WordPress Theme.json Export",
2+
"name": "Figma to WordPress Theme.json",
33
"id": "1476325215239454172",
44
"api": "1.0.0",
55
"editorType": ["figma"],
66
"permissions": [],
77
"main": "dist/code.js",
8-
"networkAccess": { "allowedDomains": ["https://cdnjs.cloudflare.com"] },
8+
"networkAccess": {
9+
"allowedDomains": ["https://cdnjs.cloudflare.com",
10+
"https://schemas.wp.org/trunk/theme.json",
11+
"https://fonts.googleapis.com",
12+
"https://fonts.gstatic.com"
13+
]
14+
},
915
"menu": [
1016
{ "command": "export", "name": "Export to theme.json" },
1117
{ "command": "css-vars", "name": "Apply CSS Variable Syntax" }

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)