@@ -15,6 +15,7 @@ $themes: (
1515 ' default' :
1616 (
1717 // 'colors': overrides $colors-[light|dark]
18+ // 'use-colors': if given, specifies which colors from the default palette to include
1819 // 'colors-text-scale': overrides $colors-text-scale-[light|dark]
1920 // 'semantic-colors': overrides $semantic-colors
2021 // 'font': overrides $font
@@ -74,6 +75,18 @@ $themes-categories-applied-at: (
7475 @return map .merge ($default-map , $map );
7576}
7677
78+ @function strip-colors ($colors , $use-colors ) {
79+ @if ($use-colors ==null) {
80+ @return $colors ;
81+ }
82+
83+ $new-colors-map : ();
84+ @each $color in $use-colors {
85+ $new-colors-map : map .merge ($new-colors-map , ($color : map .get ($colors , $color )));
86+ }
87+ @return $new-colors-map ;
88+ }
89+
7790// Normalize theme data, fill in defaults, and add computed values.
7891@function normalize-theme ($category , $theme-name , $theme ) {
7992 $theme : map .merge ($theme , (' name' : $theme-name , ' css-name' : get-theme-css-name ($category , $theme-name )));
@@ -83,6 +96,7 @@ $themes-categories-applied-at: (
8396 // colors
8497 $colors-default : if ($brightness == ' light' , colors .$colors-light , colors .$colors-dark );
8598 $colors : combine-with-default-map (map .get ($theme , ' colors' ), $colors-default );
99+ $colors : strip-colors ($colors , map .get ($theme , ' use-colors' ));
86100 $theme : map .merge ($theme , (' colors' : $colors ));
87101
88102 // colors-text-scale
0 commit comments