From 57159a2443b776b78128bfd9a83b2aa3de1a8342 Mon Sep 17 00:00:00 2001 From: Jenn Diaz Date: Wed, 22 Feb 2023 10:11:46 -0700 Subject: [PATCH] feat(color-wheel): use core tokens --- packages/color-wheel/package.json | 2 +- packages/color-wheel/src/ColorWheel.ts | 31 ++- packages/color-wheel/src/color-wheel.css | 64 +---- .../color-wheel/src/spectrum-color-wheel.css | 243 ++++++++++-------- .../color-wheel/src/spectrum-config.v2.js | 14 +- .../stories/color-wheel.stories.ts | 2 +- packages/color-wheel/test/color-wheel.test.ts | 5 +- scripts/spectrum-tokens.js | 1 + yarn.lock | 8 +- 9 files changed, 194 insertions(+), 176 deletions(-) diff --git a/packages/color-wheel/package.json b/packages/color-wheel/package.json index 7541fa8b26..3a6be9558d 100644 --- a/packages/color-wheel/package.json +++ b/packages/color-wheel/package.json @@ -68,7 +68,7 @@ "@spectrum-web-components/shared": "^0.15.5" }, "devDependencies": { - "@spectrum-css/colorwheel": "^1.0.27" + "@spectrum-css/colorwheel": "^2.0.0" }, "types": "./src/index.d.ts", "customElements": "custom-elements.json", diff --git a/packages/color-wheel/src/ColorWheel.ts b/packages/color-wheel/src/ColorWheel.ts index 4783db5606..ae40fce3e8 100644 --- a/packages/color-wheel/src/ColorWheel.ts +++ b/packages/color-wheel/src/ColorWheel.ts @@ -291,16 +291,39 @@ export class ColorWheel extends Focusable { const trackWidth = 24; const innerRadius = radius - trackWidth; const innerDiameter = innerRadius * 2; - 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")`; + const clipPathBorders = `"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"`; + const clipPath = `"M ${radius - 1} ${radius - 1} m -${radius - 1} 0 a ${ + radius - 1 + } ${radius - 1} 0 1 0 ${diameter - 2} 0 a ${radius - 1} ${ + radius - 1 + } 0 1 0 -${diameter - 2} 0 M ${radius - 1} ${radius - 1} m -${ + innerRadius + 1 + } 0 a ${innerRadius + 1} ${innerRadius + 1} 0 1 0 ${ + innerDiameter + 2 + } 0 a ${innerRadius + 1} ${innerRadius + 1} 0 1 0 -${ + innerDiameter + 2 + } 0"`; const handleLocationStyles = `transform: translate(${ - (radius - 12.5) * Math.cos((this.value * Math.PI) / 180) - }px, ${(radius - 12.5) * Math.sin((this.value * Math.PI) / 180)}px);`; + (radius - 12) * Math.cos((this.value * Math.PI) / 180) + }px, ${(radius - 12) * Math.sin((this.value * Math.PI) / 180)}px);`; return html` -
+
+
+
+
+
+
{ testForLitDevWarnings( async () => @@ -359,7 +362,7 @@ describe('ColorWheel', () => { html` ` ); diff --git a/scripts/spectrum-tokens.js b/scripts/spectrum-tokens.js index df021a855c..490377c052 100644 --- a/scripts/spectrum-tokens.js +++ b/scripts/spectrum-tokens.js @@ -56,6 +56,7 @@ const tokenPackages = [ 'progressbar', 'picker', 'colorarea', + 'colorwheel', ]; const packagePaths = tokenPackages.map((packageName) => { diff --git a/yarn.lock b/yarn.lock index f0724b2253..947469c7c7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4334,10 +4334,10 @@ resolved "https://registry.yarnpkg.com/@spectrum-css/colorslider/-/colorslider-2.0.13.tgz#c5cb6aeb6e26c61e775e06e40c23e33742f8cbad" integrity sha512-o3hHzO4LHDS/QRe42PJecgO7YLhK0buxBt9Ky1XZWXrhTzSTJezyF0PKaSOyPJa6OaS9YprWt+nnv1NIBzfg4Q== -"@spectrum-css/colorwheel@^1.0.27": - version "1.0.27" - resolved "https://registry.yarnpkg.com/@spectrum-css/colorwheel/-/colorwheel-1.0.27.tgz#42742d932123962aa2cd236ab0bddcfc4e7726f0" - integrity sha512-bsvMeVMTzscpNP1WswOTBVHTSVQMS0zwhl0fkjm1Rgvc/l4TFpftssMC7QS6dQjqF+ijhItno1O7bKDiJ/N4xQ== +"@spectrum-css/colorwheel@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@spectrum-css/colorwheel/-/colorwheel-2.0.0.tgz#a50ece1cd010a20bb5aece8bf824b05ddb8a2622" + integrity sha512-V62K5pbCJrypMIO4LSg8osHopTdU54qhaAQ4tRd7kmbQObfQ9aL8VXOoen5U88OAilhnjtULaHW8SUlr2aG9pg== "@spectrum-css/commons@^4.0.2": version "4.0.2"