@studiotoolkit/color-wheel 1.0.2 → 1.0.3
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/ColorWheel.d.ts +1 -1
- package/dist/ColorWheel.d.ts.map +1 -1
- package/dist/ThemeContext.d.ts +1 -1
- package/dist/ThemeContext.d.ts.map +1 -1
- package/dist/color-wheel.css +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +372 -359
- package/package.json +17 -14
package/dist/ColorWheel.d.ts
CHANGED
|
@@ -30,6 +30,6 @@ interface ColorWheelProps {
|
|
|
30
30
|
width?: number;
|
|
31
31
|
height?: number;
|
|
32
32
|
}
|
|
33
|
-
export default function ColorWheel({ onColorsChange, harmonyMode: propHarmonyMode, saturation: propSaturation, brightness: propBrightness, circleRadius: propCircleRadius, wheelThickness: propWheelThickness, dotSize: propDotSize, dotPosition: propDotPosition, handleThickness: propHandleThickness, handleColor: propHandleColor, harmonyPolygon: propHarmonyPolygon, polygonColor: propPolygonColor, polygonThickness: propPolygonThickness, centerDot: propCenterDot, showCenterDot: propShowCenterDot, borderColor: propBorderColor, canvasBackgroundColor: propCanvasBackgroundColor, width, height, }: ColorWheelProps): import("react
|
|
33
|
+
export default function ColorWheel({ onColorsChange, harmonyMode: propHarmonyMode, saturation: propSaturation, brightness: propBrightness, circleRadius: propCircleRadius, wheelThickness: propWheelThickness, dotSize: propDotSize, dotPosition: propDotPosition, handleThickness: propHandleThickness, handleColor: propHandleColor, harmonyPolygon: propHarmonyPolygon, polygonColor: propPolygonColor, polygonThickness: propPolygonThickness, centerDot: propCenterDot, showCenterDot: propShowCenterDot, borderColor: propBorderColor, canvasBackgroundColor: propCanvasBackgroundColor, width, height, }: ColorWheelProps): import("react").JSX.Element;
|
|
34
34
|
export {};
|
|
35
35
|
//# sourceMappingURL=ColorWheel.d.ts.map
|
package/dist/ColorWheel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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
5
5
|
}
|
|
6
6
|
export declare function ThemeProvider({ children }: {
|
|
7
7
|
children: ReactNode;
|
|
8
|
-
}): import("react
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
9
|
export declare function useTheme(): ThemeContextType;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=ThemeContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../src/ThemeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvF,UAAU,gBAAgB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI,CAAC;CAChE;AAOD,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE
|
|
1
|
+
{"version":3,"file":"ThemeContext.d.ts","sourceRoot":"","sources":["../src/ThemeContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvF,UAAU,gBAAgB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,IAAI,CAAC;CAChE;AAOD,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BASlE;AAED,wBAAgB,QAAQ,qBAEvB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.color-wheel-container{background-color:#fff;margin:0;font-family:sans-serif}[data-theme=dark] .color-wheel-container{background-color:#1a1a1a!important}.color-wheel-container h2{text-align:center;color:#fff;background:#222;margin:0;padding:15px}.layout{grid-template-columns:20% 30% 50%;height:100vh;display:grid}.panel{background-color:#fff;border-right:1px solid #ddd;padding:15px;overflow-y:auto}[data-theme=dark] .panel{color:#e0e0e0;border-right-color:#444;background-color:#1a1a1a!important}[data-theme=dark] .panel label{color:#e0e0e0}[data-theme=dark] .panel input,[data-theme=dark] .panel select{color:#e0e0e0;background-color:#2a2a2a;border:1px solid #444}[data-theme=dark] .panel hr{border-color:#444}.panel canvas{cursor:pointer;margin:auto;display:block}.panel label{margin-top:12px;font-weight:700;display:block}.panel input,.panel select{width:100%;margin-top:4px}.panel hr{margin:18px 0}.colors{flex-wrap:wrap;gap:12px;display:flex}.swatchBox{text-align:center;font-size:13px}.swatch{border:1px solid #ccc;border-radius:10px;width:70px;height:70px}.panel pre{background:#f3f3f3;border-radius:10px;max-height:320px;padding:10px;font-size:12px;overflow-x:auto}.panel h3{margin-top:0}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime");var n=(0,e.createContext)({isDark:!1,setIsDark:()=>{}});function r({children:r}){let[i,a]=(0,e.useState)(()=>localStorage.getItem(`theme`)===`dark`);return(0,e.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,i?`dark`:`light`),localStorage.setItem(`theme`,i?`dark`:`light`)},[i]),(0,t.jsx)(n.Provider,{value:{isDark:i,setIsDark:a},children:r})}function i(){return(0,e.useContext)(n)}var a={complementary:[0,180],analogous:[-30,0,30],monochromatic:[0],split:[0,150,-150],triadic:[0,120,240],square:[0,90,180,270],simple:[0]},o=[{name:`Harmony Mode`,attribute:`harmony-mode`,default:`split`,show:!0,notes:``},{name:`Saturation`,attribute:`saturation`,default:100,show:!0,notes:``},{name:`Brightness`,attribute:`brightness`,default:50,show:!0,notes:``},{name:`Circle Radius`,attribute:`circle-radius`,default:1,show:!1,notes:`If not passed, default it is false`},{name:`Wheel Thickness`,attribute:`wheel-thickness`,default:80,show:!1,notes:`If not passed, default it is false`},{name:`Dot Size`,attribute:`dot-size`,default:5,show:!1,notes:`If not passed, default it is false`},{name:`Dot Position`,attribute:`dot-position`,default:`outer`,show:!1,notes:`If not passed, default it is false`},{name:`Handle Thickness`,attribute:`handle-thickness`,default:2,show:!1,notes:`If not passed, default it is false`},{name:`Handle Color`,attribute:`handle-color`,default:`#000000`,show:!1,notes:`If not passed, default it is false`},{name:`Show Harmony Polygon`,attribute:`harmony-polygon`,default:!1,show:!1,notes:`If not passed, default it is false`},{name:`Polygon Color`,attribute:`polygon-color`,default:`#000000`,show:!1,notes:`If not passed, default it is false`},{name:`Polygon Thickness`,attribute:`polygon-thickness`,default:1,show:!1,notes:`If not passed, default it is false`},{name:`Center Dot`,attribute:`center-dot`,default:`#ffffff`,show:!1,notes:`If not passed, default it is false`},{name:`Palette`,attribute:`palette`,default:null,show:!1,notes:`If not passed, default it is false`},{name:`Palette JSON`,attribute:`palette-json`,default:null,show:!1,notes:`If not passed, default it is false`}];function s({onColorsChange:n,harmonyMode:r,saturation:s,brightness:c,circleRadius:l,wheelThickness:u,dotSize:d,dotPosition:f,handleThickness:p,handleColor:m,harmonyPolygon:h,polygonColor:g,polygonThickness:_,centerDot:v,showCenterDot:y=!1,borderColor:b=`#ffffff`,canvasBackgroundColor:x=`transparent`,width:S=450,height:C=450}){let w=(0,e.useRef)(null),[ee,T]=(0,e.useState)(!1),{isDark:E}=i(),D=e=>o.find(t=>t.attribute===e),[O,te]=(0,e.useState)(r||D(`harmony-mode`).default),[k,ne]=(0,e.useState)(s??D(`saturation`).default),[A,re]=(0,e.useState)(c??D(`brightness`).default),j=(0,e.useCallback)(()=>{let e=D(`circle-radius`).default;if(l!==void 0)return l;if(e===1){let e=Math.min(S,C),t=u??D(`wheel-thickness`).default,n=d??D(`dot-size`).default;return e/2-t/2-n-10}return e},[S,C,l,u,d]),[M,ie]=(0,e.useState)(j()),[N,ae]=(0,e.useState)(u??D(`wheel-thickness`).default),[oe,se]=(0,e.useState)(d??D(`dot-size`).default),[P,ce]=(0,e.useState)(f||D(`dot-position`).default),[F,le]=(0,e.useState)(p??D(`handle-thickness`).default),[I,ue]=(0,e.useState)(m||(D(`handle-color`).default===`black`?`#000000`:D(`handle-color`).default)),[L,de]=(0,e.useState)(h??D(`harmony-polygon`).default),[R,fe]=(0,e.useState)(g||(D(`polygon-color`).default===`black`?`#000000`:D(`polygon-color`).default)),[z,pe]=(0,e.useState)(_??D(`polygon-thickness`).default),[B,me]=(0,e.useState)(v||(D(`center-dot`).default===`white`?`#ffffff`:D(`center-dot`).default)),[V,he]=(0,e.useState)(y),[H,ge]=(0,e.useState)(b),[U,_e]=(0,e.useState)(x),[W,G]=(0,e.useState)(0);(0,e.useEffect)(()=>{r!==void 0&&te(r)},[r]),(0,e.useEffect)(()=>{s!==void 0&&ne(s)},[s]),(0,e.useEffect)(()=>{c!==void 0&&re(c)},[c]),(0,e.useEffect)(()=>{ie(l===void 0?j():l)},[l,j]),(0,e.useEffect)(()=>{u!==void 0&&ae(u)},[u]),(0,e.useEffect)(()=>{d!==void 0&&se(d)},[d]),(0,e.useEffect)(()=>{f!==void 0&&ce(f)},[f]),(0,e.useEffect)(()=>{p!==void 0&&le(p)},[p]),(0,e.useEffect)(()=>{m!==void 0&&ue(m)},[m]),(0,e.useEffect)(()=>{h!==void 0&&de(h)},[h]),(0,e.useEffect)(()=>{g!==void 0&&fe(g)},[g]),(0,e.useEffect)(()=>{_!==void 0&&pe(_)},[_]),(0,e.useEffect)(()=>{v!==void 0&&me(v)},[v]),(0,e.useEffect)(()=>{he(y)},[y]),(0,e.useEffect)(()=>{ge(b)},[b]),(0,e.useEffect)(()=>{_e(x)},[x]);let K={x:S/2,y:C/2},q=e=>(e+360)%360,J=(0,e.useCallback)((e,t=k,n=A)=>`hsl(${e}, ${t}%, ${n}%)`,[k,A]),ve=(e,t,n)=>{t/=100,n/=100;let r=(1-Math.abs(2*n-1))*t,i=r*(1-Math.abs(e/60%2-1)),a=n-r/2,o=0,s=0,c=0;return e<60?[o,s,c]=[r,i,0]:e<120?[o,s,c]=[i,r,0]:e<180?[o,s,c]=[0,r,i]:e<240?[o,s,c]=[0,i,r]:e<300?[o,s,c]=[i,0,r]:[o,s,c]=[r,0,i],{r:Math.round((o+a)*255),g:Math.round((s+a)*255),b:Math.round((c+a)*255)}},ye=(e,t,n)=>`#`+[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``),Y=(0,e.useCallback)(()=>P===`center`?M:P===`inner`?M-N/2:M+N/2,[P,M,N]),X=(0,e.useCallback)(e=>{let t=(e-90)*Math.PI/180,n=Y();return{x:K.x+n*Math.cos(t),y:K.y+n*Math.sin(t)}},[K.x,K.y,Y]),Z=(e,t)=>{let n=e-K.x,r=t-K.y,i=Math.atan2(r,n)*180/Math.PI;return q(i+90)},Q=(0,e.useCallback)(()=>{let e=[];e=O===`monochromatic`?[{h:W,l:30},{h:W,l:50},{h:W,l:70}]:a[O].map(e=>({h:q(W+e),l:A}));let t=e.map(e=>{let t=ve(e.h,k,e.l);return ye(t.r,t.g,t.b)});return{[O]:t}},[O,W,k,A]),be=(0,e.useCallback)(e=>{for(let t=0;t<360;t++)e.beginPath(),e.strokeStyle=`hsl(${t},100%,50%)`,e.lineWidth=N,e.arc(K.x,K.y,M,(t-90)*Math.PI/180,(t-89)*Math.PI/180),e.stroke()},[K.x,K.y,M,N]),xe=(0,e.useCallback)((e,t)=>{!L||t.length<3||(e.beginPath(),e.moveTo(t[0].x,t[0].y),t.slice(1).forEach(t=>{e.lineTo(t.x,t.y)}),e.closePath(),e.strokeStyle=R,e.lineWidth=z,e.stroke())},[L,R,z]),Se=(0,e.useCallback)(e=>{if(O===`simple`)return;let t=a[O],n=[];t.forEach(t=>{let r=q(W+t),i=X(r);n.push(i),e.beginPath(),e.moveTo(K.x,K.y),e.lineTo(i.x,i.y),e.strokeStyle=I,e.lineWidth=F,e.stroke(),e.beginPath(),e.arc(i.x,i.y,oe,0,Math.PI*2),e.fillStyle=J(r),e.fill(),e.strokeStyle=`white`,e.stroke()}),xe(e,n),V&&(e.beginPath(),e.arc(K.x,K.y,5,0,Math.PI*2),e.fillStyle=B,e.fill(),e.strokeStyle=`white`,e.lineWidth=1,e.stroke())},[O,W,K.x,K.y,oe,F,I,B,V,X,J,xe]),Ce=(0,e.useCallback)(()=>{let e=w.current;if(!e)return;let t=e.getContext(`2d`);t&&(t.clearRect(0,0,e.width,e.height),U&&U!==`transparent`?(t.fillStyle=U,t.fillRect(0,0,e.width,e.height)):U===`transparent`&&(t.fillStyle=E?`#1a1a1a`:`#ffffff`,t.fillRect(0,0,e.width,e.height)),be(t),Se(t),H&&(t.strokeStyle=H,t.lineWidth=1,t.strokeRect(0,0,e.width,e.height)))},[be,Se,H,U,E]),we=()=>T(!0),Te=()=>T(!1),Ee=()=>T(!1),De=e=>{if(!ee)return;let t=w.current;if(!t)return;let n=t.getBoundingClientRect(),r=Z(e.clientX-n.left,e.clientY-n.top);G(r)},Oe=e=>{let t=w.current;if(!t)return;let n=t.getBoundingClientRect(),r=Z(e.clientX-n.left,e.clientY-n.top);G(r)};(0,e.useEffect)(()=>{Ce()},[Ce]);let $=(0,e.useMemo)(()=>Q(),[Q]);(0,e.useEffect)(()=>{n&&n($)},[$,n]);let ke=(0,e.useCallback)(()=>$,[$]);return(0,e.useEffect)(()=>(window.getColorWheelPalette=ke,()=>{delete window.getColorWheelPalette}),[ke]),(0,t.jsx)(`div`,{className:`color-wheel-container`,children:(0,t.jsx)(`canvas`,{ref:w,width:S,height:C,onMouseDown:we,onMouseUp:Te,onMouseLeave:Ee,onMouseMove:De,onClick:Oe,style:{display:`block`,margin:`0 auto`,cursor:`pointer`}})})}exports.ColorWheel=s,exports.ThemeProvider=r,exports.useTheme=i;
|
package/dist/index.mjs
CHANGED
|
@@ -1,364 +1,377 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
3
|
+
// src/ThemeContext.tsx
|
|
4
|
+
var c = e({
|
|
5
|
+
isDark: !1,
|
|
6
|
+
setIsDark: () => {}
|
|
7
7
|
});
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
function l({ children: e }) {
|
|
9
|
+
let [t, n] = o(() => localStorage.getItem("theme") === "dark");
|
|
10
|
+
return r(() => {
|
|
11
|
+
document.documentElement.setAttribute("data-theme", t ? "dark" : "light"), localStorage.setItem("theme", t ? "dark" : "light");
|
|
12
|
+
}, [t]), /* @__PURE__ */ s(c.Provider, {
|
|
13
|
+
value: {
|
|
14
|
+
isDark: t,
|
|
15
|
+
setIsDark: n
|
|
16
|
+
},
|
|
17
|
+
children: e
|
|
18
|
+
});
|
|
13
19
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
20
|
+
function ee() {
|
|
21
|
+
return n(c);
|
|
16
22
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
23
|
+
// src/ColorWheel.tsx
|
|
24
|
+
var u = {
|
|
25
|
+
complementary: [0, 180],
|
|
26
|
+
analogous: [
|
|
27
|
+
-30,
|
|
28
|
+
0,
|
|
29
|
+
30
|
|
30
|
+
],
|
|
31
|
+
monochromatic: [0],
|
|
32
|
+
split: [
|
|
33
|
+
0,
|
|
34
|
+
150,
|
|
35
|
+
-150
|
|
36
|
+
],
|
|
37
|
+
triadic: [
|
|
38
|
+
0,
|
|
39
|
+
120,
|
|
40
|
+
240
|
|
41
|
+
],
|
|
42
|
+
square: [
|
|
43
|
+
0,
|
|
44
|
+
90,
|
|
45
|
+
180,
|
|
46
|
+
270
|
|
47
|
+
],
|
|
48
|
+
simple: [0]
|
|
49
|
+
}, te = [
|
|
50
|
+
{
|
|
51
|
+
name: "Harmony Mode",
|
|
52
|
+
attribute: "harmony-mode",
|
|
53
|
+
default: "split",
|
|
54
|
+
show: !0,
|
|
55
|
+
notes: ""
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "Saturation",
|
|
59
|
+
attribute: "saturation",
|
|
60
|
+
default: 100,
|
|
61
|
+
show: !0,
|
|
62
|
+
notes: ""
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "Brightness",
|
|
66
|
+
attribute: "brightness",
|
|
67
|
+
default: 50,
|
|
68
|
+
show: !0,
|
|
69
|
+
notes: ""
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "Circle Radius",
|
|
73
|
+
attribute: "circle-radius",
|
|
74
|
+
default: 1,
|
|
75
|
+
show: !1,
|
|
76
|
+
notes: "If not passed, default it is false"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "Wheel Thickness",
|
|
80
|
+
attribute: "wheel-thickness",
|
|
81
|
+
default: 80,
|
|
82
|
+
show: !1,
|
|
83
|
+
notes: "If not passed, default it is false"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "Dot Size",
|
|
87
|
+
attribute: "dot-size",
|
|
88
|
+
default: 5,
|
|
89
|
+
show: !1,
|
|
90
|
+
notes: "If not passed, default it is false"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "Dot Position",
|
|
94
|
+
attribute: "dot-position",
|
|
95
|
+
default: "outer",
|
|
96
|
+
show: !1,
|
|
97
|
+
notes: "If not passed, default it is false"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "Handle Thickness",
|
|
101
|
+
attribute: "handle-thickness",
|
|
102
|
+
default: 2,
|
|
103
|
+
show: !1,
|
|
104
|
+
notes: "If not passed, default it is false"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "Handle Color",
|
|
108
|
+
attribute: "handle-color",
|
|
109
|
+
default: "#000000",
|
|
110
|
+
show: !1,
|
|
111
|
+
notes: "If not passed, default it is false"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "Show Harmony Polygon",
|
|
115
|
+
attribute: "harmony-polygon",
|
|
116
|
+
default: !1,
|
|
117
|
+
show: !1,
|
|
118
|
+
notes: "If not passed, default it is false"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: "Polygon Color",
|
|
122
|
+
attribute: "polygon-color",
|
|
123
|
+
default: "#000000",
|
|
124
|
+
show: !1,
|
|
125
|
+
notes: "If not passed, default it is false"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "Polygon Thickness",
|
|
129
|
+
attribute: "polygon-thickness",
|
|
130
|
+
default: 1,
|
|
131
|
+
show: !1,
|
|
132
|
+
notes: "If not passed, default it is false"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "Center Dot",
|
|
136
|
+
attribute: "center-dot",
|
|
137
|
+
default: "#ffffff",
|
|
138
|
+
show: !1,
|
|
139
|
+
notes: "If not passed, default it is false"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "Palette",
|
|
143
|
+
attribute: "palette",
|
|
144
|
+
default: null,
|
|
145
|
+
show: !1,
|
|
146
|
+
notes: "If not passed, default it is false"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "Palette JSON",
|
|
150
|
+
attribute: "palette-json",
|
|
151
|
+
default: null,
|
|
152
|
+
show: !1,
|
|
153
|
+
notes: "If not passed, default it is false"
|
|
154
|
+
}
|
|
131
155
|
];
|
|
132
|
-
function
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
style: {
|
|
353
|
-
display: "block",
|
|
354
|
-
margin: "0 auto",
|
|
355
|
-
cursor: "pointer"
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
) });
|
|
156
|
+
function d({ onColorsChange: e, harmonyMode: n, saturation: c, brightness: l, circleRadius: d, wheelThickness: f, dotSize: p, dotPosition: m, handleThickness: h, handleColor: g, harmonyPolygon: _, polygonColor: v, polygonThickness: y, centerDot: b, showCenterDot: x = !1, borderColor: S = "#ffffff", canvasBackgroundColor: C = "transparent", width: w = 450, height: T = 450 }) {
|
|
157
|
+
let E = a(null), [ne, D] = o(!1), { isDark: O } = ee(), k = (e) => te.find((t) => t.attribute === e), [A, re] = o(n || k("harmony-mode").default), [j, ie] = o(c ?? k("saturation").default), [M, ae] = o(l ?? k("brightness").default), N = t(() => {
|
|
158
|
+
let e = k("circle-radius").default;
|
|
159
|
+
if (d !== void 0) return d;
|
|
160
|
+
if (e === 1) {
|
|
161
|
+
let e = Math.min(w, T), t = f ?? k("wheel-thickness").default, n = p ?? k("dot-size").default;
|
|
162
|
+
return e / 2 - t / 2 - n - 10;
|
|
163
|
+
}
|
|
164
|
+
return e;
|
|
165
|
+
}, [
|
|
166
|
+
w,
|
|
167
|
+
T,
|
|
168
|
+
d,
|
|
169
|
+
f,
|
|
170
|
+
p
|
|
171
|
+
]), [P, oe] = o(N()), [F, se] = o(f ?? k("wheel-thickness").default), [I, ce] = o(p ?? k("dot-size").default), [L, le] = o(m || k("dot-position").default), [R, ue] = o(h ?? k("handle-thickness").default), [z, de] = o(g || (k("handle-color").default === "black" ? "#000000" : k("handle-color").default)), [B, fe] = o(_ ?? k("harmony-polygon").default), [V, pe] = o(v || (k("polygon-color").default === "black" ? "#000000" : k("polygon-color").default)), [H, me] = o(y ?? k("polygon-thickness").default), [U, he] = o(b || (k("center-dot").default === "white" ? "#ffffff" : k("center-dot").default)), [W, ge] = o(x), [G, _e] = o(S), [K, ve] = o(C), [q, J] = o(0);
|
|
172
|
+
r(() => {
|
|
173
|
+
n !== void 0 && re(n);
|
|
174
|
+
}, [n]), r(() => {
|
|
175
|
+
c !== void 0 && ie(c);
|
|
176
|
+
}, [c]), r(() => {
|
|
177
|
+
l !== void 0 && ae(l);
|
|
178
|
+
}, [l]), r(() => {
|
|
179
|
+
oe(d === void 0 ? N() : d);
|
|
180
|
+
}, [d, N]), r(() => {
|
|
181
|
+
f !== void 0 && se(f);
|
|
182
|
+
}, [f]), r(() => {
|
|
183
|
+
p !== void 0 && ce(p);
|
|
184
|
+
}, [p]), r(() => {
|
|
185
|
+
m !== void 0 && le(m);
|
|
186
|
+
}, [m]), r(() => {
|
|
187
|
+
h !== void 0 && ue(h);
|
|
188
|
+
}, [h]), r(() => {
|
|
189
|
+
g !== void 0 && de(g);
|
|
190
|
+
}, [g]), r(() => {
|
|
191
|
+
_ !== void 0 && fe(_);
|
|
192
|
+
}, [_]), r(() => {
|
|
193
|
+
v !== void 0 && pe(v);
|
|
194
|
+
}, [v]), r(() => {
|
|
195
|
+
y !== void 0 && me(y);
|
|
196
|
+
}, [y]), r(() => {
|
|
197
|
+
b !== void 0 && he(b);
|
|
198
|
+
}, [b]), r(() => {
|
|
199
|
+
ge(x);
|
|
200
|
+
}, [x]), r(() => {
|
|
201
|
+
_e(S);
|
|
202
|
+
}, [S]), r(() => {
|
|
203
|
+
ve(C);
|
|
204
|
+
}, [C]);
|
|
205
|
+
let Y = {
|
|
206
|
+
x: w / 2,
|
|
207
|
+
y: T / 2
|
|
208
|
+
}, X = (e) => (e + 360) % 360, Z = t((e, t = j, n = M) => `hsl(${e}, ${t}%, ${n}%)`, [j, M]), ye = (e, t, n) => {
|
|
209
|
+
t /= 100, n /= 100;
|
|
210
|
+
let r = (1 - Math.abs(2 * n - 1)) * t, i = r * (1 - Math.abs(e / 60 % 2 - 1)), a = n - r / 2, o = 0, s = 0, c = 0;
|
|
211
|
+
return e < 60 ? [o, s, c] = [
|
|
212
|
+
r,
|
|
213
|
+
i,
|
|
214
|
+
0
|
|
215
|
+
] : e < 120 ? [o, s, c] = [
|
|
216
|
+
i,
|
|
217
|
+
r,
|
|
218
|
+
0
|
|
219
|
+
] : e < 180 ? [o, s, c] = [
|
|
220
|
+
0,
|
|
221
|
+
r,
|
|
222
|
+
i
|
|
223
|
+
] : e < 240 ? [o, s, c] = [
|
|
224
|
+
0,
|
|
225
|
+
i,
|
|
226
|
+
r
|
|
227
|
+
] : e < 300 ? [o, s, c] = [
|
|
228
|
+
i,
|
|
229
|
+
0,
|
|
230
|
+
r
|
|
231
|
+
] : [o, s, c] = [
|
|
232
|
+
r,
|
|
233
|
+
0,
|
|
234
|
+
i
|
|
235
|
+
], {
|
|
236
|
+
r: Math.round((o + a) * 255),
|
|
237
|
+
g: Math.round((s + a) * 255),
|
|
238
|
+
b: Math.round((c + a) * 255)
|
|
239
|
+
};
|
|
240
|
+
}, be = (e, t, n) => "#" + [
|
|
241
|
+
e,
|
|
242
|
+
t,
|
|
243
|
+
n
|
|
244
|
+
].map((e) => e.toString(16).padStart(2, "0")).join(""), xe = t(() => L === "center" ? P : L === "inner" ? P - F / 2 : P + F / 2, [
|
|
245
|
+
L,
|
|
246
|
+
P,
|
|
247
|
+
F
|
|
248
|
+
]), Se = t((e) => {
|
|
249
|
+
let t = (e - 90) * Math.PI / 180, n = xe();
|
|
250
|
+
return {
|
|
251
|
+
x: Y.x + n * Math.cos(t),
|
|
252
|
+
y: Y.y + n * Math.sin(t)
|
|
253
|
+
};
|
|
254
|
+
}, [
|
|
255
|
+
Y.x,
|
|
256
|
+
Y.y,
|
|
257
|
+
xe
|
|
258
|
+
]), Ce = (e, t) => {
|
|
259
|
+
let n = e - Y.x, r = t - Y.y, i = Math.atan2(r, n) * 180 / Math.PI;
|
|
260
|
+
return X(i + 90);
|
|
261
|
+
}, we = t(() => {
|
|
262
|
+
let e = [];
|
|
263
|
+
e = A === "monochromatic" ? [
|
|
264
|
+
{
|
|
265
|
+
h: q,
|
|
266
|
+
l: 30
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
h: q,
|
|
270
|
+
l: 50
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
h: q,
|
|
274
|
+
l: 70
|
|
275
|
+
}
|
|
276
|
+
] : u[A].map((e) => ({
|
|
277
|
+
h: X(q + e),
|
|
278
|
+
l: M
|
|
279
|
+
}));
|
|
280
|
+
let t = e.map((e) => {
|
|
281
|
+
let t = ye(e.h, j, e.l);
|
|
282
|
+
return be(t.r, t.g, t.b);
|
|
283
|
+
});
|
|
284
|
+
return { [A]: t };
|
|
285
|
+
}, [
|
|
286
|
+
A,
|
|
287
|
+
q,
|
|
288
|
+
j,
|
|
289
|
+
M
|
|
290
|
+
]), Te = t((e) => {
|
|
291
|
+
for (let t = 0; t < 360; t++) e.beginPath(), e.strokeStyle = `hsl(${t},100%,50%)`, e.lineWidth = F, e.arc(Y.x, Y.y, P, (t - 90) * Math.PI / 180, (t - 89) * Math.PI / 180), e.stroke();
|
|
292
|
+
}, [
|
|
293
|
+
Y.x,
|
|
294
|
+
Y.y,
|
|
295
|
+
P,
|
|
296
|
+
F
|
|
297
|
+
]), Ee = t((e, t) => {
|
|
298
|
+
!B || t.length < 3 || (e.beginPath(), e.moveTo(t[0].x, t[0].y), t.slice(1).forEach((t) => {
|
|
299
|
+
e.lineTo(t.x, t.y);
|
|
300
|
+
}), e.closePath(), e.strokeStyle = V, e.lineWidth = H, e.stroke());
|
|
301
|
+
}, [
|
|
302
|
+
B,
|
|
303
|
+
V,
|
|
304
|
+
H
|
|
305
|
+
]), De = t((e) => {
|
|
306
|
+
if (A === "simple") return;
|
|
307
|
+
let t = u[A], n = [];
|
|
308
|
+
t.forEach((t) => {
|
|
309
|
+
let r = X(q + t), i = Se(r);
|
|
310
|
+
n.push(i), e.beginPath(), e.moveTo(Y.x, Y.y), e.lineTo(i.x, i.y), e.strokeStyle = z, e.lineWidth = R, e.stroke(), e.beginPath(), e.arc(i.x, i.y, I, 0, Math.PI * 2), e.fillStyle = Z(r), e.fill(), e.strokeStyle = "white", e.stroke();
|
|
311
|
+
}), Ee(e, n), W && (e.beginPath(), e.arc(Y.x, Y.y, 5, 0, Math.PI * 2), e.fillStyle = U, e.fill(), e.strokeStyle = "white", e.lineWidth = 1, e.stroke());
|
|
312
|
+
}, [
|
|
313
|
+
A,
|
|
314
|
+
q,
|
|
315
|
+
Y.x,
|
|
316
|
+
Y.y,
|
|
317
|
+
I,
|
|
318
|
+
R,
|
|
319
|
+
z,
|
|
320
|
+
U,
|
|
321
|
+
W,
|
|
322
|
+
Se,
|
|
323
|
+
Z,
|
|
324
|
+
Ee
|
|
325
|
+
]), Oe = t(() => {
|
|
326
|
+
let e = E.current;
|
|
327
|
+
if (!e) return;
|
|
328
|
+
let t = e.getContext("2d");
|
|
329
|
+
t && (t.clearRect(0, 0, e.width, e.height), K && K !== "transparent" ? (t.fillStyle = K, t.fillRect(0, 0, e.width, e.height)) : K === "transparent" && (t.fillStyle = O ? "#1a1a1a" : "#ffffff", t.fillRect(0, 0, e.width, e.height)), Te(t), De(t), G && (t.strokeStyle = G, t.lineWidth = 1, t.strokeRect(0, 0, e.width, e.height)));
|
|
330
|
+
}, [
|
|
331
|
+
Te,
|
|
332
|
+
De,
|
|
333
|
+
G,
|
|
334
|
+
K,
|
|
335
|
+
O
|
|
336
|
+
]), ke = () => D(!0), Ae = () => D(!1), je = () => D(!1), Me = (e) => {
|
|
337
|
+
if (!ne) return;
|
|
338
|
+
let t = E.current;
|
|
339
|
+
if (!t) return;
|
|
340
|
+
let n = t.getBoundingClientRect(), r = Ce(e.clientX - n.left, e.clientY - n.top);
|
|
341
|
+
J(r);
|
|
342
|
+
}, Ne = (e) => {
|
|
343
|
+
let t = E.current;
|
|
344
|
+
if (!t) return;
|
|
345
|
+
let n = t.getBoundingClientRect(), r = Ce(e.clientX - n.left, e.clientY - n.top);
|
|
346
|
+
J(r);
|
|
347
|
+
};
|
|
348
|
+
r(() => {
|
|
349
|
+
Oe();
|
|
350
|
+
}, [Oe]);
|
|
351
|
+
let Q = i(() => we(), [we]);
|
|
352
|
+
r(() => {
|
|
353
|
+
e && e(Q);
|
|
354
|
+
}, [Q, e]);
|
|
355
|
+
let $ = t(() => Q, [Q]);
|
|
356
|
+
return r(() => (window.getColorWheelPalette = $, () => {
|
|
357
|
+
delete window.getColorWheelPalette;
|
|
358
|
+
}), [$]), /* @__PURE__ */ s("div", {
|
|
359
|
+
className: "color-wheel-container",
|
|
360
|
+
children: /* @__PURE__ */ s("canvas", {
|
|
361
|
+
ref: E,
|
|
362
|
+
width: w,
|
|
363
|
+
height: T,
|
|
364
|
+
onMouseDown: ke,
|
|
365
|
+
onMouseUp: Ae,
|
|
366
|
+
onMouseLeave: je,
|
|
367
|
+
onMouseMove: Me,
|
|
368
|
+
onClick: Ne,
|
|
369
|
+
style: {
|
|
370
|
+
display: "block",
|
|
371
|
+
margin: "0 auto",
|
|
372
|
+
cursor: "pointer"
|
|
373
|
+
}
|
|
374
|
+
})
|
|
375
|
+
});
|
|
359
376
|
}
|
|
360
|
-
export {
|
|
361
|
-
Qe as ColorWheel,
|
|
362
|
-
Ke as ThemeProvider,
|
|
363
|
-
Be as useTheme
|
|
364
|
-
};
|
|
377
|
+
export { d as ColorWheel, l as ThemeProvider, ee as useTheme };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiotoolkit/color-wheel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Interactive color wheel React component for creating and manipulating color harmonies with multiple harmony modes",
|
|
6
6
|
"author": "StudioToolkit",
|
|
@@ -53,17 +53,6 @@
|
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=16.0.0"
|
|
55
55
|
},
|
|
56
|
-
"peerDependencies": {
|
|
57
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
58
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@types/react": "^18.2.0 || ^19.0.0",
|
|
62
|
-
"@types/react-dom": "^18.2.0 || ^19.0.0",
|
|
63
|
-
"@vitejs/plugin-react": "^4.2.0",
|
|
64
|
-
"typescript": "^5.3.3",
|
|
65
|
-
"vite": "^5.0.0"
|
|
66
|
-
},
|
|
67
56
|
"scripts": {
|
|
68
57
|
"build": "npx tsc --project tsconfig.json && vite build && cp src/ColorWheel.css dist/style.css",
|
|
69
58
|
"dev": "vite build --watch",
|
|
@@ -72,6 +61,20 @@
|
|
|
72
61
|
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
73
62
|
"test": "vitest run",
|
|
74
63
|
"test:watch": "vitest",
|
|
75
|
-
"test:ui": "vitest --ui"
|
|
64
|
+
"test:ui": "vitest --ui",
|
|
65
|
+
"prepublishOnly": "pnpm run build && pnpm test"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
69
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@types/react": "^19.3.0",
|
|
73
|
+
"@types/react-dom": "^19.3.0",
|
|
74
|
+
"@vitejs/plugin-react": "^6.2.1",
|
|
75
|
+
"react": "^19.3.1",
|
|
76
|
+
"react-dom": "^19.3.1",
|
|
77
|
+
"typescript": "^6.0.3",
|
|
78
|
+
"vite": "^8.3.6"
|
|
76
79
|
}
|
|
77
|
-
}
|
|
80
|
+
}
|