1.1.1 • Published 5 years ago

atomized-scss v1.1.1

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

This is a simple library that can be used to generate atomic css rules, based on attributes.

npm i atomized-scss

I've made my own atomic css for a pretty silly reason: acss.io doesn't work with pug. Well, it does, but it's ugly. So, I did it, using attributes, so it looks like this:

    div(
        inline-block
        bg="primary" bg:hover="light"
        text-color="light" text-color:hover="dark"
        corners="rounded"
    ) Click me!

Basically, it's two SASS mixins: atom and quark.

Atom creates property=value pairs. Like bg="primary"

PropertiesType
$valueslist or mapA list of values that property can be set to.
$propertystring (css property)A name of css property like background-color or padding
$property-namestring (optional)A human-friendly name for you atom. Like bg instead of background-color. If none is provided, then $property is used.
$directionalboolean (optional)Whether additional atoms (-left, -right, -bottom, -top, -horizontal and -vertical) should be created.
$selector-modifierstring (optional)Basically it appends to the atom selector. Example: ":hover"

Example:

@use 'atomized-scss' as atomizer

$colors: (dark: #212121, light: #fff, primary: #F84C26) // You can use maps
$sizes: 4px, 8px // Or lists
$font-weights: bold, normal, (light: 300) // Or any combination of them

+atomizer.atom($colors, color, text-color) // Good ol' simple atom
+atomizer.with-states($colors, color, text-color) // Creates additional atoms for :hover, :active and :disabled states

+atomizer.directional($sizes, margin)

+atom($font-weights, font-weight)

This is compiled to:

*[text-color=dark] {
  color: #212121;
}

/* The same for other colors */

*[text-color\:hover=dark]:hover {
  color: #212121;
}

/* The same for other colors */

*[margin="4px"] {
  margin: 4px;
}

*[margin-left="4px"] {
  margin-left: 4px;
}

/* The same for other directions */

*[font-weight=bold] {
  font-weight: bold;
}

*[font-weight=normal] {
  font-weight: normal;
}

*[font-weight=light] {
  font-weight: 300;
}

Quark creates a simple attribute. Like bold or flex

PropertiesType
$valueslist or mapA list of values that property can be set to.
$propertystring (css property)A name of css property like display or font-weight
$selector-modifierstringBasically it appends to the atom selector. Example: ":hover"

Example:

$fonts: sans-serif, serif, monospace

+quark($fonts, font-family)

Is compiled to:

*[sans-serif] {
  font-family: sans-serif;
}

*[serif] {
  font-family: serif;
}

*[monospace] {
  font-family: monospace;
}
1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago