Last active
April 20, 2021 06:40
-
-
Save hz2/aa465df7f373dafc01ea755c746bde5a to your computer and use it in GitHub Desktop.
Generate class names like inline styles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@sizes: 0, 5, 8, 10, 15, 20, 25, 30, 45; | |
@sides: { | |
l: -left; | |
r: -right; | |
t: -top; | |
b: -bottom | |
} | |
.gen-space(@sizes; @sides; @index) when (@index>0) { | |
.gen-space(@sizes; @sides; @index - 1); | |
@size : extract(@sizes, @index); | |
.mx@{size} { | |
margin-left: (@size * 1px); | |
margin-right: (@size * 1px); | |
} | |
.px@{size} { | |
padding-left: (@size * 1px); | |
padding-right: (@size * 1px); | |
} | |
.my@{size} { | |
margin-top: (@size * 1px); | |
margin-bottom: (@size * 1px); | |
} | |
.py@{size} { | |
padding-top: (@size * 1px); | |
padding-bottom: (@size * 1px); | |
} | |
.m@{size} { | |
margin: (@size * 1px); | |
} | |
.p@{size} { | |
padding: (@size * 1px); | |
} | |
each(@sides, .(@v, @k, @i) { | |
.m@{k}@{size} { | |
margin@{v}: (@size * 1px); | |
} | |
.p@{k}@{size} { | |
padding@{v}: (@size * 1px); | |
} | |
} | |
); | |
} | |
.gen-space(@sizes; @sides; length(@sizes)); | |
@widths: 60, 80, 90, 100, 120, 140, 150, 160, 170, 180, 200, 220, 250, 300, 320, 350, 400; | |
each(@widths, { | |
.w@{value} { | |
width: (@value * 1px); | |
} | |
.h@{value} { | |
height:(@value * 1px); | |
} | |
} | |
); | |
@pcts: 10, 15, 20, 25, 33, 46, 50, 64, 66, 75, 80, 85, 90, 100; | |
each(@pcts, { | |
.pct@{value} { | |
width: (@value * 100% / 100); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment