@particle-academy/fancy-slides 0.1.4 → 0.1.6

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
@@ -1,9 +1,9 @@
1
- import { useId, useRef, useState, useEffect, useCallback, useMemo } from 'react';
1
+ import { isDarkColor, SlideContext } from './chunk-WIUXPQAK.js';
2
+ export { useIsDarkSlide, useSlideContext, useSlideTheme } from './chunk-WIUXPQAK.js';
3
+ import { useId, useRef, useState, useEffect, useMemo, useCallback } from 'react';
2
4
  import { ContentRenderer, Text, Action, ContextMenu, Separator, Tooltip, Dropdown, Badge, Heading, Tabs, Card, Input, Slider, Textarea, Select, ColorPicker } from '@particle-academy/react-fancy';
3
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
6
 
5
- // src/components/Slide/Slide.tsx
6
-
7
7
  // src/theme/default-theme.ts
8
8
  var defaultTheme = {
9
9
  name: "default",
@@ -259,10 +259,19 @@ function Slide({
259
259
  const slideWidthPx = measured || 1;
260
260
  const slideHeightPx = slideWidthPx / ratio;
261
261
  const bg = slide.background;
262
+ const effectiveBg = bg?.color ?? t.colors?.background ?? "#ffffff";
262
263
  const backgroundStyle = {
263
- background: bg?.gradient ? bg.gradient : bg?.image ? `${bg.color ?? "transparent"} url(${bg.image}) center/${bg.imageFit ?? "cover"} no-repeat` : bg?.color ?? t.colors?.background ?? "#ffffff"
264
+ background: bg?.gradient ? bg.gradient : bg?.image ? `${bg.color ?? "transparent"} url(${bg.image}) center/${bg.imageFit ?? "cover"} no-repeat` : effectiveBg
264
265
  };
265
- return /* @__PURE__ */ jsx(
266
+ const slideContext = useMemo(
267
+ () => ({
268
+ theme: t,
269
+ isDark: isDarkColor(effectiveBg),
270
+ slideWidthPx
271
+ }),
272
+ [t, effectiveBg, slideWidthPx]
273
+ );
274
+ return /* @__PURE__ */ jsx(SlideContext.Provider, { value: slideContext, children: /* @__PURE__ */ jsx(
266
275
  "div",
267
276
  {
268
277
  ref,
@@ -298,7 +307,7 @@ function Slide({
298
307
  element.id
299
308
  ))
300
309
  }
301
- );
310
+ ) });
302
311
  }
303
312
  var MIN_DIM = 0.02;
304
313
  var CLICK_DRAG_THRESHOLD_PX = 3;
@@ -1113,6 +1122,90 @@ function reduce(deck, op) {
1113
1122
  };
1114
1123
  }
1115
1124
  }
1125
+
1126
+ // src/utils/chart-presets.ts
1127
+ var QUARTERS = ["Q1", "Q2", "Q3", "Q4"];
1128
+ var REVENUE = [24e3, 38e3, 31e3, 47e3];
1129
+ function chartStarterOption(kind) {
1130
+ switch (kind) {
1131
+ case "bar":
1132
+ return {
1133
+ grid: { top: 24, left: 56, right: 16, bottom: 32 },
1134
+ tooltip: { trigger: "axis" },
1135
+ xAxis: { type: "category", data: [...QUARTERS] },
1136
+ yAxis: { type: "value" },
1137
+ series: [{ type: "bar", name: "Revenue", data: [...REVENUE] }]
1138
+ };
1139
+ case "line":
1140
+ return {
1141
+ grid: { top: 24, left: 56, right: 16, bottom: 32 },
1142
+ tooltip: { trigger: "axis" },
1143
+ xAxis: { type: "category", data: [...QUARTERS] },
1144
+ yAxis: { type: "value" },
1145
+ series: [{ type: "line", name: "Revenue", smooth: true, data: [...REVENUE] }]
1146
+ };
1147
+ case "area":
1148
+ return {
1149
+ grid: { top: 24, left: 56, right: 16, bottom: 32 },
1150
+ tooltip: { trigger: "axis" },
1151
+ xAxis: { type: "category", data: [...QUARTERS] },
1152
+ yAxis: { type: "value" },
1153
+ series: [
1154
+ {
1155
+ type: "line",
1156
+ name: "Revenue",
1157
+ smooth: true,
1158
+ areaStyle: {},
1159
+ data: [...REVENUE]
1160
+ }
1161
+ ]
1162
+ };
1163
+ case "pie":
1164
+ return {
1165
+ tooltip: { trigger: "item" },
1166
+ legend: { bottom: 0 },
1167
+ series: [
1168
+ {
1169
+ type: "pie",
1170
+ radius: ["40%", "70%"],
1171
+ name: "Segment",
1172
+ data: [
1173
+ { value: 1048, name: "Direct" },
1174
+ { value: 735, name: "Search" },
1175
+ { value: 580, name: "Email" }
1176
+ ]
1177
+ }
1178
+ ]
1179
+ };
1180
+ case "scatter":
1181
+ return {
1182
+ grid: { top: 24, left: 48, right: 16, bottom: 32 },
1183
+ tooltip: { trigger: "item" },
1184
+ xAxis: { type: "value" },
1185
+ yAxis: { type: "value" },
1186
+ series: [
1187
+ {
1188
+ type: "scatter",
1189
+ name: "Points",
1190
+ symbolSize: 12,
1191
+ data: [
1192
+ [10, 8.04],
1193
+ [8, 6.95],
1194
+ [13, 7.58],
1195
+ [9, 8.81],
1196
+ [11, 8.33],
1197
+ [14, 9.96],
1198
+ [6, 7.24],
1199
+ [4, 4.26],
1200
+ [12, 10.84],
1201
+ [7, 4.82],
1202
+ [5, 5.68]
1203
+ ]
1204
+ }
1205
+ ]
1206
+ };
1207
+ }
1208
+ }
1116
1209
  function SlideRail({
1117
1210
  slides,
1118
1211
  selectedId,
@@ -1238,7 +1331,16 @@ function EditorToolbar({
1238
1331
  /* @__PURE__ */ jsx(Dropdown.Item, { onClick: () => onInsertShape?.("arrow"), children: "Arrow" })
1239
1332
  ] })
1240
1333
  ] }),
1241
- /* @__PURE__ */ jsx(Tooltip, { content: "Insert chart", children: /* @__PURE__ */ jsx(Action, { variant: "ghost", size: "sm", icon: "bar-chart", onClick: onInsertChart, disabled, "aria-label": "Insert chart" }) }),
1334
+ /* @__PURE__ */ jsxs(Dropdown, { children: [
1335
+ /* @__PURE__ */ jsx(Dropdown.Trigger, { children: /* @__PURE__ */ jsx(Action, { variant: "ghost", size: "sm", icon: "bar-chart", iconTrailing: "chevron-down", disabled, "aria-label": "Insert chart" }) }),
1336
+ /* @__PURE__ */ jsxs(Dropdown.Items, { children: [
1337
+ /* @__PURE__ */ jsx(Dropdown.Item, { onClick: () => onInsertChart?.("bar"), children: "Bar chart" }),
1338
+ /* @__PURE__ */ jsx(Dropdown.Item, { onClick: () => onInsertChart?.("line"), children: "Line chart" }),
1339
+ /* @__PURE__ */ jsx(Dropdown.Item, { onClick: () => onInsertChart?.("area"), children: "Area chart" }),
1340
+ /* @__PURE__ */ jsx(Dropdown.Item, { onClick: () => onInsertChart?.("pie"), children: "Pie chart" }),
1341
+ /* @__PURE__ */ jsx(Dropdown.Item, { onClick: () => onInsertChart?.("scatter"), children: "Scatter" })
1342
+ ] })
1343
+ ] }),
1242
1344
  /* @__PURE__ */ jsx(Tooltip, { content: "Insert code", children: /* @__PURE__ */ jsx(Action, { variant: "ghost", size: "sm", icon: "code", onClick: onInsertCode, disabled, "aria-label": "Insert code" }) }),
1243
1345
  /* @__PURE__ */ jsx(Tooltip, { content: "Insert table", children: /* @__PURE__ */ jsx(Action, { variant: "ghost", size: "sm", icon: "table", onClick: onInsertTable, disabled, "aria-label": "Insert table" }) }),
1244
1346
  /* @__PURE__ */ jsx(Separator, { orientation: "vertical" }),
@@ -1618,17 +1720,13 @@ function DeckEditor({
1618
1720
  [insert]
1619
1721
  );
1620
1722
  const insertChart = useCallback(
1621
- () => insert({
1723
+ (kind = "bar") => insert({
1622
1724
  type: "chart",
1623
1725
  x: 0.1,
1624
1726
  y: 0.2,
1625
1727
  w: 0.8,
1626
1728
  h: 0.6,
1627
- option: {
1628
- xAxis: { type: "category", data: ["Q1", "Q2", "Q3", "Q4"] },
1629
- yAxis: { type: "value" },
1630
- series: [{ type: "bar", data: [24, 38, 31, 47] }]
1631
- }
1729
+ option: chartStarterOption(kind)
1632
1730
  }),
1633
1731
  [insert]
1634
1732
  );
@@ -1756,6 +1854,6 @@ function DeckEditor({
1756
1854
  );
1757
1855
  }
1758
1856
 
1759
- export { DeckEditor, EditorToolbar, ElementInspector, ImageElementRenderer, PresenterView, ShapeElementRenderer, Slide, SlideRail, SlideThumbnail, SlideViewer, SpeakerNotes, TextElementRenderer, builtinThemes, darkTheme, deckId, defaultTheme, defineTheme, elementId, nextId, reduce as reduceDeck, resolveTheme, slideId, useDeckState, useSlideKeyboard, vividTheme };
1857
+ export { DeckEditor, EditorToolbar, ElementInspector, ImageElementRenderer, PresenterView, ShapeElementRenderer, Slide, SlideRail, SlideThumbnail, SlideViewer, SpeakerNotes, TextElementRenderer, builtinThemes, chartStarterOption, darkTheme, deckId, defaultTheme, defineTheme, elementId, nextId, reduce as reduceDeck, resolveTheme, slideId, useDeckState, useSlideKeyboard, vividTheme };
1760
1858
  //# sourceMappingURL=index.js.map
1761
1859
  //# sourceMappingURL=index.js.map