-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(angular): add Angular Renaissance & update Angular snippets (#245)
* feat(angular): update the existing files + add the new angular (renaissance) practices * refactor(angular): remove deprecated routing examples * docs: update readme frameworks progress * fix(angularRenaissance): fix folder name using right framework id * fix: add some previous omissions --------- Co-authored-by: lgarcia <[email protected]> Co-authored-by: Mathieu Schimmerling <[email protected]> Co-authored-by: LcsGa <[email protected]>
- Loading branch information
1 parent
8e2f405
commit 134358d
Showing
67 changed files
with
1,000 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
content/1-reactivity/1-declare-state/angularRenaissance/name.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component, signal } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-name", | ||
template: `<h1>Hello {{ name() }}</h1>`, | ||
}) | ||
export class NameComponent { | ||
name = signal("John"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
content/1-reactivity/2-update-state/angularRenaissance/name.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Component, signal } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-name", | ||
template: `<h1>Hello {{ name() }}</h1>`, | ||
}) | ||
export class NameComponent { | ||
name = signal("John"); | ||
|
||
constructor() { | ||
this.name.set("Jane"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
content/1-reactivity/3-computed-state/angularRenaissance/doublecount.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Component, computed, signal } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-doublecount", | ||
template: `<div>{{ doubleCount() }}</div>`, | ||
}) | ||
export class DoublecountComponent { | ||
count = signal(10); | ||
|
||
doubleCount = computed(() => this.count() * 2); | ||
} |
8 changes: 7 additions & 1 deletion
8
content/2-templating/1-minimal-template/angular/helloworld.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import { Component } from "@angular/core"; | ||
import { Component, NgModule } from "@angular/core"; | ||
|
||
@Component({ | ||
selector: "app-helloworld", | ||
template: `<h1>Hello world</h1>`, | ||
}) | ||
export class HelloworldComponent {} | ||
|
||
@NgModule({ | ||
declarations: [HelloworldComponent], | ||
exports: [HelloworldComponent], | ||
}) | ||
export class HelloworldModule {} |
8 changes: 8 additions & 0 deletions
8
content/2-templating/1-minimal-template/angularRenaissance/helloworld.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-helloworld", | ||
template: `<h1>Hello world</h1>`, | ||
}) | ||
export class HelloworldComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
content/2-templating/2-styling/angularRenaissance/cssstyle.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-cssstyle", | ||
template: ` | ||
<h1 class="title">I am red</h1> | ||
<button style="font-size: 10rem">I am a button</button> | ||
`, | ||
styles: ` | ||
.title { | ||
color: red; | ||
} | ||
`, | ||
}) | ||
export class CssStyleComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
content/2-templating/3-loop/angularRenaissance/colors.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-colors", | ||
template: ` | ||
<ul> | ||
@for (color of colors; track color) { | ||
<li>{{ color }}</li> | ||
} | ||
</ul> | ||
`, | ||
}) | ||
export class ColorsComponent { | ||
colors = ["red", "green", "blue"]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
content/2-templating/4-event-click/angularRenaissance/counter.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, signal } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-counter", | ||
template: ` | ||
<p>Counter: {{ count() }}</p> | ||
<button (click)="incrementCount()">+1</button> | ||
`, | ||
}) | ||
export class CounterComponent { | ||
count = signal(0); | ||
|
||
incrementCount() { | ||
this.count.update((count) => count + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
content/2-templating/5-dom-ref/angularRenaissance/inputfocused.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { afterNextRender, Component, ElementRef, viewChild } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-inputfocused", | ||
template: `<input type="text" #inputRef />`, | ||
}) | ||
export class InputfocusedComponent { | ||
inputRef = viewChild.required<ElementRef<HTMLInputElement>>("inputRef"); | ||
|
||
constructor() { | ||
afterNextRender({ write: () => this.inputRef().nativeElement.focus() }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
content/2-templating/6-conditional/angularRenaissance/trafficlight.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Component, computed, signal } from "@angular/core"; | ||
|
||
const TRAFFIC_LIGHTS = ["red", "orange", "green"]; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-trafficlight", | ||
template: ` | ||
<button (click)="nextLight()">Next light</button> | ||
<p>Light is: {{ light() }}</p> | ||
<p> | ||
You must | ||
@switch (light()) { | ||
@case ("red") { | ||
<span>STOP</span> | ||
} | ||
@case ("orange") { | ||
<span>SLOW DOWN</span> | ||
} | ||
@case ("green") { | ||
<span>GO</span> | ||
} | ||
} | ||
</p> | ||
`, | ||
}) | ||
export class TrafficlightComponent { | ||
lightIndex = signal(0); | ||
|
||
light = computed(() => TRAFFIC_LIGHTS[this.lightIndex()]); | ||
|
||
nextLight() { | ||
this.lightIndex.update((index) => (index + 1) % TRAFFIC_LIGHTS.length); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
content/3-lifecycle/1-on-mount/angularRenaissance/pagetitle.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Component, OnInit, signal } from "@angular/core"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "app-pagetitle", | ||
template: `<p>Page title: {{ pageTitle() }}</p>`, | ||
}) | ||
export class PagetitleComponent implements OnInit { | ||
pageTitle = signal(""); | ||
|
||
ngOnInit() { | ||
this.pageTitle.set(document.title); | ||
} | ||
} |
Oops, something went wrong.