@newtonedev/configurator 0.1.4 → 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/toThemeConfig.d.ts.map +1 -1
- package/dist/index.cjs +63 -122
- 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 +63 -122
- package/dist/index.js.map +1 -1
- package/dist/panels/DesignPanel.d.ts.map +1 -1
- package/dist/state/actions.d.ts +10 -13
- 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 +9 -14
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/bridge/toThemeConfig.ts +20 -47
- package/src/index.ts +1 -1
- package/src/panels/DesignPanel.tsx +0 -31
- package/src/state/actions.ts +5 -6
- package/src/state/defaults.ts +28 -12
- package/src/state/reducer.ts +15 -48
- package/src/types.ts +12 -15
package/dist/state/actions.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DesaturationStrength, HueGradingStrength } from 'newtone';
|
|
2
2
|
import type { ColorMode } from '@newtonedev/components';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TextRole } from '@newtonedev/fonts';
|
|
4
|
+
import type { ConfiguratorState, FontSlotConfig, FontScope, SpacingPreset } from '../types';
|
|
4
5
|
export type ConfiguratorAction = {
|
|
5
6
|
readonly type: 'SET_PALETTE_HUE';
|
|
6
7
|
readonly index: number;
|
|
@@ -80,20 +81,16 @@ export type ConfiguratorAction = {
|
|
|
80
81
|
readonly type: 'SET_ROUNDNESS_INTENSITY';
|
|
81
82
|
readonly intensity: number;
|
|
82
83
|
} | {
|
|
83
|
-
readonly type: '
|
|
84
|
-
readonly
|
|
84
|
+
readonly type: 'SET_FONT';
|
|
85
|
+
readonly scope: FontScope;
|
|
86
|
+
readonly font: FontSlotConfig;
|
|
85
87
|
} | {
|
|
86
|
-
readonly type: '
|
|
87
|
-
readonly
|
|
88
|
+
readonly type: 'SET_TYPE_SCALE_OFFSET';
|
|
89
|
+
readonly offset: number;
|
|
88
90
|
} | {
|
|
89
|
-
readonly type: '
|
|
90
|
-
readonly
|
|
91
|
-
|
|
92
|
-
readonly type: 'SET_FONT_DISPLAY';
|
|
93
|
-
readonly font: FontConfig;
|
|
94
|
-
} | {
|
|
95
|
-
readonly type: 'SET_FONT_DEFAULT';
|
|
96
|
-
readonly font: FontConfig;
|
|
91
|
+
readonly type: 'SET_ROLE_WEIGHT';
|
|
92
|
+
readonly role: TextRole;
|
|
93
|
+
readonly weight: number;
|
|
97
94
|
} | {
|
|
98
95
|
readonly type: 'SET_ICON_VARIANT';
|
|
99
96
|
readonly variant: 'outlined' | 'rounded' | 'sharp';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/state/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/state/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE5F,MAAM,MAAM,kBAAkB,GAE1B;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,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,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/state/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,iBA+
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/state/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,iBA+GxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/state/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAgB,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAoBpD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/state/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAgB,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAoBpD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,kBAAkB,GACzB,iBAAiB,CAwRnB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { DesaturationStrength, HueGradingStrength } from 'newtone';
|
|
2
2
|
import type { ColorMode } from '@newtonedev/components';
|
|
3
|
+
export type { FontConfig, FontScope } from '@newtonedev/fonts';
|
|
4
|
+
export type { FontSlot as FontSlotConfig } from '@newtonedev/fonts';
|
|
5
|
+
import type { FontSlot, TextRole } from '@newtonedev/fonts';
|
|
3
6
|
/** Spacing preset options */
|
|
4
7
|
export type SpacingPreset = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
5
8
|
/** Per-palette state in the configurator (human-readable, traditional hues) */
|
|
@@ -20,13 +23,6 @@ export interface HueGradingEndpointState {
|
|
|
20
23
|
readonly strength: HueGradingStrength;
|
|
21
24
|
readonly hue: number;
|
|
22
25
|
}
|
|
23
|
-
/** Font configuration for a single font slot */
|
|
24
|
-
export interface FontConfig {
|
|
25
|
-
readonly type: 'system' | 'google' | 'custom';
|
|
26
|
-
readonly family: string;
|
|
27
|
-
readonly customUrl?: string;
|
|
28
|
-
readonly fallback: string;
|
|
29
|
-
}
|
|
30
26
|
/** Complete configurator state */
|
|
31
27
|
export interface ConfiguratorState {
|
|
32
28
|
readonly palettes: readonly PaletteState[];
|
|
@@ -49,14 +45,13 @@ export interface ConfiguratorState {
|
|
|
49
45
|
};
|
|
50
46
|
readonly typography?: {
|
|
51
47
|
readonly fonts: {
|
|
52
|
-
readonly
|
|
53
|
-
readonly display:
|
|
54
|
-
readonly
|
|
55
|
-
|
|
56
|
-
readonly scale: {
|
|
57
|
-
readonly baseSize: number;
|
|
58
|
-
readonly ratio: number;
|
|
48
|
+
readonly main: FontSlot;
|
|
49
|
+
readonly display: FontSlot;
|
|
50
|
+
readonly mono: FontSlot;
|
|
51
|
+
readonly currency: FontSlot;
|
|
59
52
|
};
|
|
53
|
+
readonly typeScaleOffset?: number;
|
|
54
|
+
readonly roleWeights?: Partial<Record<TextRole, number>>;
|
|
60
55
|
};
|
|
61
56
|
readonly icons?: {
|
|
62
57
|
readonly variant: 'outlined' | 'rounded' | 'sharp';
|
package/dist/types.d.ts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CAAC;IACF,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;QACnD,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;QACzD,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;KAC7B,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newtonedev/configurator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Embeddable palette builder widget for Newtone color systems",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"react-native": ">=0.70.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@newtonedev/fonts": "file:../../../newtone-fonts",
|
|
41
42
|
"newtone": "^0.1.0",
|
|
42
43
|
"@newtonedev/components": "^0.1.0",
|
|
43
44
|
"react-native-web": "^0.19.10"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ConfiguratorState, SpacingPreset } from '../types';
|
|
2
|
-
import type { NewtoneThemeConfig
|
|
2
|
+
import type { NewtoneThemeConfig } from '@newtonedev/components';
|
|
3
|
+
import { DEFAULT_FONT_SIZES, DEFAULT_LINE_HEIGHTS, DEFAULT_ROLE_SCALES, DEFAULT_FONT_SLOTS, ROLE_DEFAULT_WEIGHTS, migrateToFontSlot, computeBreakpointRoleScales, applyTypeScaleOffset } from '@newtonedev/fonts';
|
|
3
4
|
import type { PaletteConfig, DynamicRange, HueGrading, HueGradingEndpoint } from 'newtone';
|
|
4
5
|
import { traditionalHueToOklch } from '../hue-conversion';
|
|
5
6
|
|
|
@@ -21,43 +22,6 @@ function roundnessToMultiplier(intensity: number): number {
|
|
|
21
22
|
return intensity * 2.0; // lerp(0, 2.0, intensity)
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
/**
|
|
25
|
-
* Compute typography scale from base size and ratio.
|
|
26
|
-
* Uses modular scale: baseSize * ratio^n
|
|
27
|
-
*/
|
|
28
|
-
function computeTypographyScale(baseSize: number, ratio: number) {
|
|
29
|
-
return {
|
|
30
|
-
xs: Math.round(baseSize / (ratio ** 2)),
|
|
31
|
-
sm: Math.round(baseSize / ratio),
|
|
32
|
-
base: baseSize,
|
|
33
|
-
md: Math.round(baseSize * ratio),
|
|
34
|
-
lg: Math.round(baseSize * (ratio ** 2)),
|
|
35
|
-
xl: Math.round(baseSize * (ratio ** 3)),
|
|
36
|
-
xxl: Math.round(baseSize * (ratio ** 4)),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Default font configurations using system fonts
|
|
42
|
-
*/
|
|
43
|
-
const DEFAULT_FONTS: { readonly mono: FontConfig; readonly display: FontConfig; readonly default: FontConfig } = {
|
|
44
|
-
mono: {
|
|
45
|
-
type: 'system',
|
|
46
|
-
family: 'ui-monospace',
|
|
47
|
-
fallback: 'SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
|
48
|
-
},
|
|
49
|
-
display: {
|
|
50
|
-
type: 'system',
|
|
51
|
-
family: 'system-ui',
|
|
52
|
-
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
53
|
-
},
|
|
54
|
-
default: {
|
|
55
|
-
type: 'system',
|
|
56
|
-
family: 'system-ui',
|
|
57
|
-
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
|
|
61
25
|
/**
|
|
62
26
|
* Default icon configuration using Material Symbols Rounded
|
|
63
27
|
*/
|
|
@@ -145,15 +109,24 @@ export function toThemeConfig(state: ConfiguratorState): NewtoneThemeConfig {
|
|
|
145
109
|
xl: Math.round(12 * radiusMultiplier),
|
|
146
110
|
pill: 999,
|
|
147
111
|
},
|
|
148
|
-
typography: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
112
|
+
typography: (() => {
|
|
113
|
+
const roles = state.typography?.typeScaleOffset != null
|
|
114
|
+
? applyTypeScaleOffset(DEFAULT_ROLE_SCALES, state.typography.typeScaleOffset)
|
|
115
|
+
: DEFAULT_ROLE_SCALES;
|
|
116
|
+
return {
|
|
117
|
+
fonts: {
|
|
118
|
+
main: migrateToFontSlot(state.typography?.fonts.main ?? (state.typography?.fonts as any)?.default, DEFAULT_FONT_SLOTS.main),
|
|
119
|
+
display: migrateToFontSlot(state.typography?.fonts.display, DEFAULT_FONT_SLOTS.display),
|
|
120
|
+
mono: migrateToFontSlot(state.typography?.fonts.mono, DEFAULT_FONT_SLOTS.mono),
|
|
121
|
+
currency: migrateToFontSlot(state.typography?.fonts.currency, DEFAULT_FONT_SLOTS.currency),
|
|
122
|
+
},
|
|
123
|
+
fontSizes: DEFAULT_FONT_SIZES,
|
|
124
|
+
lineHeights: DEFAULT_LINE_HEIGHTS,
|
|
125
|
+
roles,
|
|
126
|
+
breakpointRoles: computeBreakpointRoleScales(roles),
|
|
127
|
+
roleWeights: { ...ROLE_DEFAULT_WEIGHTS, ...state.typography?.roleWeights },
|
|
128
|
+
};
|
|
129
|
+
})(),
|
|
157
130
|
icons: state.icons ?? DEFAULT_ICONS,
|
|
158
131
|
};
|
|
159
132
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { Configurator } from './Configurator';
|
|
|
3
3
|
export type { ConfiguratorProps } from './Configurator.types';
|
|
4
4
|
|
|
5
5
|
// State types
|
|
6
|
-
export type { ConfiguratorState, PaletteState, HueGradingEndpointState, SpacingPreset } from './types';
|
|
6
|
+
export type { ConfiguratorState, PaletteState, HueGradingEndpointState, SpacingPreset, FontConfig, FontScope, FontSlotConfig } from './types';
|
|
7
7
|
export type { ConfiguratorAction } from './state/actions';
|
|
8
8
|
|
|
9
9
|
// Bridge functions (for headless usage)
|
|
@@ -31,8 +31,6 @@ export function DesignPanel({ state, dispatch }: DesignPanelProps) {
|
|
|
31
31
|
|
|
32
32
|
const spacingPreset = state.spacing?.preset ?? 'md';
|
|
33
33
|
const intensity = state.roundness?.intensity ?? 0.5;
|
|
34
|
-
const baseSize = state.typography?.scale.baseSize ?? 16;
|
|
35
|
-
const ratio = state.typography?.scale.ratio ?? 1.25;
|
|
36
34
|
const variant = state.icons?.variant ?? 'rounded';
|
|
37
35
|
const weight = state.icons?.weight ?? 400;
|
|
38
36
|
return (
|
|
@@ -71,35 +69,6 @@ export function DesignPanel({ state, dispatch }: DesignPanelProps) {
|
|
|
71
69
|
showValue
|
|
72
70
|
/>
|
|
73
71
|
|
|
74
|
-
{/* Typography Section */}
|
|
75
|
-
<Text style={[styles.subtitle, { color: srgbToHex(tokens.textSecondary.srgb) }]}>
|
|
76
|
-
Typography
|
|
77
|
-
</Text>
|
|
78
|
-
<View style={styles.row}>
|
|
79
|
-
<View style={styles.flex}>
|
|
80
|
-
<Slider
|
|
81
|
-
value={baseSize}
|
|
82
|
-
onValueChange={(v) => dispatch({ type: 'SET_TYPOGRAPHY_BASE_SIZE', baseSize: v })}
|
|
83
|
-
min={12}
|
|
84
|
-
max={24}
|
|
85
|
-
step={1}
|
|
86
|
-
label="Base Size"
|
|
87
|
-
showValue
|
|
88
|
-
/>
|
|
89
|
-
</View>
|
|
90
|
-
<View style={styles.flex}>
|
|
91
|
-
<Slider
|
|
92
|
-
value={Math.round(ratio * 100)}
|
|
93
|
-
onValueChange={(v) => dispatch({ type: 'SET_TYPOGRAPHY_RATIO', ratio: v / 100 })}
|
|
94
|
-
min={110}
|
|
95
|
-
max={150}
|
|
96
|
-
step={5}
|
|
97
|
-
label="Scale Ratio"
|
|
98
|
-
showValue
|
|
99
|
-
/>
|
|
100
|
-
</View>
|
|
101
|
-
</View>
|
|
102
|
-
|
|
103
72
|
{/* Icons Section */}
|
|
104
73
|
<Text style={[styles.subtitle, { color: srgbToHex(tokens.textSecondary.srgb) }]}>
|
|
105
74
|
Icons
|
package/src/state/actions.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DesaturationStrength, HueGradingStrength } from 'newtone';
|
|
2
2
|
import type { ColorMode } from '@newtonedev/components';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TextRole } from '@newtonedev/fonts';
|
|
4
|
+
import type { ConfiguratorState, FontSlotConfig, FontScope, SpacingPreset } from '../types';
|
|
4
5
|
|
|
5
6
|
export type ConfiguratorAction =
|
|
6
7
|
// Palette actions
|
|
@@ -30,11 +31,9 @@ export type ConfiguratorAction =
|
|
|
30
31
|
// Roundness actions
|
|
31
32
|
| { readonly type: 'SET_ROUNDNESS_INTENSITY'; readonly intensity: number }
|
|
32
33
|
// Typography actions
|
|
33
|
-
| { readonly type: '
|
|
34
|
-
| { readonly type: '
|
|
35
|
-
| { readonly type: '
|
|
36
|
-
| { readonly type: 'SET_FONT_DISPLAY'; readonly font: FontConfig }
|
|
37
|
-
| { readonly type: 'SET_FONT_DEFAULT'; readonly font: FontConfig }
|
|
34
|
+
| { readonly type: 'SET_FONT'; readonly scope: FontScope; readonly font: FontSlotConfig }
|
|
35
|
+
| { readonly type: 'SET_TYPE_SCALE_OFFSET'; readonly offset: number }
|
|
36
|
+
| { readonly type: 'SET_ROLE_WEIGHT'; readonly role: TextRole; readonly weight: number }
|
|
38
37
|
// Icons actions
|
|
39
38
|
| { readonly type: 'SET_ICON_VARIANT'; readonly variant: 'outlined' | 'rounded' | 'sharp' }
|
|
40
39
|
| { readonly type: 'SET_ICON_WEIGHT'; readonly weight: 100 | 200 | 300 | 400 | 500 | 600 | 700 }
|
package/src/state/defaults.ts
CHANGED
|
@@ -78,23 +78,39 @@ export const DEFAULT_CONFIGURATOR_STATE: ConfiguratorState = {
|
|
|
78
78
|
},
|
|
79
79
|
typography: {
|
|
80
80
|
fonts: {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
main: {
|
|
82
|
+
config: {
|
|
83
|
+
type: 'system',
|
|
84
|
+
family: 'system-ui',
|
|
85
|
+
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
86
|
+
},
|
|
87
|
+
weights: { regular: 400, medium: 500, bold: 700 },
|
|
85
88
|
},
|
|
86
89
|
display: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
config: {
|
|
91
|
+
type: 'system',
|
|
92
|
+
family: 'system-ui',
|
|
93
|
+
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
94
|
+
},
|
|
95
|
+
weights: { regular: 400, medium: 500, bold: 700 },
|
|
96
|
+
},
|
|
97
|
+
mono: {
|
|
98
|
+
config: {
|
|
99
|
+
type: 'system',
|
|
100
|
+
family: 'ui-monospace',
|
|
101
|
+
fallback: 'SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
|
102
|
+
},
|
|
103
|
+
weights: { regular: 400, medium: 500, bold: 700 },
|
|
90
104
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
currency: {
|
|
106
|
+
config: {
|
|
107
|
+
type: 'system',
|
|
108
|
+
family: 'system-ui',
|
|
109
|
+
fallback: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
110
|
+
},
|
|
111
|
+
weights: { regular: 400, medium: 500, bold: 700 },
|
|
95
112
|
},
|
|
96
113
|
},
|
|
97
|
-
scale: { baseSize: 16, ratio: 1.25 },
|
|
98
114
|
},
|
|
99
115
|
icons: {
|
|
100
116
|
variant: 'rounded', // Material Design 3 aesthetic
|
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
|
-
},
|
|
217
|
+
fonts: { ...currentFonts, [action.scope]: action.font },
|
|
235
218
|
},
|
|
236
219
|
};
|
|
237
220
|
}
|
|
238
221
|
|
|
239
|
-
case '
|
|
222
|
+
case 'SET_TYPE_SCALE_OFFSET': {
|
|
240
223
|
const defaultTypography = DEFAULT_CONFIGURATOR_STATE.typography!;
|
|
224
|
+
const currentFonts = state.typography?.fonts ?? defaultTypography.fonts;
|
|
241
225
|
return {
|
|
242
226
|
...state,
|
|
243
227
|
typography: {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
default: state.typography?.fonts.default ?? defaultTypography.fonts.default,
|
|
248
|
-
},
|
|
249
|
-
scale: state.typography?.scale ?? defaultTypography.scale,
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
case 'SET_FONT_DISPLAY': {
|
|
255
|
-
const defaultTypography = DEFAULT_CONFIGURATOR_STATE.typography!;
|
|
256
|
-
return {
|
|
257
|
-
...state,
|
|
258
|
-
typography: {
|
|
259
|
-
fonts: {
|
|
260
|
-
mono: state.typography?.fonts.mono ?? defaultTypography.fonts.mono,
|
|
261
|
-
display: action.font,
|
|
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
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { DesaturationStrength, HueGradingStrength } from 'newtone';
|
|
2
2
|
import type { ColorMode } from '@newtonedev/components';
|
|
3
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';
|
|
9
|
+
|
|
4
10
|
/** Spacing preset options */
|
|
5
11
|
export type SpacingPreset = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
12
|
|
|
@@ -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[];
|
|
@@ -54,14 +52,13 @@ export interface ConfiguratorState {
|
|
|
54
52
|
};
|
|
55
53
|
readonly typography?: {
|
|
56
54
|
readonly fonts: {
|
|
57
|
-
readonly
|
|
58
|
-
readonly display:
|
|
59
|
-
readonly
|
|
60
|
-
|
|
61
|
-
readonly scale: {
|
|
62
|
-
readonly baseSize: number; // px (default: 16)
|
|
63
|
-
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
|
|
64
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)
|
|
65
62
|
};
|
|
66
63
|
readonly icons?: {
|
|
67
64
|
readonly variant: 'outlined' | 'rounded' | 'sharp';
|