Skip to content

Commit

Permalink
feat(material/core): add option to configure prefix of system variabl…
Browse files Browse the repository at this point in the history
…es (#29139)
  • Loading branch information
konstantindenerz committed Jun 5, 2024
1 parent 03e10df commit 6f698fa
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 156 deletions.
5 changes: 3 additions & 2 deletions src/material/core/theming/_config-validation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
@if $err {
@return (#{'$config should be a color configuration object. Got:'} $config);
}
$allowed: (theme-type, primary, tertiary, use-system-variables);
$allowed: (theme-type, primary, tertiary, use-system-variables, system-variables-prefix);
$err: validation.validate-allowed-values(map.keys($config or ()), $allowed...);
@if $err {
@return (
Expand Down Expand Up @@ -134,7 +134,8 @@
bold-weight,
medium-weight,
regular-weight,
use-system-variables
use-system-variables,
system-variables-prefix
);
$err: validation.validate-allowed-values(map.keys($config or ()), $allowed...);
@if $err {
Expand Down
6 changes: 4 additions & 2 deletions src/material/core/theming/_definition.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ $theme-version: 1;
$type: map.get($config, theme-type) or light;
$primary: map.get($config, primary) or palettes.$violet-palette;
$tertiary: map.get($config, tertiary) or $primary;
$system-variables-prefix: map.get($config, system-variables-prefix) or sys;
sass-utils.$use-system-color-variables: map.get($config, use-system-variables) or false;

@return (
Expand All @@ -55,7 +56,7 @@ $theme-version: 1;
error: map.get($primary, error),
),
color-tokens: m3-tokens.generate-color-tokens(
$type, $primary, $tertiary, map.get($primary, error))
$type, $primary, $tertiary, map.get($primary, error), $system-variables-prefix)
)
);
}
Expand All @@ -74,6 +75,7 @@ $theme-version: 1;
$bold: map.get($config, bold-weight) or 700;
$medium: map.get($config, medium-weight) or 500;
$regular: map.get($config, regular-weight) or 400;
$system-variables-prefix: map.get($config, system-variables-prefix) or sys;
sass-utils.$use-system-typography-variables: map.get($config, use-system-variables) or false;

@return (
Expand All @@ -87,7 +89,7 @@ $theme-version: 1;
regular: $regular,
),
typography-tokens: m3-tokens.generate-typography-tokens(
$brand, $plain, $bold, $medium, $regular)
$brand, $plain, $bold, $medium, $regular, $system-variables-prefix)
)
);
}
Expand Down
Loading

0 comments on commit 6f698fa

Please sign in to comment.