Skip to content

Commit 38ca05f

Browse files
authored
Merge pull request #1 from linchpin/improve/collection-selection-ui
Improve/collection selection UI
2 parents 769ef6b + 2568688 commit 38ca05f

22 files changed

+2002
-1066
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ out/
77
dist/
88
/coverage
99
/.DS_Store
10+
examples/*

COLOR-PRESETS-GUIDE.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ The WordPress Theme.json Exporter plugin automatically converts Figma color vari
2121

2222
## Supported Variable Types
2323

24-
The plugin processes COLOR variables from all collections except the "Primitives" collection:
25-
26-
| Collection Type | Processing | Example Variables |
27-
|----------------|------------|-------------------|
28-
| Color | All COLOR variables processed | `primary`, `secondary`, `accent` |
29-
| Design System | All COLOR variables processed | `brand/primary`, `ui/background` |
30-
| Layout | All COLOR variables processed | `surface/light`, `border/default` |
31-
| Primitives | **Excluded** from color presets | Used for base theme variables only |
24+
The plugin processes COLOR variables from all "WordPress" prefixed collections:
25+
26+
| Collection Type | Processing | Example Variables |
27+
|-----------------|---------------------------------|----------------------------------|
28+
| Color | All COLOR variables processed | `primary`, `secondary`, `accent` |
29+
| Design System | All COLOR variables processed | `brand/primary`, `ui/background` |
30+
| Layout | All COLOR variables processed | `surface/light`, `border/default` |
31+
| Primitives | **Excluded** from color presets | Used for base theme variables only |
3232

3333
## How Color Presets Are Exported
3434

README.md

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Figma to WordPress theme.json Exporter
22

3-
[![Support Level](https://img.shields.io/badge/support-beta-blueviolet.svg)](#support-level) [![MIT License](https://img.shields.io/github/license/10up/10up-block-theme-json-export.svg)](https://github.com/10up/figma-to-wordpress-theme-json-exporter/blob/develop/LICENSE.md)
3+
This is a pretty major fork of the original 10up plugin. It is highly opinionated to the approach Linchpin takes to components being exported for our design systems and client websites
4+
5+
The original 10up plugin may be a great base for your project or you can run with this one, however the baseline 10up one is more table and we have breaking changes
6+
in this experimental approach
7+
8+
[![Support Level](https://img.shields.io/badge/support-beta-blueviolet.svg)](#support-level) [![MIT License](https://img.shields.io/github/license/linchpin/linchpin-block-theme-json-export.svg)](https://github.com/linchpin/figma-to-wordpress-theme-json-exporter/blob/develop/LICENSE.md)
49

510
> This Figma plugin converts Figma design tokens/variables into WordPress theme.json format, placing all variables under the `settings.custom` section according to WordPress standards.
611
@@ -16,7 +21,7 @@
1621
- Support for responsive/fluid variables
1722
- Automatic unit handling (px) for specific value types
1823
- Supports downloading the generated files as a zip package
19-
- **Typography presets** - Convert Figma text styles to WordPress typography presets *(10up tooling feature)*
24+
- **Typography presets** - Convert Figma text styles to WordPress typography presets
2025
- **Color presets** - Generate WordPress color palette from Figma color variables with customizable selection
2126
- **Spacing presets** - Create WordPress spacing presets from Figma spacing variables
2227
- Line height values converted from percentage to decimal format (e.g., 120% → 1.2)
@@ -46,7 +51,7 @@
4651
- All existing theme.json settings and styles will be preserved
4752
- New variables will be added under settings.custom
4853

49-
3. **Typography Presets:** *(10up tooling feature)*
54+
3. **Typography Presets:**
5055
- Check "Generate typography presets from text styles"
5156
- The plugin will convert all local text styles in your Figma document
5257
- Typography presets are added to `settings.custom.typography.presets`
@@ -115,13 +120,76 @@ When uploading an existing theme.json file:
115120
- Other sections of the theme.json file remain untouched
116121
- Color modes and button styles are still exported as separate files
117122

118-
### Special Collection Handling
123+
### Collection Processing Architecture
124+
125+
The plugin uses a sophisticated processor-based architecture to handle different types of Figma variable collections. Each collection is processed by a specific processor based on its name and structure, ensuring optimal handling for different use cases.
126+
127+
### Processor System
128+
129+
The plugin employs a list of processors that are evaluated in sequence:
130+
131+
1. **Primitives Processor** - Handles the "Primitives" collection as the base theme
132+
2. **WordPress Settings Colors Processor** - Processes color collections for palette generation
133+
3. **WordPress Settings Subset Processor** - Handles layout, spacing, typography, and shadow collections
134+
4. **WordPress Settings Processor** - Processes general WordPress settings collections
135+
5. **WordPress Elements Processor** - Handles element-specific "block" collections (buttons, headings, etc.)
136+
6. **Fallback Selected Processor** - Catches any remaining collections and adds them to custom settings
119137

120-
The plugin provides special handling for certain Figma variable collections:
138+
### Collection Types and Processing
121139

122140
#### Primitives Collection
123141

124-
Variables from a collection named "Primitives" are used as the base theme and are always processed first.
142+
Variables from a collection named "Primitives" are used as the base theme and are always processed first:
143+
- Merged directly into `settings.custom` without a namespace
144+
- Serves as the foundation for all other custom variables
145+
- Always processed first in the processor chain
146+
147+
#### WordPress Settings Collections
148+
149+
Collections following the `wp.settings.*` naming convention are processed according to their specific type:
150+
151+
**Color Collections (`wp.settings.color`)**
152+
- Intentionally NOT merged into `settings.custom`
153+
- Colors are surfaced via palette presets instead of custom variables
154+
- Button styles are extracted and processed separately
155+
156+
**Subset Collections (`wp.settings.layout`, `wp.settings.spacing`, `wp.settings.typography`, `wp.settings.shadow`)**
157+
- Merged directly into the corresponding WordPress settings section
158+
- Example: `wp.settings.spacing` variables go into `settings.spacing`
159+
- Supports deep merging with existing settings
160+
161+
**General Settings Collections (`wp.settings`)**
162+
- Known WordPress settings keys are merged into the appropriate sections
163+
- Unknown keys are placed under `settings.custom`
164+
- Supports both exact matches and nested paths
165+
166+
#### WordPress Elements Collections
167+
168+
Collections following the `wp.elements.*` naming convention:
169+
- Processed into `styles.elements` structure
170+
- Special handling for button elements with automatic style file generation
171+
- Supports nested element paths (e.g., `wp.elements.buttons``styles.elements.button`)
172+
173+
#### Fallback Processing
174+
175+
Any collection not matched by specific processors:
176+
- Automatically added to `settings.custom` with sanitized naming
177+
- Color-related properties are filtered out to prevent conflicts
178+
- Ensures all variables are captured regardless of naming conventions
179+
180+
### Processing Order and Priority
181+
182+
The processor system ensures that:
183+
- More specific processors run before general ones
184+
- WordPress-specific collections are handled appropriately
185+
- All collections are processed regardless of naming conventions
186+
- No variables are lost during the export process
187+
188+
This architecture provides flexibility for different design system approaches while maintaining compatibility with WordPress theme.json standards.
189+
190+
### Legacy Collection Handling
191+
192+
For backward compatibility, the plugin also provides special handling for certain legacy collection names:
125193

126194
#### Color Collection with Multiple Modes
127195

@@ -146,7 +214,7 @@ The plugin can generate typography presets from Figma text styles:
146214
- Text decoration properties (color, style, thickness, offset) are properly handled
147215
- The plugin omits empty or invalid properties rather than using fallbacks to ensure clean output
148216

149-
### Responsive/Fluid Variables *(10up tooling feature)*
217+
### Responsive/Fluid Variables
150218

151219
If a collection has exactly two modes named "Desktop" and "Mobile", the plugin treats them as responsive variables:
152220

@@ -289,7 +357,7 @@ The plugin will automatically transpile TypeScript to JavaScript.
289357

290358
## Changelog
291359

292-
A complete listing of all notable changes to this project are documented in [CHANGELOG.md](https://github.com/10up/figma-to-wordpress-theme-json-exporter/blob/develop/CHANGELOG.md).
360+
A complete listing of all notable changes to this project are documented in [CHANGELOG.md](https://github.com/linchpin/figma-to-wordpress-theme-json-exporter/blob/develop/CHANGELOG.md).
293361

294362
## Contributing with Changesets
295363

@@ -327,12 +395,4 @@ The changeset will be saved as a file in the `.changeset` directory and should b
327395
When changesets are merged to the main branch:
328396
1. A "Release" pull request will be automatically created
329397
2. This PR will update the version number and changelog
330-
3. When the Release PR is merged, the package will be automatically published to npm
331-
332-
## Contributing
333-
334-
Please read [CODE_OF_CONDUCT.md](https://github.com/10up/figma-to-wordpress-theme-json-exporter/blob/develop/CODE_OF_CONDUCT.md) for details on our code of conduct, [CONTRIBUTING.md](https://github.com/10up/figma-to-wordpress-theme-json-exporter/blob/develop/CONTRIBUTING.md) for details on the process for submitting pull requests to us, and [CREDITS.md](https://github.com/10up/figma-to-wordpress-theme-json-exporter/blob/develop/CREDITS.md) for a listing of maintainers, contributors, and libraries for this project.
335-
336-
## Like what you see?
337-
338-
<a href="http://10up.com/contact/"><img src="https://fueled.com/wp-content/uploads/2025/06/10up-github-banner.webp" alt="Work with the 10up WordPress Practice at Fueled"></a>
398+
3. When the Release PR is merged, the package will be automatically published to npm

css-vars.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
color: var(--figma-color-text);
1616
margin: 0;
1717
padding: var(--spacing);
18-
min-height: 300px;
19-
min-width: 400px;
18+
min-height: 400px;
19+
min-width: 800px;
2020
position: relative;
2121
overflow: hidden;
2222
}
@@ -128,9 +128,9 @@
128128
<label for="overwrite-existing-vars">Overwrite existing CSS variable syntax</label>
129129
</div>
130130
</div>
131-
131+
<!--
132132
<button id="apply-vars-btn" type="button">Apply CSS Variable Syntax to All Variables</button>
133-
133+
-->
134134
<div id="status" class="status"></div>
135135
</main>
136136

0 commit comments

Comments
 (0)