@widgetic/editor 4.1.14 → 4.1.15
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/PreviewChromeControls.svelte +15 -21
- package/dist/components/WidgetPreview.svelte +136 -105
- package/dist/components/color-select/ColorSelect.svelte +203 -224
- package/dist/components/color-select/constants.d.ts +4 -2
- package/dist/components/color-select/constants.js +4 -2
- package/dist/components/color-select/render.js +10 -9
- package/dist/components/editors/CompositionEditorApp.svelte +47 -40
- package/dist/components/editors/EditLeaseNotice.svelte +44 -33
- package/dist/components/editors/EmbedEditor.svelte +133 -259
- package/dist/components/editors/PropsEditor.svelte +418 -1338
- package/dist/components/editors/props-editor.css +5 -68
- package/dist/components/ic/AngleInputController.svelte +202 -277
- package/dist/components/ic/BrowserInputController.svelte +813 -803
- package/dist/components/ic/CheckboxInputController.svelte +92 -169
- package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
- package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
- package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
- package/dist/components/ic/DateFieldInputController.svelte +455 -465
- package/dist/components/ic/DatePickerInputController.svelte +355 -368
- package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
- package/dist/components/ic/DropdownInputController.svelte +130 -200
- package/dist/components/ic/FixedPositionInputController.svelte +255 -276
- package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
- package/dist/components/ic/FontInputController.svelte +2110 -2231
- package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
- package/dist/components/ic/InputControllerHeader.svelte +141 -147
- package/dist/components/ic/InputControllerRow.svelte +74 -0
- package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +84 -47
- package/dist/components/ic/KnowledgeTextForm.svelte +35 -33
- package/dist/components/ic/NumberControls.svelte +303 -269
- package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
- package/dist/components/ic/NumberInputController.svelte +361 -301
- package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
- package/dist/components/ic/PositionInputController.svelte +253 -176
- package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
- package/dist/components/ic/RadioGroupInputController.svelte +71 -137
- package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
- package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
- package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
- package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
- package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
- package/dist/components/ic/SliderInputController.svelte +263 -332
- package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
- package/dist/components/ic/SliderRangeInputController.svelte +140 -144
- package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
- package/dist/components/ic/SwitchInputController.svelte +47 -109
- package/dist/components/ic/TagsInputController.svelte +95 -110
- package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
- package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
- package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
- package/dist/components/ic/TextInputController.svelte +65 -75
- package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
- package/dist/components/ic/TimeInputController.svelte +433 -431
- package/dist/components/ic/VectorInputController.svelte +1833 -1831
- package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
- package/dist/components/ic/index.d.ts +1 -0
- package/dist/components/ic/index.js +1 -0
- package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
- package/dist/components/ic/shared/ItemGrid.svelte +145 -179
- package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
- package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
- package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
- package/dist/i18n/language.d.ts +43 -36
- package/dist/i18n/messages.d.ts +41 -34
- package/dist/i18n/messages.js +47 -34
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +26 -2
- package/package.json +4 -4
|
@@ -1,258 +1,237 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import { createEventDispatcher } from
|
|
4
|
-
const dispatch = createEventDispatcher();
|
|
2
|
+
// Svelte imports
|
|
3
|
+
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
const dispatch = createEventDispatcher();
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
eps,
|
|
9
|
-
border_size,
|
|
10
|
-
gap_size
|
|
11
|
-
} from "./constants";
|
|
6
|
+
// Constants imports
|
|
7
|
+
import { eps, border_size, gap_size } from './constants';
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
import { render_main_image, render_slider_image } from
|
|
9
|
+
// Render functions imports
|
|
10
|
+
import { render_main_image, render_slider_image } from './render';
|
|
15
11
|
|
|
16
|
-
import { oklab_to_okhsv, okhsv_to_oklab, rgb_to_okhsv, okhsv_to_rgb } from
|
|
17
|
-
const instanceId = `okhsv_${Math.random().toString(36).slice(2, 8)}`;
|
|
12
|
+
import { oklab_to_okhsv, okhsv_to_oklab, rgb_to_okhsv, okhsv_to_rgb } from './color';
|
|
13
|
+
const instanceId = `okhsv_${Math.random().toString(36).slice(2, 8)}`;
|
|
18
14
|
|
|
19
|
-
export let rgb: RGB | undefined = undefined;
|
|
20
|
-
export let a: number = 1;
|
|
21
|
-
export let oklab: OKLab | undefined = undefined;
|
|
22
|
-
export let okhsv: OKHSV | undefined = undefined;
|
|
23
|
-
export let pickerSize = 200;
|
|
24
|
-
export let sliderWidth =
|
|
25
|
-
export let onchange: ((detail: any) => void) | undefined = undefined;
|
|
15
|
+
export let rgb: RGB | undefined = undefined;
|
|
16
|
+
export let a: number = 1;
|
|
17
|
+
export let oklab: OKLab | undefined = undefined;
|
|
18
|
+
export let okhsv: OKHSV | undefined = undefined;
|
|
19
|
+
export let pickerSize = 200;
|
|
20
|
+
export let sliderWidth = 24;
|
|
21
|
+
export let onchange: ((detail: any) => void) | undefined = undefined;
|
|
26
22
|
|
|
23
|
+
$: width = pickerSize + sliderWidth + gap_size + border_size * 2;
|
|
24
|
+
$: height = pickerSize + border_size * 2;
|
|
25
|
+
$: color = convertToInternal(rgb, oklab, okhsv);
|
|
26
|
+
$: uihsv = scale_to_ui(color);
|
|
27
|
+
// Left edge of the hue strip: right of the saturation square plus the gap
|
|
28
|
+
$: hueStripLeft = pickerSize + gap_size;
|
|
29
|
+
/** Figma Color Picker 211:3877 — area thumb centre in picker coordinates. */
|
|
30
|
+
$: areaThumbLeft = border_size + uihsv.s;
|
|
31
|
+
$: areaThumbTop = border_size + uihsv.v;
|
|
32
|
+
/** Hue column thumb: 32×8 pill centred on the hue strip. */
|
|
33
|
+
$: hueThumbLeft = border_size + pickerSize + gap_size + sliderWidth / 2;
|
|
34
|
+
$: hueThumbTop = border_size + uihsv.h;
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
// TypeScript type fixes
|
|
37
|
+
/**
|
|
38
|
+
* Types for color objects
|
|
39
|
+
*/
|
|
40
|
+
type RGB = { r: number; g: number; b: number; a?: number };
|
|
41
|
+
type OKLab = { l: number; a: number; b: number };
|
|
42
|
+
type OKHSV = { h: number; s: number; v: number };
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
// When the color or alpha changes, update the bound value
|
|
169
|
-
$: if (rgb && typeof a === 'number') {
|
|
170
|
-
rgb.a = a;
|
|
171
|
-
}
|
|
44
|
+
function scale_to_ui(okhsv2: OKHSV): { h: number; s: number; v: number } {
|
|
45
|
+
return {
|
|
46
|
+
h: clamp_ui(okhsv2.h / 360),
|
|
47
|
+
s: clamp_ui(okhsv2.s),
|
|
48
|
+
v: clamp_ui(1 - okhsv2.v)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function clamp(x: number): number {
|
|
52
|
+
return x < eps ? eps : x > 1 - eps ? 1 - eps : x;
|
|
53
|
+
}
|
|
54
|
+
function clamp_ui(value: number): number {
|
|
55
|
+
return value < 0 ? 0 : value > 1 ? pickerSize : value * pickerSize;
|
|
56
|
+
}
|
|
57
|
+
function convertToInternal(
|
|
58
|
+
rgb2: RGB | undefined,
|
|
59
|
+
oklab2: OKLab | undefined,
|
|
60
|
+
okhsv2: OKHSV | undefined
|
|
61
|
+
): OKHSV {
|
|
62
|
+
if (okhsv2) {
|
|
63
|
+
return okhsv2;
|
|
64
|
+
}
|
|
65
|
+
if (oklab2) {
|
|
66
|
+
return oklab_to_okhsv(oklab2);
|
|
67
|
+
}
|
|
68
|
+
if (rgb2) {
|
|
69
|
+
return rgb_to_okhsv(rgb2);
|
|
70
|
+
}
|
|
71
|
+
throw 'rgb, oklab, or okhsv required';
|
|
72
|
+
}
|
|
73
|
+
async function update_input(): Promise<void> {
|
|
74
|
+
if (okhsv) {
|
|
75
|
+
const detail = { okhsv: color, a };
|
|
76
|
+
dispatch('change', detail);
|
|
77
|
+
onchange?.(detail);
|
|
78
|
+
}
|
|
79
|
+
if (oklab) {
|
|
80
|
+
const detail = { oklab: okhsv_to_oklab(color), a };
|
|
81
|
+
dispatch('change', detail);
|
|
82
|
+
onchange?.(detail);
|
|
83
|
+
}
|
|
84
|
+
if (rgb) {
|
|
85
|
+
const rgbColor = okhsv_to_rgb(color);
|
|
86
|
+
const detail = { rgb: { ...rgbColor, a }, a };
|
|
87
|
+
dispatch('change', detail);
|
|
88
|
+
onchange?.(detail);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function update_sv(x: number, y: number): void {
|
|
92
|
+
let new_s = clamp(x / pickerSize);
|
|
93
|
+
let new_v = clamp(1 - y / pickerSize);
|
|
94
|
+
color.s = new_s;
|
|
95
|
+
color.v = new_v;
|
|
96
|
+
update_input();
|
|
97
|
+
}
|
|
98
|
+
function update_h(x: number, y: number): void {
|
|
99
|
+
let h = clamp(y / pickerSize);
|
|
100
|
+
color.h = h * 360;
|
|
101
|
+
color.s = Math.max(color.s, 1e-5);
|
|
102
|
+
color.v = Math.max(color.v, 1e-5);
|
|
103
|
+
update_input();
|
|
104
|
+
}
|
|
105
|
+
function pointer(node: HTMLElement, fn: (x: number, y: number) => void) {
|
|
106
|
+
let active = false;
|
|
107
|
+
function update(event: PointerEvent) {
|
|
108
|
+
const x = event.offsetX;
|
|
109
|
+
const y = event.offsetY;
|
|
110
|
+
fn(x, y);
|
|
111
|
+
}
|
|
112
|
+
function onpointerdown(event: PointerEvent) {
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
node.setPointerCapture(event.pointerId);
|
|
115
|
+
update(event);
|
|
116
|
+
active = true;
|
|
117
|
+
}
|
|
118
|
+
function onpointermove(event: PointerEvent) {
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
if (active) {
|
|
121
|
+
update(event);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function onpointerend(event: PointerEvent) {
|
|
125
|
+
event.stopPropagation();
|
|
126
|
+
node.releasePointerCapture(event.pointerId);
|
|
127
|
+
active = false;
|
|
128
|
+
}
|
|
129
|
+
node.addEventListener('pointerdown', onpointerdown, { passive: true });
|
|
130
|
+
node.addEventListener('pointermove', onpointermove, { passive: true });
|
|
131
|
+
node.addEventListener('pointerup', onpointerend, { passive: true });
|
|
132
|
+
node.addEventListener('pointercancel', onpointerend, { passive: true });
|
|
133
|
+
return {
|
|
134
|
+
destroy() {
|
|
135
|
+
node.removeEventListener('pointerdown', onpointerdown);
|
|
136
|
+
node.removeEventListener('pointermove', onpointermove);
|
|
137
|
+
node.removeEventListener('pointerup', onpointerend);
|
|
138
|
+
node.removeEventListener('pointercancel', onpointerend);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function onKeydown(event: KeyboardEvent) {
|
|
143
|
+
const keyHandled = () => {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
event.stopPropagation();
|
|
146
|
+
};
|
|
147
|
+
const step = event.shiftKey ? 10 : 1;
|
|
148
|
+
switch (event.key) {
|
|
149
|
+
case 'ArrowUp':
|
|
150
|
+
if (event.altKey) {
|
|
151
|
+
update_h(0, Math.round(uihsv.h - step));
|
|
152
|
+
} else {
|
|
153
|
+
update_sv(uihsv.s, Math.round(uihsv.v - step));
|
|
154
|
+
}
|
|
155
|
+
keyHandled();
|
|
156
|
+
break;
|
|
157
|
+
case 'ArrowDown':
|
|
158
|
+
if (event.altKey) {
|
|
159
|
+
update_h(0, Math.round(uihsv.h + step));
|
|
160
|
+
} else {
|
|
161
|
+
update_sv(uihsv.s, Math.round(uihsv.v + step));
|
|
162
|
+
}
|
|
163
|
+
keyHandled();
|
|
164
|
+
break;
|
|
165
|
+
case 'ArrowLeft':
|
|
166
|
+
update_sv(Math.round(uihsv.s - step), uihsv.v);
|
|
167
|
+
keyHandled();
|
|
168
|
+
break;
|
|
169
|
+
case 'ArrowRight':
|
|
170
|
+
update_sv(Math.round(uihsv.s + step), uihsv.v);
|
|
171
|
+
keyHandled();
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// When the color or alpha changes, update the bound value
|
|
176
|
+
$: if (rgb && typeof a === 'number') {
|
|
177
|
+
rgb.a = a;
|
|
178
|
+
}
|
|
172
179
|
</script>
|
|
173
180
|
|
|
174
181
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
175
182
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
176
183
|
<!-- The picker is a drawing: saturation grows to the right and hue is a strip next to it, on every screen, so it is a left to right island. -->
|
|
177
184
|
<div
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
class={$$props.class}
|
|
186
|
+
dir="ltr"
|
|
187
|
+
tabindex="0"
|
|
188
|
+
style="width: {width}px; min-width: {width}px; height: {height}px;"
|
|
189
|
+
on:keydown={onKeydown}
|
|
183
190
|
>
|
|
191
|
+
<!-- Saturation / value canvas (Figma 200×200, radius/lg on the popover wrapper) -->
|
|
184
192
|
<!-- svelte-ignore element_invalid_self_closing_tag -->
|
|
185
193
|
<canvas
|
|
186
194
|
id="{instanceId}_sv"
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
class="color-select-sv rounded-lg"
|
|
196
|
+
width={pickerSize}
|
|
197
|
+
height={pickerSize}
|
|
198
|
+
style="top: {border_size}px; left: {border_size}px; /* rtl-ok: the saturation square is drawn from the left edge of the picker */"
|
|
199
|
+
use:pointer={update_sv}
|
|
200
|
+
use:render_main_image={color.h}
|
|
192
201
|
/>
|
|
202
|
+
<!-- Hue bar canvas (Figma 24×200) -->
|
|
193
203
|
<!-- svelte-ignore element_invalid_self_closing_tag -->
|
|
194
204
|
<canvas
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
205
|
+
class="color-select-hue rounded-lg"
|
|
206
|
+
width={sliderWidth}
|
|
207
|
+
height={pickerSize}
|
|
208
|
+
style="top: {border_size}px; left: {hueStripLeft}px; /* rtl-ok: the hue strip is drawn next to the square, from the left edge of the picker */"
|
|
209
|
+
use:pointer={update_h}
|
|
210
|
+
use:render_slider_image
|
|
200
211
|
/>
|
|
201
212
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
cx="0"
|
|
215
|
-
cy="0"
|
|
216
|
-
r="6"
|
|
217
|
-
fill="none"
|
|
218
|
-
stroke-width="1.25"
|
|
219
|
-
stroke="#000"
|
|
220
|
-
/>
|
|
221
|
-
</g>
|
|
222
|
-
</g>
|
|
223
|
-
<g transform="translate({pickerSize + gap_size},{border_size})">
|
|
224
|
-
<g transform="translate(0,{uihsv.h})">
|
|
225
|
-
<polygon
|
|
226
|
-
points="-7,-4 -1,0 -7,4"
|
|
227
|
-
fill="#fff"
|
|
228
|
-
stroke-width="0.8"
|
|
229
|
-
stroke="#000"
|
|
230
|
-
/>
|
|
231
|
-
<polygon
|
|
232
|
-
points="{sliderWidth + 7},-4 {sliderWidth + 1},0 {sliderWidth +
|
|
233
|
-
7},4"
|
|
234
|
-
fill="#fff"
|
|
235
|
-
stroke-width="0.8"
|
|
236
|
-
stroke="#000"
|
|
237
|
-
/>
|
|
238
|
-
</g>
|
|
239
|
-
</g>
|
|
240
|
-
</svg>
|
|
213
|
+
<!-- Area thumb: 16×16 ring, stroke background 2, Shadow/Floating (Color Picker.txt) -->
|
|
214
|
+
<div
|
|
215
|
+
class="color-select-area-thumb pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-background shadow-floating"
|
|
216
|
+
style="left: {areaThumbLeft}px; top: {areaThumbTop}px; /* rtl-ok: coordinates are in the fixed LTR picker island */"
|
|
217
|
+
aria-hidden="true"
|
|
218
|
+
></div>
|
|
219
|
+
<!-- Hue thumb: 32×8 pill, same stroke and shadow as opacity scrubber -->
|
|
220
|
+
<div
|
|
221
|
+
class="color-select-hue-thumb pointer-events-none absolute h-2 w-8 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-background bg-background shadow-floating"
|
|
222
|
+
style="left: {hueThumbLeft}px; top: {hueThumbTop}px; /* rtl-ok: coordinates are in the fixed LTR picker island */"
|
|
223
|
+
aria-hidden="true"
|
|
224
|
+
></div>
|
|
241
225
|
</div>
|
|
242
226
|
|
|
243
227
|
<style>
|
|
244
|
-
div {
|
|
228
|
+
div.color-select-root {
|
|
245
229
|
position: relative;
|
|
246
230
|
outline: 0;
|
|
247
231
|
}
|
|
248
232
|
|
|
249
|
-
canvas
|
|
250
|
-
svg {
|
|
233
|
+
canvas {
|
|
251
234
|
touch-action: none;
|
|
252
235
|
position: absolute;
|
|
253
236
|
}
|
|
254
|
-
|
|
255
|
-
svg {
|
|
256
|
-
pointer-events: none;
|
|
257
|
-
}
|
|
258
237
|
</style>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/** Defaults for standalone use; the editor passes pickerSize / sliderWidth on the component. */
|
|
1
2
|
export const picker_size: 256;
|
|
2
3
|
export const slider_width: 31;
|
|
3
|
-
|
|
4
|
-
export const
|
|
4
|
+
/** Figma Color Picker: no outer inset; canvases fill the 200×200 + 8px gap + 24px hue column. */
|
|
5
|
+
export const border_size: 0;
|
|
6
|
+
export const gap_size: 8;
|
|
5
7
|
export const eps: 0.0001;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/** Defaults for standalone use; the editor passes pickerSize / sliderWidth on the component. */
|
|
1
2
|
export const picker_size = 256;
|
|
2
3
|
export const slider_width = 31;
|
|
3
|
-
|
|
4
|
-
export const
|
|
4
|
+
/** Figma Color Picker: no outer inset; canvases fill the 200×200 + 8px gap + 24px hue column. */
|
|
5
|
+
export const border_size = 0;
|
|
6
|
+
export const gap_size = 8;
|
|
5
7
|
export const eps = 0.0001;
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { f_shader, v_shader } from './shaders';
|
|
2
|
-
import { picker_size, slider_width } from './constants';
|
|
3
2
|
import { okhsl_to_rgb } from './color';
|
|
4
3
|
export function render_slider_image(canvas) {
|
|
5
4
|
const ctx = canvas.getContext('2d');
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const pickerHeight = canvas.height;
|
|
6
|
+
const sliderW = canvas.width;
|
|
7
|
+
const data = new Uint8ClampedArray(pickerHeight * sliderW * 4);
|
|
8
|
+
for (let i = 0; i < pickerHeight; i++) {
|
|
9
|
+
const a_ = Math.cos(2 * Math.PI * i / pickerHeight);
|
|
10
|
+
const b_ = Math.sin(2 * Math.PI * i / pickerHeight);
|
|
10
11
|
const rgb = okhsl_to_rgb({
|
|
11
|
-
h: i /
|
|
12
|
+
h: i / pickerHeight * 360,
|
|
12
13
|
s: 0.9,
|
|
13
14
|
l: 0.65 + 0.17 * b_ - 0.08 * a_,
|
|
14
15
|
});
|
|
15
|
-
for (let j = 0; j <
|
|
16
|
-
const index = 4 * (i *
|
|
16
|
+
for (let j = 0; j < sliderW; j++) {
|
|
17
|
+
const index = 4 * (i * sliderW + j);
|
|
17
18
|
data[index + 0] = rgb.r * 255;
|
|
18
19
|
data[index + 1] = rgb.g * 255;
|
|
19
20
|
data[index + 2] = rgb.b * 255;
|
|
20
21
|
data[index + 3] = 255;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
const imageData = new ImageData(data,
|
|
24
|
+
const imageData = new ImageData(data, sliderW);
|
|
24
25
|
ctx.putImageData(imageData, 0, 0);
|
|
25
26
|
}
|
|
26
27
|
export function render_main_image(canvas, hue) {
|