Created
April 1, 2021 12:03
-
-
Save thelemondropkid/a715ffeb65e2b1a09f25f89c5d30eb1a to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
@import "breakpoint"; | |
// SASS 'map' | |
// ---------- | |
$font-sizes: (tiny: 9px, small: 12px, medium: 16px, large:24px); | |
// SASS 'each loop' over SASS map (name = current itteration) | |
@each $name, $size in $font-sizes { | |
.#{$name} { | |
font-size: #{$size}; | |
} | |
} | |
// SASS 'list' | |
// ----------- | |
$speakers: quintin, petra, nelson; | |
// SASS 'each loop' over SASS list | |
@each $speaker in $speakers { | |
.#{$speaker}-profile { | |
background-image: url('img/#{$speaker}.png'); | |
} | |
} | |
/* | |
SASS 'while' loop. | |
@while loop is more flexible than @for loop | |
@while loop allows the step count to be adjusted | |
@while loop allows for more complex conditions than @for loop | |
*/ | |
$j: 2; // condition | |
@while $j <= 8 { | |
.picture-#{$j} { | |
width: $j * 10%; | |
} | |
// Important to prevent 'infinate loop' | |
$j: $j + 2; | |
} | |
// Breakpoint (http://breakpoint-sass.com/) | |
// ---------------------------------------- | |
// assume min-width (by default) if only a number | |
$high-tide: 500px; | |
// set min-width/max-width if both values are numbers | |
$ex-presidents: 600px 800px; | |
// if one value is a string, assume a feature/value pair | |
$surfboard-width: max-width 1000px; | |
// string tests together within parentheses, assume each item is a feature value pair | |
$surfboard-height: (min-height 1000px) (orientation portrait); | |
.reagan { | |
@include breakpoint($high-tide) { | |
content: "High tide"; | |
} | |
} | |
.nixon { | |
@include breakpoint($ex-presidents) { | |
content: 'Ex-Presidents'; | |
} | |
} | |
.johnson { | |
@include breakpoint($surfboard-width) { | |
content: 'Surfboard Width'; | |
} | |
} | |
.carter { | |
@include breakpoint($surfboard-height) { | |
content: 'Surfboard Height, Portrait'; | |
} | |
} | |
.mandela { | |
font-size: map-get($font-sizes, tiny); | |
@include breakpoint($high-tide) { | |
font-size: map-get($font-sizes, large); | |
} | |
} | |
// Working with SASS maps | |
$light-weights: ("lightest": 100, "light": 300); | |
$heavy-weights: ("medium": 500, "bold": 700); | |
.map { | |
// getting map keys | |
content: map-keys($light-weights); | |
// getting map values (with interpolation) | |
content: "#{map-values($light-weights)}"; | |
// has key? | |
content: map-has-key($light-weights, 'lightest'); | |
content: map-has-key($light-weights, 'lightest-01'); | |
// get a map value | |
content: map-get($heavy-weights, 'bold'); | |
// map merge (with 'inspect' for output) | |
content: inspect(map-merge($light-weights, $heavy-weights)); | |
// removing key/value pairs from a map (immutable operation) | |
content: inspect(map-remove($heavy-weights, 'bold')); | |
// the org map is still in tact after previous operation | |
content: inspect($heavy-weights); | |
} | |
// Function example that reduces the amount of typing when working with maps | |
@function weight($weight-name) { | |
@return map-get($heavy-weights, $weight-name); | |
} | |
.weight { | |
font-weight: weight(medium); | |
} | |
// The SASS apersand (placeholder of parent selector name) | |
.main { | |
// this will produce (.main__paragraph) | |
&__paragrapgh { | |
font-size: 1rem; | |
} | |
// but what if i want the parent class included in the selector? | |
// this will produce (.main .main__paragraph) | |
#{&}__paragraph { | |
font-size: 1rem; | |
} | |
} |
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
.tiny { | |
font-size: 9px; | |
} | |
.small { | |
font-size: 12px; | |
} | |
.medium { | |
font-size: 16px; | |
} | |
.large { | |
font-size: 24px; | |
} | |
.quintin-profile { | |
background-image: url("img/quintin.png"); | |
} | |
.petra-profile { | |
background-image: url("img/petra.png"); | |
} | |
.nelson-profile { | |
background-image: url("img/nelson.png"); | |
} | |
/* | |
SASS 'while' loop. | |
@while loop is more flexible than @for loop | |
@while loop allows the step count to be adjusted | |
@while loop allows for more complex conditions than @for loop | |
*/ | |
.picture-2 { | |
width: 20%; | |
} | |
.picture-4 { | |
width: 40%; | |
} | |
.picture-6 { | |
width: 60%; | |
} | |
.picture-8 { | |
width: 80%; | |
} | |
@media (min-width: 500px) { | |
.reagan { | |
content: "High tide"; | |
} | |
} | |
@media (min-width: 600px) and (max-width: 800px) { | |
.nixon { | |
content: "Ex-Presidents"; | |
} | |
} | |
@media (max-width: 1000px) { | |
.johnson { | |
content: "Surfboard Width"; | |
} | |
} | |
@media (min-height: 1000px) and (orientation: portrait) { | |
.carter { | |
content: "Surfboard Height, Portrait"; | |
} | |
} | |
.mandela { | |
font-size: 9px; | |
} | |
@media (min-width: 500px) { | |
.mandela { | |
font-size: 24px; | |
} | |
} | |
.map { | |
content: "lightest", "light"; | |
content: "100, 300"; | |
content: true; | |
content: false; | |
content: 700; | |
content: ("lightest": 100, "light": 300, "medium": 500, "bold": 700); | |
content: ("medium": 500); | |
content: ("medium": 500, "bold": 700); | |
} | |
.weight { | |
font-weight: 500; | |
} | |
.main__paragrapgh { | |
font-size: 1rem; | |
} | |
.main .main__paragraph { | |
font-size: 1rem; | |
} |
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
{ | |
"sass": { | |
"compiler": "dart-sass/1.26.11", | |
"extensions": {}, | |
"syntax": "SCSS", | |
"outputStyle": "expanded" | |
}, | |
"autoprefixer": false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment