@alegendstale/holly-components 0.2.2
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/LICENSE +674 -0
- package/README.md +21 -0
- package/dist/components/absolute-container/absolute-container.d.ts +34 -0
- package/dist/components/absolute-container/absolute-container.d.ts.map +1 -0
- package/dist/components/absolute-container/absolute-container.js +96 -0
- package/dist/components/absolute-container/absolute-container.stories.d.ts +9 -0
- package/dist/components/absolute-container/absolute-container.stories.d.ts.map +1 -0
- package/dist/components/absolute-container/index.d.ts +2 -0
- package/dist/components/absolute-container/index.d.ts.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts +68 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.js +312 -0
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts +14 -0
- package/dist/components/bottom-sheet/bottom-sheet.stories.d.ts.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.test.d.ts +2 -0
- package/dist/components/bottom-sheet/bottom-sheet.test.d.ts.map +1 -0
- package/dist/components/bottom-sheet/index.d.ts +2 -0
- package/dist/components/bottom-sheet/index.d.ts.map +1 -0
- package/dist/components/canvas/canvas-base.d.ts +16 -0
- package/dist/components/canvas/canvas-base.d.ts.map +1 -0
- package/dist/components/canvas/canvas-base.js +48 -0
- package/dist/components/canvas/canvas-gradient.d.ts +20 -0
- package/dist/components/canvas/canvas-gradient.d.ts.map +1 -0
- package/dist/components/canvas/canvas-gradient.js +47 -0
- package/dist/components/canvas/canvas-image.d.ts +49 -0
- package/dist/components/canvas/canvas-image.d.ts.map +1 -0
- package/dist/components/canvas/canvas-image.js +117 -0
- package/dist/components/canvas/index.d.ts +3 -0
- package/dist/components/canvas/index.d.ts.map +1 -0
- package/dist/components/carousel-scroller/carousel-scroller.d.ts +29 -0
- package/dist/components/carousel-scroller/carousel-scroller.d.ts.map +1 -0
- package/dist/components/carousel-scroller/carousel-scroller.js +125 -0
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts +11 -0
- package/dist/components/carousel-scroller/carousel-scroller.stories.d.ts.map +1 -0
- package/dist/components/carousel-scroller/index.d.ts +2 -0
- package/dist/components/carousel-scroller/index.d.ts.map +1 -0
- package/dist/components/color-palette/color-palette-utils.d.ts +69 -0
- package/dist/components/color-palette/color-palette-utils.d.ts.map +1 -0
- package/dist/components/color-palette/color-palette-utils.js +43 -0
- package/dist/components/color-palette/color-palette.d.ts +61 -0
- package/dist/components/color-palette/color-palette.d.ts.map +1 -0
- package/dist/components/color-palette/color-palette.js +346 -0
- package/dist/components/color-palette/component/color-palette-component.d.ts +22 -0
- package/dist/components/color-palette/component/color-palette-component.d.ts.map +1 -0
- package/dist/components/color-palette/component/color-palette-component.js +148 -0
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts +11 -0
- package/dist/components/color-palette/component/color-palette-component.stories.d.ts.map +1 -0
- package/dist/components/color-palette/component/index.d.ts +2 -0
- package/dist/components/color-palette/component/index.d.ts.map +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.d.ts +46 -0
- package/dist/components/color-palette/editor/color-palette-editor.d.ts.map +1 -0
- package/dist/components/color-palette/editor/color-palette-editor.js +611 -0
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts +11 -0
- package/dist/components/color-palette/editor/color-palette-editor.stories.d.ts.map +1 -0
- package/dist/components/color-palette/editor/index.d.ts +2 -0
- package/dist/components/color-palette/editor/index.d.ts.map +1 -0
- package/dist/components/color-palette/index.d.ts +6 -0
- package/dist/components/color-palette/index.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item-edit.d.ts +20 -0
- package/dist/components/color-palette/item/color-palette-item-edit.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item-edit.js +91 -0
- package/dist/components/color-palette/item/color-palette-item.d.ts +29 -0
- package/dist/components/color-palette/item/color-palette-item.d.ts.map +1 -0
- package/dist/components/color-palette/item/color-palette-item.js +146 -0
- package/dist/components/color-palette/item/index.d.ts +3 -0
- package/dist/components/color-palette/item/index.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-menu.d.ts +30 -0
- package/dist/components/color-palette/menu/color-palette-menu.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-menu.js +231 -0
- package/dist/components/color-palette/menu/color-palette-reorder.d.ts +31 -0
- package/dist/components/color-palette/menu/color-palette-reorder.d.ts.map +1 -0
- package/dist/components/color-palette/menu/color-palette-reorder.js +108 -0
- package/dist/components/color-palette/menu/index.d.ts +3 -0
- package/dist/components/color-palette/menu/index.d.ts.map +1 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts +15 -0
- package/dist/components/color-palette/storybook/color-palette-invalid.stories.d.ts.map +1 -0
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts +34 -0
- package/dist/components/color-palette/storybook/color-palette-valid.stories.d.ts.map +1 -0
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts +13 -0
- package/dist/components/color-palette/storybook/color-palette.stories.d.ts.map +1 -0
- package/dist/components/tool-tip/Tooltip2.d.ts +17 -0
- package/dist/components/tool-tip/Tooltip2.d.ts.map +1 -0
- package/dist/components/tool-tip/index.d.ts +2 -0
- package/dist/components/tool-tip/index.d.ts.map +1 -0
- package/dist/components/tool-tip/tool-tip.d.ts +29 -0
- package/dist/components/tool-tip/tool-tip.d.ts.map +1 -0
- package/dist/components/tool-tip/tool-tip.js +106 -0
- package/dist/components/tool-tip/tool-tip.stories.d.ts +12 -0
- package/dist/components/tool-tip/tool-tip.stories.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/utils/EventEmitter.d.ts +9 -0
- package/dist/utils/EventEmitter.d.ts.map +1 -0
- package/dist/utils/EventEmitter.js +24 -0
- package/dist/utils/basicUtils.d.ts +47 -0
- package/dist/utils/basicUtils.d.ts.map +1 -0
- package/dist/utils/basicUtils.js +23 -0
- package/dist/utils/dragDropUtils.d.ts +36 -0
- package/dist/utils/dragDropUtils.d.ts.map +1 -0
- package/dist/utils/generateUtils.d.ts +27 -0
- package/dist/utils/generateUtils.d.ts.map +1 -0
- package/dist/utils/generateUtils.js +40 -0
- package/dist/utils/types.d.ts +5 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
import { css as P, LitElement as H, html as g } from "lit";
|
|
2
|
+
import { query as D, property as u, state as M, customElement as U } from "lit/decorators.js";
|
|
3
|
+
import { createElement as h, Pipette as S, Shuffle as C, Image as j, Link as R, ArrowUpToLine as G } from "lucide";
|
|
4
|
+
import { defaultSettings as m, Direction as _, urlRegex as z, CopyFormat as A } from "../color-palette-utils.js";
|
|
5
|
+
import { Combination as b, generateColors as L } from "../../../utils/generateUtils.js";
|
|
6
|
+
import y from "colorsea";
|
|
7
|
+
import { parseUrl as B, copyToClipboard as F } from "../../../utils/basicUtils.js";
|
|
8
|
+
import { CanvasImage as E } from "../../canvas/canvas-image.js";
|
|
9
|
+
import { ref as f, createRef as $ } from "lit/directives/ref.js";
|
|
10
|
+
import { EventEmitter as W } from "../../../utils/EventEmitter.js";
|
|
11
|
+
import { ColorPalette as q } from "../color-palette.js";
|
|
12
|
+
var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, s = (t, i, n, a) => {
|
|
13
|
+
for (var r = a > 1 ? void 0 : a ? Y(i, n) : i, l = t.length - 1, p; l >= 0; l--)
|
|
14
|
+
(p = t[l]) && (r = (a ? p(i, n, r) : p(r)) || r);
|
|
15
|
+
return a && r && X(i, n, r), r;
|
|
16
|
+
};
|
|
17
|
+
let c = class extends H {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments), this.colors = [], this.settings = {
|
|
20
|
+
height: m.height,
|
|
21
|
+
width: m.width,
|
|
22
|
+
direction: m.direction,
|
|
23
|
+
gradient: m.gradient,
|
|
24
|
+
preventHover: m.preventHover,
|
|
25
|
+
override: m.override,
|
|
26
|
+
aliases: []
|
|
27
|
+
}, this.selectedInput = "Color Picker", this.combination = b.Random, this.colorPickerDisabled = !1, this.emitter = new W();
|
|
28
|
+
}
|
|
29
|
+
disconnectedCallback() {
|
|
30
|
+
this.emitter.clear();
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
const t = () => {
|
|
34
|
+
switch (this.selectedInput) {
|
|
35
|
+
case "Color Picker":
|
|
36
|
+
return this.pickerOption();
|
|
37
|
+
case "Generate":
|
|
38
|
+
return this.generateOption();
|
|
39
|
+
case "Image":
|
|
40
|
+
return this.imageOption();
|
|
41
|
+
case "URL":
|
|
42
|
+
return this.urlOption();
|
|
43
|
+
}
|
|
44
|
+
}, i = (n) => {
|
|
45
|
+
n instanceof q && n.emitter.on("changed", (a, r) => {
|
|
46
|
+
this.colors = a, this.settings = r;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
return g`
|
|
50
|
+
<div id="color-palette-editor">
|
|
51
|
+
<h1>Editor</h1>
|
|
52
|
+
<section id='colors'>
|
|
53
|
+
<h3>Colors</h3>
|
|
54
|
+
<div id="control-container">
|
|
55
|
+
<button
|
|
56
|
+
title="Color Picker"
|
|
57
|
+
@click=${() => this.selectedInput = "Color Picker"}
|
|
58
|
+
>
|
|
59
|
+
${h(S)}
|
|
60
|
+
</button>
|
|
61
|
+
<button
|
|
62
|
+
title="Generate"
|
|
63
|
+
@click=${() => this.selectedInput = "Generate"}
|
|
64
|
+
>
|
|
65
|
+
${h(C)}
|
|
66
|
+
</button>
|
|
67
|
+
<button
|
|
68
|
+
title="Image"
|
|
69
|
+
@click=${() => this.selectedInput = "Image"}
|
|
70
|
+
>
|
|
71
|
+
${h(j)}
|
|
72
|
+
</button>
|
|
73
|
+
<button
|
|
74
|
+
title="URL"
|
|
75
|
+
@click=${() => this.selectedInput = "URL"}
|
|
76
|
+
>
|
|
77
|
+
${h(R)}
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
<div id='colors-container'>
|
|
81
|
+
${t()}
|
|
82
|
+
</div>
|
|
83
|
+
</section>
|
|
84
|
+
<section id='preview'>
|
|
85
|
+
<color-palette
|
|
86
|
+
.colors=${this.colors}
|
|
87
|
+
height=${this.settings.height}
|
|
88
|
+
width=${this.settings.width}
|
|
89
|
+
direction=${this.settings.direction}
|
|
90
|
+
?gradient=${this.settings.gradient}
|
|
91
|
+
?preventHover=${this.settings.preventHover}
|
|
92
|
+
?override=${this.settings.override}
|
|
93
|
+
.aliases=${this.settings.aliases}
|
|
94
|
+
?editMode=${!0}
|
|
95
|
+
maxWidth=${560}
|
|
96
|
+
${f(i)}
|
|
97
|
+
>
|
|
98
|
+
</color-palette>
|
|
99
|
+
</section>
|
|
100
|
+
<section id='settings'>
|
|
101
|
+
<h3>Settings</h3>
|
|
102
|
+
${this.renderSettings()}
|
|
103
|
+
<button
|
|
104
|
+
id='create-btn'
|
|
105
|
+
@click=${() => {
|
|
106
|
+
try {
|
|
107
|
+
this.colors.length === 0 && (this.colors = L(b.Random).colors), this.emitter.emit("submit", this.colors, this.settings);
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
Create
|
|
113
|
+
</button>
|
|
114
|
+
</section>
|
|
115
|
+
</div>
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
renderSettings() {
|
|
119
|
+
return g`
|
|
120
|
+
<setting-item
|
|
121
|
+
name='Height'
|
|
122
|
+
>
|
|
123
|
+
<input
|
|
124
|
+
type='number'
|
|
125
|
+
value=${this.settings.height}
|
|
126
|
+
step=${5}
|
|
127
|
+
@input=${(t) => {
|
|
128
|
+
t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, height: +t.target.value });
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
</setting-item>
|
|
132
|
+
<setting-item
|
|
133
|
+
name='Width'
|
|
134
|
+
description='Caution - Might cause palette to display incorrectly.'
|
|
135
|
+
>
|
|
136
|
+
<input
|
|
137
|
+
type='number'
|
|
138
|
+
value=${this.settings.width}
|
|
139
|
+
step=${10}
|
|
140
|
+
@input=${(t) => {
|
|
141
|
+
t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, width: +t.target.value });
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
</setting-item>
|
|
145
|
+
<setting-item
|
|
146
|
+
name='Direction'
|
|
147
|
+
>
|
|
148
|
+
<select
|
|
149
|
+
@change=${(t) => {
|
|
150
|
+
t.target instanceof HTMLSelectElement && (this.settings = { ...this.settings, direction: t.target.value });
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
${Object.values(_).map((t) => g`<option ?selected=${this.settings.direction === t}>${t}</option>`)}
|
|
154
|
+
</select>
|
|
155
|
+
</setting-item>
|
|
156
|
+
<setting-item
|
|
157
|
+
name='Gradient'
|
|
158
|
+
>
|
|
159
|
+
<input
|
|
160
|
+
type='checkbox'
|
|
161
|
+
?checked=${this.settings.gradient}
|
|
162
|
+
@change=${(t) => {
|
|
163
|
+
t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, gradient: t.target.checked });
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
</setting-item>
|
|
167
|
+
<setting-item
|
|
168
|
+
name='Prevent Hover'
|
|
169
|
+
description='Toggles whether palettes can be hovered'
|
|
170
|
+
>
|
|
171
|
+
<input
|
|
172
|
+
type='checkbox'
|
|
173
|
+
?checked=${this.settings.preventHover}
|
|
174
|
+
@change=${(t) => {
|
|
175
|
+
t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, preventHover: t.target.checked });
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
</setting-item>
|
|
179
|
+
<setting-item
|
|
180
|
+
name='Override'
|
|
181
|
+
description='Disables color validation for full control (advanced)'
|
|
182
|
+
>
|
|
183
|
+
<input
|
|
184
|
+
type='checkbox'
|
|
185
|
+
?checked=${this.settings.override}
|
|
186
|
+
@change=${(t) => {
|
|
187
|
+
t.target instanceof HTMLInputElement && (this.settings = { ...this.settings, override: t.target.checked });
|
|
188
|
+
}}
|
|
189
|
+
>
|
|
190
|
+
</setting-item>
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
pickerOption() {
|
|
194
|
+
return g`
|
|
195
|
+
<setting-item
|
|
196
|
+
name='Color Picker'
|
|
197
|
+
description='Use handpicked colors'
|
|
198
|
+
>
|
|
199
|
+
<input
|
|
200
|
+
type='color'
|
|
201
|
+
@change=${(t) => {
|
|
202
|
+
t.target instanceof HTMLInputElement && (this.colors = [...this.colors, t.target.value], this.settings.aliases.push(""));
|
|
203
|
+
}}
|
|
204
|
+
>
|
|
205
|
+
</setting-item>
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
generateOption() {
|
|
209
|
+
return this.colorPickerDisabled = this.combination === b.Random, g`
|
|
210
|
+
<setting-item
|
|
211
|
+
name='Generate'
|
|
212
|
+
description='Generate colors based on color theory'
|
|
213
|
+
>
|
|
214
|
+
<select
|
|
215
|
+
@change=${(t) => {
|
|
216
|
+
t.target instanceof HTMLSelectElement && (this.combination = t.target.value, this.colorPickerDisabled = this.combination === b.Random);
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
${Object.values(b).map((t) => g`<option ?selected=${this.combination === t}>${t}</option>`)}
|
|
220
|
+
</select>
|
|
221
|
+
<input
|
|
222
|
+
type='color'
|
|
223
|
+
?disabled=${this.colorPickerDisabled}
|
|
224
|
+
@change=${(t) => {
|
|
225
|
+
t.target instanceof HTMLInputElement && (this.baseColor = y(t.target.value));
|
|
226
|
+
}}
|
|
227
|
+
@contextmenu=${(t) => {
|
|
228
|
+
t.preventDefault(), t.target instanceof HTMLInputElement && (t.target.value = y("#000").hex(), this.baseColor = void 0);
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
<button
|
|
232
|
+
title='Loads the generated colors'
|
|
233
|
+
@click=${(t) => {
|
|
234
|
+
const i = L(this.combination, { baseColor: this.baseColor, settings: this.settings });
|
|
235
|
+
this.colors = i.colors, i.settings && (this.settings = i.settings);
|
|
236
|
+
}}
|
|
237
|
+
>
|
|
238
|
+
${h(C)}
|
|
239
|
+
</button>
|
|
240
|
+
</setting-item>
|
|
241
|
+
`;
|
|
242
|
+
}
|
|
243
|
+
imageOption() {
|
|
244
|
+
var w;
|
|
245
|
+
let t = "", i = $(), n = $(), a = $(), r = ((w = i.value) == null ? void 0 : w.value) || "", l, p = $(), O = (e) => {
|
|
246
|
+
e instanceof E && (l = e, e.emitter.clear(), e.emitter.on("click", async (o) => await F(o.toUpperCase(), A.Raw)), e.emitter.on("move", (o) => {
|
|
247
|
+
if (!p.value) return;
|
|
248
|
+
let d = p.value;
|
|
249
|
+
d.text = e.getCanvasHex(o.x, o.y).toUpperCase(), d.setClampedPosition(o, e.getBoundingClientRect());
|
|
250
|
+
}));
|
|
251
|
+
};
|
|
252
|
+
const T = async () => {
|
|
253
|
+
if (!n.value || !l) return;
|
|
254
|
+
const e = n.value;
|
|
255
|
+
return await l.getPalette(+e.value);
|
|
256
|
+
}, k = async () => {
|
|
257
|
+
const e = await T();
|
|
258
|
+
e && (this.colors = e.map((o) => y(o).hex(0)), this.settings.aliases = []);
|
|
259
|
+
}, x = async (e) => {
|
|
260
|
+
if (!URL.canParse(e) || !l) return;
|
|
261
|
+
l.updateImage(e, this.palette.getBoundingClientRect().width, this.palette.getBoundingClientRect().height), await k();
|
|
262
|
+
};
|
|
263
|
+
return g`
|
|
264
|
+
<setting-item
|
|
265
|
+
name='Image'
|
|
266
|
+
description='Convert image into palette'
|
|
267
|
+
>
|
|
268
|
+
<input
|
|
269
|
+
type='url'
|
|
270
|
+
placeholder='Enter URL or select file'
|
|
271
|
+
${f(i)}
|
|
272
|
+
>
|
|
273
|
+
<button
|
|
274
|
+
title='Right click to clear URL'
|
|
275
|
+
@click=${async (e) => {
|
|
276
|
+
try {
|
|
277
|
+
if (!a.value) return;
|
|
278
|
+
let o = a.value;
|
|
279
|
+
if (r !== "")
|
|
280
|
+
if (URL.canParse(r)) await x(r);
|
|
281
|
+
else throw new Error("URL provided is not valid.");
|
|
282
|
+
else o.click();
|
|
283
|
+
} catch {
|
|
284
|
+
}
|
|
285
|
+
}}
|
|
286
|
+
@contextmenu=${() => {
|
|
287
|
+
if (!i.value) return;
|
|
288
|
+
const e = i.value;
|
|
289
|
+
e.value = "";
|
|
290
|
+
}}
|
|
291
|
+
>
|
|
292
|
+
${h(G)}
|
|
293
|
+
</button>
|
|
294
|
+
<input
|
|
295
|
+
type ='file'
|
|
296
|
+
accept = 'image/*'
|
|
297
|
+
@change=${(e) => {
|
|
298
|
+
var o;
|
|
299
|
+
try {
|
|
300
|
+
const d = new FileReader(), I = (o = e.target.files) == null ? void 0 : o[0];
|
|
301
|
+
I && d.readAsDataURL(I), d.addEventListener("load", async () => {
|
|
302
|
+
typeof d.result == "string" && (r = d.result, await x(r));
|
|
303
|
+
}), d.addEventListener("error", () => {
|
|
304
|
+
throw new Error("Error processing image");
|
|
305
|
+
});
|
|
306
|
+
} catch {
|
|
307
|
+
}
|
|
308
|
+
}}
|
|
309
|
+
${f(a)}
|
|
310
|
+
>
|
|
311
|
+
</setting-item>
|
|
312
|
+
<setting-item
|
|
313
|
+
name='Count'
|
|
314
|
+
description='Set the number of colors to generate from the image'
|
|
315
|
+
>
|
|
316
|
+
<input
|
|
317
|
+
id='range-slider'
|
|
318
|
+
type='range'
|
|
319
|
+
min='4'
|
|
320
|
+
max='12'
|
|
321
|
+
value='8'
|
|
322
|
+
@change=${async () => {
|
|
323
|
+
await k();
|
|
324
|
+
}}
|
|
325
|
+
${f(n)}
|
|
326
|
+
>
|
|
327
|
+
</setting-item>
|
|
328
|
+
<tool-tip
|
|
329
|
+
trigger='hover'
|
|
330
|
+
${f(p)}
|
|
331
|
+
>
|
|
332
|
+
<canvas-image
|
|
333
|
+
@mousemove=${(e) => {
|
|
334
|
+
e.target instanceof E && (t = e.target.getCanvasHex(e.clientX, e.clientY));
|
|
335
|
+
}}
|
|
336
|
+
@click=${(e) => {
|
|
337
|
+
t && (this.colors = [...this.colors, t], this.settings.aliases = [...this.settings.aliases, ""]);
|
|
338
|
+
}}
|
|
339
|
+
${f(O)}
|
|
340
|
+
>
|
|
341
|
+
</canvas-image>
|
|
342
|
+
</tool-tip>
|
|
343
|
+
`;
|
|
344
|
+
}
|
|
345
|
+
urlOption() {
|
|
346
|
+
let t;
|
|
347
|
+
return g`
|
|
348
|
+
<setting-item
|
|
349
|
+
name='URL'
|
|
350
|
+
description='Only coolors.co & colorhunt.co are currently supported'
|
|
351
|
+
>
|
|
352
|
+
<input
|
|
353
|
+
type='url'
|
|
354
|
+
placeholder='Enter URL'
|
|
355
|
+
@change=${(i) => {
|
|
356
|
+
i.target instanceof HTMLInputElement && (t = i.target);
|
|
357
|
+
}}
|
|
358
|
+
>
|
|
359
|
+
<button
|
|
360
|
+
title='Right click to clear URL'
|
|
361
|
+
@click=${(i) => {
|
|
362
|
+
try {
|
|
363
|
+
if (!t.value.match(z)) throw new Error("URL provided is not valid.");
|
|
364
|
+
this.colors = B(t.value), this.settings.aliases = [];
|
|
365
|
+
} catch {
|
|
366
|
+
}
|
|
367
|
+
}}
|
|
368
|
+
@contextmenu=${(i) => {
|
|
369
|
+
i.preventDefault(), t && (t.value = "");
|
|
370
|
+
}}
|
|
371
|
+
>
|
|
372
|
+
${h(R)}
|
|
373
|
+
</button>
|
|
374
|
+
</setting-item>
|
|
375
|
+
`;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
c.styles = [
|
|
379
|
+
P`
|
|
380
|
+
:host {
|
|
381
|
+
display: block;
|
|
382
|
+
contain: content;
|
|
383
|
+
width: 560px;
|
|
384
|
+
padding: 16px;
|
|
385
|
+
background-color: rgb(27, 27, 27);
|
|
386
|
+
color: rgba(245, 245, 245, .9);
|
|
387
|
+
border-radius: 5px;
|
|
388
|
+
|
|
389
|
+
--cta-background: hsl(262, 83%, 69%);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
input[type='file'] {
|
|
393
|
+
display: none;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
:host([selectedInput="Color Picker"]) {
|
|
397
|
+
#color-palette-editor #colors {
|
|
398
|
+
div:nth-of-type(1) {
|
|
399
|
+
button[title="Color Picker"] {
|
|
400
|
+
background-color: var(--cta-background);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
div:nth-of-type(2) {
|
|
404
|
+
canvas {
|
|
405
|
+
max-width: 100%;
|
|
406
|
+
max-height: fit-content;
|
|
407
|
+
object-fit: cover;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
:host([selectedInput="Generate"]) {
|
|
414
|
+
#color-palette-editor #colors div {
|
|
415
|
+
button[title="Generate"] {
|
|
416
|
+
background-color: var(--cta-background);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
:host([selectedInput="Image"]) {
|
|
422
|
+
#color-palette-editor #colors div {
|
|
423
|
+
button[title="Image"] {
|
|
424
|
+
background-color: var(--cta-background);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
:host([selectedInput="URL"]) {
|
|
430
|
+
#color-palette-editor #colors div {
|
|
431
|
+
button[title="URL"] {
|
|
432
|
+
background-color: var(--cta-background);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
#color-palette-editor {
|
|
438
|
+
display: flex;
|
|
439
|
+
flex-direction: column;
|
|
440
|
+
gap: .5rem;
|
|
441
|
+
|
|
442
|
+
h1 {
|
|
443
|
+
font-size: 2.25rem;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
button {
|
|
447
|
+
cursor: pointer;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
#colors {
|
|
451
|
+
div {
|
|
452
|
+
input:not([type='color']) {
|
|
453
|
+
color: rgb(245, 245, 245);
|
|
454
|
+
background-color: rgb(38, 38, 38);
|
|
455
|
+
border: none;
|
|
456
|
+
border-radius: 5px;
|
|
457
|
+
height: fit-content;
|
|
458
|
+
width: fit-content;
|
|
459
|
+
padding: .5rem;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
select {
|
|
463
|
+
color: rgb(245, 245, 245);
|
|
464
|
+
background-color: rgb(38, 38, 38);
|
|
465
|
+
border: none;
|
|
466
|
+
border-radius: 5px;
|
|
467
|
+
height: fit-content;
|
|
468
|
+
width: fit-content;
|
|
469
|
+
padding: .5rem;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
button {
|
|
473
|
+
color: rgb(245, 245, 245);
|
|
474
|
+
background-color: rgb(38, 38, 38);
|
|
475
|
+
border: none;
|
|
476
|
+
border-radius: 5px;
|
|
477
|
+
height: fit-content;
|
|
478
|
+
width: fit-content;
|
|
479
|
+
padding: 4px 12px;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
#settings {
|
|
485
|
+
display: flex;
|
|
486
|
+
flex-direction: column;
|
|
487
|
+
|
|
488
|
+
input {
|
|
489
|
+
color: rgb(245, 245, 245);
|
|
490
|
+
background-color: rgb(38, 38, 38);
|
|
491
|
+
border: none;
|
|
492
|
+
border-radius: 5px;
|
|
493
|
+
height: fit-content;
|
|
494
|
+
width: fit-content;
|
|
495
|
+
padding: .5rem;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
select {
|
|
499
|
+
color: rgb(245, 245, 245);
|
|
500
|
+
background-color: rgb(38, 38, 38);
|
|
501
|
+
border: none;
|
|
502
|
+
border-radius: 5px;
|
|
503
|
+
height: fit-content;
|
|
504
|
+
width: fit-content;
|
|
505
|
+
padding: .5rem;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
#create-btn {
|
|
509
|
+
background-color: var(--cta-background);
|
|
510
|
+
color: white;
|
|
511
|
+
border-radius: 5px;
|
|
512
|
+
padding: 4px 12px;
|
|
513
|
+
user-select: none;
|
|
514
|
+
border: none;
|
|
515
|
+
width: fit-content;
|
|
516
|
+
align-self: flex-end;
|
|
517
|
+
|
|
518
|
+
&:hover {
|
|
519
|
+
background-color: hsl(calc( 262 - 3), calc( 83% * 1.02), calc( 69% * 1.15));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
`
|
|
525
|
+
];
|
|
526
|
+
s([
|
|
527
|
+
D("#color-palette-editor")
|
|
528
|
+
], c.prototype, "palette", 2);
|
|
529
|
+
s([
|
|
530
|
+
u({ type: Array })
|
|
531
|
+
], c.prototype, "colors", 2);
|
|
532
|
+
s([
|
|
533
|
+
u({ type: Object })
|
|
534
|
+
], c.prototype, "settings", 2);
|
|
535
|
+
s([
|
|
536
|
+
u({ type: String, reflect: !0 })
|
|
537
|
+
], c.prototype, "selectedInput", 2);
|
|
538
|
+
s([
|
|
539
|
+
u({ type: String })
|
|
540
|
+
], c.prototype, "combination", 2);
|
|
541
|
+
s([
|
|
542
|
+
u({ type: Object })
|
|
543
|
+
], c.prototype, "baseColor", 2);
|
|
544
|
+
s([
|
|
545
|
+
M()
|
|
546
|
+
], c.prototype, "colorPickerDisabled", 2);
|
|
547
|
+
c = s([
|
|
548
|
+
U("color-palette-editor")
|
|
549
|
+
], c);
|
|
550
|
+
let v = class extends H {
|
|
551
|
+
constructor() {
|
|
552
|
+
super(...arguments), this.name = "", this.description = "";
|
|
553
|
+
}
|
|
554
|
+
render() {
|
|
555
|
+
return g`
|
|
556
|
+
<div>
|
|
557
|
+
<h3>${this.name}</h3>
|
|
558
|
+
<p>${this.description}</p>
|
|
559
|
+
</div>
|
|
560
|
+
<slot></slot>
|
|
561
|
+
`;
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
v.styles = [
|
|
565
|
+
P`
|
|
566
|
+
:host {
|
|
567
|
+
display: grid;
|
|
568
|
+
grid-template-columns: 1fr 1fr;
|
|
569
|
+
padding-block: 2%;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
:host(:not([description])) p {
|
|
573
|
+
display: none;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
h3 {
|
|
577
|
+
margin: 0;
|
|
578
|
+
font-size: 15px;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
p {
|
|
582
|
+
margin: 0;
|
|
583
|
+
padding-top: 4px;
|
|
584
|
+
font-size: 12px;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
slot {
|
|
588
|
+
display: flex;
|
|
589
|
+
justify-self: flex-end;
|
|
590
|
+
align-items: center;
|
|
591
|
+
gap: 5%;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
::slotted(input[type="color"]) {
|
|
595
|
+
border: none;
|
|
596
|
+
}
|
|
597
|
+
`
|
|
598
|
+
];
|
|
599
|
+
s([
|
|
600
|
+
u({ type: String })
|
|
601
|
+
], v.prototype, "name", 2);
|
|
602
|
+
s([
|
|
603
|
+
u({ type: String })
|
|
604
|
+
], v.prototype, "description", 2);
|
|
605
|
+
v = s([
|
|
606
|
+
U("setting-item")
|
|
607
|
+
], v);
|
|
608
|
+
export {
|
|
609
|
+
c as ColorPaletteEditor,
|
|
610
|
+
v as SettingItem
|
|
611
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/web-components';
|
|
2
|
+
import { PaletteSettings } from '../color-palette-utils';
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Props = {
|
|
6
|
+
colors: string[];
|
|
7
|
+
settings: PaletteSettings;
|
|
8
|
+
};
|
|
9
|
+
type Story = StoryObj<Props>;
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
//# sourceMappingURL=color-palette-editor.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-palette-editor.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/color-palette/editor/color-palette-editor.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAMhE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC;AAE7D,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAwB7B,eAAO,MAAM,OAAO,EAAE,KAMrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/color-palette/editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/color-palette/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAA;AACxB,OAAO,QAAQ,CAAA;AACf,OAAO,QAAQ,CAAA;AACf,OAAO,aAAa,CAAA;AACpB,OAAO,UAAU,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EventEmitter } from "../../../utils/EventEmitter";
|
|
2
|
+
import { ColorPaletteItem, EventMap as ItemEvents } from "./color-palette-item";
|
|
3
|
+
type EditEvents = {
|
|
4
|
+
trash: [e: MouseEvent];
|
|
5
|
+
alias: [alias: string];
|
|
6
|
+
};
|
|
7
|
+
type EventMap = EditEvents & ItemEvents;
|
|
8
|
+
export declare class ColorPaletteItemEdit extends ColorPaletteItem {
|
|
9
|
+
static styles: import("lit").CSSResult[];
|
|
10
|
+
storedAlias: string;
|
|
11
|
+
emitter: EventEmitter<EventMap>;
|
|
12
|
+
content(): import("lit-html").TemplateResult<1>;
|
|
13
|
+
}
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'color-palette-item-edit': ColorPaletteItemEdit;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=color-palette-item-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-palette-item-edit.d.ts","sourceRoot":"","sources":["../../../../src/components/color-palette/item/color-palette-item-edit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGhF,KAAK,UAAU,GAAG;IACjB,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IACvB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;CACtB,CAAA;AAED,KAAK,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAExC,qBACa,oBAAqB,SAAQ,gBAAgB;IACzD,MAAM,CAAC,MAAM,4BA2CX;IAEF,WAAW,EAAE,MAAM,CAAM;IAEzB,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAgC;IAE/D,OAAO;CA+CP;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,yBAAyB,EAAE,oBAAoB,CAAC;KAChD;CACD"}
|