Skip to content
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
4 changes: 2 additions & 2 deletions src/dev-app/list/list-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h2>Dense lists</h2>
<h2>Nav lists</h2>
<mat-nav-list>
@for (link of links; track link) {
<a mat-list-item [href]="link.href" [activated]="isActivated(link.href)">
<a mat-list-item [href]="link.href" [activated]="isActivated(link)">
{{ link.name }}
</a>
}
Expand All @@ -120,7 +120,7 @@ <h2>Nav lists</h2>
}
<mat-nav-list>
@for (link of links; track link; let last = $last) {
<a mat-list-item [href]="link.href" [activated]="isActivated(link.href)">
<a mat-list-item [href]="link.href" [activated]="isActivated(link)">
<mat-icon matListItemIcon>folder</mat-icon>
<span matListItemTitle>{{ link.name }}</span>
</a>
Expand Down
11 changes: 8 additions & 3 deletions src/dev-app/list/list-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import {MatListModule, MatListOptionTogglePosition} from '@angular/material/list
import {MatIconModule} from '@angular/material/icon';
import {CommonModule} from '@angular/common';

interface Link {
name: string;
href: string;
}

@Component({
selector: 'list-demo',
templateUrl: 'list-demo.html',
Expand Down Expand Up @@ -52,7 +57,7 @@ export class ListDemo {
},
];

links: {name: string; href: string}[] = [
links: Link[] = [
{name: 'Inbox', href: '/list#inbox'},
{name: 'Outbox', href: '/list#outbox'},
{name: 'Spam', href: '/list#spam'},
Expand Down Expand Up @@ -85,7 +90,7 @@ export class ListDemo {
alert(msg);
}

isActivated(href: string) {
return window.location.href === new URL(href, window.location.href).toString();
isActivated(link: Link) {
return `${window.location.pathname}${window.location.hash}` === link.href;
}
}
11 changes: 11 additions & 0 deletions src/material-experimental/theming/_custom-tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,17 @@
));
}

/// Generates custom tokens for the mat-list.
/// @param {Map} $systems The MDC system tokens
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values
/// @return {Map} A set of custom tokens for the mat-list
@function list($systems, $exclude-hardcoded) {
@return (
active-indicator-color: map.get($systems, md-sys-color, secondary-container),
active-indicator-shape: map.get($systems, md-sys-shape, corner-full),
);
}

/// Generates custom tokens for the mat-button.
/// @param {Map} $systems The MDC system tokens
/// @param {Boolean} $exclude-hardcoded Whether to exclude hardcoded token values
Expand Down
5 changes: 5 additions & 0 deletions src/material-experimental/theming/_m3-tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,11 @@
custom-tokens.filled-button($systems, $exclude-hardcoded),
$token-slots
),
_namespace-tokens(
(mat, list),
custom-tokens.list($systems, $exclude-hardcoded),
$token-slots
),
_namespace-tokens(
// Note: in M3 the "protected" button is called "elevated".
(mat, protected-button),
Expand Down
6 changes: 5 additions & 1 deletion src/material/core/tokens/m2/mat/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ $prefix: (mat, list);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
@function get-unthemable-tokens() {
@return ();
@return (
// active indicator themable with M3
active-indicator-color: transparent,
active-indicator-shape: 0,
);
}

// Tokens that can be configured through Angular Material's color theming API.
Expand Down
8 changes: 8 additions & 0 deletions src/material/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,12 @@ mat-action-list button {
@include token-utils.create-token-slot(margin-inline-start, list-item-leading-icon-start-space);
@include token-utils.create-token-slot(margin-inline-end, list-item-leading-icon-end-space);
}

a.mdc-list-item.mdc-list-item--activated {
@include token-utils.create-token-slot(background-color, active-indicator-color);
// active-indicator-shape overrides list-item-container-shape
&.mdc-list-item {
@include token-utils.create-token-slot(border-radius, active-indicator-shape);
}
}
}