Skip to content

refactor(material/core): move classes out of core #29811

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

Merged
merged 4 commits into from
Oct 2, 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
26 changes: 17 additions & 9 deletions src/material/core/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

// Mixin that renders all of the core styles that are not theme-dependent.
@mixin core() {
@include cdk.a11y-visually-hidden();
@include private.structural-styling();
}

// Emits the mat-app-background CSS class. This predefined class sets the
// background color and text color of an element.
@mixin app-background() {
// TODO: Move ripple styles to be dynamically loaded instead of in core.
// This variable is used as a fallback for the ripple element's
// background color. However, if it isn't defined anywhere, then MSS
Expand All @@ -14,9 +21,6 @@
--mat-app-on-surface: initial;
}

@include cdk.a11y-visually-hidden();
@include private.structural-styling();

// Wrapper element that provides the theme background when the
// user's content isn't inside of a `mat-sidenav-container`.
@at-root {
Expand All @@ -26,7 +30,17 @@
@include token-utils.create-token-slot(background-color, background-color, transparent);
@include token-utils.create-token-slot(color, text-color, inherit);
}
}
}
}

// Emits CSS classes for applying elevation. These classes follow the pattern
// mat-elevation-z#, where # is the elevation number you want, from 0 to 24.
// These predefined classes use the CSS box-shadow settings defined by the
// Material Design specification.
@mixin elevation-classes() {
@at-root {
@include token-utils.use-tokens(tokens-mat-app.$prefix, tokens-mat-app.get-token-slots()) {
// Provides external CSS classes for each elevation value. Each CSS class is formatted as
// `mat-elevation-z$z-value` where `$z-value` corresponds to the z-space to which the element
// is elevated.
Expand All @@ -42,9 +56,3 @@
}
}
}

// Mixin that provides the .mat-app-background class.
@mixin app-background() {}

// Mixin that provides the .mat-elevation-* classes.
@mixin elevation-classes() {}
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/azure-blue.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@use '../../typography/typography';

@include core.core();
@include core.app-background();
@include core.elevation-classes();

$theme: definition.define-theme((
color: (
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/cyan-orange.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@use '../../typography/typography';

@include core.core();
@include core.app-background();
@include core.elevation-classes();

$theme: definition.define-theme((
color: (
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/deeppurple-amber.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

// Include non-theme styles for core.
@include core.core();
@include core.app-background();
@include core.elevation-classes();

// Define a theme.
$primary: m2.define-palette(m2.$deep-purple-palette);
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/indigo-pink.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

// Include non-theme styles for core.
@include core.core();
@include core.app-background();
@include core.elevation-classes();

// Define a theme.
$primary: m2.define-palette(m2.$indigo-palette);
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/magenta-violet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@use '../../typography/typography';

@include core.core();
@include core.app-background();
@include core.elevation-classes();

$theme: definition.define-theme((
color: (
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/pink-bluegrey.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

// Include non-theme styles for core.
@include core.core();
@include core.app-background();
@include core.elevation-classes();

// Define a theme.
$primary: m2.define-palette(m2.$pink-palette, 700, 500, 900);
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/purple-green.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

// Include non-theme styles for core.
@include core.core();
@include core.app-background();
@include core.elevation-classes();

// Define a theme.
$primary: m2.define-palette(m2.$purple-palette, 700, 500, 800);
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/theming/prebuilt/rose-red.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@use '../../typography/typography';

@include core.core();
@include core.app-background();
@include core.elevation-classes();

$theme: definition.define-theme((
color: (
Expand Down
Loading