scss-mixin-trump-maker
Version:
A scss mixin to generate handy css trumps
93 lines (74 loc) • 2.25 kB
Markdown
### SCSS Trump Maker
It takes a map of `key: value` or list and generates a set of **trump** classes.
The trump class terminology comes from [cssguidelin.es](https://cssguidelin.es/)
#### Install
1. `npm i -S scss-mixin-trump-maker`
1. Import it into your SCSS code:
```scss
@import "~scss-mixin-trump-maker/index";
```
#### Usage
##### Parameters
- **$vairations:** `(map|list)`
- **$name:** `(string)`
- **$props...**. `(unlimited strings)`
##### Examples
- Use it to generate spacing trumps:
```scss
$spaces: (
0: 0,
1: 0.25rem,
2: 0.5rem
);
@include trumps-maker($spaces, 'm', 'margin');
@include trumps-maker($spaces, 'mt', 'margin-top');
@include trumps-maker($spaces, 'my', 'margin-top', 'margin-bottom');
@include trumps-maker($spaces, 'pr', 'padding-right');
```
It will generate:
```css
.m-0 {margin: 0 ;}
.m-1 {margin: 0.25rem ;}
.m-2 {margin: 0.5rem ;}
.mt-0 {margin-top: 0 ;}
.mt-1 {margin-top: 0.25rem ;}
.mt-2 {margin-top: 0.5rem ;}
.my-0 {margin-top: 0 ; margin-bottom: 0 ;}
.my-1 {margin-top: 0.25rem ; margin-bottom: 0.25rem ;}
.my-2 {margin-top: 0.5rem ; margin-bottom: 0.5rem ;}
.pr-0 {padding-right: 0 ;}
.pr-1 {padding-right: 0.25rem ;}
.pr-2 {padding-right: 0.5rem ;}
```
- Use it to generate height trumps:
```scss
$heights: (
1: 25vh,
2: 50vh,
3: 75vh,
4: 100vh
);
@include trumps-maker($heights, 'h', 'height');
```
It will generate:
```css
.h-1 {height: 25vh ;}
.h-2 {height: 50vh ;}
.h-3 {height: 75vh ;}
.h-4 {height: 100vh ;}
```
- Use it to primitive height trumps:
```scss
$alignments: (
right,
center,
left
);
@include trumps-maker($alignments, 'text', 'text-align');
```
It will generate:
```css
.text-right {text-align: right ;}
.text-center {text-align: center ;}
.text-left {text-align: left ;}
```