Skip to content

Instantly share code, notes, and snippets.

@mistakster
Created December 15, 2015 13:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mistakster/2dceffdab9f2afdd8321 to your computer and use it in GitHub Desktop.
Save mistakster/2dceffdab9f2afdd8321 to your computer and use it in GitHub Desktop.
// Conver scale factor into pixels
.fontScale(@scale: 0) {
@list: 14px, 16px, 20px, 24px, 28px, 34px, 41px, 50px, 60px;
.test-args(@scale) when (@scale >= -2) and (@scale <= 6) {
font-size: extract(@list, @scale + 3);
}
.test-args(@scale);
}
// Apply font with provided size or scale
.fontTimes(@size: "") {
font-family: "Times New Roman", serif;
.test-args() when (ispixel(@size)) {
font-size: @size;
}
.test-args() when (isnumber(@size)) and not (ispixel(@size)) {
.fontScale(@size);
}
.test-args();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment