3 ms·
I feel like this is akin to "killing the patient to cure the disease." In the uses I can see for this, the way this framework solves the problem, to me, seems t
by nness 11y ago
I feel like this is akin to "killing the patient to cure the disease." In the uses I can see for this, the way this framework solves the problem, to me, seems to be worse than any problem itself. Namely, I would like to know how this is any better than !important on your CSS properties.
Firstly, you're messing up your separation of concerns, you're also messing up an attribute with values that other developers will probably see as a bug — "why isn't this in a style tag?" It also won't work with JavaScript disabled (a few people will complain about that, they always do).
Why use classes at all? If the idea is to not rely on CSS, we could use a data attribute, like data-mimic or data-mimic-width="1", to apply to additional styles (although some CMS' will struggle with this).
(I realise its so easy to be negative, and HN submissions usually have their unfair share of criticism from people who think they know better. Although it obviously solves a problem for the author, at the crux of it, I'd refactor this if I found it in any projects I look after.)
- aidos 11y agoI'm assuming the whole thing is a (pretty non-obvious) parody. If so, kudos to the creator – they had me for a moment there. EDIT just actually read the post properly "More to come, including jQuery-less js components. Please stay tuned!" :-)
- peterchon 11y agoHey, thanks for taking a look. I'm sorry that it wasn't a parody. It's something that's helped me make quick small style changes without having to make more css classes.
- aidos 11y agoAhhhhh... I'm sorry for suggesting it was a parody. Is there some specific reason you're trying to solve this with css classes? In this case you're better off just using style="margin:0", or am I missing something?
- peterchon 11y agoI wouldn't necessarily say that I'm trying to solve a problem. It's more of why not have modular css-classes that I can use to build things when using custom directives.
- peterchon 11y agoHi, thanks for taking a look. Could you tell me why this won't work without JS? My motivation to write this is because I always have to go back and make quick margin/padding/etc changes and I hated trying to come up with more class names. As mentioned, this isn't a framework. It was a way for me to add styles when writing styles to custom directives.
- talmand 11y agoI too don't understand the JS comment. But, if this isn't a framework then it seems rather large. If it were to do only what you describe, simple classes for simple changes, then you are loading in lots of stuff in your inc imports that isn't required. I don't necessarily have a problem with it, it's not a bad idea. Personally I wouldn't be against using something like this that's tailored to a design so that only the necessary classes are required. That way it isn't necessary to have stepping of 1 to 100 on each property.
- peterchon 11y agoThanks, yes I agree it's a lot - but I'm hoping to make something that people can customize so that you don't have 0-100px of choices (but for now, it's an attempt at something new)
- nness 11y agoMy apologies, I noticed a JS folder and comments on the page and assume it was part of the solution. (Seems the timeframe to edit my original comment has expired).