@newtonedev/configurator 0.1.3 → 0.1.5
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/dist/bridge/toCSS.d.ts.map +1 -1
- package/dist/bridge/toThemeConfig.d.ts.map +1 -1
- package/dist/index.cjs +79 -178
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -178
- package/dist/index.js.map +1 -1
- package/dist/panels/DesignPanel.d.ts.map +1 -1
- package/dist/panels/PreviewPanel.d.ts +1 -3
- package/dist/panels/PreviewPanel.d.ts.map +1 -1
- package/dist/state/actions.d.ts +11 -17
- package/dist/state/actions.d.ts.map +1 -1
- package/dist/state/defaults.d.ts.map +1 -1
- package/dist/state/reducer.d.ts.map +1 -1
- package/dist/types.d.ts +10 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/Configurator.tsx +1 -1
- package/src/bridge/toCSS.ts +6 -8
- package/src/bridge/toThemeConfig.ts +20 -56
- package/src/index.ts +1 -1
- package/src/panels/DesignPanel.tsx +0 -31
- package/src/panels/PalettePanel.tsx +2 -2
- package/src/panels/PreviewPanel.tsx +9 -40
- package/src/state/actions.ts +6 -8
- package/src/state/defaults.ts +28 -13
- package/src/state/reducer.ts +15 -54
- package/src/types.ts +13 -17
package/src/state/reducer.ts
CHANGED
|
@@ -208,75 +208,42 @@ export function configuratorReducer(
|
|
|
208
208
|
};
|
|
209
209
|
|
|
210
210
|
// Typography actions
|
|
211
|
-
case '
|
|
211
|
+
case 'SET_FONT': {
|
|
212
212
|
const defaultTypography = DEFAULT_CONFIGURATOR_STATE.typography!;
|
|
213
|
+
const currentFonts = state.typography?.fonts ?? defaultTypography.fonts;
|
|
213
214
|
return {
|
|
214
215
|
...state,
|
|
215
216
|
typography: {
|
|
216
|
-
fonts:
|
|
217
|
-
scale: {
|
|
218
|
-
baseSize: clamp(action.baseSize, 12, 24),
|
|
219
|
-
ratio: state.typography?.scale.ratio ?? defaultTypography.scale.ratio,
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
case 'SET_TYPOGRAPHY_RATIO': {
|
|
226
|
-
const defaultTypography = DEFAULT_CONFIGURATOR_STATE.typography!;
|
|
227
|
-
return {
|
|
228
|
-
...state,
|
|
229
|
-
typography: {
|
|
230
|
-
fonts: state.typography?.fonts ?? defaultTypography.fonts,
|
|
231
|
-
scale: {
|
|
232
|
-
baseSize: state.typography?.scale.baseSize ?? defaultTypography.scale.baseSize,
|
|
233
|
-
ratio: clamp(action.ratio, 1.1, 1.5),
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
case 'SET_FONT_MONO': {
|
|
240
|
-
const defaultTypography = DEFAULT_CONFIGURATOR_STATE.typography!;
|
|
241
|
-
return {
|
|
242
|
-
...state,
|
|
243
|
-
typography: {
|
|
244
|
-
fonts: {
|
|
245
|
-
mono: action.font,
|
|
246
|
-
display: state.typography?.fonts.display ?? defaultTypography.fonts.display,
|
|
247
|
-
default: state.typography?.fonts.default ?? defaultTypography.fonts.default,
|
|
248
|
-
},
|
|
249
|
-
scale: state.typography?.scale ?? defaultTypography.scale,
|
|
217
|
+
fonts: { ...currentFonts, [action.scope]: action.font },
|
|
250
218
|
},
|
|
251
219
|
};
|
|
252
220
|
}
|
|
253
221
|
|
|
254
|
-
case '
|
|
222
|
+
case 'SET_TYPE_SCALE_OFFSET': {
|
|
255
223
|
const defaultTypography = DEFAULT_CONFIGURATOR_STATE.typography!;
|
|
224
|
+
const currentFonts = state.typography?.fonts ?? defaultTypography.fonts;
|
|
256
225
|
return {
|
|
257
226
|
...state,
|
|
258
227
|
typography: {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
default: state.typography?.fonts.default ?? defaultTypography.fonts.default,
|
|
263
|
-
},
|
|
264
|
-
scale: state.typography?.scale ?? defaultTypography.scale,
|
|
228
|
+
...state.typography,
|
|
229
|
+
fonts: currentFonts,
|
|
230
|
+
typeScaleOffset: clamp(action.offset, 0, 1),
|
|
265
231
|
},
|
|
266
232
|
};
|
|
267
233
|
}
|
|
268
234
|
|
|
269
|
-
case '
|
|
235
|
+
case 'SET_ROLE_WEIGHT': {
|
|
270
236
|
const defaultTypography = DEFAULT_CONFIGURATOR_STATE.typography!;
|
|
237
|
+
const currentFonts = state.typography?.fonts ?? defaultTypography.fonts;
|
|
271
238
|
return {
|
|
272
239
|
...state,
|
|
273
240
|
typography: {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
241
|
+
...state.typography,
|
|
242
|
+
fonts: currentFonts,
|
|
243
|
+
roleWeights: {
|
|
244
|
+
...state.typography?.roleWeights,
|
|
245
|
+
[action.role]: clamp(action.weight, 100, 900),
|
|
278
246
|
},
|
|
279
|
-
scale: state.typography?.scale ?? defaultTypography.scale,
|
|
280
247
|
},
|
|
281
248
|
};
|
|
282
249
|
}
|
|
@@ -325,12 +292,6 @@ export function configuratorReducer(
|
|
|
325
292
|
preview: { ...state.preview, mode: action.mode },
|
|
326
293
|
};
|
|
327
294
|
|
|
328
|
-
case 'SET_PREVIEW_THEME':
|
|
329
|
-
return {
|
|
330
|
-
...state,
|
|
331
|
-
preview: { ...state.preview, theme: action.theme },
|
|
332
|
-
};
|
|
333
|
-
|
|
334
295
|
// Control actions
|
|
335
296
|
case 'RESET':
|
|
336
297
|
return DEFAULT_CONFIGURATOR_STATE;
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { DesaturationStrength, HueGradingStrength } from 'newtone';
|
|
2
|
-
import type { ColorMode
|
|
2
|
+
import type { ColorMode } from '@newtonedev/components';
|
|
3
|
+
|
|
4
|
+
// Re-export font types from @newtonedev/fonts (canonical source)
|
|
5
|
+
export type { FontConfig, FontScope } from '@newtonedev/fonts';
|
|
6
|
+
// Backward-compatible alias: configurator historically used this name
|
|
7
|
+
export type { FontSlot as FontSlotConfig } from '@newtonedev/fonts';
|
|
8
|
+
import type { FontSlot, TextRole } from '@newtonedev/fonts';
|
|
3
9
|
|
|
4
10
|
/** Spacing preset options */
|
|
5
11
|
export type SpacingPreset = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -24,14 +30,6 @@ export interface HueGradingEndpointState {
|
|
|
24
30
|
readonly hue: number; // Traditional HSL hue [0, 359]
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
/** Font configuration for a single font slot */
|
|
28
|
-
export interface FontConfig {
|
|
29
|
-
readonly type: 'system' | 'google' | 'custom';
|
|
30
|
-
readonly family: string; // 'ui-monospace' | 'Roboto' | custom name
|
|
31
|
-
readonly customUrl?: string; // Supabase Storage URL for custom fonts
|
|
32
|
-
readonly fallback: string; // CSS fallback stack
|
|
33
|
-
}
|
|
34
|
-
|
|
35
33
|
/** Complete configurator state */
|
|
36
34
|
export interface ConfiguratorState {
|
|
37
35
|
readonly palettes: readonly PaletteState[];
|
|
@@ -45,7 +43,6 @@ export interface ConfiguratorState {
|
|
|
45
43
|
};
|
|
46
44
|
readonly preview: {
|
|
47
45
|
readonly mode: ColorMode;
|
|
48
|
-
readonly theme: ThemeName;
|
|
49
46
|
};
|
|
50
47
|
readonly spacing?: {
|
|
51
48
|
readonly preset: SpacingPreset; // xs=6px, sm=7px, md=8px, lg=9px, xl=10px base
|
|
@@ -55,14 +52,13 @@ export interface ConfiguratorState {
|
|
|
55
52
|
};
|
|
56
53
|
readonly typography?: {
|
|
57
54
|
readonly fonts: {
|
|
58
|
-
readonly
|
|
59
|
-
readonly display:
|
|
60
|
-
readonly
|
|
61
|
-
|
|
62
|
-
readonly scale: {
|
|
63
|
-
readonly baseSize: number; // px (default: 16)
|
|
64
|
-
readonly ratio: number; // scale ratio (default: 1.25)
|
|
55
|
+
readonly main: FontSlot; // Body/default font
|
|
56
|
+
readonly display: FontSlot; // Headlines, titles
|
|
57
|
+
readonly mono: FontSlot; // Code, technical content
|
|
58
|
+
readonly currency: FontSlot; // Monetary amounts, financial data
|
|
65
59
|
};
|
|
60
|
+
readonly typeScaleOffset?: number; // [0, 1], 0.5 = identity (default)
|
|
61
|
+
readonly roleWeights?: Partial<Record<TextRole, number>>; // CSS font-weight per role (100-900)
|
|
66
62
|
};
|
|
67
63
|
readonly icons?: {
|
|
68
64
|
readonly variant: 'outlined' | 'rounded' | 'sharp';
|