Giter Club home page Giter Club logo

quark's Introduction

quark

Quark.js is a microscopic atomic CSS polyfill in 140 bytes

This plugin is the smallest 'atomic' CSS framework, at only 140 bytes it's small enough to fit in a tweet.

What is 'atomic' CSS?

There are a number of CSS frameworks like Tailwind CSS, ACSS, BassCSS, Tachyons, Universal.CSS, and Bootstrap v4 that include pre-made classes for certain properties. These can apply directly to an element in HTML as classes instead of as styles.

How to write classes for Quark

The naming convention Quark uses for writing classes is based on the JavaScript DOM style property names which are similar to their CSS property equivalents. After the property name there is a dash -, and finally we write the value we want. All lengths are in pixels.

For example the following styles:

<div style="color: red; font-size: 20px;"></div>

Could be re-written with Quark classes as:

<div class="color-red fontSize-20"></div>

View the source of index.html to see more!

Adding Quark to your Website

To use Quark, either link to quark.js using a <script> tag like this:

<script src=quark.js></script>

Or embed the entire script inline in the page:

<script>for(t=document.querySelectorAll`*`,i=t.length;i--;)for(s=t[i].classList,c=s.length;c--;)z=s[c].split`-`,u=z[1],t[i].style[z[0]]=~~u?u+'px':u</script>

There's also an ES6 version of the code available in quark-es6.js that can be linked to or included using a <script> tag like this:

<script>[...document.querySelectorAll`*`].map(e=>[...e.classList].map(c=>e.style[[a,b]=c.split`-`,a]=~~b?b+'px':b))</script>

3rd Party Support

Github user @tomhodgins provided a way that Quark classes could be read without the use of quark.js or quark-es6.js using EQCSS in this pen on Codepen: Reading Quark Classes with EQCSS

Documentation

There is an annotated source code file similar (but not identical) to the 140 byte version that explains how the plugin works in an easier-to-read format.

Read Annotated Source

quark's People

Contributors

tomhodgins avatar voronoipotato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

quark's Issues

2 bytes shaved for the non-ES6

I believe this would work. Bored. So, I obviously I had to use Regex.

Uses the className and splits the classes and the -'s in the same go.
Pops the values on the end in sets of 2.

for(t=document.querySelectorAll`*`,i=t.length;i--;)for(s=t[i].className.split(/[- ]/);s.length;)u=s.pop(),t[i].style[s.pop()]=~~u?u+'px':u

First pass. Might mess around later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.