Skip to content

Conversation

@DmitrySharabin
Copy link
Member

@DmitrySharabin DmitrySharabin commented Aug 5, 2025

It makes things like this possible:
image


This is part 2 of 2 in a stack made with GitButler:

let dummy;
if (document) {
dummy = document.createElement("div");
document.body.appendChild(dummy);
Copy link
Member

Choose a reason for hiding this comment

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

We absolutely don't want our component modifying the light DOM to add elements, that's very much seen as an antipattern. But also, resolving based on <body> values is suboptimal, we want to resolve on the element itself.
If we went that route, we could have a shadow DOM dummy element to resolve with, but I'm not sure we need it. color-scale uses color-swatch, and all the resolving should happen there. Why does color-scale need to resolve anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I'll give it another try

Copy link
Member Author

@DmitrySharabin DmitrySharabin Aug 5, 2025

Choose a reason for hiding this comment

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

Why does color-scale need to resolve anything?

<color-scale>s have the colors prop that should be initiated and parsed before any <color-swatch> can be created and rendered. If we don't resolve colors, Color.js will throw an error for any unsupported color, and the scale's color property will remain undefined. As a result, no color swatches will be created.

I might miss something, but I don't see a way to resolve colors on <color-swatch>s instead of on <color-scale>s. 🤷‍♂️

As an example:

image image

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, and I tried to use the element itself to resolve colors, but at the time the colors prop is initialized, this corresponds to the prop, not the element. So, if we decide to use a dummy element in the element's shadow DOM, I'm unsure how to access it when we need it.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. Let me think about it. I wonder if the right solution involves changes to Color.js and Nude Element. I have some ideas.

@DmitrySharabin DmitrySharabin force-pushed the issue-212-color-scale branch from a662e22 to 90f2bcc Compare August 6, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants