@newtonedev/editor 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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { Preset, SaveStatus, ThemeName, PreviewView, SidebarSelection, EditorPersistence, EditorHeaderSlots, EditorProps, } from "./types";
1
+ export type { Preset, SaveStatus, PreviewView, SidebarSelection, EditorPersistence, EditorHeaderSlots, EditorProps, } from "./types";
2
2
  export { findPreset, updatePresetInArray, presetHasUnpublishedChanges, } from "./utils/presets";
3
3
  export { useHover } from "./hooks/useHover";
4
4
  export { usePresets } from "./hooks/usePresets";
@@ -13,7 +13,6 @@ export { PreviewWindow } from "./components/PreviewWindow";
13
13
  export { RightSidebar } from "./components/RightSidebar";
14
14
  export { Sidebar } from "./components/Sidebar";
15
15
  export { TableOfContents } from "./components/TableOfContents";
16
- export { ThemeBar } from "./components/ThemeBar";
17
16
  export { ColorsSection, FontsSection, IconsSection, OthersSection, } from "./components/sections";
18
17
  export { ComponentRenderer } from "./preview/ComponentRenderer";
19
18
  export { OverviewView } from "./preview/OverviewView";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,GACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,MAAM,EACN,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,GACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EACL,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useState, useCallback, useRef, useMemo, useEffect } from 'react';
2
- import { getComponent, useTokens, ColorScaleSlider, TextInput, HueSlider, Slider, Select, Toggle, GOOGLE_FONTS, SYSTEM_FONTS, Button, CATEGORIES, getComponentsByCategory, getCategory, generateComponentCode, NewtoneProvider, Card } from '@newtonedev/components';
2
+ import { getComponent, useTokens, ColorScaleSlider, TextInput, HueSlider, Slider, Select, Toggle, GOOGLE_FONTS, SYSTEM_FONTS, Button, CATEGORIES, getComponentsByCategory, Icon, Text, getCategory, generateComponentCode, NewtoneProvider, Wrapper, Frame, Card } from '@newtonedev/components';
3
3
  import { useConfigurator, usePreviewColors, SEMANTIC_HUE_RANGES, useWcagValidation, traditionalHueToOklch, hexToPaletteParams } from '@newtonedev/configurator';
4
- import { srgbToHex } from 'newtone';
4
+ import { srgbToHex, resolveLightness, findMaxChromaInGamut, clampSrgb, oklchToSrgb, HUE_GRADING_STRENGTH_HARD, HUE_GRADING_STRENGTH_MEDIUM, HUE_GRADING_STRENGTH_LOW, HUE_GRADING_EASING_POWER } from 'newtone';
5
5
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
6
 
7
7
  // src/utils/presets.ts
@@ -214,9 +214,6 @@ function useEditorState({
214
214
  const [colorMode, setColorMode] = useState(
215
215
  initialState.preview.mode
216
216
  );
217
- const [activeTheme, setActiveTheme] = useState(
218
- initialState.preview.theme || "neutral"
219
- );
220
217
  const [previewView, setPreviewView] = useState(
221
218
  initialPreviewView ?? { kind: "overview" }
222
219
  );
@@ -378,13 +375,6 @@ function useEditorState({
378
375
  setIsPublished(false);
379
376
  scheduleSave();
380
377
  }, [configuratorState, scheduleSave]);
381
- const handleThemeChange = useCallback(
382
- (theme) => {
383
- setActiveTheme(theme);
384
- dispatch({ type: "SET_PREVIEW_THEME", theme });
385
- },
386
- [dispatch]
387
- );
388
378
  const handleColorModeChange = useCallback(
389
379
  (mode) => {
390
380
  setColorMode(mode);
@@ -446,10 +436,8 @@ function useEditorState({
446
436
  // Preview
447
437
  previewView,
448
438
  colorMode,
449
- activeTheme,
450
439
  handlePreviewNavigate,
451
440
  handleSelectVariant,
452
- handleThemeChange,
453
441
  handleColorModeChange,
454
442
  // Sidebar
455
443
  sidebarSelection,
@@ -489,7 +477,7 @@ function EditorShell({
489
477
  {
490
478
  style: {
491
479
  display: "flex",
492
- height: "100vh",
480
+ height: "100%",
493
481
  overflow: "hidden",
494
482
  backgroundColor: srgbToHex(tokens.background.srgb)
495
483
  },
@@ -501,7 +489,7 @@ function EditorShell({
501
489
  flex: 1,
502
490
  display: "flex",
503
491
  flexDirection: "column",
504
- height: "100vh",
492
+ height: "100%",
505
493
  overflow: "hidden",
506
494
  minWidth: 0
507
495
  },
@@ -564,7 +552,7 @@ function ColorsSection({
564
552
  const palette = state.palettes[activePaletteIndex];
565
553
  const hueRange = SEMANTIC_HUE_RANGES[activePaletteIndex];
566
554
  const isNeutral = activePaletteIndex === 0;
567
- const activeColor = srgbToHex(tokens.interactive.srgb);
555
+ const activeColor = srgbToHex(tokens.accent.fill.srgb);
568
556
  const borderColor = srgbToHex(tokens.border.srgb);
569
557
  const effectiveKeyColor = colorMode === "dark" ? palette.keyColorDark : palette.keyColor;
570
558
  const setKeyColorAction = colorMode === "dark" ? "SET_PALETTE_KEY_COLOR_DARK" : "SET_PALETTE_KEY_COLOR";
@@ -796,7 +784,7 @@ function ColorsSection({
796
784
  style: {
797
785
  fontSize: 12,
798
786
  fontWeight: 500,
799
- color: srgbToHex(tokens.error.srgb)
787
+ color: srgbToHex(tokens.error.fill.srgb)
800
788
  },
801
789
  children: hexError
802
790
  }
@@ -955,7 +943,7 @@ function DualRangeSlider({
955
943
  const tokens = useTokens();
956
944
  const trackRef = useRef(null);
957
945
  const [activeThumb, setActiveThumb] = useState(null);
958
- const interactiveColor = srgbToHex(tokens.interactive.srgb);
946
+ const interactiveColor = srgbToHex(tokens.accent.fill.srgb);
959
947
  const borderColor = srgbToHex(tokens.border.srgb);
960
948
  const wDisplay = internalToDisplay(whitesValue);
961
949
  const bDisplay = internalToDisplay(blacksValue);
@@ -1126,6 +1114,154 @@ function RangeInput({ display, onCommit, toInternal }) {
1126
1114
  }
1127
1115
  );
1128
1116
  }
1117
+ var GRAPH_HEIGHT = 80;
1118
+ var GRAPH_COLS = 256;
1119
+ var GRAPH_ROWS = 64;
1120
+ function strengthToFactor(strength) {
1121
+ switch (strength) {
1122
+ case "none":
1123
+ return 0;
1124
+ case "low":
1125
+ return HUE_GRADING_STRENGTH_LOW;
1126
+ case "medium":
1127
+ return HUE_GRADING_STRENGTH_MEDIUM;
1128
+ case "hard":
1129
+ return HUE_GRADING_STRENGTH_HARD;
1130
+ }
1131
+ }
1132
+ function blendHues(lightHue, darkHue, wLight, wDark) {
1133
+ const totalW = wLight + wDark;
1134
+ if (totalW === 0) return 0;
1135
+ const delta = ((darkHue - lightHue + 180) % 360 + 360) % 360 - 180;
1136
+ const t = wDark / totalW;
1137
+ const result = lightHue + delta * t;
1138
+ return (result % 360 + 360) % 360;
1139
+ }
1140
+ function computeGraphData(state) {
1141
+ const { dynamicRange, globalHueGrading } = state;
1142
+ const lightActive = globalHueGrading.light.strength !== "none";
1143
+ const darkActive = globalHueGrading.dark.strength !== "none";
1144
+ const lightOklchHue = traditionalHueToOklch(globalHueGrading.light.hue);
1145
+ const darkOklchHue = traditionalHueToOklch(globalHueGrading.dark.hue);
1146
+ const lightFactor = strengthToFactor(globalHueGrading.light.strength);
1147
+ const darkFactor = strengthToFactor(globalHueGrading.dark.strength);
1148
+ const buffer = new Uint8ClampedArray(GRAPH_COLS * GRAPH_ROWS * 4);
1149
+ for (let col = 0; col < GRAPH_COLS; col++) {
1150
+ const nv = 1 - col / (GRAPH_COLS - 1);
1151
+ const L = resolveLightness(dynamicRange, nv);
1152
+ const wLight = lightActive ? Math.pow(nv, HUE_GRADING_EASING_POWER) : 0;
1153
+ const wDark = darkActive ? Math.pow(1 - nv, HUE_GRADING_EASING_POWER) : 0;
1154
+ const totalW = wLight + wDark;
1155
+ let topHue;
1156
+ let topChroma;
1157
+ if (totalW === 0) {
1158
+ topHue = 0;
1159
+ topChroma = 0;
1160
+ } else {
1161
+ if (!lightActive) {
1162
+ topHue = darkOklchHue;
1163
+ } else if (!darkActive) {
1164
+ topHue = lightOklchHue;
1165
+ } else {
1166
+ topHue = blendHues(lightOklchHue, darkOklchHue, wLight, wDark);
1167
+ }
1168
+ topChroma = findMaxChromaInGamut(L, topHue) * Math.min(totalW, 1);
1169
+ }
1170
+ for (let row = 0; row < GRAPH_ROWS; row++) {
1171
+ const gradingIntensity = row / (GRAPH_ROWS - 1);
1172
+ const C = topChroma * gradingIntensity;
1173
+ const srgb = clampSrgb(oklchToSrgb({ L, C, h: topHue }));
1174
+ const canvasY = GRAPH_ROWS - 1 - row;
1175
+ const idx = (canvasY * GRAPH_COLS + col) * 4;
1176
+ buffer[idx] = Math.round(srgb.r * 255);
1177
+ buffer[idx + 1] = Math.round(srgb.g * 255);
1178
+ buffer[idx + 2] = Math.round(srgb.b * 255);
1179
+ buffer[idx + 3] = 255;
1180
+ }
1181
+ }
1182
+ const curvePoints = [];
1183
+ for (let i = 0; i < 26; i++) {
1184
+ const nv = 1 - i / 25;
1185
+ const x = i / 25 * (GRAPH_COLS - 1);
1186
+ const lightContrib = Math.pow(nv, HUE_GRADING_EASING_POWER) * (lightFactor / HUE_GRADING_STRENGTH_HARD);
1187
+ const darkContrib = Math.pow(1 - nv, HUE_GRADING_EASING_POWER) * (darkFactor / HUE_GRADING_STRENGTH_HARD);
1188
+ const y = clamp(lightContrib + darkContrib, 0, 1);
1189
+ curvePoints.push({ x, y });
1190
+ }
1191
+ return { buffer, curvePoints };
1192
+ }
1193
+ function DynamicRangeGraph({ state }) {
1194
+ const tokens = useTokens();
1195
+ const canvasRef = useRef(null);
1196
+ const graphData = useMemo(
1197
+ () => computeGraphData(state),
1198
+ [
1199
+ state.dynamicRange.lightest,
1200
+ state.dynamicRange.darkest,
1201
+ state.globalHueGrading.light.strength,
1202
+ state.globalHueGrading.light.hue,
1203
+ state.globalHueGrading.dark.strength,
1204
+ state.globalHueGrading.dark.hue
1205
+ ]
1206
+ );
1207
+ useEffect(() => {
1208
+ const canvas = canvasRef.current;
1209
+ if (!canvas) return;
1210
+ canvas.width = GRAPH_COLS;
1211
+ canvas.height = GRAPH_ROWS;
1212
+ const ctx = canvas.getContext("2d");
1213
+ if (!ctx) return;
1214
+ const imageData = ctx.createImageData(GRAPH_COLS, GRAPH_ROWS);
1215
+ imageData.data.set(graphData.buffer);
1216
+ ctx.putImageData(imageData, 0, 0);
1217
+ const curveColor = srgbToHex(tokens.accent.fill.srgb);
1218
+ const { curvePoints } = graphData;
1219
+ if (curvePoints.length < 2) return;
1220
+ const mapped = curvePoints.map((p) => ({
1221
+ cx: p.x,
1222
+ cy: (1 - p.y) * (GRAPH_ROWS - 1)
1223
+ }));
1224
+ ctx.beginPath();
1225
+ ctx.strokeStyle = curveColor;
1226
+ ctx.lineWidth = 1.5;
1227
+ ctx.lineJoin = "round";
1228
+ ctx.lineCap = "round";
1229
+ ctx.moveTo(mapped[0].cx, mapped[0].cy);
1230
+ for (let i = 0; i < mapped.length - 1; i++) {
1231
+ const p0 = mapped[Math.max(0, i - 1)];
1232
+ const p1 = mapped[i];
1233
+ const p2 = mapped[i + 1];
1234
+ const p3 = mapped[Math.min(mapped.length - 1, i + 2)];
1235
+ const cp1x = p1.cx + (p2.cx - p0.cx) / 6;
1236
+ const cp1y = p1.cy + (p2.cy - p0.cy) / 6;
1237
+ const cp2x = p2.cx - (p3.cx - p1.cx) / 6;
1238
+ const cp2y = p2.cy - (p3.cy - p1.cy) / 6;
1239
+ ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, p2.cx, p2.cy);
1240
+ }
1241
+ ctx.stroke();
1242
+ ctx.fillStyle = curveColor;
1243
+ for (const p of mapped) {
1244
+ ctx.beginPath();
1245
+ ctx.arc(p.cx, p.cy, 2, 0, Math.PI * 2);
1246
+ ctx.fill();
1247
+ }
1248
+ }, [graphData, tokens]);
1249
+ const borderColor = srgbToHex(tokens.border.srgb);
1250
+ return /* @__PURE__ */ jsx(
1251
+ "canvas",
1252
+ {
1253
+ ref: canvasRef,
1254
+ style: {
1255
+ width: "100%",
1256
+ height: GRAPH_HEIGHT,
1257
+ borderRadius: 6,
1258
+ border: `1px solid ${borderColor}`,
1259
+ display: "block",
1260
+ overflow: "hidden"
1261
+ }
1262
+ }
1263
+ );
1264
+ }
1129
1265
  function DynamicRangeSection({
1130
1266
  state,
1131
1267
  dispatch
@@ -1142,6 +1278,7 @@ function DynamicRangeSection({
1142
1278
  const wDisplay = internalToDisplay(state.dynamicRange.lightest);
1143
1279
  const bDisplay = internalToDisplay(state.dynamicRange.darkest);
1144
1280
  return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 12 }, children: [
1281
+ /* @__PURE__ */ jsx(DynamicRangeGraph, { state }),
1145
1282
  /* @__PURE__ */ jsxs(
1146
1283
  "div",
1147
1284
  {
@@ -1348,7 +1485,7 @@ function FontPicker({
1348
1485
  const bgColor = srgbToHex(tokens.backgroundElevated.srgb);
1349
1486
  const borderColor = srgbToHex(tokens.border.srgb);
1350
1487
  const hoverColor = srgbToHex(tokens.backgroundSunken.srgb);
1351
- const interactiveColor = srgbToHex(tokens.interactive.srgb);
1488
+ const interactiveColor = srgbToHex(tokens.accent.fill.srgb);
1352
1489
  useEffect(() => {
1353
1490
  if (!isOpen) return;
1354
1491
  function handleMouseDown(e) {
@@ -1791,9 +1928,9 @@ function PresetSelector({
1791
1928
  const bgColor = srgbToHex(tokens.background.srgb);
1792
1929
  const textPrimary = srgbToHex(tokens.textPrimary.srgb);
1793
1930
  const textSecondary = srgbToHex(tokens.textSecondary.srgb);
1794
- const interactiveColor = srgbToHex(tokens.interactive.srgb);
1795
- const warningColor = srgbToHex(tokens.warning.srgb);
1796
- const errorColor = srgbToHex(tokens.error.srgb);
1931
+ const interactiveColor = srgbToHex(tokens.accent.fill.srgb);
1932
+ const warningColor = srgbToHex(tokens.warning.fill.srgb);
1933
+ const errorColor = srgbToHex(tokens.error.fill.srgb);
1797
1934
  const hoverBg = `${borderColor}18`;
1798
1935
  const activeBg = `${interactiveColor}14`;
1799
1936
  useEffect(() => {
@@ -2502,10 +2639,10 @@ function EditorHeader({
2502
2639
  const tokens = useTokens();
2503
2640
  const borderColor = srgbToHex(tokens.border.srgb);
2504
2641
  const statusColor = {
2505
- saved: srgbToHex(tokens.success.srgb),
2506
- saving: srgbToHex(tokens.warning.srgb),
2642
+ saved: srgbToHex(tokens.success.fill.srgb),
2643
+ saving: srgbToHex(tokens.warning.fill.srgb),
2507
2644
  unsaved: srgbToHex(tokens.textSecondary.srgb),
2508
- error: srgbToHex(tokens.error.srgb)
2645
+ error: srgbToHex(tokens.error.fill.srgb)
2509
2646
  };
2510
2647
  return /* @__PURE__ */ jsxs(
2511
2648
  "div",
@@ -2533,7 +2670,7 @@ function EditorHeader({
2533
2670
  children: STATUS_LABEL[saveStatus]
2534
2671
  }
2535
2672
  ),
2536
- saveStatus === "error" && /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", icon: "refresh", onPress: onRetry, children: "Retry" }),
2673
+ saveStatus === "error" && /* @__PURE__ */ jsx(Button, { variant: "tertiary", semantic: "neutral", size: "sm", icon: "refresh", onPress: onRetry, children: "Retry" }),
2537
2674
  /* @__PURE__ */ jsx(
2538
2675
  Button,
2539
2676
  {
@@ -2551,59 +2688,6 @@ function EditorHeader({
2551
2688
  }
2552
2689
  );
2553
2690
  }
2554
- var THEME_CHIPS = [
2555
- { id: "neutral", label: "Neutral" },
2556
- { id: "primary", label: "Primary" },
2557
- { id: "secondary", label: "Secondary" },
2558
- { id: "strong", label: "Strong" }
2559
- ];
2560
- function ThemeBar({ activeTheme, onThemeChange }) {
2561
- const tokens = useTokens();
2562
- const [hoveredChipId, setHoveredChipId] = useState(null);
2563
- const borderColor = srgbToHex(tokens.border.srgb);
2564
- const interactiveColor = srgbToHex(tokens.interactive.srgb);
2565
- return /* @__PURE__ */ jsx(
2566
- "div",
2567
- {
2568
- style: {
2569
- display: "flex",
2570
- alignItems: "center",
2571
- padding: "8px 24px",
2572
- borderBottom: `1px solid ${borderColor}`,
2573
- backgroundColor: srgbToHex(tokens.background.srgb),
2574
- flexShrink: 0
2575
- },
2576
- children: /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 8 }, role: "group", "aria-label": "Theme", children: THEME_CHIPS.map((chip) => {
2577
- const isActive = chip.id === activeTheme;
2578
- const isHovered = hoveredChipId === chip.id;
2579
- return /* @__PURE__ */ jsx(
2580
- "button",
2581
- {
2582
- onClick: () => onThemeChange(chip.id),
2583
- onMouseEnter: () => setHoveredChipId(chip.id),
2584
- onMouseLeave: () => setHoveredChipId(null),
2585
- "aria-pressed": isActive,
2586
- style: {
2587
- padding: "4px 12px",
2588
- borderRadius: 16,
2589
- border: `1px solid ${srgbToHex(
2590
- isActive ? tokens.interactive.srgb : tokens.border.srgb
2591
- )}`,
2592
- backgroundColor: isActive ? interactiveColor : isHovered ? `${interactiveColor}10` : "transparent",
2593
- color: isActive ? "#fff" : srgbToHex(tokens.textPrimary.srgb),
2594
- fontSize: 12,
2595
- fontWeight: 500,
2596
- cursor: "pointer",
2597
- transition: "background-color 150ms ease"
2598
- },
2599
- children: chip.label
2600
- },
2601
- chip.id
2602
- );
2603
- }) })
2604
- }
2605
- );
2606
- }
2607
2691
  var TOC_WIDTH = 220;
2608
2692
  function TableOfContents({
2609
2693
  activeView,
@@ -2613,7 +2697,7 @@ function TableOfContents({
2613
2697
  const tokens = useTokens();
2614
2698
  const [hoveredId, setHoveredId] = useState(null);
2615
2699
  const borderColor = srgbToHex(tokens.border.srgb);
2616
- const activeColor = srgbToHex(tokens.interactive.srgb);
2700
+ const activeColor = srgbToHex(tokens.accent.fill.srgb);
2617
2701
  const textPrimary = srgbToHex(tokens.textPrimary.srgb);
2618
2702
  const textSecondary = srgbToHex(tokens.textSecondary.srgb);
2619
2703
  const hoverBg = `${borderColor}20`;
@@ -2768,6 +2852,16 @@ function CardPreview(props) {
2768
2852
  )
2769
2853
  ] });
2770
2854
  }
2855
+ function FramePreview(props) {
2856
+ return /* @__PURE__ */ jsx(Frame, { ...props, style: { minWidth: 200, minHeight: 60 }, children: /* @__PURE__ */ jsx(Text, { size: "sm", children: "Frame content" }) });
2857
+ }
2858
+ function WrapperPreview(props) {
2859
+ return /* @__PURE__ */ jsxs(Wrapper, { ...props, style: { minWidth: 200 }, children: [
2860
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: "Item 1" }),
2861
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: "Item 2" }),
2862
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: "Item 3" })
2863
+ ] });
2864
+ }
2771
2865
  function ComponentRenderer({ componentId, props }) {
2772
2866
  const noop = useCallback(() => {
2773
2867
  }, []);
@@ -2778,9 +2872,11 @@ function ComponentRenderer({ componentId, props }) {
2778
2872
  Button,
2779
2873
  {
2780
2874
  variant: props.variant,
2875
+ semantic: props.semantic,
2781
2876
  size: props.size,
2782
2877
  icon,
2783
2878
  iconPosition: props.iconPosition,
2879
+ disabled: props.disabled,
2784
2880
  onPress: noop,
2785
2881
  children: "Button"
2786
2882
  }
@@ -2798,6 +2894,30 @@ function ComponentRenderer({ componentId, props }) {
2798
2894
  return /* @__PURE__ */ jsx(StatefulHueSlider, { ...props });
2799
2895
  case "card":
2800
2896
  return /* @__PURE__ */ jsx(CardPreview, { ...props });
2897
+ case "text":
2898
+ return /* @__PURE__ */ jsx(
2899
+ Text,
2900
+ {
2901
+ size: props.size,
2902
+ weight: props.weight,
2903
+ color: props.color,
2904
+ font: props.font,
2905
+ children: "The quick brown fox"
2906
+ }
2907
+ );
2908
+ case "icon":
2909
+ return /* @__PURE__ */ jsx(
2910
+ Icon,
2911
+ {
2912
+ name: props.name ?? "home",
2913
+ size: props.size,
2914
+ fill: props.fill
2915
+ }
2916
+ );
2917
+ case "frame":
2918
+ return /* @__PURE__ */ jsx(FramePreview, { ...props });
2919
+ case "wrapper":
2920
+ return /* @__PURE__ */ jsx(WrapperPreview, { ...props });
2801
2921
  default:
2802
2922
  return null;
2803
2923
  }
@@ -2921,7 +3041,7 @@ function ComponentCard({
2921
3041
  padding: 20,
2922
3042
  borderRadius: 12,
2923
3043
  border: `1px solid ${srgbToHex(
2924
- isHovered ? tokens.interactive.srgb : tokens.border.srgb
3044
+ isHovered ? tokens.accent.fill.srgb : tokens.border.srgb
2925
3045
  )}`,
2926
3046
  backgroundColor: srgbToHex(tokens.backgroundElevated.srgb),
2927
3047
  cursor: "pointer",
@@ -3031,7 +3151,7 @@ function CategoryView({
3031
3151
  padding: 24,
3032
3152
  borderRadius: 12,
3033
3153
  border: `1px solid ${srgbToHex(
3034
- isHovered ? tokens.interactive.srgb : tokens.border.srgb
3154
+ isHovered ? tokens.accent.fill.srgb : tokens.border.srgb
3035
3155
  )}`,
3036
3156
  backgroundColor: srgbToHex(tokens.backgroundElevated.srgb),
3037
3157
  cursor: "pointer",
@@ -3120,7 +3240,7 @@ function ComponentDetailView({
3120
3240
  const component = getComponent(componentId);
3121
3241
  const [hoveredId, setHoveredId] = useState(null);
3122
3242
  if (!component) return null;
3123
- const interactiveColor = srgbToHex(tokens.interactive.srgb);
3243
+ const interactiveColor = srgbToHex(tokens.accent.fill.srgb);
3124
3244
  return /* @__PURE__ */ jsxs("div", { style: { padding: 32 }, children: [
3125
3245
  /* @__PURE__ */ jsx(
3126
3246
  "h2",
@@ -3280,7 +3400,7 @@ function CopyButton({ text }) {
3280
3400
  setCopied(true);
3281
3401
  setTimeout(() => setCopied(false), 2e3);
3282
3402
  }, [text]);
3283
- return /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", icon: copied ? "check" : "content_copy", onPress: handleCopy, children: copied ? "Copied!" : "Copy" });
3403
+ return /* @__PURE__ */ jsx(Button, { variant: "tertiary", semantic: "neutral", size: "sm", icon: copied ? "check" : "content_copy", onPress: handleCopy, children: copied ? "Copied!" : "Copy" });
3284
3404
  }
3285
3405
  function CodeBlock({
3286
3406
  code
@@ -3410,7 +3530,7 @@ function RightSidebar({
3410
3530
  padding: 0,
3411
3531
  fontSize: 14,
3412
3532
  fontWeight: 500,
3413
- color: srgbToHex(tokens.interactive.srgb),
3533
+ color: srgbToHex(tokens.accent.fill.srgb),
3414
3534
  whiteSpace: "nowrap"
3415
3535
  },
3416
3536
  children: component.name
@@ -3648,7 +3768,7 @@ function PropControl({
3648
3768
  width: 36,
3649
3769
  height: 20,
3650
3770
  borderRadius: 10,
3651
- backgroundColor: value ? srgbToHex(tokens.interactive.srgb) : srgbToHex(tokens.border.srgb),
3771
+ backgroundColor: value ? srgbToHex(tokens.accent.fill.srgb) : srgbToHex(tokens.border.srgb),
3652
3772
  position: "relative",
3653
3773
  transition: "background-color 150ms ease",
3654
3774
  flexShrink: 0
@@ -3709,6 +3829,10 @@ function Editor({
3709
3829
  onNavigate,
3710
3830
  initialPreviewView
3711
3831
  });
3832
+ const previewConfig = useMemo(
3833
+ () => chromeThemeConfig.tokenOverrides ? { ...editor.themeConfig, tokenOverrides: chromeThemeConfig.tokenOverrides } : editor.themeConfig,
3834
+ [editor.themeConfig, chromeThemeConfig.tokenOverrides]
3835
+ );
3712
3836
  return /* @__PURE__ */ jsx(NewtoneProvider, { config: chromeThemeConfig, children: /* @__PURE__ */ jsx(
3713
3837
  EditorShell,
3714
3838
  {
@@ -3771,33 +3895,23 @@ function Editor({
3771
3895
  overflow: "hidden",
3772
3896
  minWidth: 0
3773
3897
  },
3774
- children: /* @__PURE__ */ jsxs(
3898
+ children: /* @__PURE__ */ jsx(
3775
3899
  NewtoneProvider,
3776
3900
  {
3777
- config: editor.themeConfig,
3901
+ config: previewConfig,
3778
3902
  initialMode: editor.colorMode,
3779
- initialTheme: editor.activeTheme,
3780
- children: [
3781
- /* @__PURE__ */ jsx(
3782
- ThemeBar,
3783
- {
3784
- activeTheme: editor.activeTheme,
3785
- onThemeChange: editor.handleThemeChange
3786
- }
3787
- ),
3788
- /* @__PURE__ */ jsx("div", { style: { flex: 1, overflowY: "auto", minWidth: 0 }, children: /* @__PURE__ */ jsx(
3789
- PreviewWindow,
3790
- {
3791
- view: editor.previewView,
3792
- selectedVariantId: editor.selectedVariantId,
3793
- propOverrides: editor.propOverrides,
3794
- onNavigate: editor.handlePreviewNavigate,
3795
- onSelectVariant: editor.handleSelectVariant
3796
- }
3797
- ) })
3798
- ]
3903
+ children: /* @__PURE__ */ jsx("div", { style: { flex: 1, overflowY: "auto", minWidth: 0 }, children: /* @__PURE__ */ jsx(
3904
+ PreviewWindow,
3905
+ {
3906
+ view: editor.previewView,
3907
+ selectedVariantId: editor.selectedVariantId,
3908
+ propOverrides: editor.propOverrides,
3909
+ onNavigate: editor.handlePreviewNavigate,
3910
+ onSelectVariant: editor.handleSelectVariant
3911
+ }
3912
+ ) })
3799
3913
  },
3800
- `${editor.colorMode}-${editor.activeTheme}`
3914
+ editor.colorMode
3801
3915
  )
3802
3916
  }
3803
3917
  )
@@ -3819,6 +3933,6 @@ function Editor({
3819
3933
  ) });
3820
3934
  }
3821
3935
 
3822
- export { CategoryView, CodeBlock, ColorsSection, ComponentDetailView, ComponentRenderer, CopyButton, Editor, EditorHeader, EditorShell, FontPicker, FontsSection, IconsSection, OthersSection, OverviewView, PresetSelector, PreviewWindow, RightSidebar, Sidebar, TableOfContents, ThemeBar, findPreset, presetHasUnpublishedChanges, updatePresetInArray, useEditorState, useHover, usePresets };
3936
+ export { CategoryView, CodeBlock, ColorsSection, ComponentDetailView, ComponentRenderer, CopyButton, Editor, EditorHeader, EditorShell, FontPicker, FontsSection, IconsSection, OthersSection, OverviewView, PresetSelector, PreviewWindow, RightSidebar, Sidebar, TableOfContents, findPreset, presetHasUnpublishedChanges, updatePresetInArray, useEditorState, useHover, usePresets };
3823
3937
  //# sourceMappingURL=index.js.map
3824
3938
  //# sourceMappingURL=index.js.map