DEV Community

Cover image for MOD-CSS 3.x (new version)
Dev Geos
Dev Geos

Posted on • Edited on

MOD-CSS 3.x (new version)

With great excitement that I announce version 3 of MOD-CSS.
The new features :

Your own attributes

Now, you can choose the attribute names to work with MOD-CSS.

<script>
   ModCSS.attributes({
     grid: 'mod',
     props: 'xyz',
     var: 'let',
   })
</script>
Enter fullscreen mode Exit fullscreen mode

Enhanced flexgrid

Use our flexgrid properties in any MOD-CSS attributes.
Just add dollar sign '$' in this case.

<div :mod="row[100%]">
    <div :box="col$[5.4rem]">5.4rem</div>
    <div :mod="col[25%]">25%</div>
    ...
</div> 

<div :var=".col{ col$[auto] h[10px] }"></div>
Enter fullscreen mode Exit fullscreen mode

Enhanced support of pseudo-Elements

We have improved support for pseudo-elements (before, after, mark...). You can use them as you do with pseudo-classes.
Just use double colon '::' when you set them.

<!--Set a selector-->
<div :var=".q::before { con['_'] co[blue] }"></div>
<div :var=".q::after { con['E6'] co[blue] }"></div>

<p>Some quotes, he said, <span class="q">are better than none.</span>
</p>

<!--Or set props on HTML element-->
<p>Some quotes, he said, 
  <span :box="before:: con['_'] co[blue] && after:: con['E6'] 
  co[blue]">are better than none.</span>
</p>
Enter fullscreen mode Exit fullscreen mode

Rewriting the script

We have upgraded the code to a more recent JavaScript version.
The rendering engine is more lighter than before but also faster, (only 9 kilobytes).

Github repository


Complete exemple

Define your attribute(s) (one or all)

<script>
   ModCSS.attributes({
     grid: 'mod',
     props: 'xyz',
     var: 'let',
   })
</script>
Enter fullscreen mode Exit fullscreen mode

Call them in your markup

<body>
  ...
   <div mod="container[75%]">
      <div xyz=" m.rg[1.2rem]"></div>
     <div let=".mr-3{ m.rg[1.2rem] }"></div>
  </div>
</body>
Enter fullscreen mode Exit fullscreen mode

So, try-it and fun !

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay