-
Notifications
You must be signed in to change notification settings - Fork 209
feat(colorwheel): S2 migration #3390
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| "@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. `::before` and `::after` pseudo elements are now used to draw the exterior and interior borders that overlay the exterior and interior edges of the color wheel. | ||
|
|
||
| Support is provided for the `240px` and `192px` sizes outlined in the design requirements. | ||
|
|
||
| The `forced-colors` media query has been moved to the bottom of the file consistent with our other component implementations. | ||
|
|
||
| Stories, tests and documentation have been updated to be consistent with these changes. | ||
|
|
||
| The following mods have been removed: | ||
|
|
||
| ```css | ||
| --mod-colorwheel-height | ||
| --mod-colorwheel-width | ||
| --mod-colorwheel-min-width | ||
| --mod-colorwheel-path-borders | ||
| --mod-colorwheel-colorarea-margin | ||
| --mod-colorwheel-border-width | ||
| ``` |
|
jawinn marked this conversation as resolved.
|
| 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 | ||
|
|
@@ -11,46 +11,81 @@ | |
| * 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .spectrum-ColorWheel { | ||
| --spectrum-colorwheel-inline-size: var(--spectrum-color-wheel-width); | ||
| --spectrum-colorwheel-block-size: var(--spectrum-color-wheel-width); | ||
| --spectrum-colorwheel-min-inline-size: var(--spectrum-color-wheel-minimum-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.
|
||
|
|
||
| .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-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-border-width: var(--spectrum-border-width-100); | ||
|
marissahuysentruyt marked this conversation as resolved.
|
||
| --spectrum-colorwheel-track-width: var(--spectrum-color-control-track-width); | ||
|
|
||
| --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); | ||
|
cdransf marked this conversation as resolved.
|
||
|
|
||
| position: relative; | ||
| display: block; | ||
| min-inline-size: var(--mod-colorwheel-min-width, var(--spectrum-color-wheel-minimum-width)); | ||
| inline-size: var(--spectrum-colorwheel-width); | ||
| block-size: var(--spectrum-colorwheel-height); | ||
| min-inline-size: var(--mod-colorwheel-min-inline-size, var(--spectrum-colorwheel-min-inline-size)); | ||
| inline-size: var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)); | ||
| block-size: var(--mod-colorwheel-block-size, var(--spectrum-colorwheel-block-size)); | ||
| user-select: none; | ||
| cursor: default; | ||
|
|
||
| /** | ||
| * Color wheel exterior border | ||
| * - Calcs for `inline-size` and `block-size` subtract 4 times the component's border width | ||
| * (to account for the inset width of the exterior border) from the component's width. | ||
| */ | ||
| &::before { | ||
|
cdransf marked this conversation as resolved.
|
||
| inline-size: calc(var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)) - calc(4 * var(--spectrum-colorwheel-border-width))); | ||
| block-size: calc(var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)) - calc(4 * var(--spectrum-colorwheel-border-width))); | ||
| inset: 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; | ||
| } | ||
|
|
||
| /** | ||
| * Color wheel interior border | ||
| * - Calcs for `inset` 2 times the component's border width from the | ||
| * track width (to account for the inset width of the interior border) | ||
| */ | ||
| &::after { | ||
| inset: calc(var(--mod-colorwheel-track-width, var(--spectrum-colorwheel-track-width)) - (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; | ||
| } | ||
|
|
||
| &.is-focused { | ||
| z-index: 2; | ||
| } | ||
|
|
||
| &.is-disabled { | ||
| pointer-events: none; | ||
|
|
||
| &::before, | ||
| &::after, | ||
| .spectrum-ColorWheel-inner::before { | ||
| border-color: var(--highcontrast-colorwheel-border-color-disabled, transparent); | ||
| } | ||
| } | ||
|
|
||
| &.is-dragged { | ||
|
|
@@ -77,7 +112,6 @@ | |
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| margin: var(--mod-colorwheel-colorarea-margin, var(--spectrum-color-wheel-color-area-margin)); | ||
| } | ||
|
|
||
| .spectrum-ColorWheel-slider { | ||
|
|
@@ -93,7 +127,7 @@ | |
| } | ||
|
|
||
| .spectrum-ColorWheel-handle { | ||
| transform: translate(calc(var(--spectrum-colorwheel-width) / 2 - var(--spectrum-colorwheel-track-width) / 2), 0); | ||
| transform: translate(calc(var(--mod-colorwheel-inline-size, var(--spectrum-colorwheel-inline-size)) / 2 - var(--mod-colorwheel-track-width, 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.
|
||
| } | ||
|
|
@@ -107,19 +141,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); | ||
|
|
@@ -129,6 +150,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 */ | ||
|
jawinn marked this conversation as resolved.
|
||
| @media (forced-colors: active) { | ||
| .spectrum-ColorWheel { | ||
| --highcontrast-colorwheel-border-color-disabled: GrayText; | ||
| --highcontrast-colorwheel-fill-color-disabled: Canvas; | ||
|
|
||
| forced-color-adjust: none; | ||
| } | ||
| } | ||
|
jawinn marked this conversation as resolved.
|




Uh oh!
There was an error while loading. Please reload this page.