Hacker News new | past | comments | ask | show | jobs | submit login
CSS Modules (glenmaddern.com)
281 points by geelen on Aug 19, 2015 | hide | past | favorite | 90 comments



It's wonderful that CSS problems have been distilled so clearly, it's been a long time coming. Radium[1] is really worth checking out, it's simple and clear.

From the article:

  /* BEM */
  .normal { /* all styles for Normal */ }
  .button--disabled { /* overrides for Disabled */ }
  .button--error { /* overrides for Error */ }
  .button--in-progress { /* overrides for In Progress */

  /* CSS MODULES */
  .normal { /* all styles for Normal */ }
  .disabled { /* all styles for Disabled */ }
  .error { /* all styles for Error */ }
  .inProgress { /* all styles for In Progress */

  > In CSS Modules each class should have all the styles needed for that variant
This seems like trading one set of problems for another. It violates DRY and consequently impacts code maintainability. The corollary is that .disabled should @include .normal and then define the overrides so you only have to define the base styles once in .normal... but that also requires discipline and code wrangling.

  > [BEM] requires an awful lot of cognitive effort around naming discipline.
But the proposed alternative is not too different either:

  /* components/submit-button.css */
  .error { ... }
  .inProgress { ... }
This example just replaces BEM naming and namespacing with file naming and directory structure.

[1]: https://github.com/FormidableLabs/radium

EDIT: On second reading, the stuff in there is definitely not "Welcome to the future" exploring the "adjacent possible" realm--those are quite grandoise pretexts to a solution that is just as unwieldy.


Regarding your first point, he addresses that in the next section:

"The composes keyword says that .normal includes all the styles from .common, much like the @extends keyword in Sass. But while Sass rewrites your CSS selectors to make that happen, CSS Modules changes which classes are exported to JavaScript."

And isn't file (module) naming and directory structure what we use to organize regular code? I like the idea of going to the components folder and looking for the 'submit button' file when I need to alter something much more than searching a 20,000 line css file or randomly split scss files. Even nicer is the concept of including your styles in the same directory as the components they define, further mirroring normal code organization. It seems like this would allow for much easier onboarding into a project.


I am not saying it's a bad idea. However, it trades one set of problems for another. What point is there in highlighting a problem and then proposing a remedy which introduces the same problems in a different form?

> I like the idea of going to the components folder and looking for the 'submit button'

All existing frameworks use the same approach (Bootstrap, Foundation, et al). GetMDL.io for example uses BEM and clean files to organize code https://github.com/google/material-design-lite/tree/master/s...

Dealing with that on any reasonably sized project still requires "naming discipline" and "cognitive effort", both of which the author highlights as problems ailing BEM with a remedy that still suffer from the same. It didn't read very convincingly.


> The corollary is that .disabled should @include .normal and then define the overrides so you only have to define the base styles once in .normal... but that also requires discipline and code wrangling.

If I'm using .btn-disabled everywhere, then its hard to be to write a CSS rule that says 'whenever a button follows another button, apply this style to it'. That's why we have this competition with BEM and `.btn .disabled`.

> This example just replaces BEM naming and namespacing with file naming and directory structure.

...Yes. That's the point.

The problem is that CSS is a global 'language', and everything that you write has the chance to impact all your other CSS. When I'm writing a particular component, there's no way to write CSS that's local to just that component.

We have things like BEM that is about establishing a _convention_ to write Pseudo-Local-CSS, but nothing is enforced. Everything is still global. 'CSS Modules' enforces your CSS to be 'local only' as a file-level, just like regular (Node) JS.

It's like how there's a convention of not adding a string to an integer, but adding a type system to your programming language enforces that on a technical, contractual level.


Except as far as I can tell, with Radium you get zero support for pseudo classes and media queries until after the client-side JavaScript has downloaded and been initialised. This is acceptable if it's purely a client-side app, but if you're using an kind of server-side rendering it's clearly not good enough.

I really don't want a lack of hover or focus effects on initial page load, and I really don't want my entire page layout to change once the JavaScript-powered media queries kick in.


Radium is simple, for that I like it. Complexity comes with a price and there may be alternatives but Radium leverages JS expressions which I like. Quoting from the article again:

  /* components/submit-button.jsx */
  import { Component } from 'react';
  import styles from './submit-button.css';
  
  export default class SubmitButton extends Component {
    render() {
      let className, text = "Submit"
      if (this.props.store.submissionInProgress) {
        className = styles.inProgress
        text = "Processing..."
      } else if (this.props.store.errorOccurred) {
        className = styles.error
      } else if (!this.props.form.valid) {
        className = styles.disabled
      } else {
        className = styles.normal
      }
      return <button className={className}>{text}</button>
    }
  }

That looks unwieldy -- 4 if/else clauses just to deal with CSS. Contrast that with the example in "Usage" over at the Radium page https://github.com/FormidableLabs/radium -- much simpler.


If we were to mirror the approach of the Radium example, we'd actually end up with something more like this:

  import React from 'React';
  import styles from './SubmitButton.css';

  class SubmitButton extends Component {
    defaultProps = {
      kind: 'default'
    }
    
    render() {
      const { kind } = this.props;
      const text = kind === 'in-progress' ? 'Processing...' : 'Submit';
      
      return <button className={styles[kind]}>{text}</button>
    }
  }


A lot of the latest thinking in (non-JS) CSS suggests that violating DRY is an excellent idea. Copy and pasting CSS rules is cheap, but maintaining and adapting a large complex CSS project that's blowing up in a team's face can be very expensive.


It feels to me that this conversation is quite old I'm finding myself not convinced by the examples put forward in the article. It looks like a lot of unnecessary complexity. You can have a lot of success by simply picking a common css convention.

  .mybutton
    /* all styles for Normal */
  .mybutton.disabled
    /* overrides for Disabled */
  .mybutton.error
    /* overrides for Error */
  .mybutton.in-progress
    /* overrides for In Progress */
This is simpler and works incredibly well with javascript because I don't have to find replace remove a subset. I just addClass('disabled') removeClass('disabled').


Now what if you wanted to bring in another button - a very similar one - with slightly different styles?


You extend the styles now you perhaps have:

  .mybutton
    /* all styles for Normal */
  .mybutton.skewed
    /* overrides for Skewed */
  .mybutton.disabled
    /* overrides for Disabled */

  class="mybutton skewed disabled"
The suggestion in the OP would be that each one of those classes contain all of the styles for the button. That isn't necessary. Plus it requires, what I count, a minimum of two additional language abstractions in order to do it.


Excellent answer. I love these "gotcha" examples when taking something that should be relatively simple and trying to make it more complicated to prove, um, something.

I wish people would realize that making their CSS more complicated and bloated is not necessarily the answer.


I agree, a lot of these solutions come from bad CSS. Not because CSS is bad.


That so much CSS is "bad CSS" indicates that the problem isn't the craftsman so much as the tool...


Ah, I see, so when I attempt to use a hammer as a wrench I can claim the hammer is a horrible tool.

CSS does exactly what it was designed to do and does it quite well. It only goes "bad" when people attempt to make it do things it wasn't designed to do. Blaming the tool for that is the sign of a bad craftsman.


Exactly: CSS wasn't designed for the problems we're trying to solve. We're trying to invent the proverbial wrench.


Then stop blaming the tool for bad craftsmanship. Maybe if we lay the blame where it belongs then something constructive might appear.


I agree. I tend to prefix my modifiers with "is-", though so that you know it is a modifier. e.g. ".mybutton.is-skewed" and then never have a standalone ".is-" rule. They are always modifiers only.


The modifier I use is longer, but I might switch to is-, that seems like a nice convention.


So... CSS has the same global namespace issue as C, and this CSS Modules is the same solution as C++ namespaces and classes. They call it "mangling".

https://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in...

(further commentary prudently withheld)


But just as with C++, that's effectively an implementation detail, and irrelevant to the larger issues addressed. BEM itself is just name-mangling structured for humans to execute manually. (wait, WAT.) We're talking about the cognitive model and load that designers and developers have to deal with when authoring styles.

I see CSS Modules (and Radium and ...) as being a space for experiments that I hope will ultimately point the way to better "baked in" solutions. Similar to how ideas from Coffeescript were "merged back upstream" into ES6/ES7.


I agree that mangling isn't ideal but the naming resolution rules are already defined in every browser and they use a global namespace! From a distance, I don't see a better approach to providing namespace-like-things.


I might be a majority shareholder of the following opinion, but I feel like it needs to be said.

CSS was an art, and a science. Websites like csszengarden.com showed us the promise of style sheets, and the galleries of "CSS sites" during the mid to late 2000s demonstrated what amazing works could be taken from photoshop (and Fireworks!) and made into beautiful, pixel-perfect layouts. I always felt proud to make a website with only semantic HTML and CSS, and it always worked well. Even with all the browser issues (namely those of IE6), it was easy to write cross-browser compatible code that was clean and beautiful. The (C)ascading part of CSS was still considered a feature, and deeply understanding its implications was an acceptable challenge.

Then came The Age of Great Coupling & Frameworks (made that name up) wherein CSS began to be regarded as a hindrance. Frameworks like Bootstrap became the status quo, because it meant you could go from 0% to 60% in half the time. But, no longer did anybody decide to go to 100%. The coupling I speak of isn't just a coupling of backend to frontend technologies, but a coupling of backend to frontend workflows. In a subconscious effort to become more efficient, we, as software engineers, began to find ways to incorporate automatic solutions for every problem (e.g., LESS). This is partly due to the very slow nature of completing and proliferating new CSS specifications, but in the long run all of these tools and frameworks have grown the barriers of entry, and have bifurcated the community in many ways (e.g., LESS vs SASS, responsive framework vs pure CSS, non-standard with polyfill vs standard, etc.).

These differences are not the kinds of differences that cause anger (usually), but they make it hard to hire and train, and they make it hard for frontend engineers to work together easily. At the end of the day we're all building CSS and HTML with JavaScript, but if I strike up a conversation with 3 different frontend engineers, each will be as different as if I had chosen to talk to an astronaut, a vet tech, and a professional swimmer. That's almost no exaggeration. Diversity of skills and tasks within an occupation is a good thing, but at some extreme it decreases mobility. When I felt like I had learned CSS, well years ago, the thought never crossed my mind that someday choosing a CSS-related tool would be as much a career decision as choosing a primary programming language to focus on.

FTR, I don't have solutions for the problems I pointed out, nor do I think we should somehow reset and go back to the past, but I feel strongly that we've made things more complicated than they need to be.


I feel like you're looking at the past through rose-colored glasses, my friend.

> Websites like csszengarden.com showed us the promise of style sheets

That site was always highly artificial -- huge deficiencies in CSS meant that it always wound up being tightly coupled to the HTML structure for any non-trivial site.

> I always felt proud to make a website with only semantic HTML and CSS, and it always worked well. Even with all the browser issues (namely those of IE6), it was easy to write cross-browser compatible code that was clean and beautiful.

I don't think any language has ever frustrated me more than CSS. It never worked well (float bugs? box models? browser hacks? z-index problems? vertical centering? insane precedence rules?) and was anything but clean and beautiful.

The reason for the proliferation of tools like LESS or frameworks has been exactly to address some of the huge warts and problems of CSS (like no variables, no local namespacing, etc.) -- because these bring some desperately-needed sanity back to the CSS codebase for a large site.

I agree that there are way too many choices and not enough standardization around CSS best practices -- but the original problem here was the gigantic deficiences in CSS in the first place. CSS was never "clean and beautiful", it was and continues to be an eternal headache.


> It never worked well

Don't confused 'it never worked well' with 'i never understood how it worked'.

'Good'[1] front-end/CSS developers have a very good understanding of float quirks, the box model and how to properly vertically centre things.

Just because I don't understand how pointers in C work doesn't mean that C doesn't work well.

But yes - CSS isn't ideal.

[1] Where 'good' is similar to 'stockholm syndrom'


> Don't confused 'it never worked well' with 'i never understood how it worked'. 'Good'[1] front-end/CSS developers have a very good understanding of float quirks, the box model and how to properly vertically centre things.

Great. How many "good" CSS developers are there, and what is their hourly rate? If average developers still can't figure it out after its been around for a decade (see [1]), then the language has failed. At the end of the day CSS needs to usable for regular programmers, or its not very useful as a core framework for the Web.

[1] http://howtocenterincss.com/


'Good'[1] front-end/CSS developers have a very good understanding of float quirks, the box model and how to properly vertically centre things.

That doesn't mean "it worked well", it means "people had to learn to cope with its deficiencies". I don't see that as a particularly good thing.


Re: your comment and the others below

The variables argument is the only one I can truly get on board with. I really wanted variables. Find + replace in your editor for something like #fafaf0 isn't exactly error-prone or hard to do, so it wasn't ever a huge problem, but variables would have been very nice.

Pertaining namespaces, that's what the cascading part was made for. I had 4000+ line CSS files for large ecommerce websites where I had 5 different declarations of some classes (e.g., .item), but using proper selectors and understanding specificity meant never having a problem.

Pertaining large files, @import(...) always worked for me. For the most part, I'd use one large file (hence 4000+ line files mentioned above) because it helped with load speed, which did suggest that there was value in a build tool that would read @import(...) statements and pull those files into one large file after the fact. But this didn't mean we needed a framework with its own syntax, etc.... even today, tools like django-pipeline will pull in and combine CSS files for you, in the order given, so that you can write your files separately and have them combined after.

Pertaining z-index, I never had an issue with this, except with drop-down menus, but even then it was intuitive and consistent that the next element down will be 1 layer above the one directly above it, and it was also intuitive that nested elements' implicit z-indexes would be relative to their parents, etc.


We probably shouldn't forget that a lot of the old-school CSS stuff were hacks meant to get around limitations in the standards. In isolation, they were pretty cool, but in terms of composability, maintainability, and compatibility, they were a nightmare. Life pre-SASS sucked, and even pre-BEM it was pretty horrible once an app started to sprawl. There's still a place for all of the great little CSS techniques, but just factored into mixins, where the implementation can be encapsulated, and represented by something much smaller that represents the effect.

You're right that there's a bewildering number of technologies and approaches out there, but I think we're actually converging towards something sane. Certain waypoints are basically being agreed upon. Sure, we have SASS/LESS/Stylus/PostCSS, but ultimately people use them 95% identically, and that commonality was a huge win. BEM has similarly been a huge win, wand widely adopted. Reading the OP, I was nodding my head along as I read, and I think they're on to something really good. We're getting close to a point where we'll have easy to write, easy to employ, semantically meaningful styles with a more or less transparent build process.


I agree with you! Most people miss or don't understand the _cascading_ part of CSS. If you have well written markup, you can write beautiful CSS that removes much of the need for precompilers like SASS and Less and the hundreds of lines of code they output.

I'm still in the business of full-custom HTML+CSS+JS craftsmanship.


Websites like csszengarden.com showed us the promise of style sheets

And that's all it was - promise. There is a reason why CSS Zen Garden was just an example using a single page as a template.

In reality, people now make webapps of incredible size. A lot of what CSS Modules seems to be trying to fix is exactly that - how to maintain a lot of styles without namespace clashing, one giant CSS file, etc. etc.

I spent a lot of time dealing with all that, so I don't look back at the past in a positive way. I'm not saying CSS Modules is the answer, but it's interesting at least.


I've been using CSS Modules in a couple of projects (combined with PostCSS), am pretty happy so far.

I think you could actually go one step further and embed the stylesheet in the React component's module using a tagged template string, I haven't looked into how you'd get webpack to extract this into CSS files, but I'm sure it's possible.

Eg: https://gist.github.com/AndrewIngram/e3af5e8b70fd89a9a0d3


That (extraction) can be done (React Style does that) but for it to be consistent with JS semantics you need to evaluate code at build time because such template strings can contain interpolations from JS world.


Ah yes, forget about the interpolation issue. I knew there was a reason I stopped digging into it


I've thought about this also. Alternatively some mixed format file like yaml front matter style.


Shadow DOM completely solves this problem in a better way by scoping styles to a shadow root. The scoping allows the browser to be smarter about style recalc as well.

I do really like the idea of importing CSS into JS as a module to access the classnames and IDs though. I would like to do a similar thing with HTML imports as modules: import references to elements based on id.


Indeed, i just posted the some comment, but you where first.

The shadow dom solves the css modularity problem. And also comes with better "componetization of the web". React is imho not the end solution, and the virtual-dom and the diffing of nodes should actually be built into browsers, and not into a javascript framework...


Unfortunately Shadow DOM inherits CSS properties such as color;font-family.


Yes, certain properties cascade through the shadow boundary. That's completely intended, and easy to work around by using a shadow-scoped reset if you need to, but otherwise it's useful to be able to set the font or color for an entire tree-scope at once.


Where do you read that? I just checked the spec and coundt find this exception to the rule.


I didn't, it is how it works in latest Chrome.

In all fairness, that's how a blank browser works by default (e.g. Times News Roman is the inherited font-family if you don't specify one) so is very likely the intended behavior.


One thing worth mentioning about class composition with CSS Modules is it allows for the convenient ergonomics of Sass's @extend without any of its problems.

Sass @extend is actually counterproductive in terms of reducing filesize [1] and results in unwieldy, unreadable CSS rules [2]. In contrast, CSS Modules achieves true class reusability and optimal de-duplication of styles in a manner impossible with Sass, resulting in a nice Chrome Inspector view because the original classes are preserved and their composition is naturally represented.

[1] https://tech.bellycard.com/blog/sass-mixins-vs-extends-the-d...

[2] http://pressupinc.com/blog/2014/11/dont-overextend-yourself-...


The advantage of BEM naming is that it takes 0 effort to find your style definitions in code.

.Button--disabled copied in the browser, will find exactly 1 definition in the project. .components_submit_button__normal__abc5436 will not find you anything.


But on the flipside, in the latter case, you don't even need to grep for it -- "components_submit_button__normal__abc5436" reads as "components_{filename}_{classname}...", so you know right away to go look in "submit_button.(css|less|etc)" for ".normal {...".


This is certainly a less convenient approach. You always need to parse the class name in your head to open the correct file.


As a counter argument, when grepping files you still need to parse the output in order to open the correct file.

And, yes I understand that you can have grep output a path name and pass that directly in as an argument to your text editor. Similarly, it'd be relatively trivial to write a bash function that'd parse the class name and find the correct file to open.

Something like:

    function lookupcss() {
        find . | grep $(expr "$1" : '\(.*\)__.*' | sed 's/_/.*/g')".*\.css$";
    }


THIS. Living in a world of abnormally gross class names like `components_submit_button__normal__abc5436` sounds downright painful, UGH.


Also see styling[0] which is a loader for webpack which allows to generate CSS modules with JS.

Files configured to use with this loader (usually `.style.js`) are executed at build time and produce CSS modules. You can use any JS abstractions for that (functions, modules, variables, ...) and any npm package available (color manipulation, typography, ...):

  import styling from 'styling'
  import {smallText} from './typography'
  import {colors} from './theme'

  export let caption = styling({
    ...smallText,
    color: colors.text
  })
[0]: https://github.com/andreypopp/styling


Hey, that looks great :-) I'll try it. What do you think of https://github.com/css-modules/css-modules/issues/23#issueco...


This is a very cool library. Thanks for the link. Have you used this in any projects yet?


We started to migrate away from pure CSS Modules to Styling in our apps. Code didn't hit production yet but we are close.

Writing styles in JS instead of CSS gave us a huge expressiveness boost and allowed to use existing JS tooling such as eslint. At the same time all CSS tooling still can be applied to compilation result (such as autoprefixer).

Also would be fun to write styles in TypeScript — statically typed styles sounds great.


"The composes keyword says that .normal includes all the styles from .common" -- great, except you have the meaning of the word reversed. In the context above it actually means ".normal is part of .common", which is clearly not the intent. If you wanted it to mean that ".normal includes all the styles from .common" then .normal should be "composedOf: common"


Reminds me of the one-man Wikipedia crusade against this misusage: http://www.npr.org/2015/03/12/392568604/dont-you-dare-use-co...


Correct. Would the word 'comprises' be more appropriate?


I stumbled upon the Github issue and then found the HN reference. I commented with some additional thoughts and keyword options. I don't think 'comprises' would be the best choice here; it has quite a stricter meaning than 'includes' and its synonyms.


What about 'inherits' or 'extends' to match known programming terms?


Oh, yes, I like that much more :) I've created this as an issue on their github repo, at https://github.com/css-modules/css-modules/issues/24


Abstractions are fine and dandy until they break down and you have to pry them open. What I don't understand here, is why the generated code doesn't follow the already established BEM conventions which the posts explores initially.


I'm with you, that generated css doesn't look right, something that generated the css BEM style makes more sense.


HTML is for hypertext documents, and CSS an organ of the same organism called 'HTML/CSS'. It's made for text documents, and applying it to the implementation of GUI-centric applications has always been an ugly hack. For awhile (90s to 00s AJAX) it was necessary, and now the whole professional ecosystem has built up tremendous inertia over the millions of accumulated people/hours of perfecting this 'competency'/hack. Now though, I would recommend to switch over to building 2D webapps entirely out of SVGs (say with React + Flux) e.g.: https://github.com/Terebinth/Vickers or, even better, to building them entirely out of WebGL. SVGs are easy and would lead to a wonderfully efficient workflow, but I think WebGL holds the advantage for performance considerations, given the way it goes to the hardware.


I don't believe WebGL is suitable for rendering applications. Look at game UIs, they usually are either crap (low-cost games, where devs didn't sped too much time and simply blit button sprites somewhere on screen), or the authors had to implement a widget set on top of GL (WoW comes to mind). But a widget set is exactly what React and web components give you (built in top of basic building blocks like divs and spans and of course CSS for styling).

And while HTML was initially created for hypertext documents, it doesn't mean it can't be used for somthing else. I disagree that it's an ugly hack. Some parts may not be suitable for GUI apps (uhm, like <blink>), but then simply don't use them in your application. Or implement something better on top of the good parts (like React did). Eventually the good parts may be come standard.


Moving entirely to svg for user interface has some of its own issues (i.e. there's no default layout engine in svg; everything is essentially absolutely positioned...) but would be interesting to think about. Moving entirely to WebGL would only be viable if you don't care at all about accessibility though. For some subset of applications that might be acceptable (i.e. games), but for something like gmail or other similar applications it's definitely not.


You just have to create widgets libraries, compile them to WebAsm or something alike, and export an event-based framework for the developers to use. It can even be in another language, compiled to WebAsm.

Or, alternatively, you can just use Flash, instead of cloning it.


There is already a very compact 2D vector-oriented format with its own scripting language: SWF. You don't even need to use Adobe's implementation - there are alternative Flash Players and authoring tools out there.


Hasn't this been already done in webpack (css-loader with local scope)?

https://github.com/webpack/css-loader#local-scope


Webpack's css-loader implements CSS modules specificaton, see https://github.com/webpack/css-loader#css-modules


This seems like too much abstraction (magic) of things. Plus those auto generated classes really look odd and would make debugging difficult.


Webpack allows you to change the format through its loader configuration. Perhaps, this could get implemented to CSS Modules too, if it’s not already.

loaders: [

  ...
  {
    test: /\.css$/,
    loader: 'css?localIdentName=[name]__[local]___[hash:base64:5]'
  }
]


I assume soucemaps would solve this.


It's lovely to assume this, but I see no mention of sourcemaps anywhere. This was my immediate gripe, debugging.

Yea, the class name should point you to the file you want to look at, but that is still manual legwork. And the whole atomic css-like pitch he has with the over-the-top `composes` functionality looks like its own nightmare.

I'll watch from over here and see if this pans out for ya'll.


I can't speak from experience with regards to this particular approach, but I've worked with css-modules with webpack (css-loader), and debugging the class names is no problem at all, CSS source-maps point to the source, you can view the source code within your developer tools. It shouldn't really be any different than debugging Sass generated CSS, for example.


Doesnt the shadow-dom solve the problems with css modularity. You just write the css for your component, and it doesnt leak into anything else... Why do you need something like css-modules?


This is actually perfect for shadow dom, because it allows composition.

You gotta remember, Shadow Dom is a double edged sword, - while it prevents styles from leaking in, it prevents styles from cascading too. And sometimes, cascading was a good thing. Without it, you need to reapply base styles, and that's annoying. With this approach, you can compose component styling by declaring what to inherit.


I've been using JSS for everything. It makes the most sense to me. It's minimal in size and function to the point that any extra functionality can be quickly and easily added via `jss.use(plugin)`. And it's maximally modular. Every class is namespaced, and exporting everything to a single sheet for production builds is super simple, as it should be.

https://github.com/jsstyles/jss


Aren't methodologies like SMACSS addressing such problems?

I found interesting how the whole thing is specifically related to someone reading the CSS and not used to SASS.


Forget the last sentence, was referring to another link.


Right, but what about the name? This isn't Cascading Style Sheets any more. Hmm let's see, Composable Style Sheets. There. Oh, wait...


I was first introduce to the 'CSS as code' concept by Blake at https://github.com/blakeembrey/react-free-style - worth taking a look if you're considering using one of these tools.


Am I the only one who scrolled up and down a few times just to verify the background was changing its color and it wasn't a bug in f.lux which kicked in way too early for sunset?


How does a post get to number 1 here with only 5 up votes?


There's extra weight to comments and how fast the upvotes are. If all votes are instant it'll go higher than votes over a longer period.


This is not great. I know there are controls in place to stop chain voting, but if it only takes 5 votes in 5 minutes to reach number 1 then the system is wide open to abuse.


Most systems are vulnerable if you poke around a bit. In my experience the HN voting ring detector is pretty wily.


That I agree with :)

The problem is that no system can detect signal in five votes. The numbers are just too small to be significant.


It's probably some sort of score decay over time. Surely, it the post was posted a couple of hours ago, 5 up votes would not cut it.


Surely not the future.


Not sure why you're getting downvoted. Problems with CSS at Scale are very real (as mentioned in the slide). But this is a super complicated solution. Its like one of the head-over-heels approaches in JoelOnSoftware blogs. Surely there has to be a simpler way.

Its good that the authors are trying. But just look at the picture on this article captioned "This is how intensely we’ve been thinking about CSS". That's where the whole complexity comes from I guess. Good solutions present themselves and fit naturally.


> Not sure why you're getting downvoted.

Because it doesn't contribute anything but nonconstructive criticism.

> Good solutions present themselves and fit naturally.

Complex problems require complex solutions.

Also, what's so complex and non-fitting about this solution? Explaining that (and your alternative solution) would be much better than simply criticizing as you and GP did.

> Surely there has to be a simpler way.

There's a technically simpler way: modules being part of the CSS spec. But they're not, so even if technically simpler as a solution, it's a political nightmare on which we developers have no control whatsoever.

Driving forward the status quo with hacks (like to-JS transpilers did) is nothing but beneficial. Hacks drive standards.

> "This is how intensely we’ve been thinking about CSS". That's where the whole complexity comes from I guess.

How much have you been been thinking about CSS and fighting its flaws? Obviously not a lot.


> Because it doesn't contribute anything but nonconstructive criticism.

No, it's just an opinion and a comment on the sensationalistic article (sub)title.


There is a simpler way. Even for large projects there is no need for the amount of CSS they usually have. It just takes some discipline and planning, alas that's often replaced by abdominations like BEM.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: