Skip to content

Instantly share code, notes, and snippets.

@SujalShah3234
Created January 7, 2023 11:44
Show Gist options
  • Save SujalShah3234/a121d0551036d02bd4a5982e1d23e534 to your computer and use it in GitHub Desktop.
Save SujalShah3234/a121d0551036d02bd4a5982e1d23e534 to your computer and use it in GitHub Desktop.
Snippet for a mixin that makes organizing typography a bit easier
$typeography: (
'small': (
'font-size': 1.4rem,
'line-height': 100%,
'letter-spacing': 2%
),
'medium': (
'font-size': 2rem,
'line-height': 150%,
'letter-spacing': 2%,
),
);
// @mixin that takes a key value prop and returns all the CSS props associated with it!
@mixin text-style($clsName) {
$cls: map-get($map: $typeography, $key: $clsName)
@each $prop, $value in $cls {
#{$prop}: $value;
}
}
// how to use 👇
.test {
@include text-style('medium');
color: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment