TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Mimic – class-fied inline CSS

28 pointsby peterchonover 9 years ago

23 comments

nnessover 9 years ago
I feel like this is akin to &quot;killing the patient to cure the disease.&quot; 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.<p>Firstly, you&#x27;re messing up your separation of concerns, you&#x27;re also messing up an attribute with values that other developers will probably see as a bug — &quot;why isn&#x27;t this in a style tag?&quot; It also won&#x27;t work with JavaScript disabled (a few people will complain about that, they always do).<p>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=&quot;1&quot;, to apply to additional styles (although some CMS&#x27; will struggle with this).<p>(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&#x27;d refactor this if I found it in any projects I look after.)
评论 #10184915 未加载
评论 #10185721 未加载
elausover 9 years ago
Could you please elaborate a bit more on how a class &quot;padding:10&quot; is better than just adding an inline style &quot;padding:10px&quot;?
评论 #10184799 未加载
评论 #10185730 未加载
juhqover 9 years ago
When doing things like this, you should take ie into consideration <a href="http:&#x2F;&#x2F;spaceninja.com&#x2F;2015&#x2F;03&#x2F;31&#x2F;ie-css-limits&#x2F;" rel="nofollow">http:&#x2F;&#x2F;spaceninja.com&#x2F;2015&#x2F;03&#x2F;31&#x2F;ie-css-limits&#x2F;</a><p>Using parker (<a href="https:&#x2F;&#x2F;github.com&#x2F;katiefenn&#x2F;parker" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;katiefenn&#x2F;parker</a>) tool to analyze the css:<p><pre><code> curl http:&#x2F;&#x2F;peterchon.github.io&#x2F;mimic&#x2F;css&#x2F;mimic.css -s | parker -s PARKER-JS Total Stylesheets: 1 Total Stylesheet Size: 126045 Total Rules: 2551 Total Selectors: 2611 Total Identifiers: 5292 Total Declarations: 3849 Selectors Per Rule: 1.0235201881615053 Identifiers Per Selector: 2.026809651474531 Specificity Per Selector: 19.89199540405975 Top Selector Specificity: 40 Top Selector Specificity Selector: .row\:12 .col\:1 Total Id Selectors: 0 Total Unique Colors: 6 Unique Colors: #3F3F3F,#3E49FF,#45497F,#1336CC,#CFCFCF,#CCCCCC Total Important Keywords: 0 Total Media Queries: 1 Media Queries: screen and (max-width: 736px)</code></pre>
评论 #10185755 未加载
bbxover 9 years ago
How do you handle advanced selectors? Or hover states? Or priority? Or inheritance?<p>There is a <i>lot</i> of reasons why separating content and styling is benefitial to both the designer and the developer. And why semantic classes, especially with tools like Sass where abstraction and reusability are key, allow to <i>describe</i> the content, not define its looks.<p>That&#x27;s why we went from color=&quot;red&quot; to style=&quot;color:red;&quot; to class=&quot;red-text&quot; to class=&quot;alert alert-red&quot; to class=&quot;alert-danger&quot;.
评论 #10185791 未加载
评论 #10185260 未加载
arsalanbover 9 years ago
Hey, this is a very radical approach. I have great respect for people who ship something (anything!), because they have the vision to see things differently and actually execute this vision.<p>This may take some getting used to, and a lot of debate if using this is really worth it, but it&#x27;s something. Nice job! :)
评论 #10185752 未加载
bobwaycottover 9 years ago
So, basically this is just meant to feel better about using the `class` attr instead of using the `style` attr. Oh, and spaces instead of semicolons?
inaccessibleover 9 years ago
So now I don&#x27;t have to use inline styles, just spam my css file with margin:0-100 and padding:0-100 classes, and I&#x27;m good to go?
评论 #10185806 未加载
solveforallover 9 years ago
As someone who is perpetually terrified to do a Show HN, congrats for shipping something. I also don&#x27;t think this idea is much better than inline style attributes, but it&#x27;s something different at least. You seem to take constructive criticism well and that&#x27;s a good sign. My advice (worth nothing since I haven&#x27;t shipped) is to learn from the feedback and come back with something else.<p>Also, I should mention I did have a use for something like this. On my site, I sanitize HTML generated by user plugins, and to ensure the HTML doesn&#x27;t mess up other parts of the page, I would provide a set of allowed CSS classes, but disallow inline styles. The CSS classes would not include &quot;position&quot; properties, so &quot;position: static&quot; wouldn&#x27;t be allowed. Later I was able to use phloc to parse the inline styles but prohibit &quot;position&quot;, so I didn&#x27;t need a huge set of CSS classes anymore.
sdnguyen90over 9 years ago
Going to be honest.. this doesn&#x27;t look too well thought out. Something like z-index you have a class for values of 0 up to 100. Not necessary IMO.<p>I&#x27;d recommend taking a look at Basscss for some inspiration. From my perspective, you&#x27;re trying to create something similar to Basscss.
评论 #10185888 未加载
Raphmediaover 9 years ago
That&#x27;s the equivalent of a front-end developper going into back-end, saying &quot;screw this!&quot; and hardcoding everything.<p>Urgh.<p>Also, you cannot use numbers as classes. That&#x27;s not allowed and may mess up some browsers &#x2F; devices.
评论 #10185799 未加载
jsalinasover 9 years ago
It&#x27;s sad that this reminds me to the worst CSS framework I&#x27;ve ever used (and was forced to use): <a href="https:&#x2F;&#x2F;github.com&#x2F;EasyBoxModel&#x2F;EBM" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;EasyBoxModel&#x2F;EBM</a><p>Check <a href="https:&#x2F;&#x2F;github.com&#x2F;EasyBoxModel&#x2F;EBM&#x2F;blob&#x2F;master&#x2F;app&#x2F;assets&#x2F;css&#x2F;ebm.css" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;EasyBoxModel&#x2F;EBM&#x2F;blob&#x2F;master&#x2F;app&#x2F;assets&#x2F;c...</a> to get the idea.
评论 #10185871 未加载
joe5150over 9 years ago
This doesn&#x27;t result in very readable markup or have any of the benefits of actual inline CSS, so I don&#x27;t really see the need here.
评论 #10185812 未加载
tjsixover 9 years ago
I don&#x27;t really want to be negative but I really can&#x27;t see how this could be used for anything other than a quick prototype scenario. I&#x27;m never going to add 126kb of css to a project just for shortcuts like this, it just doesn&#x27;t make sense given that the large majority of that added css weight will never be used.
KoulMomoover 9 years ago
Yahoo actually came up with something similar <a href="http:&#x2F;&#x2F;acss.io&#x2F;" rel="nofollow">http:&#x2F;&#x2F;acss.io&#x2F;</a><p>Benefits over just using inline styles: 1) support for pseudo-classes (:hover) 2) reduce markup bloat (shorter class declarations vs equivalent inline-style declarations)
namuolover 9 years ago
wat.css ¯\_(ツ)_&#x2F;¯
robotnoisesover 9 years ago
I don&#x27;t think this is a joke. I think this is just something that probably isn&#x27;t useful as a library&#x2F;framework&#x2F;whatever + maybe an incomplete understanding of how CSS best fits into the puzzle.
评论 #10185669 未加载
eduardo-costaover 9 years ago
There is something similar. <a href="https:&#x2F;&#x2F;github.com&#x2F;eduardo-costa&#x2F;shortcutcss" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;eduardo-costa&#x2F;shortcutcss</a>
Kiroover 9 years ago
I don&#x27;t think it&#x27;s a joke. It contains some useful stuff like row and col which you can&#x27;t do with inline CSS.
评论 #10185251 未加载
Mahnover 9 years ago
Perfect, now we just need an equally redundant pseudo syntax template system that produces html on top of this.
willthefirstover 9 years ago
irony has reached the front end.
dr_faustusover 9 years ago
Brilliant!
评论 #10184890 未加载
rafaquequeover 9 years ago
This is getting crazy.
评论 #10185826 未加载
评论 #10185827 未加载
jarcoover 9 years ago
This is by far the most insane and stupid idea I have seen this year.
评论 #10185803 未加载