Skip to content

Instantly share code, notes, and snippets.

@mattboon
Created March 7, 2014 09:19
Show Gist options
  • Save mattboon/9408252 to your computer and use it in GitHub Desktop.
Save mattboon/9408252 to your computer and use it in GitHub Desktop.
Copy / Micro Copy Class Generator
=font-scale($sizes, $namespace: "copy", $micro_class: true)
@each $scale in $sizes
$current-breakpoint: nth($scale,1)
$current-font-size: nth($scale,2)
$base-size: $current-font-size !default
@if $current-breakpoint > 0
+mq-min($current-breakpoint)
.#{$namespace}
font-size: $current-font-size
@if $micro_class == true
// global micro copy
.#{$namespace}__micro
font-size: pct($base-size/$current-font-size)
// modifiers
@each $breakpoint in $sizes
$this-breakpoint: nth($breakpoint,1)
$this-font-size: nth($breakpoint,2)
@if $this-breakpoint > 0 and $this-breakpoint < $current-breakpoint
.#{$namespace}__micro--#{$this-breakpoint}
font-size: pct($this-font-size/$current-font-size)
@else
.#{$namespace}
font-size: $current-font-size
// usage
$sizes: (0, 100%), (500, 200%), (1000, 300%), (1500, 400%)
+font-scale($sizes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment