-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(tutorial): create todo app tutorial based on tutorial kit (#2213)
* docs(tutorial): create todo app tutorial based on tutorial kit * chore: action to install tutorial deps * chore: codeclimate and eslintignore settings --------- Co-authored-by: Mark Whitfeld <[email protected]>
- Loading branch information
1 parent
bd43d33
commit 76347ef
Showing
69 changed files
with
7,152 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
**/*.spec.ts | ||
packages/store/types/.eslintrc.js | ||
node_modules/ |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.js"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,3 @@ | ||
# create-app | ||
|
||
This library was generated with [Nx](https://nx.dev). |
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 tutorialkit from '@tutorialkit/astro'; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
export default defineConfig({ | ||
outDir: '../../@tutorials/create-app', | ||
devToolbar: { | ||
enabled: false | ||
}, | ||
integrations: [tutorialkit()] | ||
}); |
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,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference | ||
/// <reference path=".astro/types.d.ts" /> | ||
/// <reference types="@tutorialkit/astro/types" /> | ||
/// <reference types="astro/client" /> |
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 @@ | ||
{ | ||
"name": "@ngxs/create-app-tutorial", | ||
"description": "Tutorial that shows how to create an app with @ngxs/store", | ||
"type": "module", | ||
"scripts": { | ||
"astro": "astro", | ||
"build": "astro build", | ||
"dev": "astro dev", | ||
"check": "astro check", | ||
"preview": "astro preview", | ||
"start": "astro dev" | ||
}, | ||
"dependencies": { | ||
"@tutorialkit/components-react": "0.0.1-alpha.23", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.2.75", | ||
"@astrojs/check": "^0.7.0", | ||
"@astrojs/react": "^3.5.0", | ||
"@iconify-json/ph": "^1.1.12", | ||
"@iconify-json/svg-spinners": "^1.1.2", | ||
"@tutorialkit/astro": "0.0.1-alpha.23", | ||
"@tutorialkit/types": "0.0.1-alpha.23", | ||
"@types/node": "^20.12.7", | ||
"@unocss/reset": "^0.59.4", | ||
"@unocss/transformer-directives": "^0.59.4", | ||
"astro": "4.10.2", | ||
"fast-glob": "^3.3.2", | ||
"prettier-plugin-astro": "^0.13.0", | ||
"typescript": "^5.4.5", | ||
"unocss": "^0.59.4" | ||
} | ||
} |
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,30 @@ | ||
{ | ||
"name": "create-app", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "tutorials/create-app/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"lint": { | ||
"executor": "@nx/eslint:lint" | ||
}, | ||
"serve": { | ||
"executor": "nx:run-script", | ||
"options": { | ||
"script": "dev" | ||
} | ||
}, | ||
"build": { | ||
"executor": "nx:run-script", | ||
"options": { | ||
"script": "build" | ||
} | ||
}, | ||
"check": { | ||
"executor": "nx:run-script", | ||
"options": { | ||
"script": "check" | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,13 @@ | ||
import { chapterSchema, lessonSchema, partSchema, tutorialSchema } from '@tutorialkit/types'; | ||
import { defineCollection } from 'astro:content'; | ||
|
||
const tutorial = defineCollection({ | ||
type: 'content', | ||
schema: tutorialSchema | ||
.strict() | ||
.or(partSchema.strict()) | ||
.or(chapterSchema.strict()) | ||
.or(lessonSchema.strict()) | ||
}); | ||
|
||
export const collections = { tutorial }; |
81 changes: 81 additions & 0 deletions
81
...reate-a-todo-app/1-welcome/1-welcome/_files/src/app/todo/todo-list/todo-list.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,81 @@ | ||
import { AsyncPipe, NgForOf, NgTemplateOutlet } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, inject, Signal } from '@angular/core'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
import { MatCheckboxModule } from '@angular/material/checkbox'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
import { MatListModule } from '@angular/material/list'; | ||
import { Store } from '@ngxs/store'; | ||
import { TodoItemComponent } from '../components/todo-item/todo-item.component'; | ||
import { TodoModel } from '../types/todo'; | ||
import { signal } from '@angular/core'; | ||
@Component({ | ||
selector: 'app-todo', | ||
templateUrl: './todo-list.component.html', | ||
styleUrls: ['./todo-list.component.scss'], | ||
standalone: true, | ||
imports: [ | ||
MatInputModule, | ||
MatCardModule, | ||
MatButtonModule, | ||
MatCardModule, | ||
MatListModule, | ||
MatCheckboxModule, | ||
FormsModule, | ||
AsyncPipe, | ||
NgForOf, | ||
NgTemplateOutlet, | ||
TodoItemComponent | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class TodoListComponent { | ||
private _store = inject(Store); | ||
|
||
completeTodoItems: Signal<TodoModel[]> = signal([ | ||
{ | ||
id: 1, | ||
title: 'Learn Angular', | ||
completed: true | ||
}, | ||
{ | ||
id: 2, | ||
title: 'Learn NGXS', | ||
completed: true | ||
}, | ||
{ | ||
id: 3, | ||
title: 'Learn NGXS Store', | ||
completed: true | ||
}, | ||
{ | ||
id: 4, | ||
title: 'Learn NGXS Selectors', | ||
completed: true | ||
}, | ||
{ | ||
id: 5, | ||
title: 'Learn NGXS Actions', | ||
completed: true | ||
} | ||
]); | ||
|
||
inCompleteTodoItems: Signal<TodoModel[]> = signal([ | ||
{ | ||
id: 6, | ||
title: 'Learn NGXS Utility selectors', | ||
completed: false | ||
} | ||
]); | ||
|
||
newItemName!: string; | ||
|
||
constructor() {} | ||
|
||
toggleItem(todoItem: TodoModel) {} | ||
|
||
addItem() { | ||
this.newItemName = ''; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ate-app/src/content/tutorial/1-create-a-todo-app/1-welcome/1-welcome/content.md
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,27 @@ | ||
--- | ||
type: lesson | ||
title: Welcome | ||
focus: /src/app/todo/todo-list/todo-list.component.ts | ||
--- | ||
|
||
# Welcome to the NGXS Tutorial! | ||
|
||
Let's build a Todo application together while diving into the core concepts of NGXS. This interactive tutorial will guide you through the process of managing your application's state effectively. | ||
|
||
By the end of this tutorial, you'll be able to: | ||
|
||
- Install NGXS into your Angular project using schematics | ||
- Understand the fundamental building blocks of NGXS: Actions, State, and Selectors | ||
- Create a Todo application using NGXS, demonstrating a practical application of these concepts | ||
|
||
**We'll start by focusing on Actions as the driving force behind our application.** We'll explore how to: | ||
|
||
- Define Actions to represent user interactions and data fetching | ||
- Update the application's state in response to Actions | ||
- Create Selectors to efficiently retrieve data from the state | ||
- Utilize Selectors within your components to display and interact with the state | ||
|
||
> This tutorial begins with a static Todo application displayed in the preview panel. Progressively, we'll transform this app into a dynamic, state-managed application. | ||
> To get familiar with the tutorial, add one incomplete item in the `todo-list-component.ts` file | ||
**Ready to get started?** Let's build! |
4 changes: 4 additions & 0 deletions
4
tutorials/create-app/src/content/tutorial/1-create-a-todo-app/1-welcome/meta.md
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,4 @@ | ||
--- | ||
type: chapter | ||
title: Welcome | ||
--- |
27 changes: 27 additions & 0 deletions
27
...ontent/tutorial/1-create-a-todo-app/2-installation/1-using-schematics/_files/package.json
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,27 @@ | ||
{ | ||
"name": "ngxs-project", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"start": "ng serve", | ||
"build": "ng build" | ||
}, | ||
"devDependencies": { | ||
"@angular-devkit/build-angular": "^18.0.7", | ||
"@angular/animations": "^18.0.6", | ||
"@angular/cdk": "^18.0.6", | ||
"@angular/cli": "^18.0.7", | ||
"@angular/common": "^18.0.6", | ||
"@angular/compiler": "^18.0.6", | ||
"@angular/compiler-cli": "^18.0.6", | ||
"@angular/core": "^18.0.6", | ||
"@angular/material": "^18.0.6", | ||
"@angular/platform-browser": "^18.0.6", | ||
"@angular/platform-browser-dynamic": "^18.0.6", | ||
"@ngxs/store": "^18.1.1", | ||
"rxjs": "~7.8.1", | ||
"tslib": "^2.0.0", | ||
"zone.js": "~0.14.2" | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...ntent/tutorial/1-create-a-todo-app/2-installation/1-using-schematics/content.md
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,37 @@ | ||
--- | ||
type: lesson | ||
title: Installation using schematics | ||
focus: /package.json | ||
--- | ||
|
||
# Installation | ||
|
||
In our Angular application, we should install the `@ngxs/store` using `ng-add` schematic. | ||
|
||
> The dependency of NGXS v.18 is Angular >= v.17 | ||
The command is: | ||
|
||
```bash | ||
ng add @ngxs/store | ||
``` | ||
|
||
This command will update the `package.json` file with the `@ngxs/store` dependency | ||
|
||
--- | ||
|
||
🎧 **Exercises** | ||
|
||
- There are no exercises in this lesson | ||
|
||
--- | ||
|
||
👀 **Observe** | ||
|
||
- The **package.json** file has the related dependency | ||
|
||
--- | ||
|
||
📚 **Read more** | ||
|
||
- Read more in the NGXS documentation about the <a href="https://www.ngxs.io/introduction/installation" target="_blank">installation</a> |
9 changes: 9 additions & 0 deletions
9
...t/tutorial/1-create-a-todo-app/2-installation/2-create-store/_files/src/app/app.config.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,9 @@ | ||
import { TodoState } from './todo/store/todo.state'; | ||
import { provideHttpClient } from '@angular/common/http'; | ||
import { provideAnimations } from '@angular/platform-browser/animations'; | ||
import { ApplicationConfig } from '@angular/core'; | ||
import { provideStore } from '@ngxs/store'; | ||
|
||
export const config: ApplicationConfig = { | ||
providers: [provideAnimations(), provideHttpClient(), provideStore([])] | ||
}; |
Oops, something went wrong.