Coder Social home page Coder Social logo

Comments (4)

geelen avatar geelen commented on June 3, 2024

Hey @kenkouot, this is a perfect spot to ask the question, and it's a good one :)

I'd love if you could provide a bit of a code example about what these "noop" elements might look like. The best I can think of is a "container" element, much like the default container in React Native, which went on to inspire @necolas' React Native Web. But I don't really know my way around modern Polymer/Web Component patterns for stuff like this, so I'd love some guidance there.

As for your two points, it is true that CSS Modules requires your markup to be dynamic so it can inject the compiled classnames, but that doesn't necessarily have to be JS, and certainly doesn't need to be at runtime. CSS Modules is a very natural fit for React projects at the moment (see https://github.com/gajus/react-css-modules), but we're working on making it slot into other workflows. I've started a project to figure out a good API for using CSS Modules without JS. If you've got any thoughts I'd be happy to hear them.

As for CSS Modules vs "the standards", there certainly is a sense that CSS Modules is trying to do now what new proposals hope to do in the future, so there's going to be some points where they're incompatible. But what I think we're really hoping for is a coffeescript-style outcome, where by building out from what's possible right now we help inform the "real" specifications as they mature, as CS did with ES6.

But as far as I'm concerned, the purpose of CSS Modules is to explore whether it is truly beneficial in organising and maintaining styles. I would suggest the same of style-in-JS projects like Radium as well as the React-Native-for-the-web or "noop" Polymer components. For me, the most powerful idea in CSS Modules is composition, where you can deconstruct your visual inventory into atomic classes, and assemble them at a module level, without duplicating markup or hindering performance. I'm yet to see a concept in the alternative approaches that I've felt has been a "omg must have!" that's made me want to steer CSS Modules in that direction. But I'm still looking eagerly.

So please send through some examples and we can discuss some concrete use-cases, if you like.

from css-modules.

studiosciences avatar studiosciences commented on June 3, 2024

I was trying to find out how polymer did their "combining styles scoped to a custom element by default" with a polyfill, but I couldn't quite figure out how that worked in the cases of containers. Does it use a descendent selector or prefix all class names?

Descendent selectors can be problematic when one element/view contains another:

<element-a>
    <a class="button">

    <element-b>
         <a class="button">
    </element-b>
<element-a>

How does Polymer address the conflict that both classes use the same name, but should be styled completely differently? In CSS Modules, element a's button class will have a different hash than element b's button, so it will not cascade.

from css-modules.

sergeylukin avatar sergeylukin commented on June 3, 2024

@studiosciences Regardless to Polymer, something like theme parameter could be accepted by button component, that way all styles will be inside that component and they will always have same hash. If button need to look different when inside <element-b>, you may be interested to check out this topic: #40 Hope that helps

from css-modules.

kevinSuttle avatar kevinSuttle commented on June 3, 2024

Same question for React elements. I know they render to standard DOM elements, but I'm wondering from a CSS process perspective if there is a way to (or if it's not recommended to) base styling off of JSX names.

NotificationMessage {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, sans-serif;
  font-weight: 400;
  font-style: normal;
  color: #5a0017;
  font-size: .75rem;
  padding-left: 0.875em;
  margin-left: 7.7em;
}

from css-modules.

Related Issues (20)

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.