@gradio/imageeditor 0.12.13 → 0.13.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.
- package/CHANGELOG.md +23 -0
- package/Example.svelte +1 -1
- package/IMAGE_EDITOR_OVERVIEW.md +224 -0
- package/ImageEditor.stories.svelte +4 -4
- package/Index.svelte +35 -46
- package/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +56 -103
- package/dist/Example.svelte.d.ts +1 -1
- package/dist/Index.svelte +29 -33
- package/dist/Index.svelte.d.ts +17 -16
- package/dist/{shared/InteractiveImageEditor.svelte → InteractiveImageEditor.svelte} +47 -88
- package/dist/{shared/InteractiveImageEditor.svelte.d.ts → InteractiveImageEditor.svelte.d.ts} +13 -15
- package/dist/shared/Anchor.svelte +311 -0
- package/dist/shared/Anchor.svelte.d.ts +18 -0
- package/dist/shared/Controls.svelte +162 -23
- package/dist/shared/Controls.svelte.d.ts +7 -2
- package/dist/shared/{tools/IconButton.svelte → IconButton.svelte} +19 -3
- package/dist/shared/{tools/IconButton.svelte.d.ts → IconButton.svelte.d.ts} +4 -1
- package/dist/shared/ImageEditor.svelte +546 -289
- package/dist/shared/ImageEditor.svelte.d.ts +51 -56
- package/dist/shared/Layers.svelte +233 -0
- package/dist/shared/Layers.svelte.d.ts +35 -0
- package/dist/shared/Resize.svelte +218 -0
- package/dist/shared/Resize.svelte.d.ts +29 -0
- package/dist/shared/SecondaryToolbar.svelte +54 -0
- package/dist/shared/SecondaryToolbar.svelte.d.ts +35 -0
- package/dist/shared/Toolbar.svelte +337 -0
- package/dist/shared/Toolbar.svelte.d.ts +42 -0
- package/dist/shared/{tools → brush}/BrushOptions.svelte +68 -64
- package/dist/shared/{tools → brush}/BrushOptions.svelte.d.ts +9 -9
- package/dist/shared/{tools → brush}/BrushSize.svelte +2 -27
- package/dist/shared/{tools → brush}/ColorField.svelte +2 -1
- package/dist/shared/{tools → brush}/ColorField.svelte.d.ts +1 -0
- package/dist/shared/{tools → brush}/ColorPicker.svelte +81 -9
- package/dist/shared/{tools → brush}/ColorPicker.svelte.d.ts +1 -0
- package/dist/shared/{tools → brush}/ColorSwatch.svelte +78 -38
- package/dist/shared/{tools → brush}/ColorSwatch.svelte.d.ts +6 -2
- package/dist/shared/brush/brush-cursor.d.ts +101 -0
- package/dist/shared/brush/brush-cursor.js +327 -0
- package/dist/shared/brush/brush-textures.d.ts +71 -0
- package/dist/shared/brush/brush-textures.js +404 -0
- package/dist/shared/brush/brush-utils.d.ts +32 -0
- package/dist/shared/brush/brush-utils.js +59 -0
- package/dist/shared/brush/brush.d.ts +152 -0
- package/dist/shared/brush/brush.js +396 -0
- package/dist/shared/brush/types.d.ts +37 -0
- package/dist/shared/brush/types.js +1 -0
- package/dist/shared/core/editor.d.ts +252 -0
- package/dist/shared/core/editor.js +1221 -0
- package/dist/shared/crop/crop.d.ts +201 -0
- package/dist/shared/crop/crop.js +727 -0
- package/dist/shared/image/image.d.ts +89 -0
- package/dist/shared/image/image.js +185 -0
- package/dist/shared/resize/resize.d.ts +270 -0
- package/dist/shared/resize/resize.js +1413 -0
- package/dist/shared/types.d.ts +12 -0
- package/dist/shared/utils/pixi.d.ts +16 -57
- package/dist/shared/utils/pixi.js +15 -113
- package/dist/shared/zoom/zoom.d.ts +136 -0
- package/dist/shared/zoom/zoom.js +548 -0
- package/package.json +11 -10
- package/shared/Anchor.svelte +384 -0
- package/shared/Controls.svelte +194 -27
- package/shared/{tools/IconButton.svelte → IconButton.svelte} +21 -4
- package/shared/ImageEditor.svelte +682 -349
- package/shared/Layers.svelte +249 -0
- package/shared/Resize.svelte +239 -0
- package/shared/SecondaryToolbar.svelte +61 -0
- package/shared/Toolbar.svelte +386 -0
- package/shared/brush/BRUSH_TOOL.md +134 -0
- package/shared/brush/BrushOptions.svelte +200 -0
- package/shared/{tools → brush}/BrushSize.svelte +2 -30
- package/shared/{tools → brush}/ColorField.svelte +3 -1
- package/shared/{tools → brush}/ColorPicker.svelte +86 -9
- package/shared/{tools → brush}/ColorSwatch.svelte +95 -42
- package/shared/brush/brush-cursor.ts +408 -0
- package/shared/brush/brush-textures.ts +508 -0
- package/shared/brush/brush-utils.ts +76 -0
- package/shared/brush/brush.ts +506 -0
- package/shared/brush/types.ts +41 -0
- package/shared/core/EDITOR.md +182 -0
- package/shared/core/editor.ts +1730 -0
- package/shared/crop/CROP.md +139 -0
- package/shared/crop/crop.ts +1027 -0
- package/shared/image/IMAGE.md +135 -0
- package/shared/image/image.ts +300 -0
- package/shared/resize/resize.ts +1894 -0
- package/shared/types.ts +14 -0
- package/shared/utils/pixi.ts +19 -246
- package/shared/zoom/zoom.ts +729 -0
- package/dist/shared/layers/Layers.svelte +0 -231
- package/dist/shared/layers/Layers.svelte.d.ts +0 -18
- package/dist/shared/layers/utils.d.ts +0 -73
- package/dist/shared/layers/utils.js +0 -156
- package/dist/shared/tools/Brush.svelte +0 -215
- package/dist/shared/tools/Brush.svelte.d.ts +0 -29
- package/dist/shared/tools/Crop.svelte +0 -155
- package/dist/shared/tools/Crop.svelte.d.ts +0 -16
- package/dist/shared/tools/Cropper.svelte +0 -271
- package/dist/shared/tools/Cropper.svelte.d.ts +0 -41
- package/dist/shared/tools/Handle.svelte +0 -260
- package/dist/shared/tools/Handle.svelte.d.ts +0 -29
- package/dist/shared/tools/Sources.svelte +0 -257
- package/dist/shared/tools/Sources.svelte.d.ts +0 -34
- package/dist/shared/tools/Tools.svelte +0 -102
- package/dist/shared/tools/Tools.svelte.d.ts +0 -48
- package/dist/shared/tools/brush.d.ts +0 -62
- package/dist/shared/tools/brush.js +0 -133
- package/dist/shared/tools/crop.d.ts +0 -15
- package/dist/shared/tools/crop.js +0 -154
- package/dist/shared/tools/index.d.ts +0 -5
- package/dist/shared/tools/index.js +0 -5
- package/dist/shared/tools/sources.d.ts +0 -46
- package/dist/shared/tools/sources.js +0 -121
- package/dist/shared/tools/types.d.ts +0 -1
- package/shared/layers/Layers.svelte +0 -250
- package/shared/layers/utils.ts +0 -294
- package/shared/tools/Brush.svelte +0 -280
- package/shared/tools/BrushOptions.svelte +0 -180
- package/shared/tools/Crop.svelte +0 -189
- package/shared/tools/Cropper.svelte +0 -346
- package/shared/tools/Handle.svelte +0 -289
- package/shared/tools/Sources.svelte +0 -283
- package/shared/tools/Tools.svelte +0 -162
- package/shared/tools/brush.ts +0 -247
- package/shared/tools/crop.ts +0 -213
- package/shared/tools/index.ts +0 -5
- package/shared/tools/sources.ts +0 -195
- package/shared/tools/types.ts +0 -1
- /package/dist/shared/{tools → brush}/BrushSize.svelte.d.ts +0 -0
- /package/dist/shared/{tools/types.js → types.js} +0 -0
|
@@ -10,37 +10,9 @@
|
|
|
10
10
|
const dispatch = createEventDispatcher<{
|
|
11
11
|
click_outside: void;
|
|
12
12
|
}>();
|
|
13
|
-
|
|
14
|
-
let width = 0;
|
|
15
|
-
let height = 0;
|
|
16
|
-
let c_width = 0;
|
|
17
|
-
let c_height = 0;
|
|
18
|
-
let wrap_el: HTMLDivElement;
|
|
19
|
-
let anchor_right = false;
|
|
20
|
-
let anchor_top = false;
|
|
21
|
-
|
|
22
|
-
$: {
|
|
23
|
-
if (wrap_el && (width || height || c_height || c_width)) {
|
|
24
|
-
const box = wrap_el.getBoundingClientRect();
|
|
25
|
-
|
|
26
|
-
anchor_right = box.width + 30 > width / 2;
|
|
27
|
-
anchor_top = box.y < 80;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
13
|
</script>
|
|
31
14
|
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
<div
|
|
35
|
-
class="wrap"
|
|
36
|
-
use:click_outside={() => dispatch("click_outside")}
|
|
37
|
-
bind:this={wrap_el}
|
|
38
|
-
bind:clientWidth={c_width}
|
|
39
|
-
bind:clientHeight={c_height}
|
|
40
|
-
class:right={anchor_right}
|
|
41
|
-
class:top={anchor_top}
|
|
42
|
-
class:bottom={!anchor_top}
|
|
43
|
-
>
|
|
15
|
+
<div class="wrap" use:click_outside={() => dispatch("click_outside")}>
|
|
44
16
|
<span>
|
|
45
17
|
<BrushSize />
|
|
46
18
|
</span>
|
|
@@ -49,7 +21,7 @@
|
|
|
49
21
|
|
|
50
22
|
<style>
|
|
51
23
|
.wrap {
|
|
52
|
-
width:
|
|
24
|
+
width: 230px;
|
|
53
25
|
display: flex;
|
|
54
26
|
gap: var(--size-4);
|
|
55
27
|
background: var(--background-fill-secondary);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Eyedropper } from "@gradio/icons";
|
|
2
|
+
import { Eyedropper, Plus } from "@gradio/icons";
|
|
3
3
|
import { createEventDispatcher } from "svelte";
|
|
4
4
|
|
|
5
5
|
import tinycolor from "tinycolor2";
|
|
6
|
+
import IconButton from "../IconButton.svelte";
|
|
6
7
|
export let color: string;
|
|
7
8
|
|
|
8
9
|
export let current_mode: "hex" | "rgb" | "hsl" = "hex";
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
const dispatch = createEventDispatcher<{
|
|
11
12
|
selected: string;
|
|
12
13
|
close: void;
|
|
14
|
+
add_color: void;
|
|
13
15
|
}>();
|
|
14
16
|
const modes = [
|
|
15
17
|
["Hex", "hex"],
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { tick } from "svelte";
|
|
2
|
+
import { onMount, tick } from "svelte";
|
|
3
3
|
import tinycolor from "tinycolor2";
|
|
4
4
|
import { clamp } from "../utils/pixi";
|
|
5
5
|
|
|
6
6
|
export let color = "rgb(255, 255, 255)";
|
|
7
7
|
|
|
8
|
-
let name = "world";
|
|
9
8
|
let sl_marker_pos = [0, 0];
|
|
10
9
|
let sl_rect: DOMRect | null = null;
|
|
11
10
|
let sl_moving = false;
|
|
@@ -16,6 +15,8 @@
|
|
|
16
15
|
let hue_rect: DOMRect | null = null;
|
|
17
16
|
let hue_moving = false;
|
|
18
17
|
|
|
18
|
+
let opacity_moving = false;
|
|
19
|
+
|
|
19
20
|
function handle_hue_down(
|
|
20
21
|
event: MouseEvent & { currentTarget: HTMLDivElement }
|
|
21
22
|
): void {
|
|
@@ -90,11 +91,13 @@
|
|
|
90
91
|
): void {
|
|
91
92
|
if (sl_moving) update_color_from_mouse(event.clientX, event.clientY);
|
|
92
93
|
if (hue_moving) update_hue_from_mouse(event.clientX);
|
|
94
|
+
if (opacity_moving) update_opacity_from_mouse(event.clientX);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
function handle_end(): void {
|
|
96
98
|
if (sl_moving) sl_moving = false;
|
|
97
99
|
if (hue_moving) hue_moving = false;
|
|
100
|
+
if (opacity_moving) opacity_moving = false;
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
async function update_mouse_from_color(color: string): Promise<void> {
|
|
@@ -122,6 +125,29 @@
|
|
|
122
125
|
|
|
123
126
|
let sl_wrap: HTMLDivElement;
|
|
124
127
|
let hue_wrap: HTMLDivElement;
|
|
128
|
+
|
|
129
|
+
export let opacity = 1;
|
|
130
|
+
|
|
131
|
+
let opacity_wrap: HTMLDivElement;
|
|
132
|
+
|
|
133
|
+
function handle_opacity_down(
|
|
134
|
+
event: MouseEvent & { currentTarget: HTMLDivElement }
|
|
135
|
+
): void {
|
|
136
|
+
opacity_rect = event.currentTarget.getBoundingClientRect();
|
|
137
|
+
opacity_moving = true;
|
|
138
|
+
update_opacity_from_mouse(event.clientX);
|
|
139
|
+
}
|
|
140
|
+
let opacity_rect: DOMRect | null = null;
|
|
141
|
+
|
|
142
|
+
function update_opacity_from_mouse(x: number): void {
|
|
143
|
+
if (!opacity_rect) return;
|
|
144
|
+
const _x = clamp(x - opacity_rect.left, 0, opacity_rect.width);
|
|
145
|
+
opacity = _x / opacity_rect.width;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
onMount(() => {
|
|
149
|
+
opacity_rect = opacity_wrap.getBoundingClientRect();
|
|
150
|
+
});
|
|
125
151
|
</script>
|
|
126
152
|
|
|
127
153
|
<svelte:window on:mousemove={handle_move} on:mouseup={handle_end} />
|
|
@@ -140,6 +166,19 @@
|
|
|
140
166
|
/>
|
|
141
167
|
</div>
|
|
142
168
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
169
|
+
<div
|
|
170
|
+
class="opacity-slider"
|
|
171
|
+
on:mousedown={handle_opacity_down}
|
|
172
|
+
style="--color:{color === 'auto' ? 'transparent' : color}"
|
|
173
|
+
bind:this={opacity_wrap}
|
|
174
|
+
>
|
|
175
|
+
<div
|
|
176
|
+
class="opacity-marker"
|
|
177
|
+
style:background="white"
|
|
178
|
+
style:transform="translateX({opacity * (opacity_rect?.width ?? 1)}px)"
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
143
182
|
<div class="hue-slider" on:mousedown={handle_hue_down} bind:this={hue_wrap}>
|
|
144
183
|
<div
|
|
145
184
|
class="marker"
|
|
@@ -152,9 +191,10 @@
|
|
|
152
191
|
.hue-slider {
|
|
153
192
|
position: relative;
|
|
154
193
|
width: 90%;
|
|
155
|
-
margin: 10px auto;
|
|
156
|
-
height:
|
|
157
|
-
border-radius:
|
|
194
|
+
margin: 0px auto 10px auto;
|
|
195
|
+
height: 12px;
|
|
196
|
+
border-radius: 2px;
|
|
197
|
+
border: 1px solid var(--block-border-color);
|
|
158
198
|
background: linear-gradient(
|
|
159
199
|
to right,
|
|
160
200
|
hsl(0, 100%, 50%) 0%,
|
|
@@ -168,6 +208,41 @@
|
|
|
168
208
|
border-top: none;
|
|
169
209
|
}
|
|
170
210
|
|
|
211
|
+
.opacity-slider {
|
|
212
|
+
position: relative;
|
|
213
|
+
width: 90%;
|
|
214
|
+
margin: 10px auto 5px auto;
|
|
215
|
+
height: 12px;
|
|
216
|
+
border-radius: 2px;
|
|
217
|
+
border: 1px solid var(--block-border-color);
|
|
218
|
+
/* background: linear-gradient(45deg, #808080 25%, transparent 25%),
|
|
219
|
+
linear-gradient(-45deg, #808080 25%, transparent 25%),
|
|
220
|
+
linear-gradient(45deg, transparent 75%, #808080 75%),
|
|
221
|
+
linear-gradient(-45deg, transparent 75%, #808080 75%); */
|
|
222
|
+
background:
|
|
223
|
+
linear-gradient(to right, transparent, var(--color)),
|
|
224
|
+
repeating-conic-gradient(#808080 0% 25%, transparent 0% 50%) 0 0 / 10px
|
|
225
|
+
10px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.opacity-marker {
|
|
229
|
+
position: absolute;
|
|
230
|
+
width: 16px;
|
|
231
|
+
height: 16px;
|
|
232
|
+
border-radius: 50%;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.opacity-slider > .opacity-marker {
|
|
236
|
+
box-shadow: 0 0 1px #888;
|
|
237
|
+
top: -4px;
|
|
238
|
+
margin: auto;
|
|
239
|
+
height: 18px;
|
|
240
|
+
width: 18px;
|
|
241
|
+
left: -9px;
|
|
242
|
+
margin: auto;
|
|
243
|
+
border: 1px solid var(--block-border-color);
|
|
244
|
+
}
|
|
245
|
+
|
|
171
246
|
.color-gradient {
|
|
172
247
|
position: relative;
|
|
173
248
|
--hue: white;
|
|
@@ -191,15 +266,17 @@
|
|
|
191
266
|
left: -7px;
|
|
192
267
|
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
|
|
193
268
|
pointer-events: none;
|
|
269
|
+
border: 1px solid var(--block-border-color);
|
|
194
270
|
}
|
|
195
271
|
|
|
196
272
|
.hue-slider > .marker {
|
|
197
273
|
box-shadow: 0 0 1px #888;
|
|
198
274
|
top: -3px;
|
|
199
275
|
margin: auto;
|
|
200
|
-
height:
|
|
201
|
-
width:
|
|
202
|
-
left: -
|
|
203
|
-
|
|
276
|
+
height: 18px;
|
|
277
|
+
width: 18px;
|
|
278
|
+
left: -9px;
|
|
279
|
+
|
|
280
|
+
border: 1px solid var(--block-border-color);
|
|
204
281
|
}
|
|
205
282
|
</style>
|
|
@@ -1,31 +1,58 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import tinycolor from "tinycolor2";
|
|
3
3
|
import { createEventDispatcher } from "svelte";
|
|
4
|
+
import type { ColorTuple } from "./types";
|
|
5
|
+
import type { ColorInput } from "tinycolor2";
|
|
6
|
+
import IconButton from "../IconButton.svelte";
|
|
7
|
+
import { Plus } from "@gradio/icons";
|
|
8
|
+
|
|
4
9
|
export let selected_color: string;
|
|
5
|
-
export let colors:
|
|
6
|
-
export let user_colors: (
|
|
7
|
-
import { Palette } from "@gradio/icons";
|
|
10
|
+
export let colors: (ColorInput | ColorTuple)[];
|
|
11
|
+
export let user_colors: (ColorInput | ColorTuple)[] | null = [];
|
|
8
12
|
|
|
9
13
|
export let show_empty = false;
|
|
10
14
|
export let current_mode: "hex" | "rgb" | "hsl" = "hex";
|
|
11
15
|
export let color_picker = false;
|
|
12
16
|
const dispatch = createEventDispatcher<{
|
|
13
|
-
select: { index: number | null; color: string | null };
|
|
17
|
+
select: { index: number | null; color: string | null; opacity?: number };
|
|
14
18
|
edit: { index: number; color: string | null };
|
|
19
|
+
add_color: void;
|
|
15
20
|
}>();
|
|
16
21
|
|
|
17
22
|
$: _colors = show_empty ? colors : colors.filter((c) => c);
|
|
18
23
|
|
|
24
|
+
// Helper function to extract color from either a color input or a tuple
|
|
25
|
+
function get_color(color_input: ColorInput | ColorTuple): string {
|
|
26
|
+
if (Array.isArray(color_input)) {
|
|
27
|
+
return color_input[0] as string;
|
|
28
|
+
}
|
|
29
|
+
return color_input as string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Helper function to extract opacity from a tuple or return undefined
|
|
33
|
+
function get_opacity(
|
|
34
|
+
color_input: ColorInput | ColorTuple
|
|
35
|
+
): number | undefined {
|
|
36
|
+
if (Array.isArray(color_input)) {
|
|
37
|
+
return color_input[1];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// For string colors, check if there's opacity in the color itself
|
|
41
|
+
const color = tinycolor(color_input);
|
|
42
|
+
return color.getAlpha();
|
|
43
|
+
}
|
|
44
|
+
|
|
19
45
|
function get_formatted_color(
|
|
20
|
-
color:
|
|
46
|
+
color: ColorInput | ColorTuple,
|
|
21
47
|
mode: "hex" | "rgb" | "hsl"
|
|
22
48
|
): string {
|
|
49
|
+
const color_value = get_color(color);
|
|
23
50
|
if (mode === "hex") {
|
|
24
|
-
return tinycolor(
|
|
51
|
+
return tinycolor(color_value).toHexString();
|
|
25
52
|
} else if (mode === "rgb") {
|
|
26
|
-
return tinycolor(
|
|
53
|
+
return tinycolor(color_value).toRgbString();
|
|
27
54
|
}
|
|
28
|
-
return tinycolor(
|
|
55
|
+
return tinycolor(color_value).toHslString();
|
|
29
56
|
}
|
|
30
57
|
|
|
31
58
|
let current_index = `select-${colors.findIndex(
|
|
@@ -34,11 +61,14 @@
|
|
|
34
61
|
get_formatted_color(selected_color, current_mode)
|
|
35
62
|
)}`;
|
|
36
63
|
|
|
64
|
+
$: selected_opacity = get_opacity(selected_color);
|
|
65
|
+
|
|
37
66
|
function handle_select(
|
|
38
67
|
type: "edit" | "select",
|
|
39
68
|
detail: {
|
|
40
69
|
index: number;
|
|
41
70
|
color: string | null;
|
|
71
|
+
opacity?: number;
|
|
42
72
|
}
|
|
43
73
|
): void {
|
|
44
74
|
current_index = `${type}-${detail.index}`;
|
|
@@ -56,19 +86,34 @@
|
|
|
56
86
|
{/if}
|
|
57
87
|
|
|
58
88
|
<div class="swatch-wrap">
|
|
59
|
-
<
|
|
60
|
-
<Palette />
|
|
61
|
-
</span>
|
|
62
|
-
<div>
|
|
89
|
+
<div class="swatch-container">
|
|
63
90
|
{#if user_colors}
|
|
64
91
|
<div class="swatch">
|
|
92
|
+
{#if color_picker}
|
|
93
|
+
<IconButton
|
|
94
|
+
Icon={Plus}
|
|
95
|
+
on:click={() => dispatch("add_color")}
|
|
96
|
+
roundedness="very"
|
|
97
|
+
background={get_color(selected_color)}
|
|
98
|
+
color="white"
|
|
99
|
+
/>
|
|
100
|
+
{/if}
|
|
65
101
|
{#each user_colors as color, i}
|
|
102
|
+
{@const color_string = get_color(color)}
|
|
103
|
+
{@const opacity = get_opacity(color)}
|
|
66
104
|
<button
|
|
67
|
-
on:click={() =>
|
|
105
|
+
on:click={() =>
|
|
106
|
+
handle_select("edit", {
|
|
107
|
+
index: i,
|
|
108
|
+
color: color_string,
|
|
109
|
+
opacity: opacity
|
|
110
|
+
})}
|
|
68
111
|
class="color"
|
|
69
112
|
class:empty={color === null}
|
|
70
|
-
style="background-color: {
|
|
71
|
-
|
|
113
|
+
style="background-color: {color_string}"
|
|
114
|
+
style:opacity
|
|
115
|
+
class:selected={`${color_string}-${opacity}` ===
|
|
116
|
+
`${selected_color}-${selected_opacity}`}
|
|
72
117
|
></button>
|
|
73
118
|
{/each}
|
|
74
119
|
|
|
@@ -80,13 +125,22 @@
|
|
|
80
125
|
</div>
|
|
81
126
|
{/if}
|
|
82
127
|
<menu class="swatch">
|
|
83
|
-
{#each _colors as
|
|
128
|
+
{#each _colors as color_item, i}
|
|
129
|
+
{@const color_string = get_color(color_item)}
|
|
130
|
+
{@const opacity = get_opacity(color_item)}
|
|
84
131
|
<button
|
|
85
|
-
on:click={() =>
|
|
132
|
+
on:click={() =>
|
|
133
|
+
handle_select("select", {
|
|
134
|
+
index: i,
|
|
135
|
+
color: color_string,
|
|
136
|
+
opacity: opacity
|
|
137
|
+
})}
|
|
86
138
|
class="color"
|
|
87
|
-
class:empty={
|
|
88
|
-
style="background-color: {
|
|
89
|
-
|
|
139
|
+
class:empty={color_item === null}
|
|
140
|
+
style="background-color: {color_string}"
|
|
141
|
+
style:opacity
|
|
142
|
+
class:selected={`${color_string}-${opacity}` ===
|
|
143
|
+
`${selected_color}-${selected_opacity}`}
|
|
90
144
|
></button>
|
|
91
145
|
{/each}
|
|
92
146
|
</menu>
|
|
@@ -94,32 +148,31 @@
|
|
|
94
148
|
</div>
|
|
95
149
|
|
|
96
150
|
<style>
|
|
97
|
-
.icon-wrap {
|
|
98
|
-
width: 18px;
|
|
99
|
-
margin-top: 6px;
|
|
100
|
-
|
|
101
|
-
margin-left: var(--size-4);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
151
|
.swatch-wrap {
|
|
105
152
|
display: flex;
|
|
106
153
|
justify-content: space-between;
|
|
107
154
|
align-items: flex-start;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
margin-top: 0px;
|
|
155
|
+
/* max-width: 200px; */
|
|
156
|
+
width: 205px;
|
|
111
157
|
}
|
|
112
158
|
|
|
113
159
|
span.lg {
|
|
114
|
-
margin-top: var(--spacing-
|
|
160
|
+
margin-top: var(--spacing-sm);
|
|
115
161
|
}
|
|
116
|
-
.swatch {
|
|
162
|
+
.swatch-container {
|
|
117
163
|
display: flex;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
164
|
+
flex-direction: column;
|
|
165
|
+
gap: 10px;
|
|
166
|
+
width: 100%;
|
|
167
|
+
}
|
|
168
|
+
.swatch {
|
|
169
|
+
display: grid;
|
|
170
|
+
grid-template-columns: repeat(auto-fill, 25px);
|
|
171
|
+
gap: 8px;
|
|
172
|
+
justify-content: flex-start;
|
|
173
|
+
|
|
174
|
+
overflow: hidden;
|
|
175
|
+
justify-content: center;
|
|
123
176
|
}
|
|
124
177
|
|
|
125
178
|
.empty {
|
|
@@ -140,9 +193,9 @@
|
|
|
140
193
|
}
|
|
141
194
|
|
|
142
195
|
.color {
|
|
143
|
-
width:
|
|
144
|
-
height:
|
|
145
|
-
border-radius:
|
|
196
|
+
width: 25px;
|
|
197
|
+
height: 25px;
|
|
198
|
+
border-radius: var(--radius-md);
|
|
146
199
|
}
|
|
147
200
|
|
|
148
201
|
.empty.selected,
|
|
@@ -183,14 +236,14 @@
|
|
|
183
236
|
.colorpicker::after {
|
|
184
237
|
display: flex;
|
|
185
238
|
justify-content: center;
|
|
186
|
-
align-
|
|
239
|
+
align-items: center;
|
|
187
240
|
content: "⨯";
|
|
188
241
|
color: white;
|
|
189
242
|
font-size: var(--scale-5);
|
|
190
243
|
position: absolute;
|
|
191
244
|
width: 100%;
|
|
192
245
|
height: 100%;
|
|
193
|
-
transform: translateY(-
|
|
246
|
+
transform: translateY(-7px);
|
|
194
247
|
opacity: 1;
|
|
195
248
|
transition: 0.1s;
|
|
196
249
|
top: 0;
|