@almoamendev/ngx-md3 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/fesm2022/almoamendev-ngx-md3.mjs +4368 -0
- package/fesm2022/almoamendev-ngx-md3.mjs.map +1 -0
- package/package.json +40 -0
- package/src/lib/styles/md3.scss +523 -0
- package/src/lib/styles/tokens/md-border-radius.scss +12 -0
- package/src/lib/styles/tokens/md-elevation.scss +25 -0
- package/src/lib/styles/tokens/md-grid.scss +24 -0
- package/src/lib/styles/tokens/md-motion.scss +47 -0
- package/src/lib/styles/tokens/md-scheme.scss +143 -0
- package/src/lib/styles/typography/type-body.spec.ts +28 -0
- package/src/lib/styles/typography/type-body.ts +42 -0
- package/src/lib/styles/typography/type-display.spec.ts +28 -0
- package/src/lib/styles/typography/type-display.ts +42 -0
- package/src/lib/styles/typography/type-headline.spec.ts +28 -0
- package/src/lib/styles/typography/type-headline.ts +42 -0
- package/src/lib/styles/typography/type-label.spec.ts +28 -0
- package/src/lib/styles/typography/type-label.ts +42 -0
- package/src/lib/styles/typography/type-title.spec.ts +28 -0
- package/src/lib/styles/typography/type-title.ts +42 -0
- package/types/almoamendev-ngx-md3.d.ts +1298 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
:root, .md-scheme-light {
|
|
2
|
+
/* Primary */
|
|
3
|
+
--md-scheme-primary: 92, 77, 212; /* P-40 */
|
|
4
|
+
--md-scheme-on-primary: 255, 255, 255; /* P-100 */
|
|
5
|
+
--md-scheme-primary-container: 224, 217, 255; /* P-90 */
|
|
6
|
+
--md-scheme-on-primary-container: 28, 14, 90; /* P-30 */
|
|
7
|
+
|
|
8
|
+
/* Secondary */
|
|
9
|
+
--md-scheme-secondary: 89, 84, 106; /* S-40 */
|
|
10
|
+
--md-scheme-on-secondary: 255, 255, 255; /* S-100 */
|
|
11
|
+
--md-scheme-secondary-container: 221, 216, 232; /* S-90 */
|
|
12
|
+
--md-scheme-on-secondary-container: 28, 24, 40; /* S-30 */
|
|
13
|
+
|
|
14
|
+
/* Tertiary */
|
|
15
|
+
--md-scheme-tertiary: 122, 85, 102; /* T-40 */
|
|
16
|
+
--md-scheme-on-tertiary: 255, 255, 255; /* T-100 */
|
|
17
|
+
--md-scheme-tertiary-container: 255, 217, 229; /* T-90 */
|
|
18
|
+
--md-scheme-on-tertiary-container: 44, 21, 33; /* T-30 */
|
|
19
|
+
|
|
20
|
+
/* Primary Fixed */
|
|
21
|
+
--md-scheme-primary-fixed: 224, 217, 255; /* P-90 */
|
|
22
|
+
--md-scheme-primary-fixed-dim: 199, 191, 255; /* P-80 */
|
|
23
|
+
--md-scheme-on-primary-fixed: 27, 13, 89; /* P-20 */
|
|
24
|
+
--md-scheme-on-primary-fixed-variant: 74, 62, 169; /* P-40 */
|
|
25
|
+
|
|
26
|
+
/* Secondary Fixed */
|
|
27
|
+
--md-scheme-secondary-fixed: 221, 216, 232; /* S-90 */
|
|
28
|
+
--md-scheme-secondary-fixed-dim: 200, 194, 217; /* S-80 */
|
|
29
|
+
--md-scheme-on-secondary-fixed: 28, 24, 40; /* S-20 */
|
|
30
|
+
--md-scheme-on-secondary-fixed-variant: 69, 63, 82; /* S-40 */
|
|
31
|
+
|
|
32
|
+
/* Tertiary Fixed */
|
|
33
|
+
--md-scheme-tertiary-fixed: 255, 217, 229; /* T-90 */
|
|
34
|
+
--md-scheme-tertiary-fixed-dim: 224, 189, 209; /* T-80 */
|
|
35
|
+
--md-scheme-on-tertiary-fixed: 44, 21, 33; /* T-20 */
|
|
36
|
+
--md-scheme-on-tertiary-fixed-variant: 89, 59, 75; /* T-40 */
|
|
37
|
+
|
|
38
|
+
/* Error */
|
|
39
|
+
--md-scheme-error: 186, 26, 26; /* E-40 */
|
|
40
|
+
--md-scheme-on-error: 255, 255, 255; /* E-100 */
|
|
41
|
+
--md-scheme-error-container: 255, 218, 214; /* E-90 */
|
|
42
|
+
--md-scheme-on-error-container: 65, 0, 2; /* E-30 */
|
|
43
|
+
|
|
44
|
+
/* Surface */
|
|
45
|
+
--md-scheme-surface-dim: 226, 224, 235; /* N-87 */
|
|
46
|
+
--md-scheme-surface: 247, 246, 250; /* N-98 */
|
|
47
|
+
--md-scheme-surface-bright: 247, 246, 250; /* N-98 */
|
|
48
|
+
|
|
49
|
+
--md-scheme-surface-container-lowest: 255, 255, 255; /* N-100 */
|
|
50
|
+
--md-scheme-surface-container-low: 242, 239, 248; /* N-96 */
|
|
51
|
+
--md-scheme-surface-container: 236, 232, 241; /* N-94 */
|
|
52
|
+
--md-scheme-surface-container-high: 230, 226, 236; /* N-92 */
|
|
53
|
+
--md-scheme-surface-container-highest: 224, 221, 231; /* N-90 */
|
|
54
|
+
|
|
55
|
+
/* On-Surface */
|
|
56
|
+
--md-scheme-on-surface: 26, 26, 30; /* N-10 */
|
|
57
|
+
--md-scheme-on-surface-variant: 73, 69, 79; /* NV-30 */
|
|
58
|
+
|
|
59
|
+
/* Outline */
|
|
60
|
+
--md-scheme-outline: 121, 116, 126; /* NV-50 */
|
|
61
|
+
--md-scheme-outline-variant: 202, 196, 208; /* NV-80 */
|
|
62
|
+
|
|
63
|
+
/* Inverse */
|
|
64
|
+
--md-scheme-inverse-surface: 52, 48, 52; /* N-20 */
|
|
65
|
+
--md-scheme-inverse-on-surface: 250, 248, 253; /* N-95 */
|
|
66
|
+
--md-scheme-inverse-primary: 92, 77, 212; /* P-80 */
|
|
67
|
+
|
|
68
|
+
/* Other */
|
|
69
|
+
--md-scheme-scrim: 0, 0, 0;
|
|
70
|
+
--md-scheme-shadow: 0, 0, 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.md-scheme-dark {
|
|
74
|
+
/* Primary */
|
|
75
|
+
--md-scheme-primary: 199, 191, 255; /* P-80 */
|
|
76
|
+
--md-scheme-on-primary: 55, 30, 146; /* P-20 */
|
|
77
|
+
--md-scheme-primary-container: 74, 62, 169; /* P-30 */
|
|
78
|
+
--md-scheme-on-primary-container: 224, 217, 255; /* P-90 */
|
|
79
|
+
|
|
80
|
+
/* Secondary */
|
|
81
|
+
--md-scheme-secondary: 200, 194, 217; /* S-80 */
|
|
82
|
+
--md-scheme-on-secondary: 48, 44, 63; /* S-20 */
|
|
83
|
+
--md-scheme-secondary-container: 69, 63, 82; /* S-30 */
|
|
84
|
+
--md-scheme-on-secondary-container: 221, 216, 232; /* S-90 */
|
|
85
|
+
|
|
86
|
+
/* Tertiary */
|
|
87
|
+
--md-scheme-tertiary: 224, 189, 209; /* T-80 */
|
|
88
|
+
--md-scheme-on-tertiary: 68, 37, 54; /* T-20 */
|
|
89
|
+
--md-scheme-tertiary-container: 89, 59, 75; /* T-30 */
|
|
90
|
+
--md-scheme-on-tertiary-container: 255, 217, 229; /* T-90 */
|
|
91
|
+
|
|
92
|
+
/* Primary Fixed */
|
|
93
|
+
--md-scheme-primary-fixed: 224, 217, 255; /* P-90 (same as light) */
|
|
94
|
+
--md-scheme-primary-fixed-dim: 199, 191, 255; /* P-80 */
|
|
95
|
+
--md-scheme-on-primary-fixed: 28, 14, 90; /* P-20 */
|
|
96
|
+
--md-scheme-on-primary-fixed-variant: 224, 217, 255; /* stays same */
|
|
97
|
+
|
|
98
|
+
/* Secondary Fixed */
|
|
99
|
+
--md-scheme-secondary-fixed: 221, 216, 232; /* S-90 */
|
|
100
|
+
--md-scheme-secondary-fixed-dim: 200, 194, 217; /* S-80 */
|
|
101
|
+
--md-scheme-on-secondary-fixed: 28, 24, 40; /* S-20 */
|
|
102
|
+
--md-scheme-on-secondary-fixed-variant: 221, 216, 232;
|
|
103
|
+
|
|
104
|
+
/* Tertiary Fixed */
|
|
105
|
+
--md-scheme-tertiary-fixed: 255, 217, 229; /* T-90 */
|
|
106
|
+
--md-scheme-tertiary-fixed-dim: 224, 189, 209; /* T-80 */
|
|
107
|
+
--md-scheme-on-tertiary-fixed: 44, 21, 33; /* T-20 */
|
|
108
|
+
--md-scheme-on-tertiary-fixed-variant: 255, 217, 229;
|
|
109
|
+
|
|
110
|
+
/* Error */
|
|
111
|
+
--md-scheme-error: 255, 180, 171; /* E-80 */
|
|
112
|
+
--md-scheme-on-error: 105, 0, 5; /* E-20 */
|
|
113
|
+
--md-scheme-error-container: 147, 0, 10; /* E-30 */
|
|
114
|
+
--md-scheme-on-error-container: 255, 218, 214; /* E-90 */
|
|
115
|
+
|
|
116
|
+
/* Surface */
|
|
117
|
+
--md-scheme-surface-dim: 20, 18, 24; /* N-6 */
|
|
118
|
+
--md-scheme-surface: 20, 18, 24; /* N-6 */
|
|
119
|
+
--md-scheme-surface-bright: 58, 56, 62; /* N-24 */
|
|
120
|
+
|
|
121
|
+
--md-scheme-surface-container-lowest: 15, 15, 17; /* N-4 */
|
|
122
|
+
--md-scheme-surface-container-low: 29, 26, 33; /* N-10 */
|
|
123
|
+
--md-scheme-surface-container: 35, 31, 39; /* N-12 */
|
|
124
|
+
--md-scheme-surface-container-high: 43, 39, 48; /* N-17 */
|
|
125
|
+
--md-scheme-surface-container-highest: 53, 49, 58; /* N-22 */
|
|
126
|
+
|
|
127
|
+
/* On-Surface */
|
|
128
|
+
--md-scheme-on-surface: 230, 225, 232; /* N-90 */
|
|
129
|
+
--md-scheme-on-surface-variant: 202, 196, 208; /* NV-80 */
|
|
130
|
+
|
|
131
|
+
/* Outline */
|
|
132
|
+
--md-scheme-outline: 147, 143, 153; /* NV-60 */
|
|
133
|
+
--md-scheme-outline-variant: 73, 69, 79; /* NV-30 */
|
|
134
|
+
|
|
135
|
+
/* Inverse */
|
|
136
|
+
--md-scheme-inverse-surface: 230, 225, 232; /* N-90 */
|
|
137
|
+
--md-scheme-inverse-on-surface: 29, 26, 33; /* N-20 */
|
|
138
|
+
--md-scheme-inverse-primary: 92, 77, 212; /* P-40 */
|
|
139
|
+
|
|
140
|
+
/* Other */
|
|
141
|
+
--md-scheme-scrim: 0, 0, 0;
|
|
142
|
+
--md-scheme-shadow: 0, 0, 0;
|
|
143
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
4
|
+
import { TypeBody } from './type-body';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
imports: [TypeBody],
|
|
8
|
+
template: `<md3-type-body></md3-type-body>`,
|
|
9
|
+
})
|
|
10
|
+
class HostComponent { }
|
|
11
|
+
|
|
12
|
+
describe('TypeBody', () => {
|
|
13
|
+
let fixture: ComponentFixture<HostComponent>;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [HostComponent],
|
|
18
|
+
}).compileComponents();
|
|
19
|
+
|
|
20
|
+
fixture = TestBed.createComponent(HostComponent);
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create an instance', () => {
|
|
25
|
+
const directive = fixture.debugElement.query(By.directive(TypeBody)).injector.get(TypeBody);
|
|
26
|
+
expect(directive).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { booleanAttribute, Directive, effect, ElementRef, input } from '@angular/core';
|
|
2
|
+
import { TextColor } from '../../types/text-color.type';
|
|
3
|
+
import { TextSize } from '../../types/text-size.type';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: 'md3-type-body, [md3-type-body]',
|
|
7
|
+
host: {
|
|
8
|
+
'class': 'md3-text-body',
|
|
9
|
+
'[class.md3-emphasized]': 'emphasized()',
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
export class TypeBody {
|
|
13
|
+
public size = input<TextSize | 'default'>('default');
|
|
14
|
+
public color = input<TextColor | 'default'>('default');
|
|
15
|
+
public emphasized = input<boolean, unknown>(false, {
|
|
16
|
+
transform: booleanAttribute,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
constructor(public el: ElementRef) {
|
|
20
|
+
effect((onCleanup) => {
|
|
21
|
+
const size = 'md3-text-' + this.size();
|
|
22
|
+
this.element.classList.add(size);
|
|
23
|
+
|
|
24
|
+
onCleanup(() => {
|
|
25
|
+
this.element.classList.remove(size);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
effect((onCleanup) => {
|
|
30
|
+
const color = 'md3-color-' + this.color();
|
|
31
|
+
this.element.classList.add(color);
|
|
32
|
+
|
|
33
|
+
onCleanup(() => {
|
|
34
|
+
this.element.classList.remove(color);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get element(): HTMLElement {
|
|
40
|
+
return this.el.nativeElement as HTMLElement;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
4
|
+
import { TypeDisplay } from './type-display';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
imports: [TypeDisplay],
|
|
8
|
+
template: `<md3-type-display></md3-type-display>`,
|
|
9
|
+
})
|
|
10
|
+
class HostComponent { }
|
|
11
|
+
|
|
12
|
+
describe('TypeDisplay', () => {
|
|
13
|
+
let fixture: ComponentFixture<HostComponent>;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [HostComponent],
|
|
18
|
+
}).compileComponents();
|
|
19
|
+
|
|
20
|
+
fixture = TestBed.createComponent(HostComponent);
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create an instance', () => {
|
|
25
|
+
const directive = fixture.debugElement.query(By.directive(TypeDisplay)).injector.get(TypeDisplay);
|
|
26
|
+
expect(directive).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { booleanAttribute, Directive, effect, ElementRef, input } from '@angular/core';
|
|
2
|
+
import { TextColor } from '../../types/text-color.type';
|
|
3
|
+
import { TextSize } from '../../types/text-size.type';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: 'md3-type-display, [md3-type-display]',
|
|
7
|
+
host: {
|
|
8
|
+
'class': 'md3-text-display',
|
|
9
|
+
'[class.md3-emphasized]': 'emphasized()',
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
export class TypeDisplay {
|
|
13
|
+
public size = input<TextSize | 'default'>('default');
|
|
14
|
+
public color = input<TextColor | 'default'>('default');
|
|
15
|
+
public emphasized = input<boolean, unknown>(false, {
|
|
16
|
+
transform: booleanAttribute,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
constructor(public el: ElementRef) {
|
|
20
|
+
effect((onCleanup) => {
|
|
21
|
+
const size = 'md3-text-' + this.size();
|
|
22
|
+
this.element.classList.add(size);
|
|
23
|
+
|
|
24
|
+
onCleanup(() => {
|
|
25
|
+
this.element.classList.remove(size);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
effect((onCleanup) => {
|
|
30
|
+
const color = 'md3-color-' + this.color();
|
|
31
|
+
this.element.classList.add(color);
|
|
32
|
+
|
|
33
|
+
onCleanup(() => {
|
|
34
|
+
this.element.classList.remove(color);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get element(): HTMLElement {
|
|
40
|
+
return this.el.nativeElement as HTMLElement;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
4
|
+
import { TypeHeadline } from './type-headline';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
imports: [TypeHeadline],
|
|
8
|
+
template: `<md3-type-headline></md3-type-headline>`,
|
|
9
|
+
})
|
|
10
|
+
class HostComponent { }
|
|
11
|
+
|
|
12
|
+
describe('TypeHeadline', () => {
|
|
13
|
+
let fixture: ComponentFixture<HostComponent>;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [HostComponent],
|
|
18
|
+
}).compileComponents();
|
|
19
|
+
|
|
20
|
+
fixture = TestBed.createComponent(HostComponent);
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create an instance', () => {
|
|
25
|
+
const directive = fixture.debugElement.query(By.directive(TypeHeadline)).injector.get(TypeHeadline);
|
|
26
|
+
expect(directive).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { booleanAttribute, Directive, effect, ElementRef, input } from '@angular/core';
|
|
2
|
+
import { TextColor } from '../../types/text-color.type';
|
|
3
|
+
import { TextSize } from '../../types/text-size.type';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: 'md3-type-headline, [md3-type-headline]',
|
|
7
|
+
host: {
|
|
8
|
+
'class': 'md3-text-headline',
|
|
9
|
+
'[class.md3-emphasized]': 'emphasized()',
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
export class TypeHeadline {
|
|
13
|
+
public size = input<TextSize | 'default'>('default');
|
|
14
|
+
public color = input<TextColor | 'default'>('default');
|
|
15
|
+
public emphasized = input<boolean, unknown>(false, {
|
|
16
|
+
transform: booleanAttribute,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
constructor(public el: ElementRef) {
|
|
20
|
+
effect((onCleanup) => {
|
|
21
|
+
const size = 'md3-text-' + this.size();
|
|
22
|
+
this.element.classList.add(size);
|
|
23
|
+
|
|
24
|
+
onCleanup(() => {
|
|
25
|
+
this.element.classList.remove(size);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
effect((onCleanup) => {
|
|
30
|
+
const color = 'md3-color-' + this.color();
|
|
31
|
+
this.element.classList.add(color);
|
|
32
|
+
|
|
33
|
+
onCleanup(() => {
|
|
34
|
+
this.element.classList.remove(color);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get element(): HTMLElement {
|
|
40
|
+
return this.el.nativeElement as HTMLElement;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
4
|
+
import { TypeLabel } from './type-label';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
imports: [TypeLabel],
|
|
8
|
+
template: `<md3-type-label></md3-type-label>`,
|
|
9
|
+
})
|
|
10
|
+
class HostComponent { }
|
|
11
|
+
|
|
12
|
+
describe('TypeLabel', () => {
|
|
13
|
+
let fixture: ComponentFixture<HostComponent>;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [HostComponent],
|
|
18
|
+
}).compileComponents();
|
|
19
|
+
|
|
20
|
+
fixture = TestBed.createComponent(HostComponent);
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create an instance', () => {
|
|
25
|
+
const directive = fixture.debugElement.query(By.directive(TypeLabel)).injector.get(TypeLabel);
|
|
26
|
+
expect(directive).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { booleanAttribute, Directive, effect, ElementRef, input } from '@angular/core';
|
|
2
|
+
import { TextColor } from '../../types/text-color.type';
|
|
3
|
+
import { TextSize } from '../../types/text-size.type';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: 'md3-type-label, [md3-type-label]',
|
|
7
|
+
host: {
|
|
8
|
+
'class': 'md3-text-label',
|
|
9
|
+
'[class.md3-emphasized]': 'emphasized()',
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
export class TypeLabel {
|
|
13
|
+
public size = input<TextSize | 'default'>('default');
|
|
14
|
+
public color = input<TextColor | 'default'>('default');
|
|
15
|
+
public emphasized = input<boolean, unknown>(false, {
|
|
16
|
+
transform: booleanAttribute,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
constructor(public el: ElementRef) {
|
|
20
|
+
effect((onCleanup) => {
|
|
21
|
+
const size = 'md3-text-' + this.size();
|
|
22
|
+
this.element.classList.add(size);
|
|
23
|
+
|
|
24
|
+
onCleanup(() => {
|
|
25
|
+
this.element.classList.remove(size);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
effect((onCleanup) => {
|
|
30
|
+
const color = 'md3-color-' + this.color();
|
|
31
|
+
this.element.classList.add(color);
|
|
32
|
+
|
|
33
|
+
onCleanup(() => {
|
|
34
|
+
this.element.classList.remove(color);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get element(): HTMLElement {
|
|
40
|
+
return this.el.nativeElement as HTMLElement;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { By } from '@angular/platform-browser';
|
|
4
|
+
import { TypeTitle } from './type-title';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
imports: [TypeTitle],
|
|
8
|
+
template: `<md3-type-title></md3-type-title>`,
|
|
9
|
+
})
|
|
10
|
+
class HostComponent { }
|
|
11
|
+
|
|
12
|
+
describe('TypeTitle', () => {
|
|
13
|
+
let fixture: ComponentFixture<HostComponent>;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [HostComponent],
|
|
18
|
+
}).compileComponents();
|
|
19
|
+
|
|
20
|
+
fixture = TestBed.createComponent(HostComponent);
|
|
21
|
+
fixture.detectChanges();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should create an instance', () => {
|
|
25
|
+
const directive = fixture.debugElement.query(By.directive(TypeTitle)).injector.get(TypeTitle);
|
|
26
|
+
expect(directive).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { booleanAttribute, Directive, effect, ElementRef, input } from '@angular/core';
|
|
2
|
+
import { TextColor } from '../../types/text-color.type';
|
|
3
|
+
import { TextSize } from '../../types/text-size.type';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
selector: 'md3-type-title, [md3-type-title]',
|
|
7
|
+
host: {
|
|
8
|
+
'class': 'md3-text-title',
|
|
9
|
+
'[class.md3-emphasized]': 'emphasized()',
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
export class TypeTitle {
|
|
13
|
+
public size = input<TextSize | 'default'>('default');
|
|
14
|
+
public color = input<TextColor | 'default'>('default');
|
|
15
|
+
public emphasized = input<boolean, unknown>(false, {
|
|
16
|
+
transform: booleanAttribute,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
constructor(public el: ElementRef) {
|
|
20
|
+
effect((onCleanup) => {
|
|
21
|
+
const size = 'md3-text-' + this.size();
|
|
22
|
+
this.element.classList.add(size);
|
|
23
|
+
|
|
24
|
+
onCleanup(() => {
|
|
25
|
+
this.element.classList.remove(size);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
effect((onCleanup) => {
|
|
30
|
+
const color = 'md3-color-' + this.color();
|
|
31
|
+
this.element.classList.add(color);
|
|
32
|
+
|
|
33
|
+
onCleanup(() => {
|
|
34
|
+
this.element.classList.remove(color);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public get element(): HTMLElement {
|
|
40
|
+
return this.el.nativeElement as HTMLElement;
|
|
41
|
+
}
|
|
42
|
+
}
|