Skip to content

fix(material/sort): simplify m2 sort color #31165

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 2 commits into from
May 22, 2025
Merged
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
22 changes: 1 addition & 21 deletions src/material/sort/_m2-sort.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@use 'sass:color';
@use 'sass:meta';
@use '../core/theming/inspection';

// Tokens that can't be configured through Angular Material's current theming API,
Expand All @@ -10,26 +8,8 @@

// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$table-background: inspection.get-theme-color($theme, background, card);
$text-color: inspection.get-theme-color($theme, foreground, secondary-text);
$arrow-color: null;

// Because the arrow is made up of multiple elements that are stacked on top of each other,
// we can't use the semi-transparent color from the theme directly. If the value is a color
// *type*, we convert it into a solid color by taking the opacity from the rgba value and
// using the value to determine the percentage of the background to put into foreground
// when mixing the colors together. Otherwise, if it resolves to something different
// (e.g. it resolves to a CSS variable), we use the color directly.
@if (meta.type-of($table-background) == color and meta.type-of($text-color) == color) {
$text-opacity: color.opacity($text-color);
$arrow-color: color.mix($table-background, rgba($text-color, 1), (1 - $text-opacity) * 100%);
}
@else {
$arrow-color: $text-color;
}

@return (
sort-arrow-color: $arrow-color,
sort-arrow-color: inspection.get-theme-color($theme, foreground, text),
);
}

Expand Down
Loading