Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(colorwheel): S2 migration #3390

Open
wants to merge 24 commits into
base: spectrum-two
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0da2c55
feat(colorwheel): s2 migration
cdransf Jan 6, 2025
726f4a6
chore(colorwheel): update property name
cdransf Jan 22, 2025
5f7cbb2
chore(colorwheel): wip inset borders
cdransf Jan 25, 2025
7c52020
chore(colorwheel): fix lint violations
cdransf Jan 28, 2025
7b7b5e7
chore(colorwheel): move mod declarations
cdransf Jan 28, 2025
f65af8d
chore(colorwheel): drop unused property + update metadata
cdransf Jan 28, 2025
5512957
chore(colorwheel): remove underlying border node + class
cdransf Jan 28, 2025
26019ce
chore(colorwheel): remove unused property
cdransf Jan 28, 2025
1753e49
fix(colorwheel): add missing mod
cdransf Jan 30, 2025
2876b00
fix(colorwheel): comments for updated before spacing/positioning
cdransf Jan 30, 2025
5309c2f
fix(colorwheel): adopt proper token for border opacity
cdransf Jan 30, 2025
501ac69
fix(colorwheel): remove inset border on disabled state
cdransf Jan 30, 2025
0d9b843
fix(colorwheel): remove global token reference
cdransf Jan 30, 2025
c5f47be
chore(colorwheel): highlight removed/added mods
cdransf Jan 30, 2025
146574a
chore(colorwheel): update copyright year
cdransf Jan 30, 2025
4be152e
chore(colorwheel): add color loupe to default story
cdransf Jan 30, 2025
83fd7b2
fix(colorwheel): correct WHC disabled background color value
cdransf Jan 30, 2025
95d0be6
chore(colorwheel): update test heading
cdransf Feb 4, 2025
61dfd71
fix(colorwheel): typos
cdransf Feb 4, 2025
a3dc5d0
chore(colorwheel): update token usage
cdransf Feb 4, 2025
b8b040a
chore(colorwheel): add without loupe test
cdransf Feb 4, 2025
1515e5d
chore(colorwheel): restore WHC styles
cdransf Feb 4, 2025
cfe49cb
chore(colorwheel): move isWithColorLoupe property
cdransf Feb 4, 2025
2454e32
fix(colorwheel): whc disabled background
cdransf Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/giant-windows-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
"@spectrum-css/colorwheel": major
---

# colorwheel S2 migration

This change migrates the colorwheel component to S2. It adds the `--spectrum-colorwheel-border-color-rgb` and `--spectrum-colorwheel-border-opacity` custom properties. It updates `--spectrum-colorwheel-border-color` to leverage these tokens in an `rgba(...)` function.

This removes the `spectrum-ColorWheel-border` and associated template DOM node as the outside/underlying border are no longer present in the S2 designs.
cdransf marked this conversation as resolved.
Show resolved Hide resolved

The following mods have been removed:

```css
--mod-colorwheel-height
--mod-colorwheel-path-borders
--mod-colorwheel-track-width
--mod-colorwheel-width
```

The mod `--mod-colorwheel-track-width` has been added.
21 changes: 12 additions & 9 deletions components/colorwheel/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
".spectrum-ColorWheel",
".spectrum-ColorWheel-ColorArea-handle",
".spectrum-ColorWheel-ColorArea-handle:dir(rtl)",
".spectrum-ColorWheel-border",
".spectrum-ColorWheel-border.is-disabled",
".spectrum-ColorWheel-colorarea-container",
".spectrum-ColorWheel-handle",
".spectrum-ColorWheel-inner",
".spectrum-ColorWheel-inner:before",
".spectrum-ColorWheel-slider",
".spectrum-ColorWheel-wheel",
".spectrum-ColorWheel-wheel.is-disabled",
".spectrum-ColorWheel.is-disabled",
".spectrum-ColorWheel.is-disabled .spectrum-ColorWheel-inner:before",
".spectrum-ColorWheel.is-disabled:before",
".spectrum-ColorWheel.is-dragged",
".spectrum-ColorWheel.is-focused",
".spectrum-ColorWheel:before",
"[dir=\"rtl\"] .spectrum-ColorWheel-ColorArea-handle"
],
"modifiers": [
Expand All @@ -23,32 +25,33 @@
"--mod-colorwheel-colorarea-container-size",
"--mod-colorwheel-colorarea-margin",
"--mod-colorwheel-fill-color-disabled",
"--mod-colorwheel-height",
"--mod-colorwheel-min-width",
"--mod-colorwheel-min-inline-size",
"--mod-colorwheel-path",
"--mod-colorwheel-path-borders",
"--mod-colorwheel-track-width",
"--mod-colorwheel-width"
"--mod-colorwheel-track-width"
],
"component": [
"--spectrum-color-wheel-border-opacity",
"--spectrum-color-wheel-color-area-margin",
"--spectrum-color-wheel-minimum-width",
"--spectrum-color-wheel-width",
"--spectrum-colorwheel-border-color",
"--spectrum-colorwheel-border-color-rgb",
"--spectrum-colorwheel-border-opacity",
"--spectrum-colorwheel-border-width",
"--spectrum-colorwheel-colorarea-container-size",
"--spectrum-colorwheel-colorarea-margin",
"--spectrum-colorwheel-fill-color-disabled",
"--spectrum-colorwheel-height",
"--spectrum-colorwheel-min-inline-size",
"--spectrum-colorwheel-path",
"--spectrum-colorwheel-path-borders",
"--spectrum-colorwheel-track-width",
"--spectrum-colorwheel-width"
],
"global": [
"--spectrum-border-width-100",
"--spectrum-color-control-track-width",
"--spectrum-disabled-background-color",
"--spectrum-transparent-black-300"
"--spectrum-gray-1000-rgb"
],
"passthroughs": [],
"high-contrast": [
Expand Down
102 changes: 66 additions & 36 deletions components/colorwheel/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2024 Adobe. All rights reserved.
* Copyright 2025 Adobe. All rights reserved.
*
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
Expand All @@ -11,46 +11,64 @@
* governing permissions and limitations under the License.
*/

/* Windows High Contrast Mode */
@media (forced-colors: active) {
.spectrum-ColorWheel {
--highcontrast-colorwheel-border-color-disabled: GrayText;
--highcontrast-colorwheel-fill-color-disabled: Canvas;
Comment on lines -17 to -18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally spoke too soon on the WHCM stuff! I left an updated (more thought-through 😬 ) idea that should replicate what's on prod better now.

Looks like we still need the gradient itself, and then I have a better idea how to replicate this disabled state now:
(this is production when I test in AssistivLabs)
Screenshot 2025-02-04 at 9 03 56 AM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm — took a look at current state in Assistiv and it looks better, but I'm not sure if it's exactly what we want?

image

Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah....I think there's a discrepancy between Canvas and CanvasText. I believe swapping this --highcontrast-colorwheel-fill-color-disabled: Canvas; instead of CanvasText should get rid of that white background in the disabled wheel.

Screenshot 2025-02-05 at 12 58 00 PM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yep!
image

.spectrum-ColorWheel {
--spectrum-colorwheel-width: var(--spectrum-color-wheel-width);
--spectrum-colorwheel-height: var(--spectrum-color-wheel-width);

forced-color-adjust: none;
}
}
/* @TODO: leveraging the rgb token in this case to achieve the desired border color implementation as rgb + opacity are required by the `rgba` function. */
--spectrum-colorwheel-border-color-rgb: var(--spectrum-gray-1000-rgb);
cdransf marked this conversation as resolved.
Show resolved Hide resolved

.spectrum-ColorWheel {
--spectrum-colorwheel-border-color: var(--spectrum-transparent-black-300);
--spectrum-colorwheel-border-opacity: var(--spectrum-color-wheel-border-opacity);
--spectrum-colorwheel-border-color: rgba(var(--spectrum-colorwheel-border-color-rgb), var(--spectrum-colorwheel-border-opacity));

--spectrum-colorwheel-border-width: var(--spectrum-border-width-100);
marissahuysentruyt marked this conversation as resolved.
Show resolved Hide resolved
--spectrum-colorwheel-track-width: var(--spectrum-color-control-track-width);

--spectrum-colorwheel-min-inline-size: var(--spectrum-color-wheel-minimum-width);

--spectrum-colorwheel-width: var(--mod-colorwheel-width, var(--spectrum-color-wheel-width));
--spectrum-colorwheel-height: var(--mod-colorwheel-height, var(--spectrum-color-wheel-width));
--spectrum-colorwheel-fill-color-disabled: var(--mod-colorwheel-fill-color-disabled, var(--spectrum-disabled-background-color));
--spectrum-colorwheel-border-color: var(--spectrum-transparent-black-300);
--spectrum-colorwheel-colorarea-margin: var(--spectrum-color-wheel-color-area-margin);

--spectrum-colorwheel-border-width: var(--mod-colorwheel-border-width, var(--spectrum-border-width-100));
--spectrum-colorwheel-track-width: var(--mod-colorwheel-track-width, var(--spectrum-color-control-track-width));
--spectrum-colorwheel-fill-color-disabled: var(--spectrum-disabled-background-color);

/* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used with JS in calculating the clip-path paths and colorarea-container-size */
--_track-width: var(--spectrum-colorwheel-track-width);
--_track-width: var(--mod-colorwheel-track-width, var(--spectrum-colorwheel-track-width));
/* stylelint-disable-next-line spectrum-tools/no-unused-custom-properties -- used with JS in calculating the clip-path paths and colorarea-container-size */
--_border-width: var(--spectrum-colorwheel-border-width);
--_border-width: var(--mod-colorwheel-border-width, var(--spectrum-colorwheel-border-width));

position: relative;
display: block;
min-inline-size: var(--mod-colorwheel-min-width, var(--spectrum-color-wheel-minimum-width));
min-inline-size: var(--mod-colorwheel-min-inline-size, var(--spectrum-colorwheel-min-inline-size));
inline-size: var(--spectrum-colorwheel-width);
block-size: var(--spectrum-colorwheel-height);
user-select: none;
cursor: default;

/* calcs wrapping --spectrum-colorwheel-border-width are used to properly position the border drawn using this ::before pseudo element over the exterior edge of the colorwheel. The size is reduced and positioning adjusted to create the border effect. */
&::before {
cdransf marked this conversation as resolved.
Show resolved Hide resolved
inline-size: calc(var(--spectrum-colorwheel-width) - calc(4 * var(--spectrum-colorwheel-border-width)));
block-size: calc(var(--spectrum-colorwheel-width) - calc(4 * var(--spectrum-colorwheel-border-width)));
inset-block-start: var(--spectrum-colorwheel-border-width);
inset-inline-start: var(--spectrum-colorwheel-border-width);
content: "";
position: absolute;
border-width: var(--spectrum-colorwheel-border-width);
border-style: solid;
border-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color));
border-radius: 100%;
z-index: 1;
}

&.is-focused {
z-index: 2;
}

&.is-disabled {
pointer-events: none;

&::before,
.spectrum-ColorWheel-inner::before {
border-color: var(--highcontrast-colorwheel-border-color-disabled, transparent);
}
}

&.is-dragged {
Expand All @@ -69,6 +87,21 @@
inline-size: var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size));
block-size: var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size));
margin: auto;

/* calcs wrapping --spectrum-colorwheel-border-width are used to properly position the border drawn using this ::before pseudo element over the interior edge of the colorwheel. The size is increased and positioning adjusted to create the border effect. */
&::before {
inline-size: calc(var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size)) + calc(2 * var(--spectrum-colorwheel-border-width)));
block-size: calc(var(--mod-colorwheel-colorarea-container-size, var(--spectrum-colorwheel-colorarea-container-size)) + calc(2 * var(--spectrum-colorwheel-border-width)));
inset-block-start: calc(-2 * var(--spectrum-colorwheel-border-width));
inset-inline-start: calc(-2 * var(--spectrum-colorwheel-border-width));
content: "";
position: absolute;
border-width: var(--spectrum-colorwheel-border-width);
border-style: solid;
border-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color));
border-radius: 100%;
z-index: 1;
}
}

.spectrum-ColorWheel-colorarea-container {
Expand All @@ -77,7 +110,7 @@
display: flex;
align-items: center;
justify-content: center;
margin: var(--mod-colorwheel-colorarea-margin, var(--spectrum-color-wheel-color-area-margin));
margin: var(--mod-colorwheel-colorarea-margin, var(--spectrum-colorwheel-colorarea-margin));
}

.spectrum-ColorWheel-slider {
Expand All @@ -93,7 +126,7 @@
}

.spectrum-ColorWheel-handle {
transform: translate(calc(var(--spectrum-colorwheel-width) / 2 - var(--spectrum-colorwheel-track-width) / 2), 0);
transform: translate(calc(var(--spectrum-colorwheel-width) / 2 - var(--mod-colorwheel-track-width, var(--spectrum-colorwheel-track-width)) / 2), 0);
inset-block-start: 50%;
inset-inline: 50%;
cdransf marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -107,19 +140,6 @@
}
}

/* a clip-path set border-width wider than than spectrum-colorwheel-wheel to create the appreance of a border */
.spectrum-ColorWheel-border {
position: relative;
background-color: var(--mod-colorwheel-border-color, var(--spectrum-colorwheel-border-color));
inline-size: var(--spectrum-colorwheel-width);
block-size: var(--spectrum-colorwheel-height);
clip-path: path(evenodd, var(--mod-colorwheel-path-borders, var(--spectrum-colorwheel-path-borders)));

&.is-disabled {
background-color: var(--highcontrast-colorwheel-border-color-disabled, var(--spectrum-colorwheel-fill-color-disabled));
}
}

.spectrum-ColorWheel-wheel {
position: absolute;
background: conic-gradient(from 90deg, red, rgb(255 128 0), rgb(255 255 0), rgb(128 255 0), rgb(0 255 0), rgb(0 255 128), rgb(0 255 255), rgb(0 128 255), rgb(0 0 255), rgb(128 0 255), rgb(255 0 255), rgb(255 0 128), red);
Expand All @@ -129,6 +149,16 @@

&.is-disabled {
pointer-events: none;
background: var(--highcontrast-colorwheel-fill-color-disabled, var(--spectrum-colorwheel-fill-color-disabled));
background: var(--highcontrast-colorwheel-fill-color-disabled, var(--mod-colorwheel-fill-color-disabled, var(--spectrum-colorwheel-fill-color-disabled)));
}
}

/* Windows High Contrast Mode */
@media (forced-colors: active) {
.spectrum-ColorWheel {
--highcontrast-colorwheel-border-color-disabled: GrayText;
--highcontrast-colorwheel-fill-color-disabled: Canvas;

forced-color-adjust: none;
}
}
12 changes: 11 additions & 1 deletion components/colorwheel/stories/colorwheel.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ export default {
if: { arg: "isDisabled", truthy: false },
},
isWithColorArea: {
name: "With Color Area",
name: "With color area",
type: { name: "boolean" },
table: {
type: { summary: "boolean" },
category: "State",
},
control: "boolean",
},
isWithColorLoupe: {
name: "With color loupe",
cdransf marked this conversation as resolved.
Show resolved Hide resolved
type: { name: "boolean" },
table: {
type: { summary: "boolean" },
Expand All @@ -44,6 +53,7 @@ export default {
isDisabled: false,
isFocused: false,
isWithColorArea: false,
isWithColorLoupe: true,
selectedColor: "rgba(255, 0, 0, 50%)",
},
parameters: {
Expand Down
4 changes: 4 additions & 0 deletions components/colorwheel/stories/colorwheel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export const ColorWheelGroup = Variants({
testHeading: "With color area",
isWithColorArea: true,
},
{
testHeading: "Without color loupe",
isWithColorLoupe: false,
},
],
stateData: [
{
Expand Down
11 changes: 4 additions & 7 deletions components/colorwheel/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const Template = ({
isDisabled = false,
isFocused = false,
isWithColorArea = false,
isWithColorLoupe = true,
colorHandleStyle = {},
selectedColor = "rgba(255, 0, 0, 50%)",
} = {}, context = {}) => {
Expand All @@ -37,20 +38,16 @@ export const Template = ({
</div>
</div>
<div class=${classMap({
[`${rootClass}-border`]: true,
[`${rootClass}-wheel`]: true,
"is-disabled": isDisabled,
})}>
<div class=${classMap({
[`${rootClass}-wheel`]: true,
"is-disabled": isDisabled,
})}></div>
</div>
})}></div>
${ColorHandle({
isDisabled,
isFocused,
customClasses: [`${rootClass}-handle`],
selectedColor,
customStyles: colorHandleStyle,
isWithColorLoupe,
}, context)}
<input type="range" class="${rootClass}-slider" aria-label="hue" min="0" max="360" step="">
</div>
Expand Down
Loading