@studiotoolkit/color-palette 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/ColorPalette.d.ts +1 -1
- package/dist/ColorPalette.d.ts.map +1 -1
- package/dist/color-palette.css +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +150 -216
- package/package.json +17 -14
package/dist/ColorPalette.d.ts
CHANGED
|
@@ -26,6 +26,6 @@ interface ColorPaletteProps {
|
|
|
26
26
|
/** Brightness for Part 2 (middle band) (0 = black, 50 = mid-tone, 100 = white). Default 50. */
|
|
27
27
|
brightness2?: number;
|
|
28
28
|
}
|
|
29
|
-
export default function ColorPalette({ paletteData, showCopyButton, displayType, width, boxBorderSize, boxBorderColor, displayTitle, fontColor, fontSize, backgroundColor, displayHexcode, parts, saturation1, brightness1, saturation2, brightness2, }: ColorPaletteProps): import("react
|
|
29
|
+
export default function ColorPalette({ paletteData, showCopyButton, displayType, width, boxBorderSize, boxBorderColor, displayTitle, fontColor, fontSize, backgroundColor, displayHexcode, parts, saturation1, brightness1, saturation2, brightness2, }: ColorPaletteProps): import("react").JSX.Element | null;
|
|
30
30
|
export {};
|
|
31
31
|
//# sourceMappingURL=ColorPalette.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPalette.d.ts","sourceRoot":"","sources":["../src/ColorPalette.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,KAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CAAC;AAC3D,KAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAExE,UAAU,iBAAiB;IACzB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,yIAAyI;IACzI,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,mGAAmG;IACnG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4FAA4F;IAC5F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sGAAsG;IACtG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAmMD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,cAAsB,EACtB,WAAqB,EACrB,KAAU,EACV,aAAiB,EACjB,cAAuB,EACvB,YAAmB,EACnB,SAAkB,EAClB,QAAa,EACb,eAA+B,EAC/B,cAAqB,EACrB,KAAS,EACT,WAAgB,EAChB,WAAgB,EAChB,WAAgB,EAChB,WAAgB,GACjB,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ColorPalette.d.ts","sourceRoot":"","sources":["../src/ColorPalette.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,KAAK,WAAW,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CAAC;AAC3D,KAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAExE,UAAU,iBAAiB;IACzB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,yIAAyI;IACzI,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,mGAAmG;IACnG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4FAA4F;IAC5F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sGAAsG;IACtG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAmMD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,cAAsB,EACtB,WAAqB,EACrB,KAAU,EACV,aAAiB,EACjB,cAAuB,EACvB,YAAmB,EACnB,SAAkB,EAClB,QAAa,EACb,eAA+B,EAC/B,cAAqB,EACrB,KAAS,EACT,WAAgB,EAChB,WAAgB,EAChB,WAAgB,EAChB,WAAgB,GACjB,EAAE,iBAAiB,sCAgJnB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.color-palette-container{background-color:#fff;padding:5px}[data-theme=dark] .color-palette-container{background-color:#1a1a1a!important}.palette-section{margin-bottom:8px}.palette-section-header{justify-content:space-between;align-items:center;margin-bottom:8px;display:flex}.palette-section h3{margin:0;font-size:16px}.copy-section-button{color:#fff;cursor:pointer;background:#27ae60;border:none;border-radius:4px;padding:4px 10px;font-size:12px}.copy-section-button:hover{background:#1e8449}.colors{flex-wrap:wrap;gap:6px;display:flex}.swatchBox{text-align:center;font-size:12px}.palette-table{border-collapse:collapse;border:1px solid #ddd}.palette-table .color-cell{border:1px solid #ddd;padding:0}.palette-table .hex-cell{text-align:center;color:#333;background:#fff;border:1px solid #ddd;padding:4px 2px;font-family:monospace;font-size:11px}.hex-label{color:#333;font-family:monospace;font-size:11px;display:block}[data-theme=dark] .palette-section h3{color:#e0e0e0}[data-theme=dark] .copy-section-button{background:#2ecc71}[data-theme=dark] .copy-section-button:hover{background:#27ae60}[data-theme=dark] .palette-table,[data-theme=dark] .palette-table .color-cell{border-color:#444}[data-theme=dark] .palette-table .hex-cell{color:#e0e0e0;background:#2a2a2a;border-color:#444}[data-theme=dark] .hex-label{color:#e0e0e0}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime");var t=e=>({r:parseInt(e.slice(1,3),16)/255,g:parseInt(e.slice(3,5),16)/255,b:parseInt(e.slice(5,7),16)/255}),n=({r:e,g:t,b:n})=>`#`+[e,t,n].map(e=>Math.round(Math.max(0,Math.min(1,e))*255).toString(16).padStart(2,`0`)).join(``),r=({r:e,g:t,b:n})=>{let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2;if(r===i)return{h:0,s:0,l:a};let o=r-i,s=a>.5?o/(2-r-i):o/(r+i),c=0;return c=r===e?((t-n)/o+(t<n?6:0))/6:r===t?((n-e)/o+2)/6:((e-t)/o+4)/6,{h:c,s,l:a}},i=({h:e,s:t,l:n})=>{if(t===0)return{r:n,g:n,b:n};let r=n<.5?n*(1+t):n+t-n*t,i=2*n-r,a=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e);return{r:a(i,r,e+1/3),g:a(i,r,e),b:a(i,r,e-1/3)}},a=(e,a,o)=>{let s=r(t(e)),c=Math.max(0,Math.min(100,a)),l=Math.max(0,Math.min(100,o)),u=c/100,d=l/100;return n(i({h:s.h,s:u,l:d}))};function o({hex:t,parts:n,saturation1:r,brightness1:i,saturation2:o,brightness2:s,displayType:c,width:l,borderSize:u,borderColor:d}){let f=[];n===1?f.push(a(t,r,i)):n===2?(f.push(a(t,r,i)),f.push(a(t,o,s))):(f.push(a(t,r,i)),f.push(a(t,o,s)),f.push(t));let p={width:l,height:l,overflow:`hidden`,flexShrink:0,position:`relative`,border:`${u}px solid ${d}`,boxSizing:`border-box`,...c===`circle`?{borderRadius:`50%`}:c===`square`?{borderRadius:0}:c===`triangle`?{borderRadius:0,clipPath:`polygon(50% 0%, 0% 100%, 100% 100%)`,border:`none`}:{borderRadius:10}};if(n===1)return(0,e.jsx)(`div`,{style:{...p,background:a(t,r,i)}});let m=100/f.length;return(0,e.jsx)(`div`,{style:p,children:f.map((t,n)=>(0,e.jsx)(`div`,{style:{position:`absolute`,left:0,right:0,top:`${n*m}%`,height:`${m}%`,background:t}},n))})}function s({paletteData:t,showCopyButton:n=!1,displayType:r=`block`,width:i=60,boxBorderSize:s=1,boxBorderColor:c=`#ccc`,displayTitle:l=!0,fontColor:u=`#333`,fontSize:d=11,backgroundColor:f=`transparent`,displayHexcode:p=!0,parts:m=1,saturation1:h=50,brightness1:g=50,saturation2:_=50,brightness2:v=50}){if(!t)return null;let y=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify({[e]:t},null,2))}catch{}},b=m,x=h,S=g,C=_,w=v;return(0,e.jsx)(`div`,{className:`color-palette-container`,style:f===`transparent`?void 0:{backgroundColor:f},children:Object.keys(t).map(f=>{if(Array.isArray(t[f])&&t[f].length>0){let m=t[f];return(0,e.jsxs)(`div`,{className:`palette-section`,children:[(0,e.jsxs)(`div`,{className:`palette-section-header`,children:[l&&(0,e.jsx)(`h3`,{children:f}),n&&(0,e.jsx)(`button`,{onClick:()=>y(f,m),className:`copy-section-button`,children:`Copy`})]}),r===`table`?(0,e.jsx)(`table`,{className:`palette-table`,children:(0,e.jsxs)(`tbody`,{children:[Array.from({length:b}).map((t,n)=>(0,e.jsx)(`tr`,{children:m.map((t,r)=>{let o=t;return n===0?o=a(t,x,S):n===1&&(o=a(t,C,w)),(0,e.jsx)(`td`,{className:`color-cell`,style:{background:o,width:`${i}px`,height:`${i}px`,borderWidth:`${s}px`,borderColor:c}},r)})},`part-${n}`)),p&&(0,e.jsx)(`tr`,{children:m.map((t,n)=>(0,e.jsx)(`td`,{className:`hex-cell`,style:{...u!==`#333`&&{color:u},fontSize:`${d}px`},children:t},n))})]})}):(0,e.jsx)(`div`,{className:`colors display-${r}`,children:m.map((t,n)=>(0,e.jsxs)(`div`,{className:`swatchBox`,children:[(0,e.jsx)(o,{hex:t,parts:b,saturation1:x,brightness1:S,saturation2:C,brightness2:w,displayType:r,width:i,borderSize:s,borderColor:c}),p&&(0,e.jsx)(`span`,{className:`hex-label`,style:{...u!==`#333`&&{color:u},fontSize:`${d}px`},children:t})]},n))})]},f)}return null})})}exports.ColorPalette=s;
|
package/dist/index.mjs
CHANGED
|
@@ -1,219 +1,153 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
// src/ColorPalette.tsx
|
|
3
|
+
var n = (e) => ({
|
|
4
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
5
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
6
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
7
|
+
}), r = ({ r: e, g: t, b: n }) => "#" + [
|
|
8
|
+
e,
|
|
9
|
+
t,
|
|
10
|
+
n
|
|
11
|
+
].map((e) => Math.round(Math.max(0, Math.min(1, e)) * 255).toString(16).padStart(2, "0")).join(""), i = ({ r: e, g: t, b: n }) => {
|
|
12
|
+
let r = Math.max(e, t, n), i = Math.min(e, t, n), a = (r + i) / 2;
|
|
13
|
+
if (r === i) return {
|
|
14
|
+
h: 0,
|
|
15
|
+
s: 0,
|
|
16
|
+
l: a
|
|
17
|
+
};
|
|
18
|
+
let o = r - i, s = a > .5 ? o / (2 - r - i) : o / (r + i), c = 0;
|
|
19
|
+
return c = r === e ? ((t - n) / o + (t < n ? 6 : 0)) / 6 : r === t ? ((n - e) / o + 2) / 6 : ((e - t) / o + 4) / 6, {
|
|
20
|
+
h: c,
|
|
21
|
+
s,
|
|
22
|
+
l: a
|
|
23
|
+
};
|
|
24
|
+
}, a = ({ h: e, s: t, l: n }) => {
|
|
25
|
+
if (t === 0) return {
|
|
26
|
+
r: n,
|
|
27
|
+
g: n,
|
|
28
|
+
b: n
|
|
29
|
+
};
|
|
30
|
+
let r = n < .5 ? n * (1 + t) : n + t - n * t, i = 2 * n - r, a = (e, t, n) => (n < 0 && (n += 1), n > 1 && --n, n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e);
|
|
31
|
+
return {
|
|
32
|
+
r: a(i, r, e + 1 / 3),
|
|
33
|
+
g: a(i, r, e),
|
|
34
|
+
b: a(i, r, e - 1 / 3)
|
|
35
|
+
};
|
|
36
|
+
}, o = (e, t, o) => {
|
|
37
|
+
let s = i(n(e)), c = Math.max(0, Math.min(100, t)), l = Math.max(0, Math.min(100, o)), u = c / 100, d = l / 100;
|
|
38
|
+
return r(a({
|
|
39
|
+
h: s.h,
|
|
40
|
+
s: u,
|
|
41
|
+
l: d
|
|
42
|
+
}));
|
|
33
43
|
};
|
|
34
|
-
function
|
|
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
|
-
style: {
|
|
68
|
-
...g,
|
|
69
|
-
background: u(e, t, r)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
const v = 100 / d.length;
|
|
74
|
-
return /* @__PURE__ */ a("div", { style: g, children: d.map(($, S) => /* @__PURE__ */ a(
|
|
75
|
-
"div",
|
|
76
|
-
{
|
|
77
|
-
style: {
|
|
78
|
-
position: "absolute",
|
|
79
|
-
left: 0,
|
|
80
|
-
right: 0,
|
|
81
|
-
top: `${S * v}%`,
|
|
82
|
-
height: `${v}%`,
|
|
83
|
-
background: $
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
S
|
|
87
|
-
)) });
|
|
44
|
+
function s({ hex: t, parts: n, saturation1: r, brightness1: i, saturation2: a, brightness2: s, displayType: c, width: l, borderSize: u, borderColor: d }) {
|
|
45
|
+
let f = [];
|
|
46
|
+
n === 1 ? f.push(o(t, r, i)) : n === 2 ? (f.push(o(t, r, i)), f.push(o(t, a, s))) : (f.push(o(t, r, i)), f.push(o(t, a, s)), f.push(t));
|
|
47
|
+
let p = {
|
|
48
|
+
width: l,
|
|
49
|
+
height: l,
|
|
50
|
+
overflow: "hidden",
|
|
51
|
+
flexShrink: 0,
|
|
52
|
+
position: "relative",
|
|
53
|
+
border: `${u}px solid ${d}`,
|
|
54
|
+
boxSizing: "border-box",
|
|
55
|
+
...c === "circle" ? { borderRadius: "50%" } : c === "square" ? { borderRadius: 0 } : c === "triangle" ? {
|
|
56
|
+
borderRadius: 0,
|
|
57
|
+
clipPath: "polygon(50% 0%, 0% 100%, 100% 100%)",
|
|
58
|
+
border: "none"
|
|
59
|
+
} : { borderRadius: 10 }
|
|
60
|
+
};
|
|
61
|
+
if (n === 1) return /* @__PURE__ */ e("div", { style: {
|
|
62
|
+
...p,
|
|
63
|
+
background: o(t, r, i)
|
|
64
|
+
} });
|
|
65
|
+
let m = 100 / f.length;
|
|
66
|
+
return /* @__PURE__ */ e("div", {
|
|
67
|
+
style: p,
|
|
68
|
+
children: f.map((t, n) => /* @__PURE__ */ e("div", { style: {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
left: 0,
|
|
71
|
+
right: 0,
|
|
72
|
+
top: `${n * m}%`,
|
|
73
|
+
height: `${m}%`,
|
|
74
|
+
background: t
|
|
75
|
+
} }, n))
|
|
76
|
+
});
|
|
88
77
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
);
|
|
164
|
-
}) }, `part-${f}`)
|
|
165
|
-
),
|
|
166
|
-
d && /* @__PURE__ */ a("tr", { children: m.map((p, f) => /* @__PURE__ */ a(
|
|
167
|
-
"td",
|
|
168
|
-
{
|
|
169
|
-
className: "hex-cell",
|
|
170
|
-
style: {
|
|
171
|
-
...l !== "#333" && { color: l },
|
|
172
|
-
fontSize: `${c}px`
|
|
173
|
-
},
|
|
174
|
-
children: p
|
|
175
|
-
},
|
|
176
|
-
f
|
|
177
|
-
)) })
|
|
178
|
-
] }) })
|
|
179
|
-
) : (
|
|
180
|
-
/* ── Swatch layout ── */
|
|
181
|
-
/* @__PURE__ */ a("div", { className: `colors display-${t}`, children: m.map((p, f) => /* @__PURE__ */ N("div", { className: "swatchBox", children: [
|
|
182
|
-
/* @__PURE__ */ a(
|
|
183
|
-
I,
|
|
184
|
-
{
|
|
185
|
-
hex: p,
|
|
186
|
-
parts: x,
|
|
187
|
-
saturation1: R,
|
|
188
|
-
brightness1: w,
|
|
189
|
-
saturation2: j,
|
|
190
|
-
brightness2: P,
|
|
191
|
-
displayType: t,
|
|
192
|
-
width: r,
|
|
193
|
-
borderSize: i,
|
|
194
|
-
borderColor: o
|
|
195
|
-
}
|
|
196
|
-
),
|
|
197
|
-
d && /* @__PURE__ */ a(
|
|
198
|
-
"span",
|
|
199
|
-
{
|
|
200
|
-
className: "hex-label",
|
|
201
|
-
style: {
|
|
202
|
-
...l !== "#333" && { color: l },
|
|
203
|
-
fontSize: `${c}px`
|
|
204
|
-
},
|
|
205
|
-
children: p
|
|
206
|
-
}
|
|
207
|
-
)
|
|
208
|
-
] }, f)) })
|
|
209
|
-
)
|
|
210
|
-
] }, h);
|
|
211
|
-
}
|
|
212
|
-
return null;
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
);
|
|
78
|
+
function c({ paletteData: n, showCopyButton: r = !1, displayType: i = "block", width: a = 60, boxBorderSize: c = 1, boxBorderColor: l = "#ccc", displayTitle: u = !0, fontColor: d = "#333", fontSize: f = 11, backgroundColor: p = "transparent", displayHexcode: m = !0, parts: h = 1, saturation1: g = 50, brightness1: _ = 50, saturation2: v = 50, brightness2: y = 50 }) {
|
|
79
|
+
if (!n) return null;
|
|
80
|
+
let b = async (e, t) => {
|
|
81
|
+
try {
|
|
82
|
+
await navigator.clipboard.writeText(JSON.stringify({ [e]: t }, null, 2));
|
|
83
|
+
} catch {}
|
|
84
|
+
}, x = h, S = g, C = _, w = v, T = y;
|
|
85
|
+
return /* @__PURE__ */ e("div", {
|
|
86
|
+
className: "color-palette-container",
|
|
87
|
+
style: p === "transparent" ? void 0 : { backgroundColor: p },
|
|
88
|
+
children: Object.keys(n).map((p) => {
|
|
89
|
+
if (Array.isArray(n[p]) && n[p].length > 0) {
|
|
90
|
+
let h = n[p];
|
|
91
|
+
return /* @__PURE__ */ t("div", {
|
|
92
|
+
className: "palette-section",
|
|
93
|
+
children: [/* @__PURE__ */ t("div", {
|
|
94
|
+
className: "palette-section-header",
|
|
95
|
+
children: [u && /* @__PURE__ */ e("h3", { children: p }), r && /* @__PURE__ */ e("button", {
|
|
96
|
+
onClick: () => b(p, h),
|
|
97
|
+
className: "copy-section-button",
|
|
98
|
+
children: "Copy"
|
|
99
|
+
})]
|
|
100
|
+
}), i === "table" ? /* @__PURE__ */ e("table", {
|
|
101
|
+
className: "palette-table",
|
|
102
|
+
children: /* @__PURE__ */ t("tbody", { children: [Array.from({ length: x }).map((t, n) => /* @__PURE__ */ e("tr", { children: h.map((t, r) => {
|
|
103
|
+
let i = t;
|
|
104
|
+
return n === 0 ? i = o(t, S, C) : n === 1 && (i = o(t, w, T)), /* @__PURE__ */ e("td", {
|
|
105
|
+
className: "color-cell",
|
|
106
|
+
style: {
|
|
107
|
+
background: i,
|
|
108
|
+
width: `${a}px`,
|
|
109
|
+
height: `${a}px`,
|
|
110
|
+
borderWidth: `${c}px`,
|
|
111
|
+
borderColor: l
|
|
112
|
+
}
|
|
113
|
+
}, r);
|
|
114
|
+
}) }, `part-${n}`)), m && /* @__PURE__ */ e("tr", { children: h.map((t, n) => /* @__PURE__ */ e("td", {
|
|
115
|
+
className: "hex-cell",
|
|
116
|
+
style: {
|
|
117
|
+
...d !== "#333" && { color: d },
|
|
118
|
+
fontSize: `${f}px`
|
|
119
|
+
},
|
|
120
|
+
children: t
|
|
121
|
+
}, n)) })] })
|
|
122
|
+
}) : /* @__PURE__ */ e("div", {
|
|
123
|
+
className: `colors display-${i}`,
|
|
124
|
+
children: h.map((n, r) => /* @__PURE__ */ t("div", {
|
|
125
|
+
className: "swatchBox",
|
|
126
|
+
children: [/* @__PURE__ */ e(s, {
|
|
127
|
+
hex: n,
|
|
128
|
+
parts: x,
|
|
129
|
+
saturation1: S,
|
|
130
|
+
brightness1: C,
|
|
131
|
+
saturation2: w,
|
|
132
|
+
brightness2: T,
|
|
133
|
+
displayType: i,
|
|
134
|
+
width: a,
|
|
135
|
+
borderSize: c,
|
|
136
|
+
borderColor: l
|
|
137
|
+
}), m && /* @__PURE__ */ e("span", {
|
|
138
|
+
className: "hex-label",
|
|
139
|
+
style: {
|
|
140
|
+
...d !== "#333" && { color: d },
|
|
141
|
+
fontSize: `${f}px`
|
|
142
|
+
},
|
|
143
|
+
children: n
|
|
144
|
+
})]
|
|
145
|
+
}, r))
|
|
146
|
+
})]
|
|
147
|
+
}, p);
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
})
|
|
151
|
+
});
|
|
216
152
|
}
|
|
217
|
-
export {
|
|
218
|
-
L as ColorPalette
|
|
219
|
-
};
|
|
153
|
+
export { c as ColorPalette };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiotoolkit/color-palette",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React component for displaying and managing color palettes with multiple display modes and customization options",
|
|
6
6
|
"author": "StudioToolkit",
|
|
@@ -50,17 +50,6 @@
|
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=16.0.0"
|
|
52
52
|
},
|
|
53
|
-
"peerDependencies": {
|
|
54
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
55
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
56
|
-
},
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"@types/react": "^18.2.0 || ^19.0.0",
|
|
59
|
-
"@types/react-dom": "^18.2.0 || ^19.0.0",
|
|
60
|
-
"@vitejs/plugin-react": "^4.2.0",
|
|
61
|
-
"typescript": "^5.3.3",
|
|
62
|
-
"vite": "^5.0.0"
|
|
63
|
-
},
|
|
64
53
|
"scripts": {
|
|
65
54
|
"build": "npx tsc --project tsconfig.json && vite build && cp src/ColorPalette.css dist/style.css",
|
|
66
55
|
"dev": "vite build --watch",
|
|
@@ -69,6 +58,20 @@
|
|
|
69
58
|
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
70
59
|
"test": "vitest run",
|
|
71
60
|
"test:watch": "vitest",
|
|
72
|
-
"test:ui": "vitest --ui"
|
|
61
|
+
"test:ui": "vitest --ui",
|
|
62
|
+
"prepublishOnly": "pnpm run build && pnpm test"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
66
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@types/react": "^19.3.0",
|
|
70
|
+
"@types/react-dom": "^19.3.0",
|
|
71
|
+
"@vitejs/plugin-react": "^6.2.1",
|
|
72
|
+
"react": "^19.3.1",
|
|
73
|
+
"react-dom": "^19.3.1",
|
|
74
|
+
"typescript": "^6.0.3",
|
|
75
|
+
"vite": "^8.3.6"
|
|
73
76
|
}
|
|
74
|
-
}
|
|
77
|
+
}
|