Comments (4)
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.
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.
@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.
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)
- Compose class inside media query
- Late styles loading in Next 13 HOT 3
- Class name prop not overriding component styles HOT 4
- Issue with duplicate class hashes
- Does the order of implementation of a class matter when there are two classes with the same parameters? HOT 1
- typo in https://github.com/css-modules/css-modules/blob/master/docs/local-scope.md HOT 1
- RFC: Support for hashing more types of identifiers HOT 8
- Another rant about not being able to import a class from another file
- not so good logo HOT 1
- Compose classes with attribute selector
- Best way to override styling found in module a based on module b. HOT 1
- How pseudo class :global should work๏ผ HOT 2
- ID vs Class
- Rules nesting HOT 1
- Understanding "composes" peer classes HOT 2
- It should throw an error if you use a class that doesn't exist
- Proposal: Handover Official Lead of CSS Modules to Devon Govett HOT 1
- Define how CSS modules interacts with `@layer` HOT 1
- bug: composes keyword does not work inside nested class
- how to style child Component when child and parent both use css.module? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-modules.