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

Attempt to eliminate the flash of undefined custom elements #190

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DmitrySharabin
Copy link
Member

@DmitrySharabin DmitrySharabin commented Dec 19, 2024

The proposed change is very well observed in the <color-chart> element: https://deploy-preview-190--color-elements.netlify.app/src/color-chart/

Copy link

netlify bot commented Dec 19, 2024

Deploy Preview for color-elements ready!

Name Link
🔨 Latest commit 4d2f1e7
🔍 Latest deploy log https://app.netlify.com/sites/color-elements/deploys/6764559a168e3f00084cc22e
😎 Deploy Preview https://deploy-preview-190--color-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

:is(${ colorTags.join(", ") }) {
opacity: 0;

body:not(.loading-global-color-element-styles) &:defined {
Copy link
Member

Choose a reason for hiding this comment

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

Also, ideally this should be solved in Nude Element (via a mixin): components should define their dependencies via a static property, and then these styles are generated for all dependencies.

@@ -80,6 +89,23 @@ const Self = class ColorElement extends NudeElement {
}

customElements.define(this.tagName, this);

if (this.globalStyle) {
// NudeElement imports global styles using `@import url()` inside an `<style>` element with a `data-for` attribute equal to the element's tag name
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, looks like this was a bit overfit. We should definitely support verbatim styles being included, not just URLs. We could probably even detect the two so the user can just give us an array of strings

Copy link
Member Author

@DmitrySharabin DmitrySharabin Dec 23, 2024

Choose a reason for hiding this comment

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

That's a very good idea. With something like this do: nudeui/element#43?

It allows us completely remove this code block. Probably, we won't need this PR at all, if we implement your proposal above. We'll see. 🙂

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