@luminescent/ui-qwik 6.8.3-qwikv2 → 6.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/LICENSE +661 -0
  2. package/lib/index.qwik.cjs +1747 -41
  3. package/lib/index.qwik.mjs +1748 -19
  4. package/lib-types/components/docs/Anchor.d.ts +4 -0
  5. package/lib-types/components/docs/Blobs.d.ts +4 -0
  6. package/lib-types/components/docs/ColorPicker.d.ts +4 -0
  7. package/lib-types/components/docs/Dropdown.d.ts +4 -0
  8. package/lib-types/components/docs/IconsLogos.d.ts +4 -0
  9. package/lib-types/components/docs/Nav.d.ts +4 -0
  10. package/lib-types/components/docs/NumberInput.d.ts +4 -0
  11. package/lib-types/components/docs/RangeInput.d.ts +4 -0
  12. package/lib-types/components/docs/SelectMenu.d.ts +4 -0
  13. package/lib-types/components/docs/Settings.d.ts +2 -0
  14. package/lib-types/components/docs/Sidebar.d.ts +4 -0
  15. package/lib-types/components/docs/Toggle.d.ts +4 -0
  16. package/lib-types/components/docs/lum-btn.d.ts +4 -0
  17. package/lib-types/components/docs/lum-card.d.ts +4 -0
  18. package/lib-types/components/docs/lum-classes.d.ts +4 -0
  19. package/lib-types/components/docs/lum-input.d.ts +4 -0
  20. package/{lib → lib-types}/components/elements/Anchor.d.ts +2 -2
  21. package/{lib → lib-types}/components/elements/Blobs.d.ts +1 -1
  22. package/{lib → lib-types}/components/elements/ColorPicker.d.ts +2 -2
  23. package/{lib → lib-types}/components/elements/Dropdown.d.ts +2 -2
  24. package/{lib → lib-types}/components/elements/Nav.d.ts +2 -2
  25. package/lib-types/components/elements/NumberInput.d.ts +21 -0
  26. package/{lib → lib-types}/components/elements/RangeInput.d.ts +3 -3
  27. package/{lib → lib-types}/components/elements/SelectMenu.d.ts +3 -3
  28. package/{lib → lib-types}/components/elements/Sidebar.d.ts +2 -2
  29. package/{lib → lib-types}/components/elements/Toggle.d.ts +2 -2
  30. package/lib-types/components/logos/Birdflop.d.ts +7 -0
  31. package/lib-types/components/logos/Discord.d.ts +2 -0
  32. package/lib-types/components/logos/Fabric.d.ts +2 -0
  33. package/lib-types/components/logos/Forge.d.ts +2 -0
  34. package/{lib → lib-types}/components/logos/IconProps.d.ts +1 -1
  35. package/lib-types/components/logos/Luminescent.d.ts +3 -0
  36. package/lib-types/components/logos/Paper.d.ts +2 -0
  37. package/lib-types/components/logos/Pterodactyl.d.ts +2 -0
  38. package/lib-types/components/logos/Purpur.d.ts +2 -0
  39. package/lib-types/components/logos/Velocity.d.ts +2 -0
  40. package/lib-types/components/logos/Waterfall.d.ts +2 -0
  41. package/{lib → lib-types}/components/logos.d.ts +3 -0
  42. package/lib-types/entry.dev.d.ts +2 -0
  43. package/lib-types/entry.ssr.d.ts +14 -0
  44. package/lib-types/root.d.ts +3 -0
  45. package/lib-types/svg/ChevronDown.d.ts +2 -0
  46. package/lib-types/svg/Link.d.ts +2 -0
  47. package/lib-types/svg/Menu.d.ts +2 -0
  48. package/{lib/svg/Shuffle.d.ts → lib-types/svg/Minus.d.ts} +1 -1
  49. package/lib-types/svg/Plus.d.ts +2 -0
  50. package/lib-types/svg/Shuffle.d.ts +2 -0
  51. package/package.json +35 -32
  52. package/tailwind.config.js +94 -0
  53. package/lib/components/docs/Anchor.d.ts +0 -4
  54. package/lib/components/docs/Blobs.d.ts +0 -4
  55. package/lib/components/docs/ColorPicker.d.ts +0 -4
  56. package/lib/components/docs/Dropdown.d.ts +0 -4
  57. package/lib/components/docs/IconsLogos.d.ts +0 -4
  58. package/lib/components/docs/Nav.d.ts +0 -4
  59. package/lib/components/docs/NumberInput.d.ts +0 -4
  60. package/lib/components/docs/RangeInput.d.ts +0 -4
  61. package/lib/components/docs/SelectMenu.d.ts +0 -4
  62. package/lib/components/docs/Settings.d.ts +0 -2
  63. package/lib/components/docs/Sidebar.d.ts +0 -4
  64. package/lib/components/docs/Toggle.d.ts +0 -4
  65. package/lib/components/docs/lum-btn.d.ts +0 -4
  66. package/lib/components/docs/lum-card.d.ts +0 -4
  67. package/lib/components/docs/lum-classes.d.ts +0 -4
  68. package/lib/components/docs/lum-input.d.ts +0 -4
  69. package/lib/components/elements/Anchor.qwik.cjs +0 -23
  70. package/lib/components/elements/Anchor.qwik.mjs +0 -23
  71. package/lib/components/elements/Blobs.qwik.cjs +0 -185
  72. package/lib/components/elements/Blobs.qwik.mjs +0 -184
  73. package/lib/components/elements/ColorPicker.qwik.cjs +0 -283
  74. package/lib/components/elements/ColorPicker.qwik.mjs +0 -283
  75. package/lib/components/elements/Dropdown.qwik.cjs +0 -28
  76. package/lib/components/elements/Dropdown.qwik.mjs +0 -28
  77. package/lib/components/elements/Nav.qwik.cjs +0 -80
  78. package/lib/components/elements/Nav.qwik.mjs +0 -80
  79. package/lib/components/elements/NumberInput.d.ts +0 -21
  80. package/lib/components/elements/NumberInput.qwik.cjs +0 -74
  81. package/lib/components/elements/NumberInput.qwik.mjs +0 -73
  82. package/lib/components/elements/RangeInput.qwik.cjs +0 -59
  83. package/lib/components/elements/RangeInput.qwik.mjs +0 -58
  84. package/lib/components/elements/SelectMenu.qwik.cjs +0 -109
  85. package/lib/components/elements/SelectMenu.qwik.mjs +0 -108
  86. package/lib/components/elements/Sidebar.qwik.cjs +0 -30
  87. package/lib/components/elements/Sidebar.qwik.mjs +0 -30
  88. package/lib/components/elements/Toggle.qwik.cjs +0 -31
  89. package/lib/components/elements/Toggle.qwik.mjs +0 -31
  90. package/lib/components/functions.qwik.cjs +0 -17
  91. package/lib/components/functions.qwik.mjs +0 -17
  92. package/lib/components/logos/Birdflop.d.ts +0 -10
  93. package/lib/components/logos/Birdflop.qwik.cjs +0 -66
  94. package/lib/components/logos/Birdflop.qwik.mjs +0 -67
  95. package/lib/components/logos/Fabric.d.ts +0 -5
  96. package/lib/components/logos/Fabric.qwik.cjs +0 -30
  97. package/lib/components/logos/Fabric.qwik.mjs +0 -31
  98. package/lib/components/logos/Forge.d.ts +0 -5
  99. package/lib/components/logos/Forge.qwik.cjs +0 -29
  100. package/lib/components/logos/Forge.qwik.mjs +0 -30
  101. package/lib/components/logos/Luminescent.d.ts +0 -9
  102. package/lib/components/logos/Luminescent.qwik.cjs +0 -123
  103. package/lib/components/logos/Luminescent.qwik.mjs +0 -122
  104. package/lib/components/logos/Paper.d.ts +0 -5
  105. package/lib/components/logos/Paper.qwik.cjs +0 -41
  106. package/lib/components/logos/Paper.qwik.mjs +0 -42
  107. package/lib/components/logos/Purpur.d.ts +0 -5
  108. package/lib/components/logos/Purpur.qwik.cjs +0 -75
  109. package/lib/components/logos/Purpur.qwik.mjs +0 -76
  110. package/lib/components/logos/Waterfall.d.ts +0 -5
  111. package/lib/components/logos/Waterfall.qwik.cjs +0 -20
  112. package/lib/components/logos/Waterfall.qwik.mjs +0 -21
  113. package/lib/svg/ChevronDown.d.ts +0 -2
  114. package/lib/svg/ChevronDown.qwik.cjs +0 -20
  115. package/lib/svg/ChevronDown.qwik.mjs +0 -21
  116. package/lib/svg/Link.d.ts +0 -2
  117. package/lib/svg/Link.qwik.cjs +0 -29
  118. package/lib/svg/Link.qwik.mjs +0 -30
  119. package/lib/svg/Menu.d.ts +0 -2
  120. package/lib/svg/Menu.qwik.cjs +0 -24
  121. package/lib/svg/Menu.qwik.mjs +0 -25
  122. package/lib/svg/Minus.d.ts +0 -2
  123. package/lib/svg/Minus.qwik.cjs +0 -20
  124. package/lib/svg/Minus.qwik.mjs +0 -21
  125. package/lib/svg/Plus.d.ts +0 -2
  126. package/lib/svg/Plus.qwik.cjs +0 -20
  127. package/lib/svg/Plus.qwik.mjs +0 -21
  128. package/lib/svg/Shuffle.qwik.cjs +0 -26
  129. package/lib/svg/Shuffle.qwik.mjs +0 -27
  130. package/lib/utils/color.qwik.cjs +0 -120
  131. package/lib/utils/color.qwik.mjs +0 -114
  132. /package/{lib → lib-types}/components/elements.d.ts +0 -0
  133. /package/{lib → lib-types}/components/functions.d.ts +0 -0
  134. /package/{lib → lib-types}/index.d.ts +0 -0
  135. /package/{lib → lib-types}/utils/color.d.ts +0 -0
@@ -1,283 +0,0 @@
1
- const require_color = require("../../utils/color.qwik.cjs");
2
- const require_Shuffle = require("../../svg/Shuffle.qwik.cjs");
3
- let _qwik_dev_core_jsx_runtime = require("@qwik.dev/core/jsx-runtime");
4
- let _qwik_dev_core = require("@qwik.dev/core");
5
- //#region src/components/elements/ColorPicker.tsx
6
- var ColorPicker = (0, _qwik_dev_core.component$)(({ id, value = "#000000", colors = [
7
- "#FAEDCB",
8
- "#C9E4DE",
9
- "#C6DEF1",
10
- "#DBCDF0",
11
- "#F2C6DE",
12
- "#FCD05C",
13
- "#5FE2C5",
14
- "#4498DB",
15
- "#9863E7",
16
- "#E43A96",
17
- "#000000",
18
- "#555555",
19
- "#AAAAAA",
20
- "#FFFFFF"
21
- ], onInput$, preview = "left", horizontal, showInput = true, opacity, ...props }) => {
22
- const height = 150;
23
- const width = height - 25;
24
- const maxHue = height - 2;
25
- const hsvColor = require_color.rgbToHsv(require_color.hexToRgba(value));
26
- const store = (0, _qwik_dev_core.useStore)({
27
- hue: {
28
- position: hsvColor.h * maxHue,
29
- color: require_color.rgbToHex(require_color.hsvToRgb({
30
- h: hsvColor.h,
31
- s: 1,
32
- v: 1
33
- }))
34
- },
35
- opacity: { position: hsvColor.a !== void 0 ? (1 - hsvColor.a) * maxHue : 0 },
36
- bPosition: (1 - hsvColor.v) * maxHue,
37
- sPosition: hsvColor.s * width,
38
- value
39
- });
40
- const setColor = (0, _qwik_dev_core.$)(async (color) => {
41
- if (!/^#[0-9a-f]{0,8}$/i.test(color)) return;
42
- const hsv = require_color.rgbToHsv(require_color.hexToRgba(color));
43
- store.hue.position = hsv.h * maxHue;
44
- store.hue.color = require_color.rgbToHex(require_color.hsvToRgb({
45
- h: hsv.h,
46
- s: 1,
47
- v: 1,
48
- a: hsv.a
49
- }));
50
- store.sPosition = hsv.s * width;
51
- store.bPosition = (1 - hsv.v) * maxHue;
52
- store.value = color;
53
- await onInput$?.(store.value);
54
- });
55
- const hueChange = (0, _qwik_dev_core.$)(async (e, hOffset) => {
56
- const { y } = require_color.getMousePosition(e);
57
- store.hue.position = require_color.clamp(maxHue - (y - hOffset), 0, maxHue);
58
- const hsvColor = require_color.rgbToHsv(require_color.hexToRgba(store.value));
59
- const h = store.hue.position / maxHue;
60
- hsvColor.h = h;
61
- store.hue.color = require_color.rgbToHex(require_color.hsvToRgb({
62
- h,
63
- s: 1,
64
- v: 1,
65
- a: hsvColor.a
66
- }));
67
- store.value = require_color.rgbToHex(require_color.hsvToRgb(hsvColor));
68
- await onInput$?.(store.value);
69
- });
70
- const hueMouseDown = (0, _qwik_dev_core.$)(async (e, el) => {
71
- const hOffset = el.getBoundingClientRect().top;
72
- await hueChange(e, hOffset);
73
- const eventListener = (e) => void hueChange(e, hOffset);
74
- window.addEventListener("mousemove", eventListener);
75
- window.addEventListener("touchmove", eventListener);
76
- const mouseUpListener = () => {
77
- window.removeEventListener("mousemove", eventListener);
78
- window.removeEventListener("touchmove", eventListener);
79
- window.removeEventListener("mouseup", mouseUpListener);
80
- window.removeEventListener("touchend", mouseUpListener);
81
- };
82
- window.addEventListener("mouseup", mouseUpListener);
83
- window.addEventListener("touchend", mouseUpListener);
84
- });
85
- const sbChange = (0, _qwik_dev_core.$)(async (e, hOffset) => {
86
- const { x, y } = require_color.getMousePosition(e);
87
- store.bPosition = require_color.clamp(y - hOffset.top, 0, maxHue);
88
- store.sPosition = require_color.clamp(x - hOffset.left, 0, width);
89
- const s = store.sPosition / width;
90
- const v = 1 - store.bPosition / maxHue;
91
- store.value = require_color.rgbToHex(require_color.hsvToRgb({
92
- h: store.hue.position / maxHue,
93
- s,
94
- v,
95
- a: store.opacity.position !== void 0 ? 1 - store.opacity.position / maxHue : 1
96
- }));
97
- await onInput$?.(store.value);
98
- });
99
- const sbMouseDown = (0, _qwik_dev_core.$)(async (e, el) => {
100
- const offset = el.getBoundingClientRect();
101
- await sbChange(e, offset);
102
- const eventListener = (e) => void sbChange(e, offset);
103
- window.addEventListener("mousemove", eventListener);
104
- window.addEventListener("touchmove", eventListener);
105
- const mouseUpListener = () => {
106
- window.removeEventListener("mousemove", eventListener);
107
- window.removeEventListener("touchmove", eventListener);
108
- window.removeEventListener("mouseup", mouseUpListener);
109
- window.removeEventListener("touchend", mouseUpListener);
110
- };
111
- window.addEventListener("mouseup", mouseUpListener);
112
- window.addEventListener("touchend", mouseUpListener);
113
- });
114
- const opacityChange = (0, _qwik_dev_core.$)(async (e, hOffset) => {
115
- const { x } = require_color.getMousePosition(e);
116
- store.opacity.position = require_color.clamp(x - hOffset.left, 0, maxHue);
117
- const a = 1 - store.opacity.position / maxHue;
118
- const hsvColor = require_color.rgbToHsv(require_color.hexToRgba(store.value));
119
- hsvColor.a = a;
120
- store.value = require_color.rgbToHex(require_color.hsvToRgb(hsvColor));
121
- await onInput$?.(store.value);
122
- });
123
- const opacityMouseDown = (0, _qwik_dev_core.$)(async (e, el) => {
124
- const offset = el.getBoundingClientRect();
125
- await opacityChange(e, offset);
126
- const eventListener = (e) => void opacityChange(e, offset);
127
- window.addEventListener("mousemove", eventListener);
128
- window.addEventListener("touchmove", eventListener);
129
- const mouseUpListener = () => {
130
- window.removeEventListener("mousemove", eventListener);
131
- window.removeEventListener("touchmove", eventListener);
132
- window.removeEventListener("mouseup", mouseUpListener);
133
- window.removeEventListener("touchend", mouseUpListener);
134
- };
135
- window.addEventListener("mouseup", mouseUpListener);
136
- window.addEventListener("touchend", mouseUpListener);
137
- });
138
- return /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsxs)("div", {
139
- class: {
140
- "lum-card touch-none p-4": true,
141
- "flex-col": !horizontal,
142
- ...props.class
143
- },
144
- id,
145
- onInput$: async (e, el) => {
146
- if (!el.dataset.value) return;
147
- await setColor(el.dataset.value);
148
- },
149
- children: [
150
- /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsxs)("div", {
151
- class: "flex gap-4",
152
- children: [/* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsxs)("div", {
153
- class: "relative h-37.5 w-31.25 rounded-md",
154
- style: { background: `linear-gradient(to right, #FFFFFF, ${store.hue.color})` },
155
- onMouseDown$: sbMouseDown,
156
- onTouchStart$: sbMouseDown,
157
- "preventdefault:mousedown": true,
158
- "preventdefault:touchstart": true,
159
- children: [/* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("div", { class: "h-37.5 w-31.25 rounded-md border border-gray-700 bg-linear-to-b from-transparent to-black" }), /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("div", {
160
- class: { "absolute -top-2 -left-2 h-4 w-4 rounded-md border lum-bg drop-shadow-lg": true },
161
- style: {
162
- "--bg-color": store.value,
163
- transform: `translate(${store.sPosition}px, ${store.bPosition}px)`
164
- }
165
- })]
166
- }), /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("div", {
167
- class: "relative h-37.5 w-2 rounded-md border border-gray-700",
168
- style: { background: "linear-gradient(to bottom, #ff0000, #ff00ff, #0000ff, #00ffff, #00ff00, #ffff00, #ff0000)" },
169
- onMouseDown$: hueMouseDown,
170
- onTouchStart$: hueMouseDown,
171
- "preventdefault:mousedown": true,
172
- "preventdefault:touchstart": true,
173
- children: /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("div", {
174
- class: "absolute -bottom-2 -left-1.25 h-4 w-4 rounded-md lum-bg! bg-[#ff0000] ",
175
- style: {
176
- transform: `translateY(${-store.hue.position}px)`,
177
- "--bg-color": store.hue.color
178
- }
179
- })
180
- })]
181
- }),
182
- opacity && /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsxs)("div", {
183
- class: "relative h-2 w-full rounded-md",
184
- onMouseDown$: opacityMouseDown,
185
- onTouchStart$: opacityMouseDown,
186
- "preventdefault:mousedown": true,
187
- "preventdefault:touchstart": true,
188
- style: {
189
- backgroundColor: "white",
190
- backgroundImage: `
191
- linear-gradient(45deg, #ccc 25%, transparent 25%),
192
- linear-gradient(135deg, #ccc 25%, transparent 25%),
193
- linear-gradient(45deg, transparent 75%, #ccc 75%),
194
- linear-gradient(135deg, transparent 75%, #ccc 75%);
195
- `,
196
- backgroundSize: "8px 8px",
197
- backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
198
- },
199
- children: [/* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("div", {
200
- class: "alsolute inset-0 h-2 w-full rounded-md border border-gray-700",
201
- style: { background: `linear-gradient(to right, ${store.value}, transparent)` }
202
- }), /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("div", {
203
- class: "absolute -bottom-1.25 -left-1.25 h-4 w-4 rounded-md",
204
- style: {
205
- transform: `translateX(${store.opacity.position ?? 1}px)`,
206
- backgroundColor: store.value,
207
- backgroundImage: `
208
- linear-gradient(45deg, #ccc4 25%, transparent 25%),
209
- linear-gradient(135deg, #ccc4 25%, transparent 25%),
210
- linear-gradient(45deg, transparent 75%, #ccc4 75%),
211
- linear-gradient(135deg, transparent 75%, #ccc4 75%);
212
- `,
213
- backgroundSize: "8px 8px",
214
- backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
215
- }
216
- })]
217
- }),
218
- /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsxs)("div", {
219
- class: "flex w-37.5 flex-wrap justify-between gap-1",
220
- children: [
221
- showInput && /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsxs)("div", {
222
- class: {
223
- "mb-2 flex w-37.5 border-b border-b-gray-700 pb-3": true,
224
- "flex-row gap-1": preview == "left",
225
- "flex-row-reverse gap-1": preview == "right",
226
- "flex-col": preview == "top",
227
- "flex-col-reverse": preview == "bottom"
228
- },
229
- children: [preview != "full" && /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("div", {
230
- class: {
231
- "border border-gray-700 rounded-sm": true,
232
- "aspect-square h-full": preview == "left" || preview == "right",
233
- "h-3 w-full": preview == "top" || preview == "bottom",
234
- "rounded-b-none": preview == "top",
235
- "rounded-t-none": preview == "bottom"
236
- },
237
- style: { backgroundColor: `${store.value}` }
238
- }), /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("input", {
239
- class: {
240
- "lum-input w-full p-1 text-xs rounded-sm": true,
241
- "rounded-t-none border-t-0": preview == "top",
242
- "rounded-b-none border-b-0": preview == "bottom"
243
- },
244
- value: store.value,
245
- style: preview == "full" ? {
246
- backgroundColor: `${store.value}`,
247
- color: require_color.getBrightness(require_color.hexToRgba(store.value)) > .5 ? "black" : "white"
248
- } : {},
249
- onInput$: async (e, el) => {
250
- await setColor(el.value);
251
- }
252
- })]
253
- }),
254
- colors.map((color, i) => {
255
- return /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("button", {
256
- type: "button",
257
- name: color,
258
- class: {
259
- "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0 lum-bg hover:brightness-150": true,
260
- "border-lum-accent": color === store.value
261
- },
262
- style: { "--bg-color": color },
263
- onClick$: async () => {
264
- await setColor(color);
265
- }
266
- }, i);
267
- }),
268
- /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("button", {
269
- type: "button",
270
- class: "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0.5",
271
- name: "Randomize",
272
- onClick$: async () => {
273
- await setColor(`#${Math.floor(Math.random() * 16777215).toString(16)}`);
274
- },
275
- children: /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)(require_Shuffle.Shuffle, { class: "p-0.5 pl-0.5 text-lum-text" })
276
- })
277
- ]
278
- })
279
- ]
280
- });
281
- });
282
- //#endregion
283
- exports.ColorPicker = ColorPicker;
@@ -1,283 +0,0 @@
1
- import { clamp, getBrightness, getMousePosition, hexToRgba, hsvToRgb, rgbToHex, rgbToHsv } from "../../utils/color.qwik.mjs";
2
- import { Shuffle } from "../../svg/Shuffle.qwik.mjs";
3
- import { jsx, jsxs } from "@qwik.dev/core/jsx-runtime";
4
- import { $, component$, useStore } from "@qwik.dev/core";
5
- //#region src/components/elements/ColorPicker.tsx
6
- var ColorPicker = component$(({ id, value = "#000000", colors = [
7
- "#FAEDCB",
8
- "#C9E4DE",
9
- "#C6DEF1",
10
- "#DBCDF0",
11
- "#F2C6DE",
12
- "#FCD05C",
13
- "#5FE2C5",
14
- "#4498DB",
15
- "#9863E7",
16
- "#E43A96",
17
- "#000000",
18
- "#555555",
19
- "#AAAAAA",
20
- "#FFFFFF"
21
- ], onInput$, preview = "left", horizontal, showInput = true, opacity, ...props }) => {
22
- const height = 150;
23
- const width = height - 25;
24
- const maxHue = height - 2;
25
- const hsvColor = rgbToHsv(hexToRgba(value));
26
- const store = useStore({
27
- hue: {
28
- position: hsvColor.h * maxHue,
29
- color: rgbToHex(hsvToRgb({
30
- h: hsvColor.h,
31
- s: 1,
32
- v: 1
33
- }))
34
- },
35
- opacity: { position: hsvColor.a !== void 0 ? (1 - hsvColor.a) * maxHue : 0 },
36
- bPosition: (1 - hsvColor.v) * maxHue,
37
- sPosition: hsvColor.s * width,
38
- value
39
- });
40
- const setColor = $(async (color) => {
41
- if (!/^#[0-9a-f]{0,8}$/i.test(color)) return;
42
- const hsv = rgbToHsv(hexToRgba(color));
43
- store.hue.position = hsv.h * maxHue;
44
- store.hue.color = rgbToHex(hsvToRgb({
45
- h: hsv.h,
46
- s: 1,
47
- v: 1,
48
- a: hsv.a
49
- }));
50
- store.sPosition = hsv.s * width;
51
- store.bPosition = (1 - hsv.v) * maxHue;
52
- store.value = color;
53
- await onInput$?.(store.value);
54
- });
55
- const hueChange = $(async (e, hOffset) => {
56
- const { y } = getMousePosition(e);
57
- store.hue.position = clamp(maxHue - (y - hOffset), 0, maxHue);
58
- const hsvColor = rgbToHsv(hexToRgba(store.value));
59
- const h = store.hue.position / maxHue;
60
- hsvColor.h = h;
61
- store.hue.color = rgbToHex(hsvToRgb({
62
- h,
63
- s: 1,
64
- v: 1,
65
- a: hsvColor.a
66
- }));
67
- store.value = rgbToHex(hsvToRgb(hsvColor));
68
- await onInput$?.(store.value);
69
- });
70
- const hueMouseDown = $(async (e, el) => {
71
- const hOffset = el.getBoundingClientRect().top;
72
- await hueChange(e, hOffset);
73
- const eventListener = (e) => void hueChange(e, hOffset);
74
- window.addEventListener("mousemove", eventListener);
75
- window.addEventListener("touchmove", eventListener);
76
- const mouseUpListener = () => {
77
- window.removeEventListener("mousemove", eventListener);
78
- window.removeEventListener("touchmove", eventListener);
79
- window.removeEventListener("mouseup", mouseUpListener);
80
- window.removeEventListener("touchend", mouseUpListener);
81
- };
82
- window.addEventListener("mouseup", mouseUpListener);
83
- window.addEventListener("touchend", mouseUpListener);
84
- });
85
- const sbChange = $(async (e, hOffset) => {
86
- const { x, y } = getMousePosition(e);
87
- store.bPosition = clamp(y - hOffset.top, 0, maxHue);
88
- store.sPosition = clamp(x - hOffset.left, 0, width);
89
- const s = store.sPosition / width;
90
- const v = 1 - store.bPosition / maxHue;
91
- store.value = rgbToHex(hsvToRgb({
92
- h: store.hue.position / maxHue,
93
- s,
94
- v,
95
- a: store.opacity.position !== void 0 ? 1 - store.opacity.position / maxHue : 1
96
- }));
97
- await onInput$?.(store.value);
98
- });
99
- const sbMouseDown = $(async (e, el) => {
100
- const offset = el.getBoundingClientRect();
101
- await sbChange(e, offset);
102
- const eventListener = (e) => void sbChange(e, offset);
103
- window.addEventListener("mousemove", eventListener);
104
- window.addEventListener("touchmove", eventListener);
105
- const mouseUpListener = () => {
106
- window.removeEventListener("mousemove", eventListener);
107
- window.removeEventListener("touchmove", eventListener);
108
- window.removeEventListener("mouseup", mouseUpListener);
109
- window.removeEventListener("touchend", mouseUpListener);
110
- };
111
- window.addEventListener("mouseup", mouseUpListener);
112
- window.addEventListener("touchend", mouseUpListener);
113
- });
114
- const opacityChange = $(async (e, hOffset) => {
115
- const { x } = getMousePosition(e);
116
- store.opacity.position = clamp(x - hOffset.left, 0, maxHue);
117
- const a = 1 - store.opacity.position / maxHue;
118
- const hsvColor = rgbToHsv(hexToRgba(store.value));
119
- hsvColor.a = a;
120
- store.value = rgbToHex(hsvToRgb(hsvColor));
121
- await onInput$?.(store.value);
122
- });
123
- const opacityMouseDown = $(async (e, el) => {
124
- const offset = el.getBoundingClientRect();
125
- await opacityChange(e, offset);
126
- const eventListener = (e) => void opacityChange(e, offset);
127
- window.addEventListener("mousemove", eventListener);
128
- window.addEventListener("touchmove", eventListener);
129
- const mouseUpListener = () => {
130
- window.removeEventListener("mousemove", eventListener);
131
- window.removeEventListener("touchmove", eventListener);
132
- window.removeEventListener("mouseup", mouseUpListener);
133
- window.removeEventListener("touchend", mouseUpListener);
134
- };
135
- window.addEventListener("mouseup", mouseUpListener);
136
- window.addEventListener("touchend", mouseUpListener);
137
- });
138
- return /* @__PURE__ */ jsxs("div", {
139
- class: {
140
- "lum-card touch-none p-4": true,
141
- "flex-col": !horizontal,
142
- ...props.class
143
- },
144
- id,
145
- onInput$: async (e, el) => {
146
- if (!el.dataset.value) return;
147
- await setColor(el.dataset.value);
148
- },
149
- children: [
150
- /* @__PURE__ */ jsxs("div", {
151
- class: "flex gap-4",
152
- children: [/* @__PURE__ */ jsxs("div", {
153
- class: "relative h-37.5 w-31.25 rounded-md",
154
- style: { background: `linear-gradient(to right, #FFFFFF, ${store.hue.color})` },
155
- onMouseDown$: sbMouseDown,
156
- onTouchStart$: sbMouseDown,
157
- "preventdefault:mousedown": true,
158
- "preventdefault:touchstart": true,
159
- children: [/* @__PURE__ */ jsx("div", { class: "h-37.5 w-31.25 rounded-md border border-gray-700 bg-linear-to-b from-transparent to-black" }), /* @__PURE__ */ jsx("div", {
160
- class: { "absolute -top-2 -left-2 h-4 w-4 rounded-md border lum-bg drop-shadow-lg": true },
161
- style: {
162
- "--bg-color": store.value,
163
- transform: `translate(${store.sPosition}px, ${store.bPosition}px)`
164
- }
165
- })]
166
- }), /* @__PURE__ */ jsx("div", {
167
- class: "relative h-37.5 w-2 rounded-md border border-gray-700",
168
- style: { background: "linear-gradient(to bottom, #ff0000, #ff00ff, #0000ff, #00ffff, #00ff00, #ffff00, #ff0000)" },
169
- onMouseDown$: hueMouseDown,
170
- onTouchStart$: hueMouseDown,
171
- "preventdefault:mousedown": true,
172
- "preventdefault:touchstart": true,
173
- children: /* @__PURE__ */ jsx("div", {
174
- class: "absolute -bottom-2 -left-1.25 h-4 w-4 rounded-md lum-bg! bg-[#ff0000] ",
175
- style: {
176
- transform: `translateY(${-store.hue.position}px)`,
177
- "--bg-color": store.hue.color
178
- }
179
- })
180
- })]
181
- }),
182
- opacity && /* @__PURE__ */ jsxs("div", {
183
- class: "relative h-2 w-full rounded-md",
184
- onMouseDown$: opacityMouseDown,
185
- onTouchStart$: opacityMouseDown,
186
- "preventdefault:mousedown": true,
187
- "preventdefault:touchstart": true,
188
- style: {
189
- backgroundColor: "white",
190
- backgroundImage: `
191
- linear-gradient(45deg, #ccc 25%, transparent 25%),
192
- linear-gradient(135deg, #ccc 25%, transparent 25%),
193
- linear-gradient(45deg, transparent 75%, #ccc 75%),
194
- linear-gradient(135deg, transparent 75%, #ccc 75%);
195
- `,
196
- backgroundSize: "8px 8px",
197
- backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
198
- },
199
- children: [/* @__PURE__ */ jsx("div", {
200
- class: "alsolute inset-0 h-2 w-full rounded-md border border-gray-700",
201
- style: { background: `linear-gradient(to right, ${store.value}, transparent)` }
202
- }), /* @__PURE__ */ jsx("div", {
203
- class: "absolute -bottom-1.25 -left-1.25 h-4 w-4 rounded-md",
204
- style: {
205
- transform: `translateX(${store.opacity.position ?? 1}px)`,
206
- backgroundColor: store.value,
207
- backgroundImage: `
208
- linear-gradient(45deg, #ccc4 25%, transparent 25%),
209
- linear-gradient(135deg, #ccc4 25%, transparent 25%),
210
- linear-gradient(45deg, transparent 75%, #ccc4 75%),
211
- linear-gradient(135deg, transparent 75%, #ccc4 75%);
212
- `,
213
- backgroundSize: "8px 8px",
214
- backgroundPosition: "0 0, 4px 0, 4px -4px, 0 4px"
215
- }
216
- })]
217
- }),
218
- /* @__PURE__ */ jsxs("div", {
219
- class: "flex w-37.5 flex-wrap justify-between gap-1",
220
- children: [
221
- showInput && /* @__PURE__ */ jsxs("div", {
222
- class: {
223
- "mb-2 flex w-37.5 border-b border-b-gray-700 pb-3": true,
224
- "flex-row gap-1": preview == "left",
225
- "flex-row-reverse gap-1": preview == "right",
226
- "flex-col": preview == "top",
227
- "flex-col-reverse": preview == "bottom"
228
- },
229
- children: [preview != "full" && /* @__PURE__ */ jsx("div", {
230
- class: {
231
- "border border-gray-700 rounded-sm": true,
232
- "aspect-square h-full": preview == "left" || preview == "right",
233
- "h-3 w-full": preview == "top" || preview == "bottom",
234
- "rounded-b-none": preview == "top",
235
- "rounded-t-none": preview == "bottom"
236
- },
237
- style: { backgroundColor: `${store.value}` }
238
- }), /* @__PURE__ */ jsx("input", {
239
- class: {
240
- "lum-input w-full p-1 text-xs rounded-sm": true,
241
- "rounded-t-none border-t-0": preview == "top",
242
- "rounded-b-none border-b-0": preview == "bottom"
243
- },
244
- value: store.value,
245
- style: preview == "full" ? {
246
- backgroundColor: `${store.value}`,
247
- color: getBrightness(hexToRgba(store.value)) > .5 ? "black" : "white"
248
- } : {},
249
- onInput$: async (e, el) => {
250
- await setColor(el.value);
251
- }
252
- })]
253
- }),
254
- colors.map((color, i) => {
255
- return /* @__PURE__ */ jsx("button", {
256
- type: "button",
257
- name: color,
258
- class: {
259
- "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0 lum-bg hover:brightness-150": true,
260
- "border-lum-accent": color === store.value
261
- },
262
- style: { "--bg-color": color },
263
- onClick$: async () => {
264
- await setColor(color);
265
- }
266
- }, i);
267
- }),
268
- /* @__PURE__ */ jsx("button", {
269
- type: "button",
270
- class: "lum-btn rounded-sm h-[1.6rem] w-[1.6rem] p-0.5",
271
- name: "Randomize",
272
- onClick$: async () => {
273
- await setColor(`#${Math.floor(Math.random() * 16777215).toString(16)}`);
274
- },
275
- children: /* @__PURE__ */ jsx(Shuffle, { class: "p-0.5 pl-0.5 text-lum-text" })
276
- })
277
- ]
278
- })
279
- ]
280
- });
281
- });
282
- //#endregion
283
- export { ColorPicker };
@@ -1,28 +0,0 @@
1
- const require_ChevronDown = require("../../svg/ChevronDown.qwik.cjs");
2
- let _qwik_dev_core_jsx_runtime = require("@qwik.dev/core/jsx-runtime");
3
- let _qwik_dev_core = require("@qwik.dev/core");
4
- //#region src/components/elements/Dropdown.tsx
5
- var Dropdown = (0, _qwik_dev_core.component$)(({ class: Class, hover, opened, ...props }) => {
6
- return /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsxs)("button", {
7
- type: "button",
8
- class: {
9
- "group lum-btn": true,
10
- ...Class
11
- },
12
- ...props,
13
- children: [/* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)("span", {
14
- class: "flex-1 text-left",
15
- children: /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)(_qwik_dev_core.Slot, {})
16
- }), /* @__PURE__ */ (0, _qwik_dev_core_jsx_runtime.jsx)(require_ChevronDown.ChevronDown, {
17
- size: 16,
18
- class: {
19
- "ease-out motion-safe:transition-transform": true,
20
- "rotate-180 transform": opened,
21
- "duration-300 group-hover:rotate-180 group-hover:transform group-hover:duration-75": hover,
22
- "focus-within:rotate-180 focus-within:transform focus-within:duration-75": true
23
- }
24
- })]
25
- });
26
- });
27
- //#endregion
28
- exports.Dropdown = Dropdown;
@@ -1,28 +0,0 @@
1
- import { ChevronDown } from "../../svg/ChevronDown.qwik.mjs";
2
- import { jsx, jsxs } from "@qwik.dev/core/jsx-runtime";
3
- import { Slot, component$ } from "@qwik.dev/core";
4
- //#region src/components/elements/Dropdown.tsx
5
- var Dropdown = component$(({ class: Class, hover, opened, ...props }) => {
6
- return /* @__PURE__ */ jsxs("button", {
7
- type: "button",
8
- class: {
9
- "group lum-btn": true,
10
- ...Class
11
- },
12
- ...props,
13
- children: [/* @__PURE__ */ jsx("span", {
14
- class: "flex-1 text-left",
15
- children: /* @__PURE__ */ jsx(Slot, {})
16
- }), /* @__PURE__ */ jsx(ChevronDown, {
17
- size: 16,
18
- class: {
19
- "ease-out motion-safe:transition-transform": true,
20
- "rotate-180 transform": opened,
21
- "duration-300 group-hover:rotate-180 group-hover:transform group-hover:duration-75": hover,
22
- "focus-within:rotate-180 focus-within:transform focus-within:duration-75": true
23
- }
24
- })]
25
- });
26
- });
27
- //#endregion
28
- export { Dropdown };