Created
July 7, 2023 14:28
-
-
Save sturobson/fe96339fb4b12ba34bd47e59d383ebc1 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
$colors: ( | |
red: #ff0000, | |
blue: #00ff00, | |
green: #00ffff, | |
yellow: #ffff00, | |
purple: #ff00ff, | |
pink: #ff0080, | |
orange: #ff8000 | |
); | |
$white: #ffffff; | |
$black: #000000; | |
$color-percentages: ( | |
red: (10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%), | |
green: (20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%) | |
); | |
$colors-map: (); | |
@each $color, $value in $colors { | |
$color-shades: (); | |
@for $i from 1 through 9 { | |
$percentage: if(map-has-key($color-percentages, $color), nth(map-get($color-percentages, $color), $i), $i * 10%); | |
$shade: mix($white, $value, $percentage); | |
$color-shades: map-merge($color-shades, (#{$i}00: $shade)); | |
} | |
$colors-map: map-merge($colors-map, ($color: $color-shades)); | |
} | |
$neutral-map: (); | |
@for $i from 1 through 9 { | |
$shade: $i * 100; | |
$percentage: $i * 10%; | |
$color: mix($white, $black, $percentage); | |
$neutral-map: map-merge($neutral-map, ($shade: $color)); | |
} | |
// define your use cases | |
$primary: map-get($colors-map, red); | |
$secondary: map-get($colors-map, blue); | |
$tertiary: map-get($colors-map, green); | |
// the map of the colours for your use case | |
$decision-map: ( | |
primary: $primary, | |
secondary: $secondary, | |
tertiary: $tertiary | |
); | |
// make a selection of colours | |
$desired-color: "primary"; // Specify the desired color here | |
$desired-shades: (200, 300, 400, 600, 800); | |
$selected-color-map: map-get($decision-map, $desired-color); // Select the desired color map using map-get | |
// Mixin to apply a specific color shade to an element | |
@mixin apply-color-shade($color, $shade, $property: color) { | |
$color-map: map-get($colors-map, $color); | |
$value: map-get($color-map, '#{$shade}'); | |
#{$property}: $value; | |
} | |
// Mixin to apply a specific neutral shade to an element | |
@mixin apply-neutral-shade($shade, $property: color) { | |
$value: map-get($neutral-map, $shade); | |
#{$property}: $value; | |
} | |
@mixin decision($color, $shade, $property: color) { | |
$color-map: map-get($decision-map, $color); | |
$value: map-get($color-map, '#{$shade}'); | |
#{$property}: $value; | |
} | |
.thing { | |
@include decision(primary, 200); | |
@include apply-color-shade(red, 100); | |
@include apply-neutral-shade(100); | |
} | |
// all colours | |
:root { | |
@each $color, $shades in $colors-map { | |
@each $shade, $value in $shades { | |
--#{$color}--#{$shade}: #{$value}; | |
} | |
} | |
} | |
// neutrals | |
:root { | |
@each $shade, $value in $neutral-map { | |
--neutral--#{$shade}: #{$value}; | |
} | |
} | |
// print the selection and everything else | |
:root { | |
@each $color, $shades in $decision-map { | |
// Print tertiary and secondary colors in full | |
@if $color != $desired-color { | |
@each $shade, $value in $shades { | |
--#{$color}--#{$shade}: #{$value}; | |
} | |
} | |
// Print desired shades for the desired color | |
@if $color == $desired-color and $desired-shades { | |
@each $shade in $desired-shades { | |
$shade-str: unquote('#{$shade}'); // Convert the shade to a string | |
$value: map-get($selected-color-map, $shade-str); | |
--#{$desired-color}--#{$shade-str}: #{$value}; | |
} | |
} | |
} | |
} | |
:root { | |
@each $shade in $desired-shades { | |
$shade-str: unquote('#{$shade}'); // Convert the shade to a string | |
$value: map-get($selected-color-map, $shade-str); | |
--#{$desired-color}--#{$shade-str}: #{$value}; | |
} | |
} | |
// create utility classes | |
@each $color, $shades in $decision-map { | |
@each $shade, $value in $shades { | |
.text-#{$color}--#{$shade} { | |
color: #{$value}; | |
} | |
} | |
} | |
$generate-text-css: true; | |
@if global-variable-exists(generate-text-css) { | |
@each $color, $shades in $decision-map { | |
@each $shade, $value in $shades { | |
.text-#{$color}--#{$shade} { | |
color: --#{$color}--#{$shade}; | |
} | |
} | |
} | |
} | |
// @each $color, $shades in $decision-map { | |
// @each $shade, $value in $shades { | |
// .background-#{$color}--#{$shade} { | |
// background-color: #{$value}; | |
// } | |
// } | |
// } | |
// @each $color, $shades in $decision-map { | |
// @each $shade, $value in $shades { | |
// .border-#{$color}--#{$shade} { | |
// border-color: #{$value}; | |
// } | |
// } | |
// } | |
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
.thing { | |
color: #ff3333; | |
color: #ff1a1a; | |
color: #1a1a1a; | |
} | |
:root { | |
--red--100: #ff1a1a; | |
--red--200: #ff3333; | |
--red--300: #ff4d4d; | |
--red--400: #ff6666; | |
--red--500: #ff8080; | |
--red--600: #ff9999; | |
--red--700: #ffb3b3; | |
--red--800: #ffcccc; | |
--red--900: #ffe6e6; | |
--blue--100: #1aff1a; | |
--blue--200: #33ff33; | |
--blue--300: #4dff4d; | |
--blue--400: #66ff66; | |
--blue--500: #80ff80; | |
--blue--600: #99ff99; | |
--blue--700: #b3ffb3; | |
--blue--800: #ccffcc; | |
--blue--900: #e6ffe6; | |
--green--100: #33ffff; | |
--green--200: #4dffff; | |
--green--300: #66ffff; | |
--green--400: #80ffff; | |
--green--500: #99ffff; | |
--green--600: #b3ffff; | |
--green--700: #ccffff; | |
--green--800: #e6ffff; | |
--green--900: white; | |
--yellow--100: #ffff1a; | |
--yellow--200: #ffff33; | |
--yellow--300: #ffff4d; | |
--yellow--400: #ffff66; | |
--yellow--500: #ffff80; | |
--yellow--600: #ffff99; | |
--yellow--700: #ffffb3; | |
--yellow--800: #ffffcc; | |
--yellow--900: #ffffe6; | |
--purple--100: #ff1aff; | |
--purple--200: #ff33ff; | |
--purple--300: #ff4dff; | |
--purple--400: #ff66ff; | |
--purple--500: #ff80ff; | |
--purple--600: #ff99ff; | |
--purple--700: #ffb3ff; | |
--purple--800: #ffccff; | |
--purple--900: #ffe6ff; | |
--pink--100: #ff1a8d; | |
--pink--200: #ff3399; | |
--pink--300: #ff4da6; | |
--pink--400: #ff66b3; | |
--pink--500: #ff80c0; | |
--pink--600: #ff99cc; | |
--pink--700: #ffb3d9; | |
--pink--800: #ffcce6; | |
--pink--900: #ffe6f2; | |
--orange--100: #ff8d1a; | |
--orange--200: #ff9933; | |
--orange--300: #ffa64d; | |
--orange--400: #ffb366; | |
--orange--500: #ffc080; | |
--orange--600: #ffcc99; | |
--orange--700: #ffd9b3; | |
--orange--800: #ffe6cc; | |
--orange--900: #fff2e6; | |
} | |
:root { | |
--neutral--100: #1a1a1a; | |
--neutral--200: #333333; | |
--neutral--300: #4d4d4d; | |
--neutral--400: #666666; | |
--neutral--500: gray; | |
--neutral--600: #999999; | |
--neutral--700: #b3b3b3; | |
--neutral--800: #cccccc; | |
--neutral--900: #e6e6e6; | |
} | |
:root { | |
--primary--200: #ff3333; | |
--primary--300: #ff4d4d; | |
--primary--400: #ff6666; | |
--primary--600: #ff9999; | |
--primary--800: #ffcccc; | |
--secondary--100: #1aff1a; | |
--secondary--200: #33ff33; | |
--secondary--300: #4dff4d; | |
--secondary--400: #66ff66; | |
--secondary--500: #80ff80; | |
--secondary--600: #99ff99; | |
--secondary--700: #b3ffb3; | |
--secondary--800: #ccffcc; | |
--secondary--900: #e6ffe6; | |
--tertiary--100: #33ffff; | |
--tertiary--200: #4dffff; | |
--tertiary--300: #66ffff; | |
--tertiary--400: #80ffff; | |
--tertiary--500: #99ffff; | |
--tertiary--600: #b3ffff; | |
--tertiary--700: #ccffff; | |
--tertiary--800: #e6ffff; | |
--tertiary--900: white; | |
} | |
:root { | |
--primary--200: #ff3333; | |
--primary--300: #ff4d4d; | |
--primary--400: #ff6666; | |
--primary--600: #ff9999; | |
--primary--800: #ffcccc; | |
} | |
.text-primary--100 { | |
color: #ff1a1a; | |
} | |
.text-primary--200 { | |
color: #ff3333; | |
} | |
.text-primary--300 { | |
color: #ff4d4d; | |
} | |
.text-primary--400 { | |
color: #ff6666; | |
} | |
.text-primary--500 { | |
color: #ff8080; | |
} | |
.text-primary--600 { | |
color: #ff9999; | |
} | |
.text-primary--700 { | |
color: #ffb3b3; | |
} | |
.text-primary--800 { | |
color: #ffcccc; | |
} | |
.text-primary--900 { | |
color: #ffe6e6; | |
} | |
.text-secondary--100 { | |
color: #1aff1a; | |
} | |
.text-secondary--200 { | |
color: #33ff33; | |
} | |
.text-secondary--300 { | |
color: #4dff4d; | |
} | |
.text-secondary--400 { | |
color: #66ff66; | |
} | |
.text-secondary--500 { | |
color: #80ff80; | |
} | |
.text-secondary--600 { | |
color: #99ff99; | |
} | |
.text-secondary--700 { | |
color: #b3ffb3; | |
} | |
.text-secondary--800 { | |
color: #ccffcc; | |
} | |
.text-secondary--900 { | |
color: #e6ffe6; | |
} | |
.text-tertiary--100 { | |
color: #33ffff; | |
} | |
.text-tertiary--200 { | |
color: #4dffff; | |
} | |
.text-tertiary--300 { | |
color: #66ffff; | |
} | |
.text-tertiary--400 { | |
color: #80ffff; | |
} | |
.text-tertiary--500 { | |
color: #99ffff; | |
} | |
.text-tertiary--600 { | |
color: #b3ffff; | |
} | |
.text-tertiary--700 { | |
color: #ccffff; | |
} | |
.text-tertiary--800 { | |
color: #e6ffff; | |
} | |
.text-tertiary--900 { | |
color: white; | |
} | |
.text-primary--100 { | |
color: --primary--100; | |
} | |
.text-primary--200 { | |
color: --primary--200; | |
} | |
.text-primary--300 { | |
color: --primary--300; | |
} | |
.text-primary--400 { | |
color: --primary--400; | |
} | |
.text-primary--500 { | |
color: --primary--500; | |
} | |
.text-primary--600 { | |
color: --primary--600; | |
} | |
.text-primary--700 { | |
color: --primary--700; | |
} | |
.text-primary--800 { | |
color: --primary--800; | |
} | |
.text-primary--900 { | |
color: --primary--900; | |
} | |
.text-secondary--100 { | |
color: --secondary--100; | |
} | |
.text-secondary--200 { | |
color: --secondary--200; | |
} | |
.text-secondary--300 { | |
color: --secondary--300; | |
} | |
.text-secondary--400 { | |
color: --secondary--400; | |
} | |
.text-secondary--500 { | |
color: --secondary--500; | |
} | |
.text-secondary--600 { | |
color: --secondary--600; | |
} | |
.text-secondary--700 { | |
color: --secondary--700; | |
} | |
.text-secondary--800 { | |
color: --secondary--800; | |
} | |
.text-secondary--900 { | |
color: --secondary--900; | |
} | |
.text-tertiary--100 { | |
color: --tertiary--100; | |
} | |
.text-tertiary--200 { | |
color: --tertiary--200; | |
} | |
.text-tertiary--300 { | |
color: --tertiary--300; | |
} | |
.text-tertiary--400 { | |
color: --tertiary--400; | |
} | |
.text-tertiary--500 { | |
color: --tertiary--500; | |
} | |
.text-tertiary--600 { | |
color: --tertiary--600; | |
} | |
.text-tertiary--700 { | |
color: --tertiary--700; | |
} | |
.text-tertiary--800 { | |
color: --tertiary--800; | |
} | |
.text-tertiary--900 { | |
color: --tertiary--900; | |
} |
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.32.12", | |
"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