Skip to content

Commit

Permalink
main - a72648c build: update the tokens extraction script for new ove…
Browse files Browse the repository at this point in the history
…rrides setup
  • Loading branch information
crisbeto committed Oct 18, 2024
1 parent d9fae24 commit f637802
Show file tree
Hide file tree
Showing 44 changed files with 378 additions and 222 deletions.
12 changes: 8 additions & 4 deletions autocomplete/_autocomplete-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@
}
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-autocomplete.$prefix,
tokens: tokens-mat-autocomplete.get-token-slots(),
)
),
);
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-autocomplete') {
@if inspection.get-theme-version($theme) == 1 {
Expand Down
16 changes: 10 additions & 6 deletions badge/_badge-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,22 @@
}
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-badge.$prefix,
tokens: tokens-mat-badge.get-token-slots(),
)
),
);
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-badge.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
12 changes: 8 additions & 4 deletions bottom-sheet/_bottom-sheet-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@
}
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-bottom-sheet.$prefix,
tokens: tokens-mat-bottom-sheet.get-token-slots(),
)
),
);
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-bottom-sheet') {
@if inspection.get-theme-version($theme) == 1 {
Expand Down
17 changes: 11 additions & 6 deletions button-toggle/_button-toggle-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,12 @@
}
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
$legacy-tokens: tokens-mat-legacy-button-toggle.get-token-slots();
$standard-tokens: tokens-mat-standard-button-toggle.get-token-slots();
@include token-utils.batch-create-token-values(
$tokens,

@return (
(
namespace: tokens-mat-legacy-button-toggle.$prefix,
tokens: $legacy-tokens,
Expand All @@ -102,10 +101,16 @@
(
namespace: tokens-mat-standard-button-toggle.$prefix,
tokens: $standard-tokens,
)
),
);
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-button-toggle.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
16 changes: 10 additions & 6 deletions button/_button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,8 @@
}
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
$mdc-filled-button-tokens: tokens-mdc-filled-button.get-token-slots();
$mat-filled-button-tokens: tokens-mat-filled-button.get-token-slots();
$mdc-outlined-button-tokens: tokens-mdc-outlined-button.get-token-slots();
Expand All @@ -373,8 +372,7 @@
$mdc-text-button-tokens: tokens-mdc-text-button.get-token-slots();
$mat-text-button-tokens: tokens-mat-text-button.get-token-slots();

@include token-utils.batch-create-token-values(
$tokens,
@return (
(
namespace: tokens-mdc-filled-button.$prefix,
tokens: $mdc-filled-button-tokens,
Expand Down Expand Up @@ -414,10 +412,16 @@
namespace: tokens-mat-text-button.$prefix,
tokens: $mat-text-button-tokens,
prefix: 'text-',
)
),
);
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-button.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
16 changes: 10 additions & 6 deletions button/_fab-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@
}
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mdc-fab.$prefix,
tokens: tokens-mdc-fab.get-token-slots(),
Expand All @@ -185,10 +183,16 @@
namespace: tokens-mat-fab-small.$prefix,
tokens: tokens-mat-fab-small.get-token-slots(),
prefix: 'small-',
)
),
);
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-checkbox.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
12 changes: 8 additions & 4 deletions button/_icon-button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,24 @@
}
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mdc-icon-button.$prefix,
tokens: tokens-mdc-icon-button.get-token-slots(),
),
(
namespace: tokens-mat-icon-button.$prefix,
tokens: tokens-mat-icon-button.get-token-slots(),
)
),
);
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-icon-button.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
12 changes: 8 additions & 4 deletions card/_card-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@
}
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-card.$prefix,
tokens: tokens-mat-card.get-token-slots(),
Expand All @@ -109,10 +109,14 @@
namespace: tokens-mdc-outlined-card.$prefix,
tokens: tokens-mdc-outlined-card.get-token-slots(),
prefix: 'outlined-',
)
),
);
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-card') {
@if inspection.get-theme-version($theme) == 1 {
Expand Down
16 changes: 10 additions & 6 deletions checkbox/_checkbox-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,26 @@
}
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-checkbox.$prefix,
tokens: tokens-mat-checkbox.get-token-slots(),
),
(
namespace: tokens-mdc-checkbox.$prefix,
tokens: tokens-mdc-checkbox.get-token-slots(),
)
),
);
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-checkbox.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
16 changes: 10 additions & 6 deletions chips/_chips-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,26 @@
}
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mdc-chip.$prefix,
tokens: tokens-mdc-chip.get-token-slots(),
),
(
namespace: tokens-mat-chip.$prefix,
tokens: tokens-mat-chip.get-token-slots(),
)
),
);
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-chips.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
9 changes: 2 additions & 7 deletions core/_core-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@
}
}

// This theme is a special case where not all of the imported tokens are supported in `overrides`.
// To aid the docs token extraction, we have to pull the `overrides` token config out into a
// separate function.
// !!!Important!!! renaming or removal of this function requires the `extract-tokens.ts` script to
// be updated as well.
@function _get-supported-overrides-tokens() {
@function _define-overrides() {
$app-tokens: tokens-mat-app.get-token-slots();
$ripple-tokens: tokens-mat-ripple.get-token-slots();
$option-tokens: tokens-mat-option.get-token-slots();
Expand All @@ -101,7 +96,7 @@
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _get-supported-overrides-tokens()...);
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

// Mixin that renders all of the core styles that depend on the theme.
Expand Down
12 changes: 8 additions & 4 deletions core/option/_optgroup-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@
}
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-optgroup.$prefix,
tokens: tokens-mat-optgroup.get-token-slots(),
)
),
);
}

@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

@mixin theme($theme) {
@include theming.private-check-duplicate-theme-styles($theme, 'mat-optgroup') {
@if inspection.get-theme-version($theme) == 1 {
Expand Down
16 changes: 10 additions & 6 deletions core/option/_option-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,22 @@
}
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values(
$tokens,
/// Defines the tokens that will be available in the `overrides` mixin and for docs extraction.
@function _define-overrides() {
@return (
(
namespace: tokens-mat-option.$prefix,
tokens: tokens-mat-option.get-token-slots(),
)
),
);
}

/// Outputs the CSS variable values for the given tokens.
/// @param {Map} $tokens The token values to emit.
@mixin overrides($tokens: ()) {
@include token-utils.batch-create-token-values($tokens, _define-overrides()...);
}

/// Outputs all (base, color, typography, and density) theme styles for the mat-option.
/// @param {Map} $theme The theme to generate styles for.
/// @param {ArgList} Additional optional arguments (only supported for M3 themes):
Expand Down
Loading

0 comments on commit f637802

Please sign in to comment.