Giter VIP home page Giter VIP logo

Comments (5)

yoshuawuyts avatar yoshuawuyts commented on May 22, 2024

For prefixing an approach similar to https://github.com/requireio/wrap-selectors might be interesting, though you say it won't work well when writing out to a file.css. Can you elaborate?

As for the cascading: I think the top level > lower level seems like a good approach. Some level of cascade would be nice though; reset.css-ish styles could be provided by low level components on which higher level components can in turn build. Currently that doesn't work since the component expects a class to exist on the element before css can render.

from base-element.

shama avatar shama commented on May 22, 2024

wrap-selectors looks interesting but I didn't like how you need to use custom syntax @document wrap() { }. I'd prefer if I could just write regular CSS relative to the element and the API would figure out what to do, especially with nested elements. That way existing CSS/compile-to-CSS can be brfs or attached to elements more easily.

you say it won't work well when writing out to a file.css. Can you elaborate?

If the class name is dynamically generated, it will be different upon each initialization. So if previously compiled to a file.css, the selectors localizing to the element will no longer be correct. Besides enforcing a user supplied root class on each element, I'm not sure yet of a better way to solve that.

Some level of cascade would be nice though;

I agree. It would be nice if the element author had some control over how it will cascade. It would also help optimize to avoid selectors like: .my-table .super-table .base-table for deeply nested situations.

My main goal is an elegant alternative to inline styles. Elements provide an overridable static style for a separately served asset or if the user really wants to avoid the request, an inline nonce'd style tag. Then do element.style[key] = val for all dynamic styles. That way I can disable inline style outright in my CSP.

from base-element.

yoshuawuyts avatar yoshuawuyts commented on May 22, 2024

It appears webpack is also scoping css: https://github.com/markdalgleish/postcss-local-scope. Not sure I like their non-standard :global syntax though. Also doesn't deal with cascading styles. Ghmmh, gonna ponder a little on this.

from base-element.

shama avatar shama commented on May 22, 2024

I agree. Let me know if you come up with more options for us to try. I moved the attachCSS stuff into it's own module: https://github.com/shama/attach-css

from base-element.

yoshuawuyts avatar yoshuawuyts commented on May 22, 2024

Opened an issue about this on attach-css - shama/attach-css#1

from base-element.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.