@themal/editor 0.17.1 → 0.18.1
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 +99 -7
- package/dist/index.d.ts +16 -0
- package/dist/index.js +2694 -2633
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ function App() {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
The editor writes CSS custom properties (HSL values) to `:root
|
|
39
|
+
The editor writes CSS custom properties (HSL values) to `:root` and injects global typography styles, so colors and fonts apply across your entire site.
|
|
40
40
|
|
|
41
41
|
## Props
|
|
42
42
|
|
|
@@ -54,6 +54,9 @@ The editor writes CSS custom properties (HSL values) to `:root`, so it works wit
|
|
|
54
54
|
| `showNavLinks` | `boolean` | `true` | Show page navigation links in the header and mobile menu. |
|
|
55
55
|
| `headerRight` | `React.ReactNode` | — | Custom content rendered on the right side of the header (e.g. auth buttons). |
|
|
56
56
|
| `aboutUrl` | `string` | — | URL for the About page link in the header navigation. |
|
|
57
|
+
| `customIcons` | `CustomIcon[]` | — | Custom icons to display in the Icons preview section. Each entry needs `name` and `icon` (a React component). |
|
|
58
|
+
| `iconMode` | `"append" \| "replace"` | `"append"` | `"append"` adds custom icons after the built-in lucide icons. `"replace"` hides built-ins and shows only custom icons. |
|
|
59
|
+
| `showLogo` | `boolean` | `true` | Show the Themal logo in the header. Set `false` for white-label or plugin usage. |
|
|
57
60
|
|
|
58
61
|
## Premium Features
|
|
59
62
|
|
|
@@ -64,7 +67,7 @@ The following features require a valid license key:
|
|
|
64
67
|
| Harmony schemes | Generate palettes using complementary, analogous, triadic, or split-complementary color relationships. |
|
|
65
68
|
| Color locks | Lock up to 4 colors to preserve them during palette regeneration. |
|
|
66
69
|
| PR integration | Create design system pull requests directly from the editor. |
|
|
67
|
-
| Undo/redo |
|
|
70
|
+
| Undo/redo | Up to 10 levels of undo for theme refreshes and image palette applications. |
|
|
68
71
|
| Image palette extraction | Extract color palettes from uploaded images with preview confirmation. |
|
|
69
72
|
| Palette export | Download palette as SVG/PNG, or copy as HEX/RGB/RGBA text. |
|
|
70
73
|
| Interaction states | Style hover, focus, and active states for buttons and components. |
|
|
@@ -159,6 +162,37 @@ import { LicenseProvider } from '@themal/editor';
|
|
|
159
162
|
/>
|
|
160
163
|
```
|
|
161
164
|
|
|
165
|
+
### With custom icons
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { Rocket, Star, Flame } from 'lucide-react';
|
|
169
|
+
// Or use any React component that accepts className
|
|
170
|
+
import { MyBrandIcon } from './icons';
|
|
171
|
+
|
|
172
|
+
<DesignSystemEditor
|
|
173
|
+
customIcons={[
|
|
174
|
+
{ name: "Rocket", icon: Rocket },
|
|
175
|
+
{ name: "Star", icon: Star },
|
|
176
|
+
{ name: "Flame", icon: Flame },
|
|
177
|
+
{ name: "Brand", icon: MyBrandIcon },
|
|
178
|
+
]}
|
|
179
|
+
/>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Replace built-in icons entirely
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
<DesignSystemEditor
|
|
186
|
+
customIcons={[
|
|
187
|
+
{ name: "Brand", icon: MyBrandIcon },
|
|
188
|
+
{ name: "Product", icon: ProductIcon },
|
|
189
|
+
]}
|
|
190
|
+
iconMode="replace"
|
|
191
|
+
/>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The Icons section includes a "Hide All" / "Show All" toggle so users can collapse the icon grid.
|
|
195
|
+
|
|
162
196
|
### Embedded / headless
|
|
163
197
|
|
|
164
198
|
```tsx
|
|
@@ -190,7 +224,7 @@ import {
|
|
|
190
224
|
|
|
191
225
|
// Card, typography & interaction style utilities
|
|
192
226
|
applyStoredCardStyle, // Restore card style from localStorage
|
|
193
|
-
applyStoredTypography, // Restore typography from localStorage
|
|
227
|
+
applyStoredTypography, // Restore typography from localStorage (applies site-wide)
|
|
194
228
|
applyStoredAlertStyle, // Restore dialog alert style from localStorage
|
|
195
229
|
applyStoredToastStyle, // Restore toast style from localStorage
|
|
196
230
|
applyStoredInteractionStyle, // Restore button interaction style from localStorage
|
|
@@ -228,6 +262,7 @@ import {
|
|
|
228
262
|
import type {
|
|
229
263
|
DesignSystemEditorProps,
|
|
230
264
|
TokenDefinition,
|
|
265
|
+
CustomIcon,
|
|
231
266
|
HarmonyScheme,
|
|
232
267
|
CardStyleState,
|
|
233
268
|
TypographyState,
|
|
@@ -245,10 +280,10 @@ import type {
|
|
|
245
280
|
|
|
246
281
|
## How It Works
|
|
247
282
|
|
|
248
|
-
1. **Color picking** — Click any swatch to open the native color picker. Changing a key color (brand, secondary, accent, background) automatically derives related tokens.
|
|
283
|
+
1. **Color picking** — Click any swatch to scroll the Colors section into view, then open the native color picker. Changing a key color (brand, secondary, accent, background) automatically derives related tokens.
|
|
249
284
|
2. **Harmony schemes** *(Pro)* — Generate palettes using complementary, analogous, triadic, or split-complementary color relationships.
|
|
250
|
-
3. **Contrast enforcement** — Every foreground/background pair is checked against WCAG AA (4.5:1). Failing pairs are auto-corrected by adjusting lightness.
|
|
251
|
-
4. **Typography** — Choose heading and body fonts (including custom Google Fonts), adjust sizes, weights, line height, and letter spacing with live preview. Five built-in presets (System, Modern, Classic, Compact, Editorial).
|
|
285
|
+
3. **Contrast enforcement** — Every foreground/background pair is checked against WCAG AA (4.5:1). Failing pairs are auto-corrected by adjusting lightness. The accessibility audit shows a centered modal with results. On failure, choose "Ignore" to dismiss or "Suggest Alternative" to auto-fix contrast issues. A WCAG On/Off toggle lets you disable auto-correction for marketing or other contexts that don't require WCAG compliance. Locks are still honored when enforcement is off.
|
|
286
|
+
4. **Typography** — Choose heading and body fonts (including custom Google Fonts), adjust sizes, weights, line height, and letter spacing with live preview. Five built-in presets (System, Modern, Classic, Compact, Editorial). Typography applies site-wide, not just within the editor component, so toggling fonts updates the entire page.
|
|
252
287
|
5. **Button interactions** *(Pro)* — Fine-tune hover opacity, hover/active scale, transition duration, and focus ring width with presets (Subtle, Elevated, Bold).
|
|
253
288
|
6. **Typography interactions** *(Pro)* — Customize link hover/active behavior (opacity, scale, underline) and heading hover effects with live preview.
|
|
254
289
|
7. **Persistence** — All settings (colors, typography, card styles, dialog styles, toast styles, interactions) are saved to `localStorage` and restored on reload.
|
|
@@ -256,7 +291,7 @@ import type {
|
|
|
256
291
|
9. **Shareable URLs** — Encode your full theme state in the URL hash and share it with anyone via a single link.
|
|
257
292
|
10. **Palette export** *(Pro)* — Download your palette as SVG or PNG, or copy as a HEX/RGB/RGBA text list.
|
|
258
293
|
11. **Custom fonts** *(Pro)* — Add any Google Font by name. The editor validates the font exists, loads all weights, adds it to heading/body dropdowns, and persists it across sessions.
|
|
259
|
-
12. **Mobile friendly** — Fully responsive UI with mobile-optimized dropdowns, compact swatch labels, and stacked layouts for smaller screens.
|
|
294
|
+
12. **Mobile friendly** — Fully responsive UI with a 2D color spectrum picker (saturation/lightness canvas + hue slider) for intuitive touch-based color selection, mobile-optimized dropdowns, compact swatch labels, and stacked layouts for smaller screens.
|
|
260
295
|
|
|
261
296
|
## Package Architecture
|
|
262
297
|
|
|
@@ -284,6 +319,63 @@ Import the main entry point for components and utilities, and `style.css` separa
|
|
|
284
319
|
|
|
285
320
|
The editor ships pre-compiled CSS via `@themal/editor/style.css`. Styles are scoped using Tailwind's `important: '.ds-editor'` so they don't conflict with your app's styles. The root element is automatically wrapped in `<div className="ds-editor">`.
|
|
286
321
|
|
|
322
|
+
## Web Component
|
|
323
|
+
|
|
324
|
+
The editor is also available as a `<themal-editor>` custom element for non-React sites (WordPress, Shopify, plain HTML).
|
|
325
|
+
|
|
326
|
+
### Basic usage
|
|
327
|
+
|
|
328
|
+
```html
|
|
329
|
+
<script src="https://unpkg.com/@themal/editor/dist/themal-editor.js"></script>
|
|
330
|
+
<themal-editor></themal-editor>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### Attributes
|
|
334
|
+
|
|
335
|
+
All props that accept strings or booleans can be set as HTML attributes using kebab-case:
|
|
336
|
+
|
|
337
|
+
```html
|
|
338
|
+
<themal-editor
|
|
339
|
+
license-key="THEMAL-XXXX-XXXX-XXXX"
|
|
340
|
+
show-header="false"
|
|
341
|
+
show-nav-links="false"
|
|
342
|
+
icon-mode="replace"
|
|
343
|
+
show-logo="true"
|
|
344
|
+
accessibility-audit="true"
|
|
345
|
+
upgrade-url="/pricing"
|
|
346
|
+
sign-in-url="/sign-in"
|
|
347
|
+
about-url="/about"
|
|
348
|
+
pr-endpoint-url="/api/create-design-pr"
|
|
349
|
+
></themal-editor>
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Note: The Themal logo is hidden by default in the web component. Set `show-logo="true"` to display it.
|
|
353
|
+
|
|
354
|
+
### Custom icons via JavaScript
|
|
355
|
+
|
|
356
|
+
Since HTML attributes can only pass strings, custom icons are set programmatically with the `setIcons()` method. Pass an array of `{ name, svg }` objects where `svg` is a raw SVG string:
|
|
357
|
+
|
|
358
|
+
```html
|
|
359
|
+
<script src="https://unpkg.com/@themal/editor/dist/themal-editor.js"></script>
|
|
360
|
+
<themal-editor icon-mode="replace"></themal-editor>
|
|
361
|
+
|
|
362
|
+
<script>
|
|
363
|
+
const editor = document.querySelector('themal-editor');
|
|
364
|
+
editor.setIcons([
|
|
365
|
+
{
|
|
366
|
+
name: "Heart",
|
|
367
|
+
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>'
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
name: "Star",
|
|
371
|
+
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>'
|
|
372
|
+
},
|
|
373
|
+
]);
|
|
374
|
+
</script>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Set `icon-mode="replace"` to hide the built-in icons and show only your custom set, or omit it (defaults to `"append"`) to add yours alongside the built-ins.
|
|
378
|
+
|
|
287
379
|
## Development
|
|
288
380
|
|
|
289
381
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,16 @@ export declare interface CustomFontEntry {
|
|
|
64
64
|
spec: string;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
export declare interface CustomIcon {
|
|
68
|
+
/** Display name for the icon */
|
|
69
|
+
name: string;
|
|
70
|
+
/** React component that renders the icon. Receives className and standard SVG props. */
|
|
71
|
+
icon: default_2.ComponentType<{
|
|
72
|
+
className?: string;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
|
|
67
77
|
export declare function deserializeThemeState(hash: string): {
|
|
68
78
|
colors: Record<string, string>;
|
|
69
79
|
cardStyle: CardStyleState;
|
|
@@ -103,6 +113,12 @@ export declare interface DesignSystemEditorProps {
|
|
|
103
113
|
featuresUrl?: string;
|
|
104
114
|
/** URL for the About page link in the header */
|
|
105
115
|
aboutUrl?: string;
|
|
116
|
+
/** Custom icons to display in the Icons preview section */
|
|
117
|
+
customIcons?: CustomIcon[];
|
|
118
|
+
/** How custom icons interact with built-in icons. "append" adds them after built-ins, "replace" hides built-ins entirely. Default: "append" */
|
|
119
|
+
iconMode?: "append" | "replace";
|
|
120
|
+
/** Show the Themal logo in the header. Default: true */
|
|
121
|
+
showLogo?: boolean;
|
|
106
122
|
}
|
|
107
123
|
|
|
108
124
|
export declare const EDITABLE_VARS: readonly [{
|