Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions apps/angular/styling/src/app/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ import { TextComponent } from './text.component';
selector: 'page',
standalone: true,
imports: [TextStaticComponent, TextComponent],
styles: [
`
text {
--text-font-size: 15px;
--text-color: blue;
}
`,
],
template: `
<static-text></static-text>
<static-text type="error"></static-text>
<static-text type="warning"></static-text>
<text [font]="15" color="blue">This a a blue text</text>
<static-text class="error"></static-text>
<static-text class="warning"></static-text>
<text>This a a blue text</text>
`,
})
export class PageComponent {}
45 changes: 25 additions & 20 deletions apps/angular/styling/src/app/static-text.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @angular-eslint/component-selector */
import { Component, Input } from '@angular/core';
import { Component } from '@angular/core';
import { TextComponent } from './text.component';

export type StaticTextType = 'normal' | 'warning' | 'error';
Expand All @@ -8,26 +8,31 @@ export type StaticTextType = 'normal' | 'warning' | 'error';
selector: 'static-text',
standalone: true,
imports: [TextComponent],
template: `
<text [font]="font" [color]="color">This is a static text</text>
`,
})
export class TextStaticComponent {
@Input() set type(type: StaticTextType) {
switch (type) {
case 'error': {
this.font = 30;
this.color = 'red';
break;
styles: [
`
text {
--text-font-size: 10px;
--text-color: black;
}
case 'warning': {
this.font = 25;
this.color = 'orange';
break;

:host-context(.error) {
text {
--text-font-size: 30px;
--text-color: red;
}
}
}
}

font = 10;
color = 'black';
:host-context(.warning) {
text {
--text-font-size: 25px;
--text-color: orange;
}
}
`,
],
template: ` <text>This is a static text</text> `,
})
export class TextStaticComponent {
// font = 10;
// color = 'black';
}
17 changes: 11 additions & 6 deletions apps/angular/styling/src/app/text.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
/* eslint-disable @angular-eslint/component-selector */
import { Component, Input } from '@angular/core';
import { Component } from '@angular/core';

@Component({
selector: 'text',
standalone: true,
styles: [
`
p {
font-size: var(--text-font-size, 10px);
color: var(--text-color, black);
}
`,
],
template: `
<p style="font-size: {{ font }}px; color: {{ color }}">
<p>
<ng-content></ng-content>
</p>
`,
})
export class TextComponent {
@Input() font = 10;
@Input() color = 'black';
}
export class TextComponent {}
1 change: 0 additions & 1 deletion apps/angular/styling/src/styles.scss
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
/* You can add global styles to this file, and also import other style files */