├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── demo_page
├── package-lock.json
├── package.json
├── public
│ ├── bundle.css
│ ├── bundle.css.map
│ ├── bundle.js
│ ├── bundle.js.map
│ ├── favicon.png
│ ├── global.css
│ └── index.html
├── rollup.config.js
└── src
│ ├── App.svelte
│ └── main.js
├── docs
├── bundle.css
├── bundle.css.map
├── bundle.js
├── bundle.js.map
├── favicon.png
├── global.css
└── index.html
├── package-lock.json
├── package.json
├── rollup.config.js
└── src
├── HsvPicker.svelte
├── index.js
└── main.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | tab_size = 2
7 | max_line_length = 120
8 | charset = utf-8
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public
3 | /demo_page/node_modules
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 qintarp
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Svelte Color Picker [\[Demo Page\]](https://efeskucuk.github.io/svelte-color-picker/)
2 | [](https://svelte.dev)
3 | ## Installation
4 |
5 | With npm
6 | ```sh
7 | $ cd yourSvelteProject
8 | $ npm i svelte-color-picker
9 | ```
10 |
11 | ## Usage
12 | In your component :
13 | ```jsx
14 |
21 |
22 |
23 | ```
24 |
25 |
26 | ## Components
27 |
28 | Svelte Color Picker currently has one type of colorpicker.
29 |
30 | #### \
31 | | Props | Value Type | Use |
32 | | ------ | ------ | ------ |
33 | | on:colorChange | function | Given function gets called every time color changes |
34 | | startColor | string | Initializes color picker with the value (hexadecimal without alpha). |
35 |
36 | License
37 | ----
38 |
39 | MIT
40 |
--------------------------------------------------------------------------------
/demo_page/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-app",
3 | "version": "1.0.0",
4 | "devDependencies": {
5 | "npm-run-all": "^4.1.5",
6 | "rollup": "^1.10.1",
7 | "rollup-plugin-commonjs": "^9.3.4",
8 | "rollup-plugin-livereload": "^1.0.0",
9 | "rollup-plugin-node-resolve": "^4.2.3",
10 | "rollup-plugin-svelte": "^5.0.3",
11 | "rollup-plugin-terser": "^4.0.4",
12 | "svelte": "^3.0.0"
13 | },
14 | "dependencies": {
15 | "sirv-cli": "^0.4.4",
16 | "svelte-color-picker": "^1.0.6",
17 | "ws": "^7.0.1"
18 | },
19 | "scripts": {
20 | "build": "rollup -c",
21 | "autobuild": "rollup -c -w",
22 | "dev": "run-p start:dev autobuild",
23 | "start": "sirv public --single",
24 | "start:dev": "sirv public --single --dev"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/demo_page/public/bundle.css:
--------------------------------------------------------------------------------
1 | h3.svelte-1ceuvkr{padding:0;margin:0;font-family:sans-serif}p.svelte-1ceuvkr{margin:10px 5px}.main.svelte-1ceuvkr{border-radius:20px;width:600px;padding:20px;margin:0 auto}.container.svelte-1ceuvkr{display:inline-block;vertical-align:top}
2 | .main-container.svelte-8esefu{width:240px;height:265px;background:#f2f2f2;border-radius:1px;-webkit-box-shadow:0px 0px 4px 0px rgba(0, 0, 0, 0.51);-moz-box-shadow:0px 0px 4px 0px rgba(0, 0, 0, 0.51);box-shadow:0px 0px 4px 0px rgba(0, 0, 0, 0.51);-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.saturation-gradient.svelte-8esefu{background:linear-gradient(to right, rgb(255, 255, 255), rgba(255, 255, 255, 0));width:240px;height:160px}.value-gradient.svelte-8esefu{background:linear-gradient(to top, rgb(0, 0, 0), rgba(0, 0, 0, 0));overflow:hidden;width:240px;height:160px}.hue-selector.svelte-8esefu{background:linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);margin:15px 10px 10px 10px;border-radius:10px;height:10px}#hue-picker.svelte-8esefu{background:#FFF;width:12px;height:12px;border-radius:50%;left:0%;position:relative;cursor:default;transform:translate(-5px, -1px);-webkit-box-shadow:0px 0px 5px 0px rgba(0, 0, 0, 0.67);-moz-box-shadow:0px 0px 5px 0px rgba(0, 0, 0, 0.67);box-shadow:0px 0px 5px 0px rgba(0, 0, 0, 0.67)}#hue-event.svelte-8esefu{width:236px;height:14px;transform:translate(-8px, -14px);cursor:default;touch-action:none}.alpha-selector.svelte-8esefu{background-image:linear-gradient(45deg, #808080 25%, transparent 25%), linear-gradient(-45deg, #808080 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #808080 75%), linear-gradient(-45deg, transparent 75%, #808080 75%);background-size:10px 10px;background-position:0 0, 0 5px, 5px -5px, -5px 0px;margin:10px 10px;border-radius:10px;height:10px;position:relative}#alpha-picker.svelte-8esefu{background:#FFF;width:12px;height:12px;border-radius:50%;left:100%;position:relative;cursor:default;transform:translate(-5px, -11px);-webkit-box-shadow:0px 0px 5px 0px rgba(0, 0, 0, 0.67);-moz-box-shadow:0px 0px 5px 0px rgba(0, 0, 0, 0.67);box-shadow:0px 0px 5px 0px rgba(0, 0, 0, 0.67)}#alpha-event.svelte-8esefu{width:236px;height:14px;transform:translate(-8px, -24px);cursor:default;touch-action:none}.alpha-value.svelte-8esefu{background:linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1));width:100%;height:100%;border-radius:10px}.colorsquare.svelte-8esefu{background:rgb(255, 0, 0)}#colorsquare-picker.svelte-8esefu{margin:0;padding:0;width:12px;height:12px;border-radius:50%;border:2px solid #FFFB;position:relative;transform:translate(-9px, -9px);left:100%}#colorsquare-event.svelte-8esefu{width:100%;height:100%;position:relative;transform:translate(0, -16px);touch-action:none}.color-info-box.svelte-8esefu{margin:10px;width:100%;height:22px;vertical-align:middle;position:relative}.color-picked.svelte-8esefu{width:18px;height:18px;border-radius:2px;background:rgba(255, 0, 0, 1);display:inline-block}.color-picked-bg.svelte-8esefu{background-image:linear-gradient(45deg, #808080 25%, transparent 25%), linear-gradient(-45deg, #808080 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #808080 75%), linear-gradient(-45deg, transparent 75%, #808080 75%);background-size:10px 10px;background-position:0 0, 0 5px, 5px -5px, -5px 0px;border:2px solid #FFF;border-radius:4px;width:18px;height:18px;color:#fff;display:inline-block}.hex-text-block.svelte-8esefu{display:inline-block;background:white;border-radius:2px;padding:2px;border:1px solid #e3e3e3;height:16px;width:54px;vertical-align:top;text-align:center}.rgb-text-block.svelte-8esefu{display:inline-block;background:white;border-radius:2px;padding:2px;margin:0 1px;border:1px solid #dcdcdc;height:16px;width:23px;vertical-align:top;text-align:center}.rgb-text-div.svelte-8esefu{right:10%;display:inline-block;vertical-align:top;position:absolute}.text-label.svelte-8esefu{position:relative;top:-12px;font-family:sans-serif;font-size:small;color:#888}.text.svelte-8esefu{display:inline;font-family:sans-serif;margin:0;display:inline-block;font-size:12px;font-size-adjust:0.50;position:relative;top:-1px;vertical-align:middle;-webkit-touch-callout:all;-webkit-user-select:all;-khtml-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all}
3 |
4 | /*# sourceMappingURL=bundle.css.map */
--------------------------------------------------------------------------------
/demo_page/public/bundle.css.map:
--------------------------------------------------------------------------------
1 | {
2 | "version": 3,
3 | "file": "bundle.css",
4 | "sources": [
5 | "../src/App.svelte",
6 | "../node_modules/svelte-color-picker/src/HsvPicker.svelte"
7 | ],
8 | "sourcesContent": [
9 | "
\n\n\n\n\n\n\n\n\n\t
\n\t\t
Svelte Color Picker
\n\t\t
A color picker component for svelte.
\n\t\t
Star\n\t
\n\t
\n\t\t\n\t
\n
\n",
10 | "\n\n\n\n\n"
11 | ],
12 | "names": [],
13 | "mappings": "AA2BC,EAAE,eAAC,CAAC,AACH,QAAQ,CAAC,CACT,OAAO,CAAC,CACR,WAAW,CAAE,UAAU,AACxB,CAAC,AAED,CAAC,eAAC,CAAC,AACF,OAAO,IAAI,CAAC,GAAG,AAChB,CAAC,AAED,KAAK,eAAC,CAAC,AACN,cAAc,IAAI,CAClB,MAAM,KAAK,CACX,QAAQ,IAAI,CACZ,OAAO,CAAC,CAAC,IAAI,AACd,CAAC,AACD,yBAAU,CAAC,AACV,QAAQ,YAAY,CACpB,cAAc,CAAE,GAAG,AACpB,CAAC;ACuVF,eAAe,cAAC,CAAC,AAChB,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,KAAK,CACb,UAAU,CAAE,OAAO,CACnB,aAAa,CAAE,GAAG,CAClB,kBAAkB,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CACvD,eAAe,CAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAA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,MAAM,CAAE,CAAC,CAAC,GAAG,CACb,MAAM,CAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CACzB,MAAM,CAAE,IAAI,CACZ,KAAK,CAAE,IAAI,CACX,cAAc,CAAE,GAAG,CACnB,UAAU,CAAE,MAAM,AACnB,CAAC,AAED,aAAa,cAAC,CAAC,AACd,KAAK,CAAE,GAAG,CACV,OAAO,CAAE,YAAY,CACrB,cAAc,CAAE,GAAG,CACnB,QAAQ,CAAE,QAAQ,AACnB,CAAC,AAED,WAAW,cAAC,CAAC,AACZ,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,KAAK,CACV,WAAW,CAAE,UAAU,CACvB,SAAS,CAAE,KAAK,CACf,MAAM,IAAI,AACZ,CAAC,AAED,KAAK,cAAC,CAAC,AACN,OAAO,CAAE,MAAM,CACf,WAAW,CAAE,UAAU,CACvB,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,YAAY,CACrB,SAAS,CAAE,IAAI,CACf,gBAAgB,CAAE,IAAI,CACtB,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,IAAI,CACR,cAAc,CAAE,MAAM,CACtB,qBAAqB,CAAE,GAAG,CACxB,mBAAmB,CAAE,GAAG,CACvB,kBAAkB,CAAE,GAAG,CACrB,gBAAgB,CAAE,GAAG,CACpB,eAAe,CAAE,GAAG,CAChB,WAAW,CAAE,GAAG,AAC5B,CAAC"
14 | }
--------------------------------------------------------------------------------
/demo_page/public/bundle.js:
--------------------------------------------------------------------------------
1 | var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function o(e){e.forEach(t)}function r(e){return"function"==typeof e}function c(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}function s(e,t){e.appendChild(t)}function u(e,t,n){e.insertBefore(t,n||null)}function l(e){e.parentNode.removeChild(e)}function a(e){return document.createElement(e)}function i(e){return document.createTextNode(e)}function d(){return i(" ")}function f(e,t,n,o){return e.addEventListener(t,n,o),()=>e.removeEventListener(t,n,o)}function v(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function h(e,t){t=""+t,e.data!==t&&(e.data=t)}let p;function m(e){p=e}function g(e){(function(){if(!p)throw new Error("Function called outside component initialization");return p})().$$.on_mount.push(e)}function y(){const e=p;return(t,n)=>{const o=e.$$.callbacks[t];if(o){const r=function(e,t){const n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!1,!1,t),n}(t,n);o.slice().forEach(t=>{t.call(e,r)})}}}const b=[],$=[],x=[],k=[],q=Promise.resolve();let w=!1;function E(e){x.push(e)}function S(){const e=new Set;do{for(;b.length;){const e=b.shift();m(e),L(e.$$)}for(;$.length;)$.pop()();for(let t=0;t{const n=u.map(t).filter(r);l?l.push(...n):o(n),e.$$.on_mount=[]}),a.forEach(E)}function D(e,t){e.$$.fragment&&(o(e.$$.on_destroy),e.$$.fragment.d(t),e.$$.on_destroy=e.$$.fragment=null,e.$$.ctx={})}function M(e,t){e.$$.dirty||(b.push(e),w||(w=!0,q.then(S)),e.$$.dirty=n()),e.$$.dirty[t]=!0}function X(t,r,c,s,u,l){const a=p;m(t);const i=r.props||{},d=t.$$={fragment:null,ctx:null,props:l,update:e,not_equal:u,bound:n(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(a?a.$$.context:[]),callbacks:n(),dirty:null};let f=!1;var v;d.ctx=c?c(t,i,(e,n)=>{d.ctx&&u(d.ctx[e],d.ctx[e]=n)&&(d.bound[e]&&d.bound[e](n),f&&M(t,e))}):i,d.update(),f=!0,o(d.before_update),d.fragment=s(d.ctx),r.target&&(r.hydrate?d.fragment.l((v=r.target,Array.from(v.childNodes))):d.fragment.c(),r.intro&&T(t.$$.fragment),_(t,r.target,r.anchor),S()),m(a)}class A{$destroy(){D(this,1),this.$destroy=e}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(){}}function B(t){var n,r,c,p,m,g,y,b,$,x,k,q,w,E,S,L,C,F,T,_,D,M,X,A,B,R,V,H,I,N,Y,j,z,G,O,P,U,J,K,Q,W,Z,ee,te,ne,oe;return{c(){n=a("div"),r=a("div"),c=a("div"),p=a("div"),m=a("div"),g=d(),y=a("div"),b=d(),$=a("div"),x=a("div"),k=d(),q=a("div"),w=d(),E=a("div"),S=a("div"),L=d(),C=a("div"),F=d(),T=a("div"),_=d(),D=a("div"),(M=a("div")).innerHTML='',X=d(),A=a("div"),B=a("p"),R=i(t.hexValue),V=d(),H=a("div"),I=a("div"),N=a("p"),Y=i(t.r),j=d(),(z=a("p")).textContent="R",G=d(),O=a("div"),P=a("p"),U=i(t.g),J=d(),(K=a("p")).textContent="G",Q=d(),W=a("div"),Z=a("p"),ee=i(t.b),te=d(),(ne=a("p")).textContent="B",v(m,"id","colorsquare-picker"),v(m,"class","svelte-8esefu"),v(y,"id","colorsquare-event"),v(y,"class","svelte-8esefu"),v(p,"class","value-gradient svelte-8esefu"),v(c,"class","saturation-gradient svelte-8esefu"),v(r,"class","colorsquare size svelte-8esefu"),v(x,"id","hue-picker"),v(x,"class","svelte-8esefu"),v(q,"id","hue-event"),v(q,"class","svelte-8esefu"),v($,"class","hue-selector svelte-8esefu"),v(S,"class","alpha-value svelte-8esefu"),v(C,"id","alpha-picker"),v(C,"class","svelte-8esefu"),v(T,"id","alpha-event"),v(T,"class","svelte-8esefu"),v(E,"class","alpha-selector svelte-8esefu"),v(M,"class","color-picked-bg svelte-8esefu"),v(B,"class","text svelte-8esefu"),v(A,"class","hex-text-block svelte-8esefu"),v(N,"class","text svelte-8esefu"),v(z,"class","text-label svelte-8esefu"),v(I,"class","rgb-text-block svelte-8esefu"),v(P,"class","text svelte-8esefu"),v(K,"class","text-label svelte-8esefu"),v(O,"class","rgb-text-block svelte-8esefu"),v(Z,"class","text svelte-8esefu"),v(ne,"class","text-label svelte-8esefu"),v(W,"class","rgb-text-block svelte-8esefu"),v(H,"class","rgb-text-div svelte-8esefu"),v(D,"class","color-info-box svelte-8esefu"),v(n,"class","main-container svelte-8esefu"),oe=[f(y,"mousedown",t.csDown),f(y,"touchstart",t.csDownTouch),f(q,"mousedown",t.hueDown),f(q,"touchstart",t.hueDownTouch),f(T,"mousedown",t.alphaDown),f(T,"touchstart",t.alphaDownTouch)]},m(e,t){u(e,n,t),s(n,r),s(r,c),s(c,p),s(p,m),s(p,g),s(p,y),s(n,b),s(n,$),s($,x),s($,k),s($,q),s(n,w),s(n,E),s(E,S),s(E,L),s(E,C),s(E,F),s(E,T),s(n,_),s(n,D),s(D,M),s(D,X),s(D,A),s(A,B),s(B,R),s(D,V),s(D,H),s(H,I),s(I,N),s(N,Y),s(I,j),s(I,z),s(H,G),s(H,O),s(O,P),s(P,U),s(O,J),s(O,K),s(H,Q),s(H,W),s(W,Z),s(Z,ee),s(W,te),s(W,ne)},p(e,t){e.hexValue&&h(R,t.hexValue),e.r&&h(Y,t.r),e.g&&h(U,t.g),e.b&&h(ee,t.b)},i:e,o:e,d(e){e&&l(n),o(oe)}}}function R(e,t,n){var o,r,c,s=Math.floor(6*e),u=6*e-s,l=n*(1-t),a=n*(1-u*t),i=n*(1-(1-u)*t);switch(s%6){case 0:o=n,r=i,c=l;break;case 1:o=a,r=n,c=l;break;case 2:o=l,r=n,c=i;break;case 3:o=l,r=a,c=n;break;case 4:o=i,r=l,c=n;break;case 5:o=n,r=l,c=a}return[Math.round(255*o),Math.round(255*r),Math.round(255*c)]}function V(e,t,n){let{startColor:o="#FF0000"}=t;g(()=>{document.addEventListener("mouseup",k),document.addEventListener("touchend",k),document.addEventListener("mousemove",m),document.addEventListener("touchmove",b),document.addEventListener("touchstart",h),document.addEventListener("mousedown",p),function(){let e=o.replace("#","");if(6!==e.length&&3!==e.length&&!e.match(/([^A-F0-9])/gi))return void alert("Invalid property value (startColor)");let t="";3===e.length?e.split("").forEach(e=>{t+=e+e}):t=e;n("hexValue",v=t),n("r",i=parseInt(t.substring(0,2),16)),n("g",d=parseInt(t.substring(2,4),16)),n("b",f=parseInt(t.substring(4,6),16)),function(e,t,n,o){let r,c,a,i,d,f,v,h,p,m;r=e/255,c=t/255,a=n/255,i=Math.max(r,c,a),d=Math.min(r,c,a),f=i-d,p=0==(m=i)?0:f/i;for(let e=0;e<3;e++)if([r,c,a][e]===i){v=e;break}if(0==f)return h=0,o?(s=h,u=p,l=m,void E()):{h:h,s:p,v:m};switch(v){case 0:h=(c-a)/f%6*60/360;break;case 1:h=60*((a-r)/f+2)/360;break;case 2:h=60*((r-c)/f+4)/360}h<0&&(h+=6);if(!o)return{h:h,s:p,v:m};s=h,u=p,l=m,E()}(i,d,f,!0),function(){let e=document.querySelector("#colorsquare-picker"),t=100*u,n=100*(1-l);e.style.top=n+"%",e.style.left=t+"%"}(),function(){let e=document.querySelector("#hue-picker"),t=100*s;e.style.left=t+"%"}()}()}),Number.prototype.mod=function(e){return(this%e+e)%e};const r=y();let c,s=1,u=1,l=1,a=1,i=255,d=0,f=0,v="#FF0000";function h(){document.querySelector("#alpha-event").removeEventListener("mousedown",L),document.querySelector("#colorsquare-event").removeEventListener("mousedown",$),document.querySelector("#hue-event").removeEventListener("mousedown",q),document.removeEventListener("mouseup",k),document.removeEventListener("mousemove",m),document.removeEventListener("touchstart",h),document.removeEventListener("mousedown",p)}function p(){document.querySelector("#alpha-event").removeEventListener("touchstart",C),document.querySelector("#colorsquare-event").removeEventListener("touchstart",x),document.querySelector("#hue-event").removeEventListener("touchstart",w),document.removeEventListener("touchend",k),document.removeEventListener("touchmove",b),document.removeEventListener("touchstart",h),document.removeEventListener("mousedown",p)}function m(e){if(c){let t,n,o,r=e.clientX,i=e.clientY,d=c.getBoundingClientRect();switch(c.id){case"colorsquare-event":t=(r-d.x)/240*100,n=(i-d.y)/160*100,t>100?t=100:t<0&&(t=0),n>100?n=100:n<0&&(n=0),o=document.querySelector("#colorsquare-picker"),n=n.toFixed(2),t=t.toFixed(2),o.style.top=n+"%",o.style.left=t+"%",u=t/100,l=1-n/100,S();break;case"hue-event":(t=(r-10-d.x)/220*100)>100?t=100:t<0&&(t=0),t=t.toFixed(2),(o=document.querySelector("#hue-picker")).style.left=t+"%",s=t/100,E();break;case"alpha-event":(t=(r-10-d.x)/220*100)>100?t=100:t<0&&(t=0),t=t.toFixed(2),(o=document.querySelector("#alpha-picker")).style.left=t+"%",a=t/100,S()}}}function b(e){if(c){let t,n,o,r=e.touches[0].clientX,i=e.touches[0].clientY,d=c.getBoundingClientRect();switch(c.id){case"colorsquare-event":t=(r-d.x)/240*100,n=(i-d.y)/160*100,t>100?t=100:t<0&&(t=0),n>100?n=100:n<0&&(n=0),o=document.querySelector("#colorsquare-picker"),n=n.toFixed(2),t=t.toFixed(2),o.style.top=n+"%",o.style.left=t+"%",u=t/100,l=1-n/100,S();break;case"hue-event":(t=(r-10-d.x)/220*100)>100?t=100:t<0&&(t=0),t=t.toFixed(2),(o=document.querySelector("#hue-picker")).style.left=t+"%",s=t/100,E();break;case"alpha-event":(t=(r-10-d.x)/220*100)>100?t=100:t<0&&(t=0),t=t.toFixed(2),(o=document.querySelector("#alpha-picker")).style.left=t+"%",a=t/100,S()}}}function $(e){c=e.currentTarget;let t=(e.offsetX+1)/240*100,n=(e.offsetY+1)/160*100;n=n.toFixed(2),t=t.toFixed(2);let o=document.querySelector("#colorsquare-picker");o.style.top=n+"%",o.style.left=t+"%",u=t/100,l=1-n/100,S()}function x(e){c=e.currentTarget;let t=e.target.getBoundingClientRect(),n=(e.targetTouches[0].clientX-t.left+1)/240*100,o=(e.targetTouches[0].clientY-t.top+1)/160*100;o=o.toFixed(2),n=n.toFixed(2);let r=document.querySelector("#colorsquare-picker");r.style.top=o+"%",r.style.left=n+"%",u=n/100,l=1-o/100,S()}function k(e){c=null}function q(e){c=e.currentTarget;let t=(e.offsetX-9)/220*100;t=t.toFixed(2),document.querySelector("#hue-picker").style.left=t+"%",s=t/100,E()}function w(e){c=e.currentTarget;let t=e.target.getBoundingClientRect(),n=(e.targetTouches[0].clientX-t.left-9)/220*100;n=n.toFixed(2),document.querySelector("#hue-picker").style.left=n+"%",s=n/100,E()}function E(){let e=R(s,1,1);document.querySelector(".colorsquare").style.background=`rgba(${e[0]},${e[1]},${e[2]},1)`,S()}function S(){let e=R(s,u,l);n("r",i=e[0]),n("g",d=e[1]),n("b",f=e[2]),n("hexValue",v=function(){let e=i.toString(16),t=d.toString(16),n=f.toString(16);1==e.length&&(e="0"+e);1==t.length&&(t="0"+t);1==n.length&&(n="0"+n);return("#"+e+t+n).toUpperCase()}()),document.querySelector(".color-picked").style.background=`rgba(${e[0]},${e[1]},${e[2]},${a})`,r("colorChange",{r:i,g:d,b:f,a:a})}function L(e){c=e.currentTarget;let t=(e.offsetX-9)/220*100;t=t.toFixed(2),document.querySelector("#alpha-picker").style.left=t+"%",a=t/100,S()}function C(e){c=e.currentTarget;let t=e.target.getBoundingClientRect(),n=(e.targetTouches[0].clientX-t.left-9)/220*100;n=n.toFixed(2),document.querySelector("#alpha-picker").style.left=n+"%",a=n/100,S()}return e.$set=(e=>{"startColor"in e&&n("startColor",o=e.startColor)}),{startColor:o,r:i,g:d,b:f,hexValue:v,csDown:$,csDownTouch:x,hueDown:q,hueDownTouch:w,alphaDown:L,alphaDownTouch:C}}class H extends A{constructor(e){super(),X(this,e,V,B,c,["startColor"])}}function I(t){var n,o,r,c,i,f,h,p=new H({props:{startColor:"#82EAEA"}});return p.$on("colorChange",N),{c(){(n=a("head")).innerHTML='
16 |