@widgetic/editor 4.1.16 → 4.1.17
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/components/editors/EmbedEditor.svelte +2 -1
- package/dist/components/editors/PropsEditor.svelte +14 -11
- package/dist/components/ic/AngleInputController.svelte +1 -1
- package/dist/components/ic/DropdownInputController.svelte +2 -12
- package/dist/components/ic/FontInputController.svelte +3 -12
- package/dist/components/ic/NumberControls.svelte +69 -25
- package/dist/components/ic/NumberControls.svelte.d.ts +5 -1
- package/dist/components/ic/TextAreaInputController.svelte +3 -11
- package/dist/components/ic/VectorInputController.svelte +2 -7
- package/dist/components/ic/numberControlsSteps.d.ts +17 -0
- package/dist/components/ic/numberControlsSteps.js +23 -0
- package/dist/components/ic/shared/DropdownChevron.svelte +23 -0
- package/dist/components/ic/shared/DropdownChevron.svelte.d.ts +9 -0
- package/package.json +1 -1
|
@@ -112,8 +112,9 @@
|
|
|
112
112
|
on:propertyChange
|
|
113
113
|
>
|
|
114
114
|
{#snippet headerContent()}
|
|
115
|
+
<!-- Figma Embed panel: 16 under the grip row (the panel header and its 16 gap), and no padding below: the 16 gap to the first accordion belongs to the list under it (PropsEditor). -->
|
|
115
116
|
<section
|
|
116
|
-
class="embed-editor-code-header flex flex-col gap-3 px-6 pt-
|
|
117
|
+
class="embed-editor-code-header flex flex-col gap-3 px-6 pt-4 pb-0"
|
|
117
118
|
aria-label={$t('editor.embed.headerArea')}
|
|
118
119
|
aria-busy={loading}
|
|
119
120
|
>
|
|
@@ -170,6 +170,11 @@
|
|
|
170
170
|
|
|
171
171
|
/** Optional content below the shared toolbar, before property fields. */
|
|
172
172
|
export let headerContent = undefined;
|
|
173
|
+
/**
|
|
174
|
+
* The space above the first accordion when there is only one tab. Under a header block (the Embed code header) Figma's panel gap
|
|
175
|
+
* puts the first accordion 16 below it; without a header the list starts 24 below the panel's top edge.
|
|
176
|
+
*/
|
|
177
|
+
$: singleTabTopPaddingClass = headerContent ? 'pt-4' : 'pt-6';
|
|
173
178
|
export let headerClass = '';
|
|
174
179
|
export let dragHandleClass = '';
|
|
175
180
|
export let title: string | undefined = undefined;
|
|
@@ -2141,10 +2146,10 @@
|
|
|
2141
2146
|
class="h-full"
|
|
2142
2147
|
type="hover"
|
|
2143
2148
|
scrollHideDelay={0}
|
|
2144
|
-
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ?
|
|
2149
|
+
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'} [&>div]:w-2 [&>div]:cursor-pointer [&>div]:rounded-full [&>div]:bg-border [&>div]:duration-fast [&>div]:hover:bg-muted-foreground/30"
|
|
2145
2150
|
>
|
|
2146
2151
|
<div class="scroll-viewport" data-radix-scroll-area-viewport bind:this={designScrollViewport}>
|
|
2147
|
-
<div class="px-6 pb-6 {!designSchema || !contentSchema ?
|
|
2152
|
+
<div class="px-6 pb-6 {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'}" bind:this={designContentWrapper}>
|
|
2148
2153
|
<Tabs.Content
|
|
2149
2154
|
value="design"
|
|
2150
2155
|
class="design-tab-content mt-0! tabs-content-container w-full outline-none {isFirstLoad ? 'initial-load' : !isInitialTabLoad ? 'animate-slide-left' : ''}"
|
|
@@ -2257,10 +2262,10 @@
|
|
|
2257
2262
|
class="h-full"
|
|
2258
2263
|
type="hover"
|
|
2259
2264
|
scrollHideDelay={0}
|
|
2260
|
-
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ?
|
|
2265
|
+
scrollbarYClasses="flex w-6 touch-none select-none px-2 pb-6 transition-colors duration-fast {headerContent ? 'bg-transparent' : 'bg-background'} {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'} [&>div]:w-2 [&>div]:cursor-pointer [&>div]:rounded-full [&>div]:bg-border [&>div]:duration-fast [&>div]:hover:bg-muted-foreground/30"
|
|
2261
2266
|
>
|
|
2262
2267
|
<div class="scroll-viewport" data-radix-scroll-area-viewport bind:this={contentScrollViewport}>
|
|
2263
|
-
<div class="px-6 pb-6 {!designSchema || !contentSchema ?
|
|
2268
|
+
<div class="px-6 pb-6 {!designSchema || !contentSchema ? singleTabTopPaddingClass : 'pt-0'}" bind:this={contentWrapper}>
|
|
2264
2269
|
<Tabs.Content
|
|
2265
2270
|
value="content"
|
|
2266
2271
|
class="content-tab-content mt-0! tabs-content-container w-full {isFirstLoad ? 'initial-load' : !isInitialTabLoad ? 'animate-slide-right' : ''}"
|
|
@@ -2558,13 +2563,11 @@
|
|
|
2558
2563
|
position: static;
|
|
2559
2564
|
}
|
|
2560
2565
|
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
transition: transform var(--duration-base) ease-out;
|
|
2567
|
-
}
|
|
2566
|
+
/*
|
|
2567
|
+
* The accordion arrow is turned and eased by the design system's own trigger (`[&[data-state=open]>svg]:rotate-180` with
|
|
2568
|
+
* `transition-transform duration-base`). A second `transform: rotate(180deg)` here used to be added to the trigger's `rotate`
|
|
2569
|
+
* (Tailwind 4 uses the `rotate` property), which made an open accordion turn a full 360 degrees and point down again.
|
|
2570
|
+
*/
|
|
2568
2571
|
|
|
2569
2572
|
/* Content card headers: underline title on hover, not when hovering the drag handle. */
|
|
2570
2573
|
:global(.content-item-trigger:hover .content-title),
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* Shadcn UI select components for consistent styling and behavior
|
|
39
39
|
*/
|
|
40
40
|
import { Select } from '@widgetic/design-system/components';
|
|
41
|
-
import
|
|
41
|
+
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
42
42
|
|
|
43
43
|
// The words of the editor in the language of the page.
|
|
44
44
|
const { t } = useEditorLanguage();
|
|
@@ -182,17 +182,7 @@
|
|
|
182
182
|
>
|
|
183
183
|
{triggerContent}
|
|
184
184
|
</span>
|
|
185
|
-
{
|
|
186
|
-
<IconChevronUp
|
|
187
|
-
class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
|
|
188
|
-
aria-hidden="true"
|
|
189
|
-
/>
|
|
190
|
-
{:else}
|
|
191
|
-
<IconChevronDown
|
|
192
|
-
class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
|
|
193
|
-
aria-hidden="true"
|
|
194
|
-
/>
|
|
195
|
-
{/if}
|
|
185
|
+
<DropdownChevron {open} />
|
|
196
186
|
</Select.Trigger>
|
|
197
187
|
|
|
198
188
|
<Select.Content
|
|
@@ -52,8 +52,6 @@
|
|
|
52
52
|
import {
|
|
53
53
|
IconCheck,
|
|
54
54
|
IconCloudUpload,
|
|
55
|
-
IconChevronDown,
|
|
56
|
-
IconChevronUp,
|
|
57
55
|
IconTrash
|
|
58
56
|
} from '@widgetic/design-system/icons';
|
|
59
57
|
import fontsJsonUrl from '../../assets/fonts.json?url';
|
|
@@ -86,6 +84,7 @@
|
|
|
86
84
|
// Import shared components
|
|
87
85
|
import { SearchInput } from '@widgetic/design-system/components';
|
|
88
86
|
import CategoryTabs from './shared/CategoryTabs.svelte';
|
|
87
|
+
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
89
88
|
import { RecentItemsSection, ItemGrid } from './shared';
|
|
90
89
|
import { useEditorLanguage } from '../../i18n/language';
|
|
91
90
|
import { categoryLabel, fontWeightLabel } from '../../i18n/labels';
|
|
@@ -1825,11 +1824,7 @@
|
|
|
1825
1824
|
>
|
|
1826
1825
|
{resolvedFont?.family || $t('editor.font.select')}
|
|
1827
1826
|
</span>
|
|
1828
|
-
{
|
|
1829
|
-
<IconChevronUp class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
1830
|
-
{:else}
|
|
1831
|
-
<IconChevronDown class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
1832
|
-
{/if}
|
|
1827
|
+
<DropdownChevron open={$openDropdowns?.has(controllerId)} />
|
|
1833
1828
|
</Popover.Trigger>
|
|
1834
1829
|
|
|
1835
1830
|
<Popover.Content
|
|
@@ -2060,11 +2055,7 @@
|
|
|
2060
2055
|
<span class="truncate flex-1 text-start text-body text-foreground">
|
|
2061
2056
|
{fontWeightLabel(displayWeight || 'Regular', $t)}
|
|
2062
2057
|
</span>
|
|
2063
|
-
{
|
|
2064
|
-
<IconChevronUp class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
2065
|
-
{:else}
|
|
2066
|
-
<IconChevronDown class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
2067
|
-
{/if}
|
|
2058
|
+
<DropdownChevron open={$openDropdowns?.has('weight-' + controllerId)} />
|
|
2068
2059
|
</Popover.Trigger>
|
|
2069
2060
|
<Popover.Content
|
|
2070
2061
|
align="end"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { onDestroy } from 'svelte';
|
|
3
3
|
import { Input, StepperButton } from '@widgetic/design-system/components';
|
|
4
4
|
import { useEditorLanguage } from '../../i18n/language';
|
|
5
|
+
import { steppedNumber } from './numberControlsSteps';
|
|
5
6
|
|
|
6
7
|
const { t } = useEditorLanguage();
|
|
7
8
|
|
|
@@ -19,8 +20,13 @@
|
|
|
19
20
|
let className = '';
|
|
20
21
|
export { className as class };
|
|
21
22
|
export let disabled: boolean = false;
|
|
22
|
-
/**
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Padding at the end of the accent surface, after the steppers (Figma IC Number vs IC Angle field).
|
|
25
|
+
* The padding at the start is not on the surface: it is inside the text hit area, so the hit area reaches the edge.
|
|
26
|
+
*/
|
|
27
|
+
export let surfacePaddingClass: string = 'pe-1';
|
|
28
|
+
/** Padding at the start of the text hit area: it keeps the value 12px in from the edge (Figma IC Number: the value is at x=12). */
|
|
29
|
+
export let inputPaddingClass: string = 'ps-3';
|
|
24
30
|
/** @deprecated use `class` — kept for Angle layout width. */
|
|
25
31
|
export let width: string | undefined = undefined;
|
|
26
32
|
|
|
@@ -49,26 +55,30 @@
|
|
|
49
55
|
const surfaceBaseClass =
|
|
50
56
|
'number-controls-surface flex h-9 w-full min-w-0 items-center gap-1 rounded-lg bg-accent transition-colors duration-fast hover:bg-accent-hover focus-within:outline-hidden focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background disabled:pointer-events-none disabled:opacity-50';
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
/**
|
|
59
|
+
* One step of the stepper (button, hold or arrow key). Returns false when nothing was applied because the value is at a limit.
|
|
60
|
+
*/
|
|
61
|
+
function handleValueChange(adjustment: number): boolean {
|
|
53
62
|
try {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (min !== undefined && newValue < min) {
|
|
61
|
-
newValue = min;
|
|
62
|
-
}
|
|
63
|
-
if (max !== undefined && newValue > max) {
|
|
64
|
-
newValue = max;
|
|
65
|
-
}
|
|
63
|
+
const newValue = steppedNumber(value, adjustment, { min, max, wrapAround });
|
|
64
|
+
|
|
65
|
+
// At a limit there is nothing to apply, and nothing to repeat: no event for the page, and a held button stops here
|
|
66
|
+
if (newValue === value) {
|
|
67
|
+
stopAutoRepeat();
|
|
68
|
+
return false;
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
value = newValue;
|
|
72
|
+
// The field shows the new number at once, also when the person has typed in it. It used to keep the typed text
|
|
73
|
+
// (`isEditing` stays true while the field has the focus, and a stepper button does not take the focus) and
|
|
74
|
+
// `handleBlur` then wrote that old text back over the number the stepper had set.
|
|
75
|
+
inputValue = String(newValue);
|
|
76
|
+
isEditing = false;
|
|
69
77
|
onChange(newValue);
|
|
78
|
+
return true;
|
|
70
79
|
} catch (error) {
|
|
71
80
|
console.error('Error in handleValueChange:', error);
|
|
81
|
+
return false;
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
|
|
@@ -181,12 +191,21 @@
|
|
|
181
191
|
}
|
|
182
192
|
|
|
183
193
|
function startAutoRepeat(operation: 'increment' | 'decrement', event: MouseEvent) {
|
|
194
|
+
// Only the main button steps: a right or middle click must not
|
|
195
|
+
if (event.button !== 0) return;
|
|
184
196
|
event.preventDefault();
|
|
185
197
|
stopAutoRepeat();
|
|
186
198
|
|
|
187
199
|
const adjustment = operation === 'increment' ? step : -step;
|
|
188
200
|
isPressed = true;
|
|
189
|
-
|
|
201
|
+
|
|
202
|
+
// The button turns disabled when the value reaches a limit, and a disabled button gets no mouseup and no mouseleave:
|
|
203
|
+
// the release is watched on the window too, or the repeat would go on firing `onChange` at the limit until the next press.
|
|
204
|
+
window.addEventListener('mouseup', releasePress);
|
|
205
|
+
window.addEventListener('blur', releasePress);
|
|
206
|
+
|
|
207
|
+
// At a limit there is nothing to hold
|
|
208
|
+
if (!handleValueChange(adjustment)) return;
|
|
190
209
|
|
|
191
210
|
autoRepeatTimer = setTimeout(() => {
|
|
192
211
|
if (isPressed) {
|
|
@@ -199,12 +218,28 @@
|
|
|
199
218
|
}, HOLD_DELAY);
|
|
200
219
|
}
|
|
201
220
|
|
|
221
|
+
/** The release of a press, seen on the window (see `startAutoRepeat`). */
|
|
222
|
+
function releasePress() {
|
|
223
|
+
stopAutoRepeat();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** A stepper button pressed with the keyboard (Enter or Space) clicks without a mouse down: `detail` is 0 then. */
|
|
227
|
+
function handleStepperClick(operation: 'increment' | 'decrement', event: MouseEvent) {
|
|
228
|
+
if (event.detail !== 0) return;
|
|
229
|
+
handleValueChange(operation === 'increment' ? step : -step);
|
|
230
|
+
}
|
|
231
|
+
|
|
202
232
|
function stopAutoRepeat(event?: MouseEvent | FocusEvent) {
|
|
203
233
|
if (event) {
|
|
204
234
|
event.preventDefault();
|
|
205
235
|
event.stopPropagation();
|
|
206
236
|
}
|
|
207
237
|
|
|
238
|
+
if (typeof window !== 'undefined') {
|
|
239
|
+
window.removeEventListener('mouseup', releasePress);
|
|
240
|
+
window.removeEventListener('blur', releasePress);
|
|
241
|
+
}
|
|
242
|
+
|
|
208
243
|
if (autoRepeatTimer !== null) {
|
|
209
244
|
clearTimeout(autoRepeatTimer);
|
|
210
245
|
autoRepeatTimer = null;
|
|
@@ -258,13 +293,20 @@
|
|
|
258
293
|
class:opacity-50={disabled}
|
|
259
294
|
class:pointer-events-none={disabled}
|
|
260
295
|
>
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
296
|
+
<!--
|
|
297
|
+
The hit area of the text: from the start edge of the surface to the steppers, with the surface's own rounded corner at
|
|
298
|
+
the start edge, so the whole area reads as one field. A label focuses the input when the area is clicked, so nothing in
|
|
299
|
+
it is dead space (the padding that keeps the value 12px in used to sit on the surface, outside the input, and the input
|
|
300
|
+
drew its own square hover box inside the rounded surface, which looked cut out).
|
|
301
|
+
-->
|
|
302
|
+
<label
|
|
303
|
+
for={inputId}
|
|
304
|
+
class="number-controls-hit-area flex h-full min-w-0 flex-1 items-center rounded-s-lg {inputPaddingClass} {isDisabled
|
|
305
|
+
? 'cursor-default'
|
|
306
|
+
: 'cursor-text'} {suffix ? 'justify-start gap-0' : ''}"
|
|
265
307
|
>
|
|
266
308
|
{#if suffix}
|
|
267
|
-
<
|
|
309
|
+
<span class="number-controls-value inline-flex max-w-full min-w-0 items-baseline gap-0">
|
|
268
310
|
<Input
|
|
269
311
|
id={inputId}
|
|
270
312
|
type="text"
|
|
@@ -276,10 +318,10 @@
|
|
|
276
318
|
readonly={isLocked}
|
|
277
319
|
{disabled}
|
|
278
320
|
size={Math.max(1, inputValue.length)}
|
|
279
|
-
class="number-controls-input number-controls-input-with-suffix h-full w-auto min-w-[1ch] max-w-full shrink border-0 bg-transparent px-0 text-start text-body text-foreground shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
321
|
+
class="number-controls-input number-controls-input-with-suffix h-full w-auto min-w-[1ch] max-w-full shrink border-0 bg-transparent px-0 text-start text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
280
322
|
/>
|
|
281
323
|
<span class="pointer-events-none shrink-0 text-body text-foreground">{suffix}</span>
|
|
282
|
-
</
|
|
324
|
+
</span>
|
|
283
325
|
{:else}
|
|
284
326
|
<Input
|
|
285
327
|
id={inputId}
|
|
@@ -291,10 +333,10 @@
|
|
|
291
333
|
onkeydown={handleKeyDown}
|
|
292
334
|
readonly={isLocked}
|
|
293
335
|
{disabled}
|
|
294
|
-
class="number-controls-input h-full min-w-0 flex-1 border-0 bg-transparent px-0 text-body text-foreground shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
336
|
+
class="number-controls-input h-full min-w-0 flex-1 border-0 bg-transparent px-0 text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
295
337
|
/>
|
|
296
338
|
{/if}
|
|
297
|
-
</
|
|
339
|
+
</label>
|
|
298
340
|
|
|
299
341
|
<div class="flex shrink-0 items-center gap-0">
|
|
300
342
|
<StepperButton
|
|
@@ -304,6 +346,7 @@
|
|
|
304
346
|
onmousedown={(e: MouseEvent) => startAutoRepeat('decrement', e)}
|
|
305
347
|
onmouseup={stopAutoRepeat}
|
|
306
348
|
onmouseleave={stopAutoRepeat}
|
|
349
|
+
onclick={(e: MouseEvent) => handleStepperClick('decrement', e)}
|
|
307
350
|
/>
|
|
308
351
|
<StepperButton
|
|
309
352
|
kind="plus"
|
|
@@ -312,6 +355,7 @@
|
|
|
312
355
|
onmousedown={(e: MouseEvent) => startAutoRepeat('increment', e)}
|
|
313
356
|
onmouseup={stopAutoRepeat}
|
|
314
357
|
onmouseleave={stopAutoRepeat}
|
|
358
|
+
onclick={(e: MouseEvent) => handleStepperClick('increment', e)}
|
|
315
359
|
/>
|
|
316
360
|
</div>
|
|
317
361
|
</div>
|
|
@@ -24,7 +24,11 @@ declare const NumberControls: $$__sveltets_2_IsomorphicComponent<{
|
|
|
24
24
|
suffix?: string;
|
|
25
25
|
/** Extra classes on the outer control surface (default full width of the control column). */ class?: string;
|
|
26
26
|
disabled?: boolean;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Padding at the end of the accent surface, after the steppers (Figma IC Number vs IC Angle field).
|
|
29
|
+
* The padding at the start is not on the surface: it is inside the text hit area, so the hit area reaches the edge.
|
|
30
|
+
*/ surfacePaddingClass?: string;
|
|
31
|
+
/** Padding at the start of the text hit area: it keeps the value 12px in from the edge (Figma IC Number: the value is at x=12). */ inputPaddingClass?: string;
|
|
28
32
|
/** @deprecated use `class` — kept for Angle layout width. */ width?: string | undefined;
|
|
29
33
|
}, {
|
|
30
34
|
[evt: string]: CustomEvent<any>;
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
IconBold,
|
|
59
59
|
IconBrush,
|
|
60
60
|
IconCheck,
|
|
61
|
-
IconChevronDown,
|
|
62
61
|
IconChevronUp,
|
|
63
62
|
IconH1,
|
|
64
63
|
IconH2,
|
|
@@ -85,6 +84,7 @@
|
|
|
85
84
|
|
|
86
85
|
// Add local ColorPickerInputController import
|
|
87
86
|
import ColorPickerInputController from './ColorPickerInputController.svelte';
|
|
87
|
+
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
88
88
|
|
|
89
89
|
// Looking things up and listening for scrolling in the tree the editor is in (a module has a shadow root)
|
|
90
90
|
import {
|
|
@@ -1245,11 +1245,7 @@
|
|
|
1245
1245
|
<span class="text-label-small">{$t(currentTextStyleMessageKey)}</span>
|
|
1246
1246
|
{/if}
|
|
1247
1247
|
{/if}
|
|
1248
|
-
{
|
|
1249
|
-
<IconChevronUp class={toolbarIconClass} />
|
|
1250
|
-
{:else}
|
|
1251
|
-
<IconChevronDown class={toolbarIconClass} />
|
|
1252
|
-
{/if}
|
|
1248
|
+
<DropdownChevron open={textStyleDropdownOpen} class={toolbarIconClass} />
|
|
1253
1249
|
</div>
|
|
1254
1250
|
</Button>
|
|
1255
1251
|
</Popover.Trigger>
|
|
@@ -1335,11 +1331,7 @@
|
|
|
1335
1331
|
{:else}
|
|
1336
1332
|
<IconList class={toolbarIconClass} />
|
|
1337
1333
|
{/if}
|
|
1338
|
-
{
|
|
1339
|
-
<IconChevronUp class={toolbarIconClass} />
|
|
1340
|
-
{:else}
|
|
1341
|
-
<IconChevronDown class={toolbarIconClass} />
|
|
1342
|
-
{/if}
|
|
1334
|
+
<DropdownChevron open={listStyleDropdownOpen} class={toolbarIconClass} />
|
|
1343
1335
|
</div>
|
|
1344
1336
|
</Button>
|
|
1345
1337
|
</Popover.Trigger>
|
|
@@ -46,8 +46,6 @@
|
|
|
46
46
|
|
|
47
47
|
import {
|
|
48
48
|
IconCloudUpload,
|
|
49
|
-
IconChevronDown,
|
|
50
|
-
IconChevronUp,
|
|
51
49
|
IconAlertTriangle
|
|
52
50
|
} from '@widgetic/design-system/icons';
|
|
53
51
|
|
|
@@ -57,6 +55,7 @@
|
|
|
57
55
|
// import { SearchInput } from './shared';
|
|
58
56
|
import { SearchInput } from '@widgetic/design-system/components';
|
|
59
57
|
import CategoryTabs from './shared/CategoryTabs.svelte';
|
|
58
|
+
import DropdownChevron from './shared/DropdownChevron.svelte';
|
|
60
59
|
import { RecentItemsSection, ItemGrid } from './shared';
|
|
61
60
|
import { useEditorLanguage } from '../../i18n/language';
|
|
62
61
|
import { categoryLabel } from '../../i18n/labels';
|
|
@@ -1613,11 +1612,7 @@
|
|
|
1613
1612
|
</span>
|
|
1614
1613
|
{/if}
|
|
1615
1614
|
</div>
|
|
1616
|
-
{
|
|
1617
|
-
<IconChevronUp class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
1618
|
-
{:else}
|
|
1619
|
-
<IconChevronDown class="size-4 shrink-0 stroke-[1.333] text-muted-foreground" />
|
|
1620
|
-
{/if}
|
|
1615
|
+
<DropdownChevron open={$openDropdowns?.has(controllerId)} />
|
|
1621
1616
|
</Popover.Trigger>
|
|
1622
1617
|
|
|
1623
1618
|
<Popover.Content
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic of the number stepper (`NumberControls.svelte`), kept apart from the component so Node can test it.
|
|
3
|
+
*/
|
|
4
|
+
export interface NumberStepLimits {
|
|
5
|
+
/** The lowest value; no limit when left out. */
|
|
6
|
+
min?: number;
|
|
7
|
+
/** The highest value; no limit when left out. */
|
|
8
|
+
max?: number;
|
|
9
|
+
/** An angle: a step past 360 comes back round to 0, and a step below 0 to 360, instead of stopping at a limit. */
|
|
10
|
+
wrapAround?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The value after one press of a stepper button (or one arrow key): `currentValue` moved by `adjustment`, then kept inside
|
|
14
|
+
* the limits, or brought back round for an angle. At a limit the result is `currentValue` itself, which tells the caller
|
|
15
|
+
* that there is nothing to apply (and nothing to repeat).
|
|
16
|
+
*/
|
|
17
|
+
export declare function steppedNumber(currentValue: number, adjustment: number, { min, max, wrapAround }?: NumberStepLimits): number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic of the number stepper (`NumberControls.svelte`), kept apart from the component so Node can test it.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The value after one press of a stepper button (or one arrow key): `currentValue` moved by `adjustment`, then kept inside
|
|
6
|
+
* the limits, or brought back round for an angle. At a limit the result is `currentValue` itself, which tells the caller
|
|
7
|
+
* that there is nothing to apply (and nothing to repeat).
|
|
8
|
+
*/
|
|
9
|
+
export function steppedNumber(currentValue, adjustment, { min, max, wrapAround = false } = {}) {
|
|
10
|
+
let steppedValue = currentValue + adjustment;
|
|
11
|
+
if (wrapAround) {
|
|
12
|
+
if (steppedValue >= 360)
|
|
13
|
+
steppedValue -= 360;
|
|
14
|
+
if (steppedValue < 0)
|
|
15
|
+
steppedValue += 360;
|
|
16
|
+
return steppedValue;
|
|
17
|
+
}
|
|
18
|
+
if (min !== undefined && steppedValue < min)
|
|
19
|
+
steppedValue = min;
|
|
20
|
+
if (max !== undefined && steppedValue > max)
|
|
21
|
+
steppedValue = max;
|
|
22
|
+
return steppedValue;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The arrow of a dropdown trigger (Figma IC Dropdown, Select Trigger): ONE chevron that turns half a turn while the list is open.
|
|
3
|
+
It used to be two icons swapped on open (chevron down, chevron up), so it jumped from one to the other. The accordion turns
|
|
4
|
+
one arrow with `transition-transform duration-base`, and so does this one: the same 160 ms, the same ease.
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { IconChevronDown } from '@widgetic/design-system/icons';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
open = false,
|
|
11
|
+
class: className = 'size-4 shrink-0 stroke-[1.333] text-muted-foreground'
|
|
12
|
+
}: {
|
|
13
|
+
/** True while the list the trigger opens is open: the arrow points up. */
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/** The size and colour of the arrow. */
|
|
16
|
+
class?: string;
|
|
17
|
+
} = $props();
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<IconChevronDown
|
|
21
|
+
class="{className} transition-transform duration-base {open ? 'rotate-180' : ''}"
|
|
22
|
+
aria-hidden="true"
|
|
23
|
+
/>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
/** True while the list the trigger opens is open: the arrow points up. */
|
|
3
|
+
open?: boolean;
|
|
4
|
+
/** The size and colour of the arrow. */
|
|
5
|
+
class?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const DropdownChevron: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type DropdownChevron = ReturnType<typeof DropdownChevron>;
|
|
9
|
+
export default DropdownChevron;
|