canvas-ui-sdk 0.3.2 → 0.3.4

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.js CHANGED
@@ -27392,8 +27392,13 @@ function generateBakePrompt(theme) {
27392
27392
  lines.push("");
27393
27393
  sections.push(lines.join("\n"));
27394
27394
  }
27395
- sectionNum++;
27396
- {
27395
+ const brandingChanged = theme.branding.iconShape !== defaultBranding.iconShape || theme.branding.iconName !== defaultBranding.iconName || theme.branding.bgColor !== defaultBranding.bgColor || theme.branding.iconColor !== defaultBranding.iconColor || theme.branding.wordmark !== defaultBranding.wordmark;
27396
+ const imageKeys = ["logoLight", "logoDark", "faviconLight", "faviconDark"];
27397
+ const imagesChanged = imageKeys.some(
27398
+ (key) => (theme.images[key] || "") !== (defaultImages[key] || "")
27399
+ );
27400
+ if (brandingChanged || imagesChanged) {
27401
+ sectionNum++;
27397
27402
  const lines = [];
27398
27403
  lines.push(`## ${sectionNum}. Update \`src/lib/theme-config.ts\``);
27399
27404
  lines.push("");
@@ -27412,7 +27417,6 @@ function generateBakePrompt(theme) {
27412
27417
  lines.push(`};`);
27413
27418
  lines.push("");
27414
27419
  lines.push(`export const savedImages: Record<ImageKey, string> = {`);
27415
- const imageKeys = ["logoLight", "logoDark", "faviconLight", "faviconDark"];
27416
27420
  for (const key of imageKeys) {
27417
27421
  lines.push(` ${key}: "${theme.images[key] || ""}",`);
27418
27422
  }
@@ -27442,13 +27446,11 @@ function generateBakePrompt(theme) {
27442
27446
  return header + sections.join("\n");
27443
27447
  }
27444
27448
  function ExportPanel({ theme }) {
27445
- const [importValue, setImportValue] = useState("");
27446
- const [importStatus, setImportStatus] = useState("idle");
27447
27449
  const [copyStatus, setCopyStatus] = useState(null);
27448
- const handleCopy = async (content, type) => {
27450
+ const handleCopy = async (content) => {
27449
27451
  try {
27450
27452
  await navigator.clipboard.writeText(content);
27451
- setCopyStatus(type);
27453
+ setCopyStatus("bake");
27452
27454
  setTimeout(() => setCopyStatus(null), 2e3);
27453
27455
  } catch {
27454
27456
  const textarea = document.createElement("textarea");
@@ -27457,16 +27459,10 @@ function ExportPanel({ theme }) {
27457
27459
  textarea.select();
27458
27460
  document.execCommand("copy");
27459
27461
  document.body.removeChild(textarea);
27460
- setCopyStatus(type);
27462
+ setCopyStatus("bake");
27461
27463
  setTimeout(() => setCopyStatus(null), 2e3);
27462
27464
  }
27463
27465
  };
27464
- const handleImport = () => {
27465
- const success = theme.importJSON(importValue);
27466
- setImportStatus(success ? "success" : "error");
27467
- if (success) setImportValue("");
27468
- setTimeout(() => setImportStatus("idle"), 3e3);
27469
- };
27470
27466
  const overrideCount = Object.keys(theme.overrides).length;
27471
27467
  return /* @__PURE__ */ jsxs("div", { "data-theme-drawer-panel": true, className: "flex flex-col gap-5 p-4", children: [
27472
27468
  /* @__PURE__ */ jsx(
@@ -27482,218 +27478,73 @@ function ExportPanel({ theme }) {
27482
27478
  children: theme.isDirty ? `${overrideCount} variable${overrideCount !== 1 ? "s" : ""} modified` : "No modifications \u2014 using defaults"
27483
27479
  }
27484
27480
  ),
27485
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
27486
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
27487
- /* @__PURE__ */ jsx(
27488
- "h3",
27489
- {
27490
- style: {
27491
- fontSize: "13px",
27492
- fontWeight: 600,
27493
- color: "#374151",
27494
- textTransform: "uppercase",
27495
- letterSpacing: "0.05em"
27496
- },
27497
- children: "Export CSS"
27498
- }
27499
- ),
27481
+ overrideCount > 0 && (() => {
27482
+ const prompt = generateBakePrompt(theme);
27483
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
27484
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
27485
+ /* @__PURE__ */ jsx(
27486
+ "h3",
27487
+ {
27488
+ style: {
27489
+ fontSize: "13px",
27490
+ fontWeight: 600,
27491
+ color: "#374151",
27492
+ textTransform: "uppercase",
27493
+ letterSpacing: "0.05em"
27494
+ },
27495
+ children: "Bake into source code"
27496
+ }
27497
+ ),
27498
+ /* @__PURE__ */ jsx(
27499
+ "button",
27500
+ {
27501
+ onClick: () => handleCopy(prompt),
27502
+ style: {
27503
+ fontSize: "12px",
27504
+ color: copyStatus === "bake" ? "#059669" : "#1165ef",
27505
+ background: "none",
27506
+ border: "none",
27507
+ cursor: "pointer",
27508
+ fontWeight: 500
27509
+ },
27510
+ children: copyStatus === "bake" ? "Copied!" : "Copy prompt"
27511
+ }
27512
+ )
27513
+ ] }),
27500
27514
  /* @__PURE__ */ jsx(
27501
- "button",
27515
+ "p",
27502
27516
  {
27503
- onClick: () => handleCopy(theme.exportCSS(), "css"),
27504
27517
  style: {
27505
27518
  fontSize: "12px",
27506
- color: copyStatus === "css" ? "#059669" : "#1165ef",
27507
- background: "none",
27508
- border: "none",
27509
- cursor: "pointer",
27510
- fontWeight: 500
27511
- },
27512
- children: copyStatus === "css" ? "Copied!" : "Copy"
27513
- }
27514
- )
27515
- ] }),
27516
- /* @__PURE__ */ jsx(
27517
- "pre",
27518
- {
27519
- style: {
27520
- fontSize: "11px",
27521
- fontFamily: "monospace",
27522
- padding: "12px",
27523
- background: "#f9fafb",
27524
- border: "1px solid #e5e7eb",
27525
- borderRadius: "6px",
27526
- overflowX: "auto",
27527
- maxHeight: "200px",
27528
- overflowY: "auto",
27529
- color: "#374151",
27530
- whiteSpace: "pre-wrap",
27531
- wordBreak: "break-all"
27532
- },
27533
- children: theme.exportCSS()
27534
- }
27535
- )
27536
- ] }),
27537
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
27538
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
27539
- /* @__PURE__ */ jsx(
27540
- "h3",
27541
- {
27542
- style: {
27543
- fontSize: "13px",
27544
- fontWeight: 600,
27545
- color: "#374151",
27546
- textTransform: "uppercase",
27547
- letterSpacing: "0.05em"
27519
+ color: "#6b7280",
27520
+ lineHeight: "1.4"
27548
27521
  },
27549
- children: "Export JSON"
27522
+ children: "Copies a prompt for Claude Code that updates your source files with the current theme values."
27550
27523
  }
27551
27524
  ),
27552
27525
  /* @__PURE__ */ jsx(
27553
- "button",
27526
+ "pre",
27554
27527
  {
27555
- onClick: () => handleCopy(theme.exportJSON(), "json"),
27556
27528
  style: {
27557
- fontSize: "12px",
27558
- color: copyStatus === "json" ? "#059669" : "#1165ef",
27559
- background: "none",
27560
- border: "none",
27561
- cursor: "pointer",
27562
- fontWeight: 500
27529
+ fontSize: "11px",
27530
+ fontFamily: "ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace",
27531
+ background: "#f9fafb",
27532
+ border: "1px solid #e5e7eb",
27533
+ borderRadius: "6px",
27534
+ padding: "12px",
27535
+ maxHeight: "300px",
27536
+ overflow: "auto",
27537
+ whiteSpace: "pre-wrap",
27538
+ wordBreak: "break-word",
27539
+ color: "#374151",
27540
+ lineHeight: "1.5",
27541
+ margin: 0
27563
27542
  },
27564
- children: copyStatus === "json" ? "Copied!" : "Copy"
27543
+ children: prompt
27565
27544
  }
27566
27545
  )
27567
- ] }),
27568
- /* @__PURE__ */ jsx(
27569
- "pre",
27570
- {
27571
- style: {
27572
- fontSize: "11px",
27573
- fontFamily: "monospace",
27574
- padding: "12px",
27575
- background: "#f9fafb",
27576
- border: "1px solid #e5e7eb",
27577
- borderRadius: "6px",
27578
- overflowX: "auto",
27579
- maxHeight: "200px",
27580
- overflowY: "auto",
27581
- color: "#374151",
27582
- whiteSpace: "pre-wrap",
27583
- wordBreak: "break-all"
27584
- },
27585
- children: theme.exportJSON()
27586
- }
27587
- )
27588
- ] }),
27589
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
27590
- /* @__PURE__ */ jsx(
27591
- "h3",
27592
- {
27593
- style: {
27594
- fontSize: "13px",
27595
- fontWeight: 600,
27596
- color: "#374151",
27597
- textTransform: "uppercase",
27598
- letterSpacing: "0.05em"
27599
- },
27600
- children: "Import JSON"
27601
- }
27602
- ),
27603
- /* @__PURE__ */ jsx(
27604
- "textarea",
27605
- {
27606
- value: importValue,
27607
- onChange: (e) => setImportValue(e.target.value),
27608
- placeholder: "Paste exported JSON here...",
27609
- rows: 5,
27610
- style: {
27611
- fontSize: "11px",
27612
- fontFamily: "monospace",
27613
- padding: "12px",
27614
- border: "1px solid #e5e7eb",
27615
- borderRadius: "6px",
27616
- color: "#374151",
27617
- background: "#ffffff",
27618
- resize: "vertical"
27619
- }
27620
- }
27621
- ),
27622
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
27623
- /* @__PURE__ */ jsx(
27624
- "button",
27625
- {
27626
- onClick: handleImport,
27627
- disabled: !importValue.trim(),
27628
- style: {
27629
- fontSize: "13px",
27630
- fontWeight: 500,
27631
- color: "#ffffff",
27632
- background: importValue.trim() ? "#1165ef" : "#9ca3af",
27633
- border: "none",
27634
- cursor: importValue.trim() ? "pointer" : "not-allowed",
27635
- padding: "8px 16px",
27636
- borderRadius: "6px"
27637
- },
27638
- children: "Import"
27639
- }
27640
- ),
27641
- importStatus === "success" && /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#059669" }, children: "Theme imported!" }),
27642
- importStatus === "error" && /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#dc2626" }, children: "Invalid JSON format" })
27643
- ] })
27644
- ] }),
27645
- overrideCount > 0 && /* @__PURE__ */ jsx(
27646
- "div",
27647
- {
27648
- style: {
27649
- borderTop: "1px solid #e5e7eb",
27650
- paddingTop: "16px"
27651
- },
27652
- children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
27653
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
27654
- /* @__PURE__ */ jsx(
27655
- "h3",
27656
- {
27657
- style: {
27658
- fontSize: "13px",
27659
- fontWeight: 600,
27660
- color: "#374151",
27661
- textTransform: "uppercase",
27662
- letterSpacing: "0.05em"
27663
- },
27664
- children: "Bake into source code"
27665
- }
27666
- ),
27667
- /* @__PURE__ */ jsx(
27668
- "button",
27669
- {
27670
- onClick: () => handleCopy(generateBakePrompt(theme), "bake"),
27671
- style: {
27672
- fontSize: "12px",
27673
- color: copyStatus === "bake" ? "#059669" : "#1165ef",
27674
- background: "none",
27675
- border: "none",
27676
- cursor: "pointer",
27677
- fontWeight: 500
27678
- },
27679
- children: copyStatus === "bake" ? "Copied!" : "Copy prompt"
27680
- }
27681
- )
27682
- ] }),
27683
- /* @__PURE__ */ jsx(
27684
- "p",
27685
- {
27686
- style: {
27687
- fontSize: "12px",
27688
- color: "#6b7280",
27689
- lineHeight: "1.4"
27690
- },
27691
- children: "Copies a prompt for Claude Code that updates your source files with the current theme values."
27692
- }
27693
- )
27694
- ] })
27695
- }
27696
- ),
27546
+ ] });
27547
+ })(),
27697
27548
  theme.isDirty && /* @__PURE__ */ jsx(
27698
27549
  "div",
27699
27550
  {