@spectrum-web-components/color-wheel 0.1.13-lit-next.0 → 0.2.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.
- package/custom-elements.json +2 -2
- package/package.json +6 -6
- package/src/ColorWheel.js +3 -4
- package/src/ColorWheel.js.map +1 -1
- package/src/color-wheel.css.js +18 -8
- package/src/color-wheel.css.js.map +1 -1
- package/src/spectrum-color-wheel.css.js +18 -8
- package/src/spectrum-color-wheel.css.js.map +1 -1
package/custom-elements.json
CHANGED
|
@@ -483,7 +483,7 @@
|
|
|
483
483
|
{
|
|
484
484
|
"kind": "variable",
|
|
485
485
|
"name": "styles",
|
|
486
|
-
"default": "css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(--spectrum-colorwheel-width)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity
|
|
486
|
+
"default": "css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n);box-sizing:border-box;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .outerCircle{fill:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}.innerCircle,.outerCircle{stroke:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}:host{touch-action:none}:host(:focus){outline:none}.wheel{background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);height:100%;width:100%}.wheel:after,.wheel:before{border:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n) solid var(--spectrum-colorwheel-border-color);border-radius:50%;content:\"\";position:absolute}.wheel:after{bottom:0;left:0;right:0;top:0}.wheel:before{bottom:24px;left:24px;right:24px;top:24px}:host([disabled]) .wheel:after,:host([disabled]) .wheel:before{border-color:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-global-color-gray-300)\n)}:host([disabled]) .wheel{background:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-global-color-gray-300)\n)}\n`"
|
|
487
487
|
}
|
|
488
488
|
],
|
|
489
489
|
"exports": [
|
|
@@ -519,7 +519,7 @@
|
|
|
519
519
|
{
|
|
520
520
|
"kind": "variable",
|
|
521
521
|
"name": "styles",
|
|
522
|
-
"default": "css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(--spectrum-colorwheel-width)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity
|
|
522
|
+
"default": "css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n);box-sizing:border-box;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .outerCircle{fill:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}.innerCircle,.outerCircle{stroke:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}\n`"
|
|
523
523
|
}
|
|
524
524
|
],
|
|
525
525
|
"exports": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/color-wheel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@ctrl/tinycolor": "^3.3.3",
|
|
48
|
-
"@spectrum-web-components/base": "^0.4.
|
|
49
|
-
"@spectrum-web-components/color-handle": "^0.
|
|
50
|
-
"@spectrum-web-components/shared": "^0.12.
|
|
48
|
+
"@spectrum-web-components/base": "^0.4.5",
|
|
49
|
+
"@spectrum-web-components/color-handle": "^0.2.0",
|
|
50
|
+
"@spectrum-web-components/shared": "^0.12.10",
|
|
51
51
|
"tslib": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@spectrum-css/colorwheel": "^1.0.
|
|
54
|
+
"@spectrum-css/colorwheel": "^1.0.4"
|
|
55
55
|
},
|
|
56
56
|
"types": "./src/index.d.ts",
|
|
57
57
|
"customElements": "custom-elements.json",
|
|
58
58
|
"sideEffects": [
|
|
59
59
|
"./sp-*.js"
|
|
60
60
|
],
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "12d891f3dc85e8de641804d8efc9ca06b7fdee2d"
|
|
62
62
|
}
|
package/src/ColorWheel.js
CHANGED
|
@@ -322,10 +322,9 @@ export class ColorWheel extends Focusable {
|
|
|
322
322
|
color="hsl(${this.value}, 100%, 50%)"
|
|
323
323
|
?disabled=${this.disabled}
|
|
324
324
|
style=${handleLocationStyles}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
end: [['pointerup', 'pointercancel'], this.handlePointerup],
|
|
325
|
+
@manage=${streamingListener({ type: 'pointerdown', fn: this.handlePointerdown }, { type: 'pointermove', fn: this.handlePointermove }, {
|
|
326
|
+
type: ['pointerup', 'pointercancel'],
|
|
327
|
+
fn: this.handlePointerup,
|
|
329
328
|
})}
|
|
330
329
|
></sp-color-handle>
|
|
331
330
|
|
package/src/ColorWheel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorWheel.js","sourceRoot":"","sources":["ColorWheel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,IAAI,EAGJ,QAAQ,EACR,KAAK,EAEL,SAAS,GACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAC7E,OAAO,0DAA0D,CAAC;AAClE,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAGH,6BAA6B,EAC7B,6BAA6B,GAChC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IAAzC;;QAMW,aAAQ,GAAG,KAAK,CAAC;QAGjB,YAAO,GAAG,KAAK,CAAC;QAMhB,UAAK,GAAG,KAAK,CAAC;QAGd,SAAI,GAAG,CAAC,CAAC;QAmBR,WAAM,GAAG,CAAC,CAAC;QA2FX,WAAM,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAE7C,mBAAc,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAIrD,YAAO,GAA0C;YACrD,MAAM,EAAE,EAAE;YACV,Q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K,IAAI,OAAO,EAAE;oBACzB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC;iBAC/C;gBACD,IAAI,CAAC,aAAa,EAAE,CAAC;YACzB,CAAC,CACJ,CAAC;SACL;QACD,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEM,oBAAoB;;QACvB,MAAA,IAAI,CAAC,QAAQ,0CAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;CACJ;AA/ZG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACnB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACpB;AAGvB;IADC,KAAK,CAAC,SAAS,CAAC;0CACY;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACN;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACX;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAG1B;AAiBD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAiD1B;AA8DD;IADC,KAAK,CAAC,OAAO,CAAC;yCACiB","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n html,\n CSSResultArray,\n TemplateResult,\n property,\n query,\n PropertyValues,\n ifDefined,\n} from '@spectrum-web-components/base';\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport { WithSWCResizeObserver, SWCResizeObserverEntry } from './types';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport styles from './color-wheel.css.js';\nimport {\n ColorHandle,\n ColorValue,\n extractHueAndSaturationRegExp,\n replaceHueAndSaturationRegExp,\n} from '@spectrum-web-components/color-handle';\nimport { TinyColor } from '@ctrl/tinycolor';\n\n/**\n * @element sp-color-wheel\n * @slot gradient - a custom gradient visually outlining the available color values\n */\nexport class ColorWheel extends Focusable {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.handle')\n private handle!: ColorHandle;\n\n @property({ type: String })\n public label = 'hue';\n\n @property({ type: Number })\n public step = 1;\n\n @property({ type: Number })\n public get value(): number {\n return this._value;\n }\n\n public set value(hue: number) {\n const value = Math.min(360, Math.max(0, hue));\n if (value === this.value) {\n return;\n }\n const oldValue = this.value;\n const { s, v } = this._color.toHsv();\n this._color = new TinyColor({ h: value, s, v });\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n private _value = 0;\n\n @property({ type: String })\n public get color(): ColorValue {\n switch (this._format.format) {\n case 'rgb':\n return this._format.isString\n ? this._color.toRgbString()\n : this._color.toRgb();\n case 'prgb':\n return this._format.isString\n ? this._color.toPercentageRgbString()\n : this._color.toPercentageRgb();\n case 'hex':\n case 'hex3':\n case 'hex4':\n case 'hex6':\n return this._format.isString\n ? this._color.toHexString()\n : this._color.toHex();\n case 'hex8':\n return this._format.isString\n ? this._color.toHex8String()\n : this._color.toHex8();\n case 'name':\n return this._color.toName() || this._color.toRgbString();\n case 'hsl':\n if (this._format.isString) {\n const hslString = this._color.toHslString();\n return hslString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.value}$2${this._saturation}`\n );\n } else {\n const { s, l, a } = this._color.toHsl();\n return { h: this.value, s, l, a };\n }\n case 'hsv':\n if (this._format.isString) {\n const hsvString = this._color.toHsvString();\n return hsvString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.value}$2${this._saturation}`\n );\n } else {\n const { s, v, a } = this._color.toHsv();\n return { h: this.value, s, v, a };\n }\n default:\n return 'No color format applied.';\n }\n }\n\n public set color(color: ColorValue) {\n if (color === this.color) {\n return;\n }\n const oldValue = this._color;\n this._color = new TinyColor(color);\n const format = this._color.format;\n let isString = typeof color === 'string' || color instanceof String;\n\n if (format.startsWith('hex')) {\n isString = (color as string).startsWith('#');\n }\n\n this._format = {\n format,\n isString,\n };\n\n if (isString && format.startsWith('hs')) {\n const values = extractHueAndSaturationRegExp.exec(color as string);\n\n if (values !== null) {\n const [, h, s] = values;\n this.value = Number(h);\n this._saturation = Number(s);\n }\n } else if (!isString && format.startsWith('hs')) {\n const colorInput = this._color.originalInput;\n const colorValues = Object.values(colorInput);\n this.value = colorValues[0];\n this._saturation = colorValues[1];\n } else {\n const { h } = this._color.toHsv();\n this.value = h;\n }\n this.requestUpdate('color', oldValue);\n }\n\n private _color = new TinyColor({ h: 0, s: 1, v: 1 });\n\n private _previousColor = new TinyColor({ h: 0, s: 1, v: 1 });\n\n private _saturation!: number;\n\n private _format: { format: string; isString: boolean } = {\n format: '',\n isString: false,\n };\n private get altered(): number {\n return this._altered;\n }\n\n private set altered(altered: number) {\n this._altered = altered;\n this.step = Math.max(1, this.altered * 10);\n }\n\n private _altered = 0;\n\n @query('input')\n public input!: HTMLInputElement;\n\n public get focusElement(): HTMLInputElement {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { key } = event;\n this.focused = true;\n this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(\n (key) => !!key\n ).length;\n let delta = 0;\n switch (key) {\n case 'ArrowUp':\n delta = this.step;\n break;\n case 'ArrowDown':\n delta = -this.step;\n break;\n case 'ArrowLeft':\n delta = this.step * (this.isLTR ? -1 : 1);\n break;\n case 'ArrowRight':\n delta = this.step * (this.isLTR ? 1 : -1);\n break;\n default:\n return;\n }\n event.preventDefault();\n this.value = (360 + this.value + delta) % 360;\n this._previousColor = this._color.clone();\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this._color = this._previousColor;\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n }\n\n private handleChange(event: Event & { target: HTMLInputElement }): void {\n this.handleInput(event);\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n public focus(focusOptions: FocusOptions = {}): void {\n super.focus(focusOptions);\n this.forwardFocus();\n }\n\n private forwardFocus(): void {\n const activeElement = (this.getRootNode() as Document)\n .activeElement as HTMLElement;\n if (activeElement) {\n let shouldFocus = false;\n try {\n // Browsers without support for the `:focus-visible`\n // selector will throw on the following test (Safari, older things).\n // Some won't throw, but will be focusing item rather than the menu and\n // will rely on the polyfill to know whether focus is \"visible\" or not.\n shouldFocus =\n activeElement.matches(':focus-visible') ||\n activeElement.matches('.focus-visible');\n } catch (error) {\n shouldFocus = activeElement.matches('.focus-visible');\n }\n this.focused = shouldFocus;\n }\n this.input.focus();\n }\n\n private handleFocusin(): void {\n this.focused = true;\n }\n\n private handleFocusout(): void {\n if (this._pointerDown) {\n return;\n }\n this.altered = 0;\n this.focused = false;\n }\n\n private boundingClientRect!: DOMRect;\n private _pointerDown = false;\n\n private handlePointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n event.preventDefault();\n return;\n }\n this._pointerDown = true;\n this._previousColor = this._color.clone();\n this.boundingClientRect = this.getBoundingClientRect();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if (event.pointerType === 'mouse') {\n this.focused = true;\n }\n }\n\n private handlePointermove(event: PointerEvent): void {\n this.value = this.calculateHandlePosition(event);\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n private handlePointerup(event: PointerEvent): void {\n this._pointerDown = false;\n (event.target as HTMLElement).releasePointerCapture(event.pointerId);\n\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this._color = this._previousColor;\n }\n // Retain focus on input element after mouse up to enable keyboard interactions\n this.focus();\n if (event.pointerType === 'mouse') {\n this.focused = false;\n }\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(event: PointerEvent): number {\n /* c8 ignore next 3 */\n if (!this.boundingClientRect) {\n return this.value;\n }\n const rect = this.boundingClientRect;\n const { width, height, left, top } = rect;\n const centerX = left + width / 2;\n const centerY = top + height / 2;\n const pointX = event.clientX - centerX;\n const pointY = event.clientY - centerY;\n const value = (Math.atan2(pointY, pointX) * 180) / Math.PI;\n\n return (360 + (360 + value)) % 360;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (\n event.button !== 0 ||\n (event.target as SVGElement).classList.contains('innerCircle')\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n this.handle.dispatchEvent(new PointerEvent('pointerdown', event));\n this.handlePointermove(event);\n }\n\n protected render(): TemplateResult {\n const { width: diameter = 160 } = this.boundingClientRect || {};\n\n const radius = diameter / 2;\n const trackWidth = 24;\n const innerRadius = radius - trackWidth;\n const innerDiameter = innerRadius * 2;\n const clipPath = `path(evenodd, \"M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0\")`;\n const handleLocationStyles = `transform: translate(${\n (radius - 12.5) * Math.cos((this.value * Math.PI) / 180)\n }px, ${(radius - 12.5) * Math.sin((this.value * Math.PI) / 180)}px);`;\n return html`\n <slot\n name=\"gradient\"\n @pointerdown=${this.handleGradientPointerdown}\n >\n <div class=\"wheel\" style=\"clip-path: ${clipPath}\"></div>\n </slot>\n\n <sp-color-handle\n tabindex=${ifDefined(this.focused ? undefined : '0')}\n @focus=${this.forwardFocus}\n ?focused=${this.focused}\n class=\"handle\"\n color=\"hsl(${this.value}, 100%, 50%)\"\n ?disabled=${this.disabled}\n style=${handleLocationStyles}\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [['pointerup', 'pointercancel'], this.handlePointerup],\n })}\n ></sp-color-handle>\n\n <input\n type=\"range\"\n class=\"slider\"\n aria-label=${this.label}\n min=\"0\"\n max=\"360\"\n step=${this.step}\n .value=${String(this.value)}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeydown}\n />\n `;\n }\n\n protected firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.boundingClientRect = this.getBoundingClientRect();\n this.addEventListener('focusin', this.handleFocusin);\n this.addEventListener('focusout', this.handleFocusout);\n }\n\n private observer?: WithSWCResizeObserver['ResizeObserver'];\n\n public connectedCallback(): void {\n super.connectedCallback();\n if (\n !this.observer &&\n ((window as unknown) as WithSWCResizeObserver).ResizeObserver\n ) {\n this.observer = new ((window as unknown) as WithSWCResizeObserver).ResizeObserver(\n (entries: SWCResizeObserverEntry[]) => {\n for (const entry of entries) {\n this.boundingClientRect = entry.contentRect;\n }\n this.requestUpdate();\n }\n );\n }\n this.observer?.observe(this);\n }\n\n public disconnectedCallback(): void {\n this.observer?.unobserve(this);\n super.disconnectedCallback();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ColorWheel.js","sourceRoot":"","sources":["ColorWheel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EACH,IAAI,EAGJ,QAAQ,EACR,KAAK,EAEL,SAAS,GACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAC7E,OAAO,0DAA0D,CAAC;AAClE,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAGH,6BAA6B,EAC7B,6BAA6B,GAChC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,SAAS;IAAzC;;QAMW,aAAQ,GAAG,KAAK,CAAC;QAGjB,YAAO,GAAG,KAAK,CAAC;QAMhB,UAAK,GAAG,KAAK,CAAC;QAGd,SAAI,GAAG,CAAC,CAAC;QAmBR,WAAM,GAAG,CAAC,CAAC;QA2FX,WAAM,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAE7C,mBAAc,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAIrD,YAAO,GAA0C;YACrD,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,KAAK;SAClB,CAAC;QAUM,aAAQ,GAAG,CAAC,CAAC;QA8Gb,iBAAY,GAAG,KAAK,CAAC;IAuKjC,CAAC;IAvaU,MAAM,KAAK,MAAM;QAC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,CAAC;YACzB,CAAC,CACJ,CAAC;SACL;QACD,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEM,oBAAoB;;QACvB,MAAA,IAAI,CAAC,QAAQ,0CAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC/B,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;CACJ;AAlaG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACnB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACpB;AAGvB;IADC,KAAK,CAAC,SAAS,CAAC;0CACY;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACN;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCACX;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAG1B;AAiBD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAiD1B;AA8DD;IADC,KAAK,CAAC,OAAO,CAAC;yCACiB","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n html,\n CSSResultArray,\n TemplateResult,\n property,\n query,\n PropertyValues,\n ifDefined,\n} from '@spectrum-web-components/base';\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport { WithSWCResizeObserver, SWCResizeObserverEntry } from './types';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport styles from './color-wheel.css.js';\nimport {\n ColorHandle,\n ColorValue,\n extractHueAndSaturationRegExp,\n replaceHueAndSaturationRegExp,\n} from '@spectrum-web-components/color-handle';\nimport { TinyColor } from '@ctrl/tinycolor';\n\n/**\n * @element sp-color-wheel\n * @slot gradient - a custom gradient visually outlining the available color values\n */\nexport class ColorWheel extends Focusable {\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.handle')\n private handle!: ColorHandle;\n\n @property({ type: String })\n public label = 'hue';\n\n @property({ type: Number })\n public step = 1;\n\n @property({ type: Number })\n public get value(): number {\n return this._value;\n }\n\n public set value(hue: number) {\n const value = Math.min(360, Math.max(0, hue));\n if (value === this.value) {\n return;\n }\n const oldValue = this.value;\n const { s, v } = this._color.toHsv();\n this._color = new TinyColor({ h: value, s, v });\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n private _value = 0;\n\n @property({ type: String })\n public get color(): ColorValue {\n switch (this._format.format) {\n case 'rgb':\n return this._format.isString\n ? this._color.toRgbString()\n : this._color.toRgb();\n case 'prgb':\n return this._format.isString\n ? this._color.toPercentageRgbString()\n : this._color.toPercentageRgb();\n case 'hex':\n case 'hex3':\n case 'hex4':\n case 'hex6':\n return this._format.isString\n ? this._color.toHexString()\n : this._color.toHex();\n case 'hex8':\n return this._format.isString\n ? this._color.toHex8String()\n : this._color.toHex8();\n case 'name':\n return this._color.toName() || this._color.toRgbString();\n case 'hsl':\n if (this._format.isString) {\n const hslString = this._color.toHslString();\n return hslString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.value}$2${this._saturation}`\n );\n } else {\n const { s, l, a } = this._color.toHsl();\n return { h: this.value, s, l, a };\n }\n case 'hsv':\n if (this._format.isString) {\n const hsvString = this._color.toHsvString();\n return hsvString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.value}$2${this._saturation}`\n );\n } else {\n const { s, v, a } = this._color.toHsv();\n return { h: this.value, s, v, a };\n }\n default:\n return 'No color format applied.';\n }\n }\n\n public set color(color: ColorValue) {\n if (color === this.color) {\n return;\n }\n const oldValue = this._color;\n this._color = new TinyColor(color);\n const format = this._color.format;\n let isString = typeof color === 'string' || color instanceof String;\n\n if (format.startsWith('hex')) {\n isString = (color as string).startsWith('#');\n }\n\n this._format = {\n format,\n isString,\n };\n\n if (isString && format.startsWith('hs')) {\n const values = extractHueAndSaturationRegExp.exec(color as string);\n\n if (values !== null) {\n const [, h, s] = values;\n this.value = Number(h);\n this._saturation = Number(s);\n }\n } else if (!isString && format.startsWith('hs')) {\n const colorInput = this._color.originalInput;\n const colorValues = Object.values(colorInput);\n this.value = colorValues[0];\n this._saturation = colorValues[1];\n } else {\n const { h } = this._color.toHsv();\n this.value = h;\n }\n this.requestUpdate('color', oldValue);\n }\n\n private _color = new TinyColor({ h: 0, s: 1, v: 1 });\n\n private _previousColor = new TinyColor({ h: 0, s: 1, v: 1 });\n\n private _saturation!: number;\n\n private _format: { format: string; isString: boolean } = {\n format: '',\n isString: false,\n };\n private get altered(): number {\n return this._altered;\n }\n\n private set altered(altered: number) {\n this._altered = altered;\n this.step = Math.max(1, this.altered * 10);\n }\n\n private _altered = 0;\n\n @query('input')\n public input!: HTMLInputElement;\n\n public get focusElement(): HTMLInputElement {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { key } = event;\n this.focused = true;\n this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(\n (key) => !!key\n ).length;\n let delta = 0;\n switch (key) {\n case 'ArrowUp':\n delta = this.step;\n break;\n case 'ArrowDown':\n delta = -this.step;\n break;\n case 'ArrowLeft':\n delta = this.step * (this.isLTR ? -1 : 1);\n break;\n case 'ArrowRight':\n delta = this.step * (this.isLTR ? 1 : -1);\n break;\n default:\n return;\n }\n event.preventDefault();\n this.value = (360 + this.value + delta) % 360;\n this._previousColor = this._color.clone();\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this._color = this._previousColor;\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n }\n\n private handleChange(event: Event & { target: HTMLInputElement }): void {\n this.handleInput(event);\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n public focus(focusOptions: FocusOptions = {}): void {\n super.focus(focusOptions);\n this.forwardFocus();\n }\n\n private forwardFocus(): void {\n const activeElement = (this.getRootNode() as Document)\n .activeElement as HTMLElement;\n if (activeElement) {\n let shouldFocus = false;\n try {\n // Browsers without support for the `:focus-visible`\n // selector will throw on the following test (Safari, older things).\n // Some won't throw, but will be focusing item rather than the menu and\n // will rely on the polyfill to know whether focus is \"visible\" or not.\n shouldFocus =\n activeElement.matches(':focus-visible') ||\n activeElement.matches('.focus-visible');\n } catch (error) {\n shouldFocus = activeElement.matches('.focus-visible');\n }\n this.focused = shouldFocus;\n }\n this.input.focus();\n }\n\n private handleFocusin(): void {\n this.focused = true;\n }\n\n private handleFocusout(): void {\n if (this._pointerDown) {\n return;\n }\n this.altered = 0;\n this.focused = false;\n }\n\n private boundingClientRect!: DOMRect;\n private _pointerDown = false;\n\n private handlePointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n event.preventDefault();\n return;\n }\n this._pointerDown = true;\n this._previousColor = this._color.clone();\n this.boundingClientRect = this.getBoundingClientRect();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if (event.pointerType === 'mouse') {\n this.focused = true;\n }\n }\n\n private handlePointermove(event: PointerEvent): void {\n this.value = this.calculateHandlePosition(event);\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n private handlePointerup(event: PointerEvent): void {\n this._pointerDown = false;\n (event.target as HTMLElement).releasePointerCapture(event.pointerId);\n\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this._color = this._previousColor;\n }\n // Retain focus on input element after mouse up to enable keyboard interactions\n this.focus();\n if (event.pointerType === 'mouse') {\n this.focused = false;\n }\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(event: PointerEvent): number {\n /* c8 ignore next 3 */\n if (!this.boundingClientRect) {\n return this.value;\n }\n const rect = this.boundingClientRect;\n const { width, height, left, top } = rect;\n const centerX = left + width / 2;\n const centerY = top + height / 2;\n const pointX = event.clientX - centerX;\n const pointY = event.clientY - centerY;\n const value = (Math.atan2(pointY, pointX) * 180) / Math.PI;\n\n return (360 + (360 + value)) % 360;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (\n event.button !== 0 ||\n (event.target as SVGElement).classList.contains('innerCircle')\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n this.handle.dispatchEvent(new PointerEvent('pointerdown', event));\n this.handlePointermove(event);\n }\n\n protected render(): TemplateResult {\n const { width: diameter = 160 } = this.boundingClientRect || {};\n\n const radius = diameter / 2;\n const trackWidth = 24;\n const innerRadius = radius - trackWidth;\n const innerDiameter = innerRadius * 2;\n const clipPath = `path(evenodd, \"M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0\")`;\n const handleLocationStyles = `transform: translate(${\n (radius - 12.5) * Math.cos((this.value * Math.PI) / 180)\n }px, ${(radius - 12.5) * Math.sin((this.value * Math.PI) / 180)}px);`;\n return html`\n <slot\n name=\"gradient\"\n @pointerdown=${this.handleGradientPointerdown}\n >\n <div class=\"wheel\" style=\"clip-path: ${clipPath}\"></div>\n </slot>\n\n <sp-color-handle\n tabindex=${ifDefined(this.focused ? undefined : '0')}\n @focus=${this.forwardFocus}\n ?focused=${this.focused}\n class=\"handle\"\n color=\"hsl(${this.value}, 100%, 50%)\"\n ?disabled=${this.disabled}\n style=${handleLocationStyles}\n @manage=${streamingListener(\n { type: 'pointerdown', fn: this.handlePointerdown },\n { type: 'pointermove', fn: this.handlePointermove },\n {\n type: ['pointerup', 'pointercancel'],\n fn: this.handlePointerup,\n }\n )}\n ></sp-color-handle>\n\n <input\n type=\"range\"\n class=\"slider\"\n aria-label=${this.label}\n min=\"0\"\n max=\"360\"\n step=${this.step}\n .value=${String(this.value)}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeydown}\n />\n `;\n }\n\n protected firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.boundingClientRect = this.getBoundingClientRect();\n this.addEventListener('focusin', this.handleFocusin);\n this.addEventListener('focusout', this.handleFocusout);\n }\n\n private observer?: WithSWCResizeObserver['ResizeObserver'];\n\n public connectedCallback(): void {\n super.connectedCallback();\n if (\n !this.observer &&\n ((window as unknown) as WithSWCResizeObserver).ResizeObserver\n ) {\n this.observer = new ((window as unknown) as WithSWCResizeObserver).ResizeObserver(\n (entries: SWCResizeObserverEntry[]) => {\n for (const entry of entries) {\n this.boundingClientRect = entry.contentRect;\n }\n this.requestUpdate();\n }\n );\n }\n this.observer?.observe(this);\n }\n\n public disconnectedCallback(): void {\n this.observer?.unobserve(this);\n super.disconnectedCallback();\n }\n}\n"]}
|
package/src/color-wheel.css.js
CHANGED
|
@@ -11,26 +11,36 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
import { css } from '@spectrum-web-components/base';
|
|
13
13
|
const styles = css `
|
|
14
|
-
:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(
|
|
14
|
+
:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(
|
|
15
|
+
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
16
|
+
)}:host([focused]) .handle{height:calc(var(
|
|
15
17
|
--spectrum-colorhandle-size,
|
|
16
18
|
var(--spectrum-global-dimension-size-200)
|
|
17
19
|
)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(
|
|
18
20
|
--spectrum-colorhandle-size,
|
|
19
21
|
var(--spectrum-global-dimension-size-200)
|
|
20
|
-
)*2)}.slider{height:100%;left:0;margin:0;opacity
|
|
22
|
+
)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(
|
|
23
|
+
--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)
|
|
24
|
+
);position:relative;-webkit-user-select:none;user-select:none;width:var(
|
|
25
|
+
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
26
|
+
)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(
|
|
21
27
|
--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)
|
|
22
|
-
);box-sizing:border-box;height:var(
|
|
28
|
+
);box-sizing:border-box;height:var(
|
|
29
|
+
--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)
|
|
30
|
+
);position:relative;width:var(
|
|
31
|
+
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
32
|
+
);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(
|
|
23
33
|
--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)
|
|
24
34
|
)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(
|
|
25
|
-
--spectrum-colorarea-border-color
|
|
35
|
+
--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)
|
|
26
36
|
)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(
|
|
27
|
-
--spectrum-colorwheel-border-color-disabled,var(--spectrum-
|
|
37
|
+
--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)
|
|
28
38
|
)}:host([disabled]) .outerCircle{fill:var(
|
|
29
|
-
--spectrum-colorwheel-fill-color-disabled,var(--spectrum-
|
|
39
|
+
--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)
|
|
30
40
|
)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(
|
|
31
|
-
--spectrum-colorwheel-border-color
|
|
41
|
+
--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)
|
|
32
42
|
)}.innerCircle,.outerCircle{stroke:var(
|
|
33
|
-
--spectrum-colorwheel-border-color
|
|
43
|
+
--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)
|
|
34
44
|
)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}:host{touch-action:none}:host(:focus){outline:none}.wheel{background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);height:100%;width:100%}.wheel:after,.wheel:before{border:var(
|
|
35
45
|
--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)
|
|
36
46
|
) solid var(--spectrum-colorwheel-border-color);border-radius:50%;content:"";position:absolute}.wheel:after{bottom:0;left:0;right:0;top:0}.wheel:before{bottom:24px;left:24px;right:24px;top:24px}:host([disabled]) .wheel:after,:host([disabled]) .wheel:before{border-color:var(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-wheel.css.js","sourceRoot":"","sources":["color-wheel.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"color-wheel.css.js","sourceRoot":"","sources":["color-wheel.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n);box-sizing:border-box;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .outerCircle{fill:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}.innerCircle,.outerCircle{stroke:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}:host{touch-action:none}:host(:focus){outline:none}.wheel{background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);height:100%;width:100%}.wheel:after,.wheel:before{border:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n) solid var(--spectrum-colorwheel-border-color);border-radius:50%;content:\"\";position:absolute}.wheel:after{bottom:0;left:0;right:0;top:0}.wheel:before{bottom:24px;left:24px;right:24px;top:24px}:host([disabled]) .wheel:after,:host([disabled]) .wheel:before{border-color:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-global-color-gray-300)\n)}:host([disabled]) .wheel{background:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-global-color-gray-300)\n)}\n`;\nexport default styles;"]}
|
|
@@ -11,26 +11,36 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
import { css } from '@spectrum-web-components/base';
|
|
13
13
|
const styles = css `
|
|
14
|
-
:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(
|
|
14
|
+
:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(
|
|
15
|
+
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
16
|
+
)}:host([focused]) .handle{height:calc(var(
|
|
15
17
|
--spectrum-colorhandle-size,
|
|
16
18
|
var(--spectrum-global-dimension-size-200)
|
|
17
19
|
)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(
|
|
18
20
|
--spectrum-colorhandle-size,
|
|
19
21
|
var(--spectrum-global-dimension-size-200)
|
|
20
|
-
)*2)}.slider{height:100%;left:0;margin:0;opacity
|
|
22
|
+
)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(
|
|
23
|
+
--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)
|
|
24
|
+
);position:relative;-webkit-user-select:none;user-select:none;width:var(
|
|
25
|
+
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
26
|
+
)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(
|
|
21
27
|
--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)
|
|
22
|
-
);box-sizing:border-box;height:var(
|
|
28
|
+
);box-sizing:border-box;height:var(
|
|
29
|
+
--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)
|
|
30
|
+
);position:relative;width:var(
|
|
31
|
+
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
32
|
+
);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(
|
|
23
33
|
--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)
|
|
24
34
|
)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(
|
|
25
|
-
--spectrum-colorarea-border-color
|
|
35
|
+
--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)
|
|
26
36
|
)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(
|
|
27
|
-
--spectrum-colorwheel-border-color-disabled,var(--spectrum-
|
|
37
|
+
--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)
|
|
28
38
|
)}:host([disabled]) .outerCircle{fill:var(
|
|
29
|
-
--spectrum-colorwheel-fill-color-disabled,var(--spectrum-
|
|
39
|
+
--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)
|
|
30
40
|
)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(
|
|
31
|
-
--spectrum-colorwheel-border-color
|
|
41
|
+
--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)
|
|
32
42
|
)}.innerCircle,.outerCircle{stroke:var(
|
|
33
|
-
--spectrum-colorwheel-border-color
|
|
43
|
+
--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)
|
|
34
44
|
)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}
|
|
35
45
|
`;
|
|
36
46
|
export default styles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectrum-color-wheel.css.js","sourceRoot":"","sources":["spectrum-color-wheel.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"spectrum-color-wheel.css.js","sourceRoot":"","sources":["spectrum-color-wheel.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));margin-top:calc(-1*var(--spectrum-colorhandle-size, var(--spectrum-global-dimension-size-200)));width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n);box-sizing:border-box;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .outerCircle{fill:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}.innerCircle,.outerCircle{stroke:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}\n`;\nexport default styles;"]}
|