Skip to content

Instantly share code, notes, and snippets.

@zastrow
Last active March 4, 2022 13:00
Show Gist options
  • Save zastrow/ca640bec6780407168ba4d4911d3974b to your computer and use it in GitHub Desktop.
Save zastrow/ca640bec6780407168ba4d4911d3974b to your computer and use it in GitHub Desktop.
Holy Trinity of Sass: Complex Function Demo
> 1%
last 2 versions
// ----
// libsass (v3.5.4)
// ----
$sans: sans-serif;
$serif: serif;
$sans-weight: (
lighter: 300,
bolder: 700
);
$serif-weight: (
lighter: 400,
bolder: 900
);
@function weight($family:null, $weight:null, ) {
@if $weight == lighter or bolder {
@if $family == $sans {
@return map-get($sans-weight, $weight);
}
@else if $family == $serif {
@return map-get($serif-weight, $weight);
}
}
}
.my-class {
font-family: $serif;
font-weight: weight($serif, bolder);
}
.my-class {
font-family: serif;
font-weight: 900;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment