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(colorloupe): migrate to s2 drop-shadow tokens #3301

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/strange-glasses-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spectrum-css/colorloupe": major
---

Migrates color loupe to Spectrum 2 tokens. Color loupe now uses the new drop shadow tokens `--spectrum-drop-shadow-elevated-x`, `--spectrum-drop-shadow-elevated-y`, `--spectrum-drop-shadow-elevated-blur`, and `--spectrum-drop-shadow-elevated-color` rather than specific color loupe tokens.
107 changes: 52 additions & 55 deletions components/colorloupe/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,87 +9,84 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/
.spectrum-ColorLoupe {
--spectrum-colorloupe-width: var(--spectrum-color-loupe-width);
--spectrum-colorloupe-height: var(--spectrum-color-loupe-height);
--spectrum-colorloupe-width: var(--spectrum-color-loupe-width);
--spectrum-colorloupe-height: var(--spectrum-color-loupe-height);

--spectrum-colorloupe-offset: var(--spectrum-color-loupe-bottom-to-color-handle);
--spectrum-colorloupe-animation-distance: 8px; /* TODO: replace with forthcoming animation token */
--spectrum-colorloupe-offset: var(--spectrum-color-loupe-bottom-to-color-handle);
--spectrum-colorloupe-animation-distance: 8px; /* TODO: replace with forthcoming animation token */

--spectrum-colorloupe-drop-shadow-x: var(--spectrum-drop-shadow-x);
--spectrum-colorloupe-drop-shadow-y: var(--spectrum-color-loupe-drop-shadow-y);
--spectrum-colorloupe-drop-shadow-blur: var(--spectrum-color-loupe-drop-shadow-blur);
--spectrum-colorloupe-drop-shadow-color: var(--spectrum-color-loupe-drop-shadow-color);
--spectrum-colorloupe-drop-shadow-x: var(--spectrum-drop-shadow-elevated-x);
--spectrum-colorloupe-drop-shadow-y: var(--spectrum-drop-shadow-elevated-y);
--spectrum-colorloupe-drop-shadow-blur: var(--spectrum-drop-shadow-elevated-blur);
--spectrum-colorloupe-drop-shadow-color: var(--spectrum-drop-shadow-elevated-color);

--spectrum-colorloupe-outer-border-width: var(--spectrum-color-loupe-outer-border-width);
--spectrum-colorloupe-inner-border-width: var(--spectrum-color-loupe-inner-border-width);
--spectrum-colorloupe-outer-border-color: var(--spectrum-color-loupe-outer-border);
--spectrum-colorloupe-inner-border-color: var(--spectrum-color-loupe-inner-border);
--spectrum-colorloupe-outer-border-width: var(--spectrum-color-loupe-outer-border-width);
--spectrum-colorloupe-inner-border-width: var(--spectrum-color-loupe-inner-border-width);
marissahuysentruyt marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +23 to +24
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we let design know that there's just a typo in the Border section of the tokens file? I think the second color-loupe-outer-border (which is supposed to be transparent black 200) is meant to say color-loupe-inner-border. Do they want to update and correct that?

--spectrum-colorloupe-outer-border-color: var(--spectrum-color-loupe-outer-border);
--spectrum-colorloupe-inner-border-color: var(--spectrum-color-loupe-inner-border);

--spectrum-colorloupe-checkerboard-dark-color: var(--spectrum-opacity-checkerboard-square-dark);
--spectrum-colorloupe-checkerboard-light-color: var(--spectrum-opacity-checkerboard-square-light);
--spectrum-colorloupe-checkerboard-dark-color: var(--spectrum-opacity-checkerboard-square-dark);
--spectrum-colorloupe-checkerboard-light-color: var(--spectrum-opacity-checkerboard-square-light);
}

.spectrum-ColorLoupe {
inline-size: var(--spectrum-colorloupe-width);
block-size: var(--spectrum-colorloupe-height);

position: absolute;
transform: translate(0, var(--mod-colorloupe-animation-distance, var(--spectrum-colorloupe-animation-distance)));
opacity: 0;
transform-origin: bottom center;
inset-block-end: calc((var(--spectrum-color-handle-size) - var(--spectrum-color-handle-outer-border-width)) + var(--mod-colorloupe-offset, var(--spectrum-colorloupe-offset)));
inset-inline-end: calc(50% - (var(--spectrum-colorloupe-width) / 2));

transition: transform 100ms ease-in-out, opacity 125ms ease-in-out;
pointer-events: none;

filter:drop-shadow(
var(--mod-colorloupe-drop-shadow-x, var(--spectrum-colorloupe-drop-shadow-x))
var(--mod-colorloupe-drop-shadow-y, var(--spectrum-colorloupe-drop-shadow-y))
var(--mod-colorloupe-drop-shadow-blur, var(--spectrum-colorloupe-drop-shadow-blur))
var(--mod-colorloupe-drop-shadow-color, var(--spectrum-colorloupe-drop-shadow-color))
);

&:dir(rtl) {
inset-inline-end: calc(50% - (var(--spectrum-colorloupe-width) / 2) - 1px);;
rise-erpelding marked this conversation as resolved.
Show resolved Hide resolved
}

&.is-open {
transform: translate(0, 0);
opacity: 1;
}
inline-size: var(--spectrum-colorloupe-width);
block-size: var(--spectrum-colorloupe-height);

position: absolute;
transform: translate(0, var(--mod-colorloupe-animation-distance, var(--spectrum-colorloupe-animation-distance)));
opacity: 0;
transform-origin: bottom center;
inset-block-end: calc((var(--spectrum-color-handle-size) - var(--spectrum-color-handle-outer-border-width)) + var(--mod-colorloupe-offset, var(--spectrum-colorloupe-offset)));
inset-inline-end: calc(50% - (var(--spectrum-colorloupe-width) / 2));

transition:
transform 100ms ease-in-out,
opacity 125ms ease-in-out;
pointer-events: none;

filter: drop-shadow(var(--mod-colorloupe-drop-shadow-x, var(--spectrum-colorloupe-drop-shadow-x)) var(--mod-colorloupe-drop-shadow-y, var(--spectrum-colorloupe-drop-shadow-y)) var(--mod-colorloupe-drop-shadow-blur, var(--spectrum-colorloupe-drop-shadow-blur)) var(--mod-colorloupe-drop-shadow-color, var(--spectrum-colorloupe-drop-shadow-color)));

&:dir(rtl) {
inset-inline-end: calc(50% - (var(--spectrum-colorloupe-width) / 2) - 1px);
}

&.is-open {
transform: translate(0, 0);
opacity: 1;
}
}

.spectrum-ColorLoupe-inner-border {
/* Undefined variable allows custom stylesheet or JS to pass the value to this element */
fill: var(--spectrum-picked-color);
stroke: var(--mod-colorloupe-inner-border-color, var(--spectrum-colorloupe-inner-border-color));
stroke-width: var(--mod-colorloupe-inner-border-width, var(--spectrum-colorloupe-inner-border-width));
/* Undefined variable allows custom stylesheet or JS to pass the value to this element */
fill: var(--spectrum-picked-color);
stroke: var(--mod-colorloupe-inner-border-color, var(--spectrum-colorloupe-inner-border-color));
stroke-width: var(--mod-colorloupe-inner-border-width, var(--spectrum-colorloupe-inner-border-width));
}

.spectrum-ColorLoupe-outer-border {
fill: none;
stroke: var(--highcontrast-colorloupe-outer-border-color, var(--mod-colorloupe-outer-border-color, var(--spectrum-colorloupe-outer-border-color)));
stroke-width: calc(var(--mod-colorloupe-outer-border-width, var(--spectrum-colorloupe-outer-border-width)) + 2px);
fill: none;
stroke: var(--highcontrast-colorloupe-outer-border-color, var(--mod-colorloupe-outer-border-color, var(--spectrum-colorloupe-outer-border-color)));
stroke-width: calc(var(--mod-colorloupe-outer-border-width, var(--spectrum-colorloupe-outer-border-width)) + 2px);
}

/* The checkerboard classes use opacity checkerboard tokens for dark and light color.
The opacity-checkerboard-square-size token is not able to be used witin the SVG pattern and instead colorloupe.yml is using two different patterns toggled by --spectrum-colorloupe-checkerboard-fill */

.spectrum-ColorLoupe-checkerboard-pattern {
fill: var(--spectrum-colorloupe-checkerboard-dark-color);
fill: var(--spectrum-colorloupe-checkerboard-dark-color);
}

.spectrum-ColorLoupe-checkerboard-background {
fill: var(--spectrum-colorloupe-checkerboard-light-color);
fill: var(--spectrum-colorloupe-checkerboard-light-color);
}

.spectrum-ColorLoupe-checkerboard-fill {
fill: var(--spectrum-colorloupe-checkerboard-fill);
fill: var(--spectrum-colorloupe-checkerboard-fill);
}

@media (forced-colors: active) {
.spectrum-ColorLoupe {
--highcontrast-colorloupe-outer-border-color: CanvasText;
}
.spectrum-ColorLoupe {
--highcontrast-colorloupe-outer-border-color: CanvasText;
}
}
Loading