Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/core): custom system-level variable prefix not used in some mixins #29513

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/material/core/theming/_definition.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ $theme-version: 1;
neutral-variant: map.get($primary, neutral-variant),
error: map.get($primary, error),
),
color-system-variables-prefix: $system-variables-prefix,
color-tokens: m3-tokens.generate-color-tokens(
$type, $primary, $tertiary, map.get($primary, error), $system-variables-prefix)
)
Expand Down Expand Up @@ -88,6 +89,7 @@ $theme-version: 1;
medium: $medium,
regular: $regular,
),
typography-system-variables-prefix: $system-variables-prefix,
typography-tokens: m3-tokens.generate-typography-tokens(
$brand, $plain, $bold, $medium, $regular, $system-variables-prefix)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,19 @@ describe('theming definition api', () => {
--color-tokens: #{list.length(map.get($data, color-tokens)) > 0};
--typography-tokens: #{list.length(map.get($data, typography-tokens)) > 0};
--density-tokens: #{list.length(map.get($data, density-tokens)) > 0};
--color-system-variables-prefix: #{map.get($data, color-system-variables-prefix)};
--typography-system-variables-prefix: #{map.get($data, typography-system-variables-prefix)};
}
`);
const vars = getRootVars(css);
expect(vars['keys'].split(', ')).toEqual([
'theme-version',
'theme-type',
'palettes',
'color-system-variables-prefix',
'color-tokens',
'font-definition',
'typography-system-variables-prefix',
'typography-tokens',
'density-scale',
'density-tokens',
Expand All @@ -92,6 +96,8 @@ describe('theming definition api', () => {
expect(vars['color-tokens']).toBe('true');
expect(vars['typography-tokens']).toBe('true');
expect(vars['density-tokens']).toBe('true');
expect(vars['typography-system-variables-prefix']).toBe('sys');
expect(vars['color-system-variables-prefix']).toBe('sys');
});

it('should customize colors', () => {
Expand Down Expand Up @@ -253,6 +259,7 @@ describe('theming definition api', () => {
'theme-version',
'theme-type',
'palettes',
'color-system-variables-prefix',
'color-tokens',
]);
});
Expand All @@ -271,13 +278,14 @@ describe('theming definition api', () => {
expect(vars['keys'].split(', ')).toEqual([
'theme-version',
'font-definition',
'typography-system-variables-prefix',
'typography-tokens',
]);
});
});

describe('define-density', () => {
it('should omit non-color info', () => {
it('should omit non-density info', () => {
const css = transpile(`
$theme: mat.define-density();
$data: map.get($theme, $internals);
Expand Down
6 changes: 4 additions & 2 deletions src/material/core/tokens/_m3-tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ $_cached-token-slots: null;
);

$type: map.get($theme, _mat-theming-internals-do-not-access, theme-type);
$system-variables-prefix: map.get($theme, system-variables-prefix) or sys;
$system-variables-prefix: map.get($theme, _mat-theming-internals-do-not-access,
color-system-variables-prefix) or sys;
$primary: map.merge(map.get($palettes, primary), $base-palettes);
$tertiary: map.merge(map.get($palettes, tertiary), $base-palettes);
$error: map.get($palettes, error);
Expand All @@ -160,7 +161,8 @@ $_cached-token-slots: null;
$bold: map.get($font-definition, bold);
$medium: map.get($font-definition, medium);
$regular: map.get($font-definition, regular);
$system-variables-prefix: map.get($theme, system-variables-prefix) or sys;
$system-variables-prefix: map.get($theme, _mat-theming-internals-do-not-access,
typography-system-variables-prefix) or sys;
$ref: (
md-ref-typeface: _generate-ref-typeface-tokens($brand, $plain, $bold, $medium, $regular)
);
Expand Down
Loading