Skip to content

Commit c9f8075

Browse files
committed
docs: improve styling filters
close #30911
1 parent 7dfabca commit c9f8075

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

docs/src/app/pages/component-viewer/token-table.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,23 @@
1010

1111
<mat-form-field subscriptSizing="dynamic" appearance="outline">
1212
<mat-label>Filter by type</mat-label>
13-
<mat-select [value]="typeFilter()" (selectionChange)="typeFilter.set($event.value)">
13+
<mat-select [(value)]="typeFilter">
1414
@for (type of types; track $index) {
1515
<mat-option [value]="type">{{type | titlecase}}</mat-option>
1616
}
1717
</mat-select>
18+
@if (typeFilter()) {
19+
<button matSuffix matIconButton aria-label="Clear type filter" matTooltip="Clear type filter"
20+
(click)="typeFilter.set(null); $event.stopPropagation()">
21+
<mat-icon>clear</mat-icon>
22+
</button>
23+
}
24+
</mat-form-field>
25+
26+
<mat-form-field subscriptSizing="dynamic" appearance="outline">
27+
<mat-label>Filter by system token</mat-label>
28+
<input #systemTokenInput matInput [value]="systemTokenFilter()"
29+
(input)="systemTokenFilter.set(systemTokenInput.value)"/>
1830
</mat-form-field>
1931

2032
<button mat-button (click)="reset()">Reset filters</button>

docs/src/app/pages/component-viewer/token-table.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
import {ChangeDetectionStrategy, Component, computed, input, signal} from '@angular/core';
1010
import {TitleCasePipe} from '@angular/common';
11-
import {MatButton} from '@angular/material/button';
12-
import {MatFormField, MatLabel} from '@angular/material/form-field';
11+
import {MatButton, MatIconButton} from '@angular/material/button';
12+
import {MatFormField, MatLabel, MatSuffix} from '@angular/material/form-field';
13+
import {MatIcon} from '@angular/material/icon';
1314
import {MatInput} from '@angular/material/input';
1415
import {MatOption, MatSelect} from '@angular/material/select';
16+
import {MatTooltip} from '@angular/material/tooltip';
1517
import {TokenName} from './token-name';
1618

1719
type TokenType = 'base' | 'color' | 'typography' | 'density';
@@ -31,34 +33,42 @@ export interface Token {
3133
changeDetection: ChangeDetectionStrategy.OnPush,
3234
imports: [
3335
MatButton,
36+
MatIconButton,
3437
MatFormField,
3538
MatLabel,
39+
MatSuffix,
40+
MatIcon,
3641
MatInput,
3742
MatSelect,
3843
MatOption,
44+
MatTooltip,
3945
TokenName,
4046
TitleCasePipe,
4147
],
4248
})
4349
export class TokenTable {
44-
tokens = input.required<Token[]>();
50+
readonly tokens = input.required<Token[]>();
4551

46-
protected nameFilter = signal('');
47-
protected typeFilter = signal<TokenType | null>(null);
48-
protected types: TokenType[] = ['base', 'color', 'typography', 'density'];
49-
protected filteredTokens = computed(() => {
52+
protected readonly nameFilter = signal('');
53+
protected readonly typeFilter = signal<TokenType | null>(null);
54+
protected readonly systemTokenFilter = signal('');
55+
protected readonly types: TokenType[] = ['base', 'color', 'typography', 'density'];
56+
protected readonly filteredTokens = computed(() => {
5057
const name = this.nameFilter().trim().toLowerCase();
5158
const typeFilter = this.typeFilter();
59+
const systemTokenFilter = this.systemTokenFilter();
5260

5361
return this.tokens().filter(
5462
token =>
5563
(!name || token.overridesName.toLowerCase().includes(name)) &&
56-
(!typeFilter || token.type === typeFilter),
64+
(!typeFilter || token.type === typeFilter) &&
65+
(!systemTokenFilter || token.derivedFrom?.toLowerCase().includes(systemTokenFilter)),
5766
);
5867
});
5968

6069
protected reset() {
6170
this.nameFilter.set('');
6271
this.typeFilter.set(null);
72+
this.systemTokenFilter.set('');
6373
}
6474
}

0 commit comments

Comments
 (0)