@open-slide/core 1.19.0 → 2.0.0-beta.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.
Files changed (100) hide show
  1. package/dist/{build-CaV_vhIw.js → build-CfAxF6Dm.js} +2 -5
  2. package/dist/cli/bin.d.ts +1 -1
  3. package/dist/cli/bin.js +139 -13
  4. package/dist/{config-CDHB8Oow.d.ts → config-AtA2Bqtn.d.ts} +4 -4
  5. package/dist/{config-GA6NMgs_.js → config-C_VI2EpT.js} +545 -776
  6. package/dist/{design-cpzS8aud.js → design-Cpqx7SJs.js} +1 -2
  7. package/dist/{dev-D57ui2yV.js → dev-BChELmc-.js} +4 -7
  8. package/dist/index.d.ts +7 -37
  9. package/dist/index.js +51 -54
  10. package/dist/locale/index.d.ts +2 -8
  11. package/dist/locale/index.js +13 -3
  12. package/dist/{preview-D40Zw_o0.js → preview-CcCQa268.js} +3 -7
  13. package/dist/{types-8HghULIe.d.ts → types-BzPSOxe-.d.ts} +5 -9
  14. package/dist/vite/index.d.ts +1 -4
  15. package/dist/vite/index.js +2 -4
  16. package/dist/{format-74A3B6zu.js → zh-tw-BxZ_pYqe.js} +13 -49
  17. package/package.json +12 -12
  18. package/skills/create-slide/SKILL.md +4 -1
  19. package/skills/slide-authoring/SKILL.md +25 -2
  20. package/src/app/app.tsx +18 -15
  21. package/src/app/assets/open-slide.png +0 -0
  22. package/src/app/components/asset-view.tsx +46 -39
  23. package/src/app/components/command/command-menu.tsx +5 -1
  24. package/src/app/components/command/command.tsx +4 -2
  25. package/src/app/components/command/home-command-menu.tsx +6 -6
  26. package/src/app/components/export-progress-toast.tsx +80 -0
  27. package/src/app/components/history-provider.tsx +1 -5
  28. package/src/app/components/icon-tooltip.tsx +24 -15
  29. package/src/app/components/image-placeholder.tsx +4 -12
  30. package/src/app/components/inspector/asset-picker-dialog.tsx +24 -32
  31. package/src/app/components/inspector/comment-widget.tsx +33 -7
  32. package/src/app/components/inspector/image-crop-dialog.tsx +9 -6
  33. package/src/app/components/inspector/inline-text-editor.tsx +798 -0
  34. package/src/app/components/inspector/inspect-overlay.tsx +35 -76
  35. package/src/app/components/inspector/inspector-panel.tsx +31 -53
  36. package/src/app/components/inspector/inspector-provider.tsx +53 -36
  37. package/src/app/components/language-toggle.tsx +2 -3
  38. package/src/app/components/notes-drawer.tsx +4 -7
  39. package/src/app/components/overview-grid.tsx +15 -8
  40. package/src/app/components/panel/panel-shell.tsx +1 -3
  41. package/src/app/components/panel/save-card.tsx +12 -3
  42. package/src/app/components/player.tsx +5 -6
  43. package/src/app/components/present/blackout-overlay.tsx +16 -3
  44. package/src/app/components/present/control-bar.tsx +21 -13
  45. package/src/app/components/present/jump-input.tsx +27 -5
  46. package/src/app/components/present/laser-pointer.tsx +34 -11
  47. package/src/app/components/present/progress-bar.tsx +1 -1
  48. package/src/app/components/present/use-presenter-channel.ts +0 -1
  49. package/src/app/components/present/use-touch-swipe.ts +9 -2
  50. package/src/app/components/sidebar/folder-item.tsx +48 -21
  51. package/src/app/components/sidebar/icon-picker.tsx +1 -1
  52. package/src/app/components/sidebar/sidebar-footer.tsx +20 -7
  53. package/src/app/components/sidebar/sidebar.tsx +91 -64
  54. package/src/app/components/slide-canvas.tsx +2 -6
  55. package/src/app/components/slide-transition-layer.tsx +48 -76
  56. package/src/app/components/style-panel/design-provider.tsx +1 -14
  57. package/src/app/components/style-panel/style-panel.tsx +16 -12
  58. package/src/app/components/style-panel/use-design.ts +1 -28
  59. package/src/app/components/theme-toggle.tsx +4 -5
  60. package/src/app/components/themes/theme-detail.tsx +11 -8
  61. package/src/app/components/themes/themes-gallery.tsx +13 -8
  62. package/src/app/components/thumbnail-rail.tsx +14 -15
  63. package/src/app/index.html +21 -0
  64. package/src/app/lib/assets.ts +6 -7
  65. package/src/app/lib/dom.ts +42 -0
  66. package/src/app/lib/export-html.ts +10 -25
  67. package/src/app/lib/export-pdf.ts +11 -28
  68. package/src/app/lib/export-pptx.ts +6 -36
  69. package/src/app/lib/folders.ts +51 -46
  70. package/src/app/lib/inspector/inline-text.ts +31 -0
  71. package/src/app/lib/inspector/pick-target.ts +38 -0
  72. package/src/app/lib/inspector/use-comments.ts +1 -1
  73. package/src/app/lib/keys.ts +18 -0
  74. package/src/app/lib/last-home-location.ts +18 -0
  75. package/src/app/lib/print-ready.ts +2 -4
  76. package/src/app/lib/slides.ts +7 -4
  77. package/src/app/lib/text-diff.ts +19 -0
  78. package/src/app/lib/use-click-page-navigation.ts +2 -6
  79. package/src/app/lib/use-is-mobile.ts +2 -14
  80. package/src/app/lib/use-media-query.ts +20 -0
  81. package/src/app/lib/use-prefers-reduced-motion.ts +5 -13
  82. package/src/app/lib/use-slide-module.ts +1 -1
  83. package/src/app/lib/use-wheel-page-navigation.ts +1 -1
  84. package/src/app/lib/utils.test.ts +25 -1
  85. package/src/app/lib/utils.ts +8 -0
  86. package/src/app/routes/home-shell.tsx +71 -64
  87. package/src/app/routes/home.tsx +50 -58
  88. package/src/app/routes/presenter.tsx +14 -23
  89. package/src/app/routes/slide.tsx +90 -77
  90. package/src/app/routes/themes.tsx +7 -8
  91. package/src/app/styles.css +40 -44
  92. package/src/locale/en.ts +2 -7
  93. package/src/locale/ja.ts +2 -7
  94. package/src/locale/types.ts +2 -7
  95. package/src/locale/zh-cn.ts +2 -7
  96. package/src/locale/zh-tw.ts +2 -7
  97. package/dist/sync-BCJDRIqo.js +0 -139
  98. package/dist/sync-j9_QPovT.js +0 -3
  99. package/src/app/components/pdf-progress-toast.tsx +0 -32
  100. package/src/app/components/pptx-progress-toast.tsx +0 -32
@@ -2,6 +2,8 @@ import config from 'virtual:open-slide/config';
2
2
  import { Loader2, RefreshCw, RotateCw } from 'lucide-react';
3
3
  import { useEffect, useState } from 'react';
4
4
  import { toast } from 'sonner';
5
+ import { LanguageToggle } from '@/components/language-toggle';
6
+ import { ThemeToggle } from '@/components/theme-toggle';
5
7
  import { Button } from '@/components/ui/button';
6
8
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
7
9
  import { format, useLocale } from '@/lib/use-locale';
@@ -53,15 +55,22 @@ export function SidebarFooter() {
53
55
  }
54
56
  }
55
57
 
56
- const versionRow = (
57
- <span className="inline-flex cursor-default items-center gap-1.5">
58
- {update?.latest && <span className="size-1.5 rounded-full bg-brand" aria-hidden />}
58
+ const versionRow = update?.latest ? (
59
+ // Real button: the tooltip holds actionable controls, so keyboard users
60
+ // must be able to reach and open it.
61
+ <button
62
+ type="button"
63
+ className="inline-flex cursor-default items-center gap-1.5 rounded-[3px] outline-none focus-visible:ring-1 focus-visible:ring-brand"
64
+ >
65
+ <span className="size-1.5 rounded-full bg-brand" aria-hidden />
59
66
  {label}
60
- </span>
67
+ </button>
68
+ ) : (
69
+ <span className="inline-flex cursor-default items-center gap-1.5">{label}</span>
61
70
  );
62
71
 
63
72
  return (
64
- <div className="px-4 py-3 text-[11px] text-muted-foreground/70 tabular-nums">
73
+ <div className="flex items-center justify-between gap-2 py-1.5 pr-2 pl-4 text-[11px] text-muted-foreground/70 tabular-nums">
65
74
  {update?.latest ? (
66
75
  <TooltipProvider delay={200}>
67
76
  <Tooltip
@@ -93,7 +102,7 @@ export function SidebarFooter() {
93
102
  onClick={restartServer}
94
103
  >
95
104
  {restarting ? (
96
- <Loader2 className="animate-spin" aria-hidden />
105
+ <Loader2 className="animate-spin motion-reduce:animate-none" aria-hidden />
97
106
  ) : (
98
107
  <RotateCw aria-hidden />
99
108
  )}
@@ -115,7 +124,7 @@ export function SidebarFooter() {
115
124
  onClick={updatePackage}
116
125
  >
117
126
  {isUpdating ? (
118
- <Loader2 className="animate-spin" aria-hidden />
127
+ <Loader2 className="animate-spin motion-reduce:animate-none" aria-hidden />
119
128
  ) : (
120
129
  <RefreshCw aria-hidden />
121
130
  )}
@@ -134,6 +143,10 @@ export function SidebarFooter() {
134
143
  ) : (
135
144
  versionRow
136
145
  )}
146
+ <div className="flex shrink-0 items-center">
147
+ <LanguageToggle />
148
+ <ThemeToggle />
149
+ </div>
137
150
  </div>
138
151
  );
139
152
  }
@@ -1,13 +1,12 @@
1
- import { Plus } from 'lucide-react';
1
+ import { Plus, Search } from 'lucide-react';
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { toast } from 'sonner';
4
- import { LanguageToggle } from '@/components/language-toggle';
5
- import { ThemeToggle } from '@/components/theme-toggle';
4
+ import logo from '@/assets/open-slide.png';
6
5
  import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
7
6
  import type { Folder, FolderIcon } from '@/lib/sdk';
8
7
  import { format, useLocale } from '@/lib/use-locale';
9
8
  import { cn } from '@/lib/utils';
10
- import { CommandMenuTrigger } from '../command/command-menu';
9
+ import { COMMAND_MENU_SHORTCUT } from '../command/command-menu';
11
10
  import { FolderIconChip, FolderItem } from './folder-item';
12
11
  import { IconPicker, PRESET_COLORS } from './icon-picker';
13
12
  import { SidebarFooter } from './sidebar-footer';
@@ -129,17 +128,42 @@ export function Sidebar({
129
128
  }, [creating]);
130
129
 
131
130
  return (
132
- <aside className="relative flex h-full w-[16.5rem] shrink-0 flex-col border-r border-hairline bg-sidebar text-sidebar-foreground">
133
- <div className="flex items-center justify-between px-4 pt-5 pb-4">
134
- <h1 className="font-heading text-lg font-bold tracking-tight">{t.home.appTitle}</h1>
135
- <div className="-mr-1.5 flex items-center">
136
- <CommandMenuTrigger onClick={onOpenCommandMenu} />
137
- <LanguageToggle />
138
- <ThemeToggle />
139
- </div>
131
+ <aside className="group/side relative flex h-full w-[16.5rem] shrink-0 flex-col bg-sidebar text-sidebar-foreground">
132
+ <div className="flex items-center gap-2.5 px-4 pt-4 pb-3">
133
+ <img
134
+ src={logo}
135
+ alt=""
136
+ aria-hidden
137
+ draggable={false}
138
+ className="size-6 shrink-0 select-none rounded-[6px] ring-1 ring-foreground/10"
139
+ />
140
+ <h1 className="font-heading text-[13.5px] font-semibold tracking-tight">
141
+ {t.home.appTitle}
142
+ </h1>
143
+ </div>
144
+
145
+ <div className="px-2 pb-3">
146
+ <button
147
+ type="button"
148
+ onClick={onOpenCommandMenu}
149
+ aria-label={t.commandMenu.triggerAria}
150
+ aria-haspopup="dialog"
151
+ className={cn(
152
+ 'flex h-8 w-full items-center gap-2 rounded-[6px] border border-border bg-card px-2.5 text-[12.5px] text-muted-foreground shadow-edge outline-none',
153
+ 'transition-[border-color,color,background-color] duration-100',
154
+ 'hover:border-foreground/20 hover:text-foreground',
155
+ 'focus-visible:border-foreground/30 focus-visible:ring-2 focus-visible:ring-ring/30',
156
+ )}
157
+ >
158
+ <Search className="size-3.5 shrink-0" aria-hidden />
159
+ <span className="flex-1 truncate text-left">{t.commandMenu.triggerTooltip}</span>
160
+ <kbd className="rounded-[4px] border border-hairline bg-muted/60 px-1 py-px font-mono text-[9.5px] leading-none tracking-[0.04em] text-muted-foreground">
161
+ {COMMAND_MENU_SHORTCUT}
162
+ </kbd>
163
+ </button>
140
164
  </div>
141
165
 
142
- <div className="px-2">
166
+ <div className="space-y-0.5 px-2">
143
167
  <FolderItem
144
168
  row={{ kind: 'all' }}
145
169
  count={allCount}
@@ -165,12 +189,27 @@ export function Sidebar({
165
189
  )}
166
190
  </div>
167
191
 
168
- <div className="mt-5 flex items-center gap-2 px-4 pb-1.5">
192
+ <div className="mt-5 flex h-6 items-center justify-between pr-2.5 pl-4 pb-0.5">
169
193
  <span className="eyebrow">{t.home.folders}</span>
170
- <span className="h-px flex-1 bg-hairline" aria-hidden />
194
+ {import.meta.env.DEV && (
195
+ <button
196
+ type="button"
197
+ onClick={startCreating}
198
+ aria-label={t.home.newFolder}
199
+ title={t.home.newFolder}
200
+ className={cn(
201
+ 'flex size-5 items-center justify-center rounded-[4px] text-muted-foreground/70 opacity-0 outline-none',
202
+ 'transition-[opacity,background-color,color,scale] duration-100',
203
+ 'hover:bg-muted hover:text-foreground active:scale-90',
204
+ 'group-hover/side:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-brand',
205
+ )}
206
+ >
207
+ <Plus className="size-3.5" />
208
+ </button>
209
+ )}
171
210
  </div>
172
211
 
173
- <div className="flex-1 overflow-y-auto px-2 pb-2">
212
+ <div className="flex-1 space-y-0.5 overflow-y-auto px-2 pb-2">
174
213
  <FolderItem
175
214
  row={{ kind: 'draft' }}
176
215
  count={countFor(null)}
@@ -246,57 +285,45 @@ export function Sidebar({
246
285
  );
247
286
  })}
248
287
 
249
- {import.meta.env.DEV &&
250
- (creating ? (
251
- <div
252
- data-folder-create
253
- className="mt-1 flex items-center gap-2.5 rounded-[5px] border border-dashed border-foreground/30 bg-card px-2 py-[5px]"
254
- >
255
- <Popover open={iconOpen} onOpenChange={setIconOpen}>
256
- <PopoverTrigger
257
- render={
258
- <button
259
- type="button"
260
- className="flex size-5 shrink-0 items-center justify-center rounded transition-transform hover:scale-110"
261
- aria-label={t.home.pickIcon}
262
- >
263
- <FolderIconChip icon={newIcon} />
264
- </button>
265
- }
266
- />
267
- <PopoverContent side="right" align="start" className="w-auto p-2">
268
- <IconPicker value={newIcon} onChange={setNewIcon} />
269
- </PopoverContent>
270
- </Popover>
271
- <input
272
- ref={inputRef}
273
- value={newName}
274
- onChange={(e) => setNewName(e.target.value)}
275
- onKeyDown={(e) => {
276
- if (e.nativeEvent.isComposing) return;
277
- if (e.key === 'Enter') commitCreate();
278
- if (e.key === 'Escape') exitCreate();
279
- }}
280
- placeholder={t.home.folderName}
281
- maxLength={40}
282
- className="min-w-0 flex-1 bg-transparent text-[12.5px] outline-none placeholder:text-muted-foreground/60"
288
+ {import.meta.env.DEV && creating && (
289
+ <div
290
+ data-folder-create
291
+ className="mt-1 flex items-center gap-2.5 rounded-[5px] border border-dashed border-foreground/30 bg-card px-2 py-[5px]"
292
+ >
293
+ <Popover open={iconOpen} onOpenChange={setIconOpen}>
294
+ <PopoverTrigger
295
+ render={
296
+ <button
297
+ type="button"
298
+ className="flex size-5 shrink-0 items-center justify-center rounded outline-none motion-safe:transition-transform motion-safe:duration-150 hover:scale-110 active:scale-95 focus-visible:ring-1 focus-visible:ring-brand"
299
+ aria-label={t.home.pickIcon}
300
+ >
301
+ <FolderIconChip icon={newIcon} />
302
+ </button>
303
+ }
283
304
  />
284
- </div>
285
- ) : (
286
- <button
287
- type="button"
288
- onClick={startCreating}
289
- className="mt-1 flex w-full items-center gap-2 rounded-[5px] px-2 py-1.5 text-[12px] text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground"
290
- >
291
- <Plus className="size-3.5" />
292
- <span>{t.home.newFolder}</span>
293
- </button>
294
- ))}
305
+ <PopoverContent side="right" align="start" className="w-auto p-2">
306
+ <IconPicker value={newIcon} onChange={setNewIcon} />
307
+ </PopoverContent>
308
+ </Popover>
309
+ <input
310
+ ref={inputRef}
311
+ value={newName}
312
+ onChange={(e) => setNewName(e.target.value)}
313
+ onKeyDown={(e) => {
314
+ if (e.nativeEvent.isComposing) return;
315
+ if (e.key === 'Enter') commitCreate();
316
+ if (e.key === 'Escape') exitCreate();
317
+ }}
318
+ placeholder={t.home.folderName}
319
+ maxLength={40}
320
+ className="min-w-0 flex-1 bg-transparent text-[12.5px] outline-none placeholder:text-muted-foreground/60"
321
+ />
322
+ </div>
323
+ )}
295
324
  </div>
296
325
 
297
- <div className="border-t border-hairline">
298
- <SidebarFooter />
299
- </div>
326
+ <SidebarFooter />
300
327
  </aside>
301
328
  );
302
329
  }
@@ -10,7 +10,6 @@ type Props = {
10
10
  center?: boolean;
11
11
  flat?: boolean;
12
12
  freezeMotion?: boolean;
13
- className?: string;
14
13
  design?: DesignSystem;
15
14
  };
16
15
 
@@ -20,7 +19,6 @@ export function SlideCanvas({
20
19
  center = true,
21
20
  flat = false,
22
21
  freezeMotion = false,
23
- className,
24
22
  design,
25
23
  }: Props) {
26
24
  const containerRef = useRef<HTMLDivElement>(null);
@@ -50,13 +48,11 @@ export function SlideCanvas({
50
48
  const designVars = design ? designToCssVars(design) : undefined;
51
49
 
52
50
  return (
53
- <div ref={containerRef} className={cn('relative h-full w-full overflow-hidden', className)}>
51
+ <div ref={containerRef} className={cn('relative h-full w-full', flat && 'overflow-hidden')}>
54
52
  <div
55
53
  className={cn(
56
54
  'overflow-hidden bg-white text-black',
57
- // Inset shadow keeps the 1px edge inside the canvas box so it
58
- // can't be clipped by the parent's overflow-hidden.
59
- !flat && 'rounded-[6px] shadow-[inset_0_0_0_1px_oklch(0_0_0/0.08)]',
55
+ !flat && 'rounded-[6px] shadow-floating',
60
56
  )}
61
57
  style={
62
58
  {
@@ -180,7 +180,7 @@ function shouldSkipCopiedStyle(
180
180
  prop: string,
181
181
  preserveInheritedVisualStyle: boolean,
182
182
  ): boolean {
183
- if (prop === TEXT_FILL_COLOR_PROPERTY && getStyleProperty(styles, prop) === styles.color) {
183
+ if (prop === TEXT_FILL_COLOR_PROPERTY && styles.getPropertyValue(prop) === styles.color) {
184
184
  return true;
185
185
  }
186
186
 
@@ -190,7 +190,7 @@ function shouldSkipCopiedStyle(
190
190
  if (!parent) return false;
191
191
 
192
192
  const parentStyles = getComputedStyle(parent);
193
- return getStyleProperty(styles, prop) === getStyleProperty(parentStyles, prop);
193
+ return styles.getPropertyValue(prop) === parentStyles.getPropertyValue(prop);
194
194
  }
195
195
 
196
196
  function copyComputedStyles(
@@ -261,10 +261,6 @@ function morphTranslateTransform(rect: LocalRect, local: string): string {
261
261
  return [`translate(${rect.left}px, ${rect.top}px)`, local].filter(Boolean).join(' ');
262
262
  }
263
263
 
264
- function getStyleProperty(styles: CSSStyleDeclaration, css: string): string {
265
- return styles.getPropertyValue(css);
266
- }
267
-
268
264
  // element.animate() silently drops kebab-case keys; keyframe properties must
269
265
  // use their IDL camelCase names.
270
266
  function keyframeProperty(css: string): string {
@@ -284,7 +280,7 @@ function visualStyleKeyframe(
284
280
  ) {
285
281
  continue;
286
282
  }
287
- const value = getStyleProperty(styles, prop);
283
+ const value = styles.getPropertyValue(prop);
288
284
  if (prop === TEXT_FILL_COLOR_PROPERTY && value === styles.color) continue;
289
285
  if (value) frame[keyframeProperty(prop)] = value;
290
286
  }
@@ -302,8 +298,8 @@ function isVisibleBorderSide(
302
298
  styles: CSSStyleDeclaration,
303
299
  side: (typeof BORDER_SIDE_PROPERTIES)[number],
304
300
  ): boolean {
305
- const width = parsePx(getStyleProperty(styles, side.cssWidth)) ?? 0;
306
- const borderStyle = getStyleProperty(styles, side.cssStyle);
301
+ const width = parsePx(styles.getPropertyValue(side.cssWidth)) ?? 0;
302
+ const borderStyle = styles.getPropertyValue(side.cssStyle);
307
303
  return width > 0 && borderStyle !== 'none' && borderStyle !== 'hidden';
308
304
  }
309
305
 
@@ -325,8 +321,8 @@ function borderFrameKeyframe(
325
321
  };
326
322
 
327
323
  for (const side of BORDER_SIDE_PROPERTIES) {
328
- frame[side.width] = getStyleProperty(styles, side.cssWidth);
329
- frame[side.color] = getStyleProperty(styles, side.cssColor);
324
+ frame[side.width] = styles.getPropertyValue(side.cssWidth);
325
+ frame[side.color] = styles.getPropertyValue(side.cssColor);
330
326
  }
331
327
 
332
328
  return frame;
@@ -357,9 +353,9 @@ function appendBorderFrame(
357
353
 
358
354
  for (const side of BORDER_SIDE_PROPERTIES) {
359
355
  const styles = isVisibleBorderSide(sourceStyles, side) ? sourceStyles : targetStyles;
360
- frame.style[side.style] = getStyleProperty(styles, side.cssStyle);
361
- frame.style[side.width] = getStyleProperty(sourceStyles, side.cssWidth);
362
- frame.style[side.color] = getStyleProperty(sourceStyles, side.cssColor);
356
+ frame.style[side.style] = styles.getPropertyValue(side.cssStyle);
357
+ frame.style[side.width] = sourceStyles.getPropertyValue(side.cssWidth);
358
+ frame.style[side.color] = sourceStyles.getPropertyValue(side.cssColor);
363
359
  }
364
360
 
365
361
  overlay.appendChild(frame);
@@ -368,7 +364,7 @@ function appendBorderFrame(
368
364
 
369
365
  function hasVisualStyleChange(from: CSSStyleDeclaration, to: CSSStyleDeclaration): boolean {
370
366
  for (const prop of MORPH_VISUAL_PROPERTIES) {
371
- if (getStyleProperty(from, prop) !== getStyleProperty(to, prop)) return true;
367
+ if (from.getPropertyValue(prop) !== to.getPropertyValue(prop)) return true;
372
368
  }
373
369
  return false;
374
370
  }
@@ -508,7 +504,38 @@ function runMorphTransition(
508
504
  const animations: Animation[] = [];
509
505
  const restore: Array<() => void> = [];
510
506
  const outgoing = collectMorphElements(outgoingLayer);
511
- const handledIncoming = new Set<string>();
507
+
508
+ // An element with no counterpart (or no usable rect on one side) can't
509
+ // travel, so it fades in place instead of morphing.
510
+ const fadeOutSource = (source: HTMLElement, from: LocalRect) => {
511
+ const clone = appendPositionedClone(wrapper, overlay, source, from);
512
+ restore.push(hideOriginal(source));
513
+ animations.push(
514
+ runStationaryMorphAnimation(
515
+ clone,
516
+ from,
517
+ getComputedStyle(source),
518
+ effectiveOpacity(source, outgoingLayer),
519
+ '0',
520
+ phase,
521
+ ),
522
+ );
523
+ };
524
+
525
+ const fadeInTarget = (target: HTMLElement, to: LocalRect) => {
526
+ const clone = appendPositionedClone(wrapper, overlay, target, to);
527
+ restore.push(hideOriginal(target));
528
+ animations.push(
529
+ runStationaryMorphAnimation(
530
+ clone,
531
+ to,
532
+ getComputedStyle(target),
533
+ '0',
534
+ effectiveOpacity(target, incomingLayer),
535
+ phase,
536
+ ),
537
+ );
538
+ };
512
539
 
513
540
  for (const [id, source] of outgoing) {
514
541
  const target = incoming.get(id);
@@ -517,65 +544,23 @@ function runMorphTransition(
517
544
  if (target) {
518
545
  const to = measureLocalRect(target, wrapper, wrapperRect);
519
546
  if (hasUsableRect(to)) {
520
- handledIncoming.add(id);
521
- const clone = appendPositionedClone(wrapper, overlay, target, to);
522
- restore.push(hideOriginal(target));
523
-
524
- const targetStyles = getComputedStyle(target);
525
- animations.push(
526
- runStationaryMorphAnimation(
527
- clone,
528
- to,
529
- targetStyles,
530
- '0',
531
- effectiveOpacity(target, incomingLayer),
532
- phase,
533
- ),
534
- );
547
+ fadeInTarget(target, to);
535
548
  }
536
549
  }
537
550
  continue;
538
551
  }
539
552
 
540
553
  if (!target) {
541
- const clone = appendPositionedClone(wrapper, overlay, source, from);
542
- restore.push(hideOriginal(source));
543
-
544
- const sourceStyles = getComputedStyle(source);
545
- animations.push(
546
- runStationaryMorphAnimation(
547
- clone,
548
- from,
549
- sourceStyles,
550
- effectiveOpacity(source, outgoingLayer),
551
- '0',
552
- phase,
553
- ),
554
- );
554
+ fadeOutSource(source, from);
555
555
  continue;
556
556
  }
557
557
 
558
558
  const to = measureLocalRect(target, wrapper, wrapperRect);
559
559
  if (!hasUsableRect(to)) {
560
- const clone = appendPositionedClone(wrapper, overlay, source, from);
561
- restore.push(hideOriginal(source));
562
-
563
- const sourceStyles = getComputedStyle(source);
564
- animations.push(
565
- runStationaryMorphAnimation(
566
- clone,
567
- from,
568
- sourceStyles,
569
- effectiveOpacity(source, outgoingLayer),
570
- '0',
571
- phase,
572
- ),
573
- );
560
+ fadeOutSource(source, from);
574
561
  continue;
575
562
  }
576
563
 
577
- handledIncoming.add(id);
578
-
579
564
  const clone = appendPositionedClone(wrapper, overlay, source, from);
580
565
  restore.push(hideOriginal(source), hideOriginal(target));
581
566
 
@@ -628,25 +613,12 @@ function runMorphTransition(
628
613
  }
629
614
 
630
615
  for (const [id, target] of incoming) {
631
- if (handledIncoming.has(id) || outgoing.has(id)) continue;
616
+ if (outgoing.has(id)) continue;
632
617
 
633
618
  const to = measureLocalRect(target, wrapper, wrapperRect);
634
619
  if (!hasUsableRect(to)) continue;
635
620
 
636
- const clone = appendPositionedClone(wrapper, overlay, target, to);
637
- restore.push(hideOriginal(target));
638
-
639
- const targetStyles = getComputedStyle(target);
640
- animations.push(
641
- runStationaryMorphAnimation(
642
- clone,
643
- to,
644
- targetStyles,
645
- '0',
646
- effectiveOpacity(target, incomingLayer),
647
- phase,
648
- ),
649
- );
621
+ fadeInTarget(target, to);
650
622
  }
651
623
 
652
624
  if (animations.length === 0) overlay.remove();
@@ -10,7 +10,7 @@ import {
10
10
  } from 'react';
11
11
  import { toast } from 'sonner';
12
12
  import { useHistory } from '@/components/history-provider';
13
- import { type DesignSystem, defaultDesign, designToCssVars } from '../../lib/design';
13
+ import { type DesignSystem, designToCssVars } from '../../lib/design';
14
14
  import { shuffleDesign } from '../../lib/design-presets';
15
15
  import { useDesign as useDesignFetch } from './use-design';
16
16
 
@@ -26,7 +26,6 @@ type DesignCtx = {
26
26
  update: (mut: (next: DesignSystem) => void, coalesceKey?: string) => void;
27
27
  commit: () => Promise<void>;
28
28
  discard: () => void;
29
- resetToDefaults: () => void;
30
29
  shuffle: () => void;
31
30
  };
32
31
 
@@ -89,17 +88,6 @@ export function DesignProvider({ slideId, children }: { slideId: string; childre
89
88
  history.clear();
90
89
  }, [design, history]);
91
90
 
92
- const resetToDefaults = useCallback(() => {
93
- const prev = draftRef.current;
94
- const next = clone(defaultDesign);
95
- setDraft(next);
96
- history.record({
97
- coalesceKey: 'design:reset',
98
- undo: () => setDraft(prev),
99
- redo: () => setDraft(next),
100
- });
101
- }, [history]);
102
-
103
91
  const shuffle = useCallback(() => {
104
92
  const prev = draftRef.current;
105
93
  const next = clone(shuffleDesign(prev));
@@ -132,7 +120,6 @@ export function DesignProvider({ slideId, children }: { slideId: string; childre
132
120
  update,
133
121
  commit,
134
122
  discard,
135
- resetToDefaults,
136
123
  shuffle,
137
124
  };
138
125
 
@@ -3,6 +3,7 @@ import { useEffect, useState } from 'react';
3
3
  import { Field, NumberField, Section } from '@/components/panel/panel-fields';
4
4
  import { PanelShell, usePanelMount } from '@/components/panel/panel-shell';
5
5
  import { useLocale } from '@/lib/use-locale';
6
+ import { cn } from '@/lib/utils';
6
7
  import { Button } from '../ui/button';
7
8
  import { Input } from '../ui/input';
8
9
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select';
@@ -29,12 +30,14 @@ type DesignPanelProps = {
29
30
 
30
31
  export function DesignPanel({ open, onClose }: DesignPanelProps) {
31
32
  const { draft, exists, warning, loaded, dirty, update, shuffle } = useDesignPanelState();
32
- const { mounted, animVisible } = usePanelMount(open);
33
+ // Gate the mount on data readiness so the first open still slides in
34
+ // instead of popping fully expanded once loading finishes.
35
+ const ready = loaded && draft != null;
36
+ const { mounted, animVisible } = usePanelMount(open && ready);
33
37
  const t = useLocale();
34
38
 
35
- if (!loaded) return null;
39
+ if (!ready) return null;
36
40
  if (!mounted) return null;
37
- if (!draft) return null;
38
41
 
39
42
  return (
40
43
  <PanelShell
@@ -52,13 +55,14 @@ export function DesignPanel({ open, onClose }: DesignPanelProps) {
52
55
  {t.stylePanel.draftBadge}
53
56
  </span>
54
57
  )}
55
- {dirty && (
56
- <span
57
- className="size-1.5 rounded-full bg-brand"
58
- title={t.stylePanel.unsavedTitle}
59
- aria-hidden
60
- />
61
- )}
58
+ <span
59
+ className={cn(
60
+ 'size-1.5 rounded-full bg-brand transition-opacity duration-150',
61
+ dirty ? 'opacity-100' : 'opacity-0',
62
+ )}
63
+ title={dirty ? t.stylePanel.unsavedTitle : undefined}
64
+ aria-hidden
65
+ />
62
66
  </div>
63
67
  <div className="flex items-center gap-0.5">
64
68
  <Button
@@ -232,7 +236,7 @@ function ColorField({
232
236
 
233
237
  return (
234
238
  <Field label={label}>
235
- <label className="relative inline-flex size-8 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-md border bg-background shadow-xs">
239
+ <label className="relative inline-flex size-8 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-md border bg-background shadow-xs transition-[border-color,scale] duration-150 hover:border-foreground/20 active:scale-[0.96] has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring/40">
236
240
  <span className="size-5 rounded-sm" style={{ backgroundColor: value }} />
237
241
  <input
238
242
  type="color"
@@ -252,7 +256,7 @@ function ColorField({
252
256
  onBlur={() => {
253
257
  if (!/^#[0-9a-fA-F]{6}$/.test(hexDraft)) setHexDraft(value);
254
258
  }}
255
- className="h-8 flex-1 font-mono text-[11px] uppercase"
259
+ className="nums h-8 flex-1 font-mono text-[11px] uppercase"
256
260
  spellCheck={false}
257
261
  />
258
262
  </Field>
@@ -9,9 +9,7 @@ type FetchedState = {
9
9
  };
10
10
 
11
11
  export type UseDesignReturn = FetchedState & {
12
- refresh: () => Promise<void>;
13
12
  save: (patch: Partial<DesignSystem>) => Promise<{ ok: boolean; error?: string }>;
14
- reset: () => Promise<{ ok: boolean; error?: string }>;
15
13
  };
16
14
 
17
15
  export function useDesign(slideId: string): UseDesignReturn {
@@ -83,30 +81,5 @@ export function useDesign(slideId: string): UseDesignReturn {
83
81
  }
84
82
  }, []);
85
83
 
86
- const reset = useCallback(async () => {
87
- const id = slideIdRef.current;
88
- if (!id) return { ok: false, error: 'no slide id' };
89
- try {
90
- const res = await fetch(`/__design/reset?slideId=${encodeURIComponent(id)}`, {
91
- method: 'POST',
92
- });
93
- const body = (await res.json()) as { ok?: boolean; error?: string; design?: DesignSystem };
94
- if (!res.ok || !body.ok) {
95
- return { ok: false, error: body.error ?? `HTTP ${res.status}` };
96
- }
97
- if (body.design) {
98
- setState((s) => ({
99
- ...s,
100
- design: body.design ?? s.design,
101
- exists: true,
102
- warning: null,
103
- }));
104
- }
105
- return { ok: true };
106
- } catch (err) {
107
- return { ok: false, error: String((err as Error).message) };
108
- }
109
- }, []);
110
-
111
- return { ...state, refresh, save, reset };
84
+ return { ...state, save };
112
85
  }