@newtonedev/editor 0.1.11 → 0.2.0
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/Editor.d.ts.map +1 -1
- package/dist/components/CodeBlock.d.ts.map +1 -1
- package/dist/components/ConfiguratorPanel.d.ts +6 -3
- package/dist/components/ConfiguratorPanel.d.ts.map +1 -1
- package/dist/components/EditorHeader.d.ts +3 -2
- package/dist/components/EditorHeader.d.ts.map +1 -1
- package/dist/components/EditorShell.d.ts.map +1 -1
- package/dist/components/PresetSelector.d.ts +3 -2
- package/dist/components/PresetSelector.d.ts.map +1 -1
- package/dist/components/PreviewWindow.d.ts.map +1 -1
- package/dist/components/RightSidebar.d.ts.map +1 -1
- package/dist/components/Sidebar.d.ts +8 -1
- package/dist/components/Sidebar.d.ts.map +1 -1
- package/dist/components/TableOfContents.d.ts.map +1 -1
- package/dist/components/sections/ColorsSection.d.ts +6 -3
- package/dist/components/sections/ColorsSection.d.ts.map +1 -1
- package/dist/components/sections/DynamicRangeSection.d.ts +2 -2
- package/dist/components/sections/DynamicRangeSection.d.ts.map +1 -1
- package/dist/components/sections/FontsSection.d.ts +2 -2
- package/dist/components/sections/FontsSection.d.ts.map +1 -1
- package/dist/components/sections/IconsSection.d.ts +2 -2
- package/dist/components/sections/IconsSection.d.ts.map +1 -1
- package/dist/components/sections/OthersSection.d.ts +2 -2
- package/dist/components/sections/OthersSection.d.ts.map +1 -1
- package/dist/components/sections/ScalePlots.d.ts +11 -0
- package/dist/components/sections/ScalePlots.d.ts.map +1 -0
- package/dist/components/sections/index.d.ts +1 -0
- package/dist/components/sections/index.d.ts.map +1 -1
- package/dist/configurator/bridge/toCSS.d.ts +7 -0
- package/dist/configurator/bridge/toCSS.d.ts.map +1 -0
- package/dist/configurator/bridge/toJSON.d.ts +15 -0
- package/dist/configurator/bridge/toJSON.d.ts.map +1 -0
- package/dist/configurator/bridge/toThemeConfig.d.ts +8 -0
- package/dist/configurator/bridge/toThemeConfig.d.ts.map +1 -0
- package/dist/configurator/constants.d.ts +13 -0
- package/dist/configurator/constants.d.ts.map +1 -0
- package/dist/configurator/hex-conversion.d.ts +21 -0
- package/dist/configurator/hex-conversion.d.ts.map +1 -0
- package/dist/configurator/hooks/useConfigurator.d.ts +11 -0
- package/dist/configurator/hooks/useConfigurator.d.ts.map +1 -0
- package/dist/configurator/hooks/usePreviewColors.d.ts +8 -0
- package/dist/configurator/hooks/usePreviewColors.d.ts.map +1 -0
- package/dist/configurator/hooks/useWcagValidation.d.ts +20 -0
- package/dist/configurator/hooks/useWcagValidation.d.ts.map +1 -0
- package/dist/configurator/hue-conversion.d.ts +10 -0
- package/dist/configurator/hue-conversion.d.ts.map +1 -0
- package/dist/configurator/state/actions.d.ts +107 -0
- package/dist/configurator/state/actions.d.ts.map +1 -0
- package/dist/configurator/state/defaults.d.ts +7 -0
- package/dist/configurator/state/defaults.d.ts.map +1 -0
- package/dist/configurator/state/reducer.d.ts +19 -0
- package/dist/configurator/state/reducer.d.ts.map +1 -0
- package/dist/configurator/types.d.ts +60 -0
- package/dist/configurator/types.d.ts.map +1 -0
- package/dist/hooks/useEditorState.d.ts +8 -6
- package/dist/hooks/useEditorState.d.ts.map +1 -1
- package/dist/hooks/usePresets.d.ts +7 -6
- package/dist/hooks/usePresets.d.ts.map +1 -1
- package/dist/index.cjs +30380 -828
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30359 -819
- package/dist/index.js.map +1 -1
- package/dist/preview/CategoryView.d.ts.map +1 -1
- package/dist/preview/ComponentDetailView.d.ts.map +1 -1
- package/dist/preview/ComponentRenderer.d.ts.map +1 -1
- package/dist/preview/IconBrowserView.d.ts.map +1 -1
- package/dist/preview/OverviewView.d.ts.map +1 -1
- package/dist/preview/PaletteScaleView.d.ts +11 -0
- package/dist/preview/PaletteScaleView.d.ts.map +1 -0
- package/dist/types.d.ts +4 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/Editor.tsx +43 -19
- package/src/components/CodeBlock.tsx +7 -11
- package/src/components/ConfiguratorPanel.tsx +25 -18
- package/src/components/EditorHeader.tsx +29 -39
- package/src/components/EditorShell.tsx +17 -29
- package/src/components/FontPicker.tsx +7 -7
- package/src/components/PresetSelector.tsx +211 -129
- package/src/components/PreviewWindow.tsx +5 -12
- package/src/components/PrimaryNav.tsx +6 -6
- package/src/components/RightSidebar.tsx +24 -25
- package/src/components/Sidebar.tsx +54 -60
- package/src/components/TableOfContents.tsx +4 -5
- package/src/components/sections/ColorsSection.tsx +118 -147
- package/src/components/sections/DynamicRangeSection.tsx +61 -75
- package/src/components/sections/FontsSection.tsx +17 -28
- package/src/components/sections/IconsSection.tsx +2 -2
- package/src/components/sections/OthersSection.tsx +4 -5
- package/src/components/sections/ScalePlots.tsx +221 -0
- package/src/components/sections/index.ts +1 -0
- package/src/configurator/bridge/toCSS.ts +44 -0
- package/src/configurator/bridge/toJSON.ts +24 -0
- package/src/configurator/bridge/toThemeConfig.ts +114 -0
- package/src/configurator/constants.ts +13 -0
- package/src/configurator/hex-conversion.ts +67 -0
- package/src/configurator/hooks/useConfigurator.ts +33 -0
- package/src/configurator/hooks/usePreviewColors.ts +47 -0
- package/src/configurator/hooks/useWcagValidation.ts +133 -0
- package/src/configurator/hue-conversion.ts +25 -0
- package/src/configurator/state/actions.ts +43 -0
- package/src/configurator/state/defaults.ts +107 -0
- package/src/configurator/state/reducer.ts +399 -0
- package/src/configurator/types.ts +65 -0
- package/src/hooks/useEditorState.ts +25 -11
- package/src/hooks/usePresets.ts +54 -33
- package/src/index.ts +33 -0
- package/src/preview/CategoryView.tsx +8 -11
- package/src/preview/ComponentDetailView.tsx +24 -54
- package/src/preview/ComponentRenderer.tsx +2 -4
- package/src/preview/IconBrowserView.tsx +9 -10
- package/src/preview/OverviewView.tsx +9 -12
- package/src/preview/PaletteScaleView.tsx +122 -0
- package/src/types.ts +4 -3
package/src/hooks/usePresets.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useState, useCallback, useRef } from "react";
|
|
2
|
-
import type { ConfiguratorState } from "
|
|
2
|
+
import type { ConfiguratorState } from "../configurator/types";
|
|
3
3
|
import type { Preset } from "../types";
|
|
4
4
|
|
|
5
5
|
interface UsePresetsOptions {
|
|
6
6
|
readonly initialPresets: readonly Preset[];
|
|
7
7
|
readonly initialActivePresetId: string;
|
|
8
|
-
readonly
|
|
8
|
+
readonly initialDefaultVariantId: string | null;
|
|
9
9
|
readonly defaultState: ConfiguratorState;
|
|
10
10
|
readonly onPresetSwitch: (newState: ConfiguratorState) => void;
|
|
11
11
|
readonly getCurrentState: () => ConfiguratorState;
|
|
@@ -13,14 +13,14 @@ interface UsePresetsOptions {
|
|
|
13
13
|
readonly persistPresets: (params: {
|
|
14
14
|
readonly presets: readonly Preset[];
|
|
15
15
|
readonly activePresetId: string;
|
|
16
|
-
readonly
|
|
16
|
+
readonly defaultVariantId: string | null;
|
|
17
17
|
}) => Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
interface UsePresetsReturn {
|
|
21
21
|
readonly presets: readonly Preset[];
|
|
22
22
|
readonly activePresetId: string;
|
|
23
|
-
readonly
|
|
23
|
+
readonly defaultVariantId: string | null;
|
|
24
24
|
readonly activePreset: Preset;
|
|
25
25
|
readonly switchPreset: (presetId: string) => Promise<void>;
|
|
26
26
|
readonly createPreset: (name: string) => Promise<string>;
|
|
@@ -33,16 +33,17 @@ interface UsePresetsReturn {
|
|
|
33
33
|
readonly updateActivePresetDraftState: (
|
|
34
34
|
state: ConfiguratorState,
|
|
35
35
|
) => readonly Preset[];
|
|
36
|
-
readonly
|
|
36
|
+
readonly publishAllVariants: (
|
|
37
37
|
state: ConfiguratorState,
|
|
38
38
|
) => readonly Preset[];
|
|
39
39
|
readonly revertActivePreset: () => ConfiguratorState | null;
|
|
40
|
+
readonly setDefaultVariant: (presetId: string) => void;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
export function usePresets({
|
|
43
44
|
initialPresets,
|
|
44
45
|
initialActivePresetId,
|
|
45
|
-
|
|
46
|
+
initialDefaultVariantId,
|
|
46
47
|
defaultState,
|
|
47
48
|
onPresetSwitch,
|
|
48
49
|
getCurrentState,
|
|
@@ -51,13 +52,15 @@ export function usePresets({
|
|
|
51
52
|
}: UsePresetsOptions): UsePresetsReturn {
|
|
52
53
|
const [presets, setPresets] = useState<readonly Preset[]>(initialPresets);
|
|
53
54
|
const [activePresetId, setActivePresetId] = useState(initialActivePresetId);
|
|
54
|
-
const [
|
|
55
|
-
|
|
55
|
+
const [defaultVariantId, setDefaultVariantId] = useState<string | null>(
|
|
56
|
+
initialDefaultVariantId,
|
|
56
57
|
);
|
|
57
58
|
const presetsRef = useRef(presets);
|
|
59
|
+
const activePresetIdRef = useRef(activePresetId);
|
|
58
60
|
|
|
59
|
-
// Keep
|
|
61
|
+
// Keep refs in sync
|
|
60
62
|
presetsRef.current = presets;
|
|
63
|
+
activePresetIdRef.current = activePresetId;
|
|
61
64
|
|
|
62
65
|
const activePreset =
|
|
63
66
|
presets.find((p) => p.id === activePresetId) ?? presets[0];
|
|
@@ -92,12 +95,12 @@ export function usePresets({
|
|
|
92
95
|
await persistPresets({
|
|
93
96
|
presets: updatedPresets,
|
|
94
97
|
activePresetId: presetId,
|
|
95
|
-
|
|
98
|
+
defaultVariantId,
|
|
96
99
|
});
|
|
97
100
|
},
|
|
98
101
|
[
|
|
99
102
|
activePresetId,
|
|
100
|
-
|
|
103
|
+
defaultVariantId,
|
|
101
104
|
flushPendingSave,
|
|
102
105
|
getCurrentState,
|
|
103
106
|
onPresetSwitch,
|
|
@@ -120,11 +123,11 @@ export function usePresets({
|
|
|
120
123
|
await persistPresets({
|
|
121
124
|
presets: newPresets,
|
|
122
125
|
activePresetId,
|
|
123
|
-
|
|
126
|
+
defaultVariantId,
|
|
124
127
|
});
|
|
125
128
|
return newPreset.id;
|
|
126
129
|
},
|
|
127
|
-
[defaultState, activePresetId,
|
|
130
|
+
[defaultState, activePresetId, defaultVariantId, persistPresets],
|
|
128
131
|
);
|
|
129
132
|
|
|
130
133
|
// --- Duplicate preset ---
|
|
@@ -136,7 +139,7 @@ export function usePresets({
|
|
|
136
139
|
const newPreset: Preset = {
|
|
137
140
|
id: crypto.randomUUID(),
|
|
138
141
|
name: newName,
|
|
139
|
-
draft_state: source.draft_state,
|
|
142
|
+
draft_state: structuredClone(source.draft_state),
|
|
140
143
|
published_state: null,
|
|
141
144
|
};
|
|
142
145
|
const newPresets = [...presetsRef.current, newPreset];
|
|
@@ -145,11 +148,11 @@ export function usePresets({
|
|
|
145
148
|
await persistPresets({
|
|
146
149
|
presets: newPresets,
|
|
147
150
|
activePresetId,
|
|
148
|
-
|
|
151
|
+
defaultVariantId,
|
|
149
152
|
});
|
|
150
153
|
return newPreset.id;
|
|
151
154
|
},
|
|
152
|
-
[activePresetId,
|
|
155
|
+
[activePresetId, defaultVariantId, persistPresets],
|
|
153
156
|
);
|
|
154
157
|
|
|
155
158
|
// --- Rename preset ---
|
|
@@ -164,10 +167,10 @@ export function usePresets({
|
|
|
164
167
|
persistPresets({
|
|
165
168
|
presets: newPresets,
|
|
166
169
|
activePresetId,
|
|
167
|
-
|
|
170
|
+
defaultVariantId,
|
|
168
171
|
});
|
|
169
172
|
},
|
|
170
|
-
[activePresetId,
|
|
173
|
+
[activePresetId, defaultVariantId, persistPresets],
|
|
171
174
|
);
|
|
172
175
|
|
|
173
176
|
// --- Delete preset ---
|
|
@@ -177,7 +180,7 @@ export function usePresets({
|
|
|
177
180
|
|
|
178
181
|
const newPresets = presetsRef.current.filter((p) => p.id !== presetId);
|
|
179
182
|
let newActiveId = activePresetId;
|
|
180
|
-
let newPublishedId =
|
|
183
|
+
let newPublishedId = defaultVariantId;
|
|
181
184
|
|
|
182
185
|
// If deleting active preset, switch to first remaining
|
|
183
186
|
if (presetId === activePresetId) {
|
|
@@ -186,50 +189,54 @@ export function usePresets({
|
|
|
186
189
|
}
|
|
187
190
|
|
|
188
191
|
// If deleting published preset, clear it
|
|
189
|
-
if (presetId ===
|
|
192
|
+
if (presetId === defaultVariantId) {
|
|
190
193
|
newPublishedId = null;
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
setPresets(newPresets);
|
|
194
197
|
presetsRef.current = newPresets;
|
|
195
198
|
setActivePresetId(newActiveId);
|
|
196
|
-
|
|
199
|
+
setDefaultVariantId(newPublishedId);
|
|
197
200
|
await persistPresets({
|
|
198
201
|
presets: newPresets,
|
|
199
202
|
activePresetId: newActiveId,
|
|
200
|
-
|
|
203
|
+
defaultVariantId: newPublishedId,
|
|
201
204
|
});
|
|
202
205
|
},
|
|
203
|
-
[activePresetId,
|
|
206
|
+
[activePresetId, defaultVariantId, onPresetSwitch, persistPresets],
|
|
204
207
|
);
|
|
205
208
|
|
|
206
209
|
// --- Update active preset's draft_state (called during auto-save) ---
|
|
210
|
+
// Uses ref instead of state to avoid stale closures in debounced saves
|
|
207
211
|
const updateActivePresetDraftState = useCallback(
|
|
208
212
|
(state: ConfiguratorState): readonly Preset[] => {
|
|
213
|
+
const currentId = activePresetIdRef.current;
|
|
209
214
|
const newPresets = presetsRef.current.map((p) =>
|
|
210
|
-
p.id ===
|
|
215
|
+
p.id === currentId ? { ...p, draft_state: state } : p,
|
|
211
216
|
);
|
|
212
217
|
setPresets(newPresets);
|
|
213
218
|
presetsRef.current = newPresets;
|
|
214
219
|
return newPresets;
|
|
215
220
|
},
|
|
216
|
-
[
|
|
221
|
+
[],
|
|
217
222
|
);
|
|
218
223
|
|
|
219
|
-
// --- Publish
|
|
220
|
-
const
|
|
224
|
+
// --- Publish all presets as variants ---
|
|
225
|
+
const publishAllVariants = useCallback(
|
|
221
226
|
(state: ConfiguratorState): readonly Preset[] => {
|
|
227
|
+
const currentId = activePresetIdRef.current;
|
|
222
228
|
const newPresets = presetsRef.current.map((p) =>
|
|
223
|
-
p.id ===
|
|
229
|
+
p.id === currentId
|
|
224
230
|
? { ...p, draft_state: state, published_state: state }
|
|
225
|
-
: p,
|
|
231
|
+
: { ...p, published_state: p.draft_state },
|
|
226
232
|
);
|
|
227
233
|
setPresets(newPresets);
|
|
228
234
|
presetsRef.current = newPresets;
|
|
229
|
-
|
|
235
|
+
// Set default variant to current active if not already set
|
|
236
|
+
if (!defaultVariantId) setDefaultVariantId(currentId);
|
|
230
237
|
return newPresets;
|
|
231
238
|
},
|
|
232
|
-
[
|
|
239
|
+
[defaultVariantId],
|
|
233
240
|
);
|
|
234
241
|
|
|
235
242
|
// --- Revert active preset to its published_state ---
|
|
@@ -237,10 +244,23 @@ export function usePresets({
|
|
|
237
244
|
return activePreset.published_state;
|
|
238
245
|
}, [activePreset]);
|
|
239
246
|
|
|
247
|
+
// --- Set default variant ---
|
|
248
|
+
const setDefaultVariant = useCallback(
|
|
249
|
+
(presetId: string) => {
|
|
250
|
+
setDefaultVariantId(presetId);
|
|
251
|
+
persistPresets({
|
|
252
|
+
presets: presetsRef.current,
|
|
253
|
+
activePresetId: activePresetIdRef.current,
|
|
254
|
+
defaultVariantId: presetId,
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
[persistPresets],
|
|
258
|
+
);
|
|
259
|
+
|
|
240
260
|
return {
|
|
241
261
|
presets,
|
|
242
262
|
activePresetId,
|
|
243
|
-
|
|
263
|
+
defaultVariantId,
|
|
244
264
|
activePreset,
|
|
245
265
|
switchPreset,
|
|
246
266
|
createPreset,
|
|
@@ -248,7 +268,8 @@ export function usePresets({
|
|
|
248
268
|
deletePreset,
|
|
249
269
|
duplicatePreset,
|
|
250
270
|
updateActivePresetDraftState,
|
|
251
|
-
|
|
271
|
+
publishAllVariants,
|
|
252
272
|
revertActivePreset,
|
|
273
|
+
setDefaultVariant,
|
|
253
274
|
};
|
|
254
275
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
// ===== Configurator exports (formerly @newtonedev/configurator) =====
|
|
2
|
+
|
|
3
|
+
// State types
|
|
4
|
+
export type { ConfiguratorState, PaletteState, SpacingPreset, FontConfig, FontScope, FontSlotConfig } from './configurator/types';
|
|
5
|
+
export type { ConfiguratorAction } from './configurator/state/actions';
|
|
6
|
+
|
|
7
|
+
// Bridge functions (for headless usage)
|
|
8
|
+
export { toThemeConfig } from './configurator/bridge/toThemeConfig';
|
|
9
|
+
export { toCSS } from './configurator/bridge/toCSS';
|
|
10
|
+
export { toJSON } from './configurator/bridge/toJSON';
|
|
11
|
+
export type { ConfiguratorExport } from './configurator/bridge/toJSON';
|
|
12
|
+
|
|
13
|
+
// Hue conversion utilities
|
|
14
|
+
export { traditionalHueToOklch } from './configurator/hue-conversion';
|
|
15
|
+
export { hexToPaletteParams } from './configurator/hex-conversion';
|
|
16
|
+
export type { HexPaletteParams } from './configurator/hex-conversion';
|
|
17
|
+
|
|
18
|
+
// Defaults & migration
|
|
19
|
+
export { DEFAULT_CONFIGURATOR_STATE } from './configurator/state/defaults';
|
|
20
|
+
export { migratePaletteState, migrateConfiguratorState } from './configurator/state/reducer';
|
|
21
|
+
|
|
22
|
+
// Constants
|
|
23
|
+
export { SEMANTIC_HUE_RANGES } from './configurator/constants';
|
|
24
|
+
|
|
25
|
+
// Hooks (for custom configurator UIs)
|
|
26
|
+
export { useConfigurator } from './configurator/hooks/useConfigurator';
|
|
27
|
+
export type { UseConfiguratorResult } from './configurator/hooks/useConfigurator';
|
|
28
|
+
export { usePreviewColors } from './configurator/hooks/usePreviewColors';
|
|
29
|
+
export { useWcagValidation } from './configurator/hooks/useWcagValidation';
|
|
30
|
+
export type { WcagValidation } from './configurator/hooks/useWcagValidation';
|
|
31
|
+
|
|
32
|
+
// ===== Editor exports =====
|
|
33
|
+
|
|
1
34
|
// Types
|
|
2
35
|
export type {
|
|
3
36
|
Preset,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { useTokens } from "@newtonedev/components";
|
|
3
|
-
import { srgbToHex } from "newtone";
|
|
4
3
|
import { getCategory, getComponentsByCategory } from "@newtonedev/components";
|
|
5
4
|
import { ComponentRenderer } from "./ComponentRenderer";
|
|
6
5
|
|
|
@@ -26,7 +25,7 @@ export function CategoryView({
|
|
|
26
25
|
style={{
|
|
27
26
|
fontSize: 22,
|
|
28
27
|
fontWeight: 700,
|
|
29
|
-
color:
|
|
28
|
+
color: tokens.colors.primary.main.fontPrimary,
|
|
30
29
|
margin: 0,
|
|
31
30
|
marginBottom: 4,
|
|
32
31
|
}}
|
|
@@ -36,7 +35,7 @@ export function CategoryView({
|
|
|
36
35
|
<p
|
|
37
36
|
style={{
|
|
38
37
|
fontSize: 14,
|
|
39
|
-
color:
|
|
38
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
40
39
|
margin: 0,
|
|
41
40
|
marginBottom: 32,
|
|
42
41
|
}}
|
|
@@ -65,10 +64,8 @@ export function CategoryView({
|
|
|
65
64
|
flexDirection: "column",
|
|
66
65
|
padding: 24,
|
|
67
66
|
borderRadius: 12,
|
|
68
|
-
border: `1px solid ${
|
|
69
|
-
|
|
70
|
-
)}`,
|
|
71
|
-
backgroundColor: srgbToHex(tokens.backgroundElevated.srgb),
|
|
67
|
+
border: `1px solid ${isHovered ? tokens.colors.secondary.emphasis.fontPrimary : tokens.colors.primary.main.fontDisabled}`,
|
|
68
|
+
backgroundColor: tokens.colors.primary.main.divider,
|
|
72
69
|
cursor: "pointer",
|
|
73
70
|
textAlign: "left",
|
|
74
71
|
transform: isHovered ? "translateY(-1px)" : "none",
|
|
@@ -87,7 +84,7 @@ export function CategoryView({
|
|
|
87
84
|
padding: 20,
|
|
88
85
|
marginBottom: 16,
|
|
89
86
|
borderRadius: 8,
|
|
90
|
-
backgroundColor:
|
|
87
|
+
backgroundColor: tokens.colors.primary.main.background,
|
|
91
88
|
minHeight: 60,
|
|
92
89
|
}}
|
|
93
90
|
>
|
|
@@ -100,7 +97,7 @@ export function CategoryView({
|
|
|
100
97
|
style={{
|
|
101
98
|
fontSize: 15,
|
|
102
99
|
fontWeight: 600,
|
|
103
|
-
color:
|
|
100
|
+
color: tokens.colors.primary.main.fontPrimary,
|
|
104
101
|
marginBottom: 4,
|
|
105
102
|
}}
|
|
106
103
|
>
|
|
@@ -109,7 +106,7 @@ export function CategoryView({
|
|
|
109
106
|
<span
|
|
110
107
|
style={{
|
|
111
108
|
fontSize: 13,
|
|
112
|
-
color:
|
|
109
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
113
110
|
lineHeight: 1.4,
|
|
114
111
|
}}
|
|
115
112
|
>
|
|
@@ -118,7 +115,7 @@ export function CategoryView({
|
|
|
118
115
|
<span
|
|
119
116
|
style={{
|
|
120
117
|
fontSize: 12,
|
|
121
|
-
color:
|
|
118
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
122
119
|
marginTop: 8,
|
|
123
120
|
}}
|
|
124
121
|
>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useState, useCallback, useMemo, useRef, useEffect } from "react";
|
|
2
|
-
import { useTokens, useNewtoneTheme, NewtoneProvider } from "@newtonedev/components";
|
|
3
|
-
import { srgbToHex } from "newtone";
|
|
2
|
+
import { useTokens, useNewtoneTheme, NewtoneProvider, Text } from "@newtonedev/components";
|
|
4
3
|
import { getComponent } from "@newtonedev/components";
|
|
5
4
|
import type { TextRole, BreakpointKey, TextSize, RoleScales } from "@newtonedev/fonts";
|
|
6
5
|
import { ROLE_DEFAULT_WEIGHTS, BREAKPOINT_ROLE_SCALE, scaleRoleStep, resolveResponsiveSize } from "@newtonedev/fonts";
|
|
@@ -331,26 +330,12 @@ export function ComponentDetailView({
|
|
|
331
330
|
}}
|
|
332
331
|
>
|
|
333
332
|
<div style={{ padding: "0 32px", marginBottom: 24 }}>
|
|
334
|
-
<
|
|
335
|
-
style={{
|
|
336
|
-
fontSize: 22,
|
|
337
|
-
fontWeight: 700,
|
|
338
|
-
color: srgbToHex(tokens.textPrimary.srgb),
|
|
339
|
-
margin: 0,
|
|
340
|
-
marginBottom: 4,
|
|
341
|
-
}}
|
|
342
|
-
>
|
|
333
|
+
<Text size="lg" weight="bold" style={{ marginBottom: 4 }}>
|
|
343
334
|
{component.name}
|
|
344
|
-
</
|
|
345
|
-
<
|
|
346
|
-
style={{
|
|
347
|
-
fontSize: 14,
|
|
348
|
-
color: srgbToHex(tokens.textSecondary.srgb),
|
|
349
|
-
margin: 0,
|
|
350
|
-
}}
|
|
351
|
-
>
|
|
335
|
+
</Text>
|
|
336
|
+
<Text size="sm" color="tertiary">
|
|
352
337
|
{component.description}
|
|
353
|
-
</
|
|
338
|
+
</Text>
|
|
354
339
|
</div>
|
|
355
340
|
<IconBrowserView
|
|
356
341
|
selectedIconName={(propOverrides.name as string) ?? "add"}
|
|
@@ -360,32 +345,17 @@ export function ComponentDetailView({
|
|
|
360
345
|
);
|
|
361
346
|
}
|
|
362
347
|
|
|
363
|
-
const interactiveColor =
|
|
348
|
+
const interactiveColor = tokens.colors.secondary.emphasis.fontPrimary;
|
|
364
349
|
const isTextComponent = componentId === "text";
|
|
365
350
|
|
|
366
351
|
return (
|
|
367
352
|
<div style={{ padding: 32 }}>
|
|
368
|
-
<
|
|
369
|
-
style={{
|
|
370
|
-
fontSize: 22,
|
|
371
|
-
fontWeight: 700,
|
|
372
|
-
color: srgbToHex(tokens.textPrimary.srgb),
|
|
373
|
-
margin: 0,
|
|
374
|
-
marginBottom: 4,
|
|
375
|
-
}}
|
|
376
|
-
>
|
|
353
|
+
<Text size="lg" weight="bold" style={{ marginBottom: 4 }}>
|
|
377
354
|
{component.name}
|
|
378
|
-
</
|
|
379
|
-
<
|
|
380
|
-
style={{
|
|
381
|
-
fontSize: 14,
|
|
382
|
-
color: srgbToHex(tokens.textSecondary.srgb),
|
|
383
|
-
margin: 0,
|
|
384
|
-
marginBottom: isTextComponent ? 16 : 32,
|
|
385
|
-
}}
|
|
386
|
-
>
|
|
355
|
+
</Text>
|
|
356
|
+
<Text size="sm" color="tertiary" style={{ marginBottom: isTextComponent ? 16 : 32 }}>
|
|
387
357
|
{component.description}
|
|
388
|
-
</
|
|
358
|
+
</Text>
|
|
389
359
|
|
|
390
360
|
{isTextComponent && (
|
|
391
361
|
<div style={{ display: "flex", flexDirection: "column", gap: 12, marginBottom: 16 }}>
|
|
@@ -399,9 +369,9 @@ export function ComponentDetailView({
|
|
|
399
369
|
padding: "8px 12px",
|
|
400
370
|
fontSize: 14,
|
|
401
371
|
fontFamily: "'SF Mono', 'Fira Code', Menlo, monospace",
|
|
402
|
-
color:
|
|
403
|
-
backgroundColor:
|
|
404
|
-
border: `1px solid ${
|
|
372
|
+
color: tokens.colors.primary.main.fontPrimary,
|
|
373
|
+
backgroundColor: tokens.colors.primary.main.actionEnabled,
|
|
374
|
+
border: `1px solid ${tokens.colors.primary.main.divider}`,
|
|
405
375
|
borderRadius: 8,
|
|
406
376
|
boxSizing: "border-box",
|
|
407
377
|
outline: "none",
|
|
@@ -418,9 +388,9 @@ export function ComponentDetailView({
|
|
|
418
388
|
padding: "4px 10px",
|
|
419
389
|
fontSize: 11,
|
|
420
390
|
fontWeight: isActive ? 600 : 400,
|
|
421
|
-
color: isActive ? interactiveColor :
|
|
391
|
+
color: isActive ? interactiveColor : tokens.colors.primary.main.fontTertiary,
|
|
422
392
|
backgroundColor: isActive ? `${interactiveColor}18` : "transparent",
|
|
423
|
-
border: `1px solid ${isActive ? interactiveColor :
|
|
393
|
+
border: `1px solid ${isActive ? interactiveColor : tokens.colors.primary.main.divider}`,
|
|
424
394
|
borderRadius: 4,
|
|
425
395
|
cursor: "pointer",
|
|
426
396
|
textTransform: "uppercase",
|
|
@@ -446,7 +416,7 @@ export function ComponentDetailView({
|
|
|
446
416
|
? interactiveColor
|
|
447
417
|
: isHovered
|
|
448
418
|
? `${interactiveColor}66`
|
|
449
|
-
:
|
|
419
|
+
: tokens.colors.primary.main.divider;
|
|
450
420
|
|
|
451
421
|
// Weight control for text roles
|
|
452
422
|
const showWeightControl =
|
|
@@ -483,7 +453,7 @@ export function ComponentDetailView({
|
|
|
483
453
|
onChange={(w) =>
|
|
484
454
|
onRoleWeightChange(role as TextRole, w)
|
|
485
455
|
}
|
|
486
|
-
textColor={
|
|
456
|
+
textColor={tokens.colors.primary.main.fontTertiary}
|
|
487
457
|
accentColor={interactiveColor}
|
|
488
458
|
/>
|
|
489
459
|
);
|
|
@@ -504,7 +474,7 @@ export function ComponentDetailView({
|
|
|
504
474
|
padding: "12px 16px",
|
|
505
475
|
borderRadius: 12,
|
|
506
476
|
border: `2px solid ${borderColor}`,
|
|
507
|
-
backgroundColor:
|
|
477
|
+
backgroundColor: tokens.colors.primary.main.actionEnabled,
|
|
508
478
|
cursor: "pointer",
|
|
509
479
|
textAlign: "left",
|
|
510
480
|
transition: "border-color 150ms ease",
|
|
@@ -516,7 +486,7 @@ export function ComponentDetailView({
|
|
|
516
486
|
fontWeight: 500,
|
|
517
487
|
color: isSelected
|
|
518
488
|
? interactiveColor
|
|
519
|
-
:
|
|
489
|
+
: tokens.colors.primary.main.fontTertiary,
|
|
520
490
|
width: 88,
|
|
521
491
|
flexShrink: 0,
|
|
522
492
|
textTransform: "uppercase",
|
|
@@ -542,7 +512,7 @@ export function ComponentDetailView({
|
|
|
542
512
|
ROLE_DEFAULT_WEIGHTS[role as TextRole] ??
|
|
543
513
|
400
|
|
544
514
|
}
|
|
545
|
-
textColor={
|
|
515
|
+
textColor={tokens.colors.primary.main.fontTertiary}
|
|
546
516
|
accentColor={interactiveColor}
|
|
547
517
|
previewText={previewText}
|
|
548
518
|
/>
|
|
@@ -570,7 +540,7 @@ export function ComponentDetailView({
|
|
|
570
540
|
? interactiveColor
|
|
571
541
|
: isHovered
|
|
572
542
|
? `${interactiveColor}66`
|
|
573
|
-
:
|
|
543
|
+
: tokens.colors.primary.main.divider;
|
|
574
544
|
|
|
575
545
|
return (
|
|
576
546
|
<button
|
|
@@ -585,7 +555,7 @@ export function ComponentDetailView({
|
|
|
585
555
|
padding: 16,
|
|
586
556
|
borderRadius: 12,
|
|
587
557
|
border: `2px solid ${borderColor}`,
|
|
588
|
-
backgroundColor:
|
|
558
|
+
backgroundColor: tokens.colors.primary.main.actionEnabled,
|
|
589
559
|
cursor: "pointer",
|
|
590
560
|
textAlign: "left",
|
|
591
561
|
transition: "border-color 150ms ease",
|
|
@@ -599,7 +569,7 @@ export function ComponentDetailView({
|
|
|
599
569
|
padding: 20,
|
|
600
570
|
marginBottom: 12,
|
|
601
571
|
borderRadius: 8,
|
|
602
|
-
backgroundColor:
|
|
572
|
+
backgroundColor: tokens.colors.primary.main.background,
|
|
603
573
|
minHeight: 56,
|
|
604
574
|
}}
|
|
605
575
|
>
|
|
@@ -614,7 +584,7 @@ export function ComponentDetailView({
|
|
|
614
584
|
fontWeight: isSelected ? 600 : 500,
|
|
615
585
|
color: isSelected
|
|
616
586
|
? interactiveColor
|
|
617
|
-
:
|
|
587
|
+
: tokens.colors.primary.main.fontPrimary,
|
|
618
588
|
}}
|
|
619
589
|
>
|
|
620
590
|
{variant.label}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
Wrapper,
|
|
14
14
|
useTokens,
|
|
15
15
|
} from "@newtonedev/components";
|
|
16
|
-
import { srgbToHex } from "newtone";
|
|
17
16
|
|
|
18
17
|
interface ComponentRendererProps {
|
|
19
18
|
readonly componentId: string;
|
|
@@ -57,7 +56,7 @@ function CardPreview(props: AnyProps) {
|
|
|
57
56
|
style={{
|
|
58
57
|
fontSize: 14,
|
|
59
58
|
fontWeight: 600,
|
|
60
|
-
color:
|
|
59
|
+
color: tokens.colors.primary.main.fontPrimary,
|
|
61
60
|
marginBottom: 8,
|
|
62
61
|
}}
|
|
63
62
|
>
|
|
@@ -66,7 +65,7 @@ function CardPreview(props: AnyProps) {
|
|
|
66
65
|
<div
|
|
67
66
|
style={{
|
|
68
67
|
fontSize: 13,
|
|
69
|
-
color:
|
|
68
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
70
69
|
lineHeight: 1.4,
|
|
71
70
|
}}
|
|
72
71
|
>
|
|
@@ -103,7 +102,6 @@ export function ComponentRenderer({ componentId, props, previewText }: Component
|
|
|
103
102
|
return (
|
|
104
103
|
<Button
|
|
105
104
|
variant={props.variant as AnyProps}
|
|
106
|
-
semantic={props.semantic as AnyProps}
|
|
107
105
|
size={props.size as AnyProps}
|
|
108
106
|
icon={icon}
|
|
109
107
|
iconPosition={props.iconPosition as AnyProps}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useEffect, useMemo } from "react";
|
|
2
2
|
import { Icon, useTokens, ICON_CATALOG } from "@newtonedev/components";
|
|
3
|
-
import { srgbToHex } from "newtone";
|
|
4
3
|
|
|
5
4
|
interface IconBrowserViewProps {
|
|
6
5
|
readonly selectedIconName: string;
|
|
@@ -38,7 +37,7 @@ export function IconBrowserView({
|
|
|
38
37
|
}
|
|
39
38
|
}, [selectedIconName]);
|
|
40
39
|
|
|
41
|
-
const accentColor =
|
|
40
|
+
const accentColor = tokens.colors.secondary.emphasis.fontPrimary;
|
|
42
41
|
|
|
43
42
|
return (
|
|
44
43
|
<div
|
|
@@ -55,7 +54,7 @@ export function IconBrowserView({
|
|
|
55
54
|
<Icon
|
|
56
55
|
name="search"
|
|
57
56
|
size={18}
|
|
58
|
-
color={
|
|
57
|
+
color={tokens.colors.primary.main.fontDisabled}
|
|
59
58
|
style={{
|
|
60
59
|
position: "absolute",
|
|
61
60
|
left: 10,
|
|
@@ -72,9 +71,9 @@ export function IconBrowserView({
|
|
|
72
71
|
width: "100%",
|
|
73
72
|
padding: "8px 12px 8px 34px",
|
|
74
73
|
borderRadius: 8,
|
|
75
|
-
border: `1px solid ${
|
|
76
|
-
backgroundColor:
|
|
77
|
-
color:
|
|
74
|
+
border: `1px solid ${tokens.colors.primary.main.fontDisabled}`,
|
|
75
|
+
backgroundColor: tokens.colors.primary.main.divider,
|
|
76
|
+
color: tokens.colors.primary.main.fontPrimary,
|
|
78
77
|
fontSize: 13,
|
|
79
78
|
boxSizing: "border-box",
|
|
80
79
|
outline: "none",
|
|
@@ -96,7 +95,7 @@ export function IconBrowserView({
|
|
|
96
95
|
<p
|
|
97
96
|
style={{
|
|
98
97
|
fontSize: 13,
|
|
99
|
-
color:
|
|
98
|
+
color: tokens.colors.primary.main.fontDisabled,
|
|
100
99
|
textAlign: "center",
|
|
101
100
|
marginTop: 32,
|
|
102
101
|
}}
|
|
@@ -111,7 +110,7 @@ export function IconBrowserView({
|
|
|
111
110
|
style={{
|
|
112
111
|
fontSize: 12,
|
|
113
112
|
fontWeight: 600,
|
|
114
|
-
color:
|
|
113
|
+
color: tokens.colors.primary.main.fontTertiary,
|
|
115
114
|
textTransform: "uppercase",
|
|
116
115
|
letterSpacing: 0.5,
|
|
117
116
|
margin: "0 0 8px",
|
|
@@ -153,7 +152,7 @@ export function IconBrowserView({
|
|
|
153
152
|
borderRadius: 8,
|
|
154
153
|
border: `2px solid ${borderColor}`,
|
|
155
154
|
backgroundColor: isSelected
|
|
156
|
-
?
|
|
155
|
+
? tokens.colors.primary.main.divider
|
|
157
156
|
: "transparent",
|
|
158
157
|
cursor: "pointer",
|
|
159
158
|
transition: "border-color 150ms ease",
|
|
@@ -165,7 +164,7 @@ export function IconBrowserView({
|
|
|
165
164
|
fontSize: 10,
|
|
166
165
|
color: isSelected
|
|
167
166
|
? accentColor
|
|
168
|
-
:
|
|
167
|
+
: tokens.colors.primary.main.fontDisabled,
|
|
169
168
|
fontWeight: isSelected ? 600 : 400,
|
|
170
169
|
maxWidth: "100%",
|
|
171
170
|
overflow: "hidden",
|