-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
Copy pathicon-demo.ts
78 lines (73 loc) · 2.67 KB
/
icon-demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
import {MatIconModule, MatIconRegistry} from '@angular/material/icon';
import {DomSanitizer} from '@angular/platform-browser';
@Component({
selector: 'mat-icon-demo',
templateUrl: 'icon-demo.html',
styleUrl: 'icon-demo.css',
imports: [MatIconModule],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class IconDemo {
constructor() {
const iconRegistry = inject(MatIconRegistry);
const sanitizer = inject(DomSanitizer);
iconRegistry
.addSvgIcon(
'thumb-up',
sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/thumbup-icon.svg'),
)
.addSvgIconLiteral('bike', sanitizer.bypassSecurityTrustHtml(BIKE_ICON))
.addSvgIconSetInNamespace(
'core',
sanitizer.bypassSecurityTrustResourceUrl('/icon/assets/core-icon-set.svg'),
)
.addSvgIconSetLiteralInNamespace(
'core-inline',
sanitizer.bypassSecurityTrustHtml(INLINE_ICON_SET),
)
.registerFontClassAlias('fontawesome', 'fa');
}
}
const BIKE_ICON =
`
<svg xmlns="http://www.w3.org/2000/svg">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M15.5 5.5c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zM5 12c-2.8 0-5 2.2-5 ` +
`5s2.2 5 5 5 5-2.2 5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 ` +
`1.6 3.5 3.5-1.6 3.5-3.5 3.5zm5.8-10l2.4-2.4.8.8c1.3 1.3 3 2.1 5.1 2.1V9c-1.5 ` +
`0-2.7-.6-3.6-1.5l-1.9-1.9c-.5-.4-1-.6-1.6-.6s-1.1.2-1.4.6L7.8 8.4c-.4.4-.6.9-.6 ` +
`1.4 0 .6.2 1.1.6 1.4L11 14v5h2v-6.2l-2.2-2.3zM19 12c-2.8 0-5 2.2-5 5s2.2 5 5 5 5-2.2 ` +
`5-5-2.2-5-5-5zm0 8.5c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5 3.5 1.6 3.5 3.5-1.6 ` +
`3.5-3.5 3.5z"/>
</svg>
`;
const INLINE_ICON_SET =
`
<svg>
<defs>
<svg id="account-balance">
<path d="M4 10v7h3v-7H4zm6 0v7h3v-7h-3zM2 22h19v-3H2v3zm14-12v7h3v-` +
`7h-3zm-4.5-9L2 6v2h19V6l-9.5-5z"/>
</svg>
<svg id="account-balance-wallet">
<path d="M21 18v1c0 1.1-.9 2-2 2H5c-1.11 0-2-.9-2-2V5c0-1.1.89-2 2-` +
`2h14c1.1 0 2 .9 2 2v1h-9c-1.11 0-2 .9-2 2v8c0 1.1.89 2 2 2h9zm-9` +
`-2h10V8H12v8zm4-2.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"
/>
</svg>
<svg id="account-box">
<path d="M3 5v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H` +
`5c-1.11 0-2 .9-2 2zm12 4c0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-` +
`3 3 1.34 3 3zm-9 8c0-2 4-3.1 6-3.1s6 1.1 6 3.1v1H6v-1z"/>
</svg>
</defs>
</svg>
`;