Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions starter-apps/angular/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Angular Starter App with GCDS Components Angular Package

This is a starter app that you can use to bootstrap your project using Angular and GCDS Components

## Project Structure

A brief overview of the project structure:

```graphql
angular-template/ # Project root
├── e2e/ # End-to-end tests
├── public/ # Static assets
├── src/ # Source files
│ ├── app/ # Project assets
│ │ ├── layout/ # Files and components related to global layout
│ │ │ ├── header.component.(html,scss,ts.spec.ts) # Template, Styles, Typescript and unit test for the header component
│ │ ├── pages/ # Files and components related to pages
│ │ │ ├── about/ # Files and components related to about page
│ │ │ │ ├── topic/ # Files and components related to topic page
│ │ │ │ │ ├── topic.component.(html,scss,ts.spec.ts) # Template, Styles, Typescript and unit test for the topic page
│ │ │ │ ├── about.component.(html,scss,ts.spec.ts) # Template, Styles, Typescript and unit test for the about page
│ │ │ ├── home/ # Files and components related to home page
│ │ │ │ ├── home.component.(html,scss,ts.spec.ts) # Template, Styles, Typescript and unit test for the home page
│ │ │ ├── report-a-bug/ # Files and components related to report a bug page
│ │ │ │ ├── report-a-bug.component.(html,scss,ts.spec.ts) # Template, Styles, Typescript and unit test for the report a bug page
│ │ ├── app.component.(html,scss,ts.spec.ts) # Template, Styles, Typescript and unit test for app component
│ │ ├── app.config.ts # App initialization config
│ │ ├── app.routes.ts # App routes config
│ │ ├── breadcrumb.service.(ts,spec.ts) # Exemple breadcrumb service integrated with Angular Router
│ ├── locale/ # Translation Files
│ │ ├── messages.fr.xlf # French Translation
│ │ ├── messages.g.xlf # Original Translation (English)
│ ├── index.html # HTML template
│ ├── main.ts # Entry point
│ ├── styles.scss # Main style file
├── .editorconfig # IDE config
├── .gitignore # Git ignore rules
├── .prettierrc # Prettier configuration
├── angular.json # Angular configuration
├── eslint.config.js # Prettier configuration
├── package.json # Project metadata and dependencies
├── package-lock.json # Project metadata and dependencies
├── playwright.config.js # Playwright configuration
├── README.md # Project documentation
├── tsconfig.json # Global typescript configuration
├── tsconfig.app.json # App only typescript configuration
├── tsconfig.spec.json # Test only typescript configuration
```
18 changes: 18 additions & 0 deletions starter-apps/angular/angular-template/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 180

[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false

[*.md]
max_line_length = off
trim_trailing_whitespace = false
47 changes: 47 additions & 0 deletions starter-apps/angular/angular-template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db

# Playwright
/test-results/
/playwright-report/
/playwright/.cache/
4 changes: 4 additions & 0 deletions starter-apps/angular/angular-template/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}
59 changes: 59 additions & 0 deletions starter-apps/angular/angular-template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# AngularTemplate

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.

## Development server

To start a local development server, run:

```bash
ng serve
```

Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.

## Code scaffolding

Angular CLI includes powerful code scaffolding tools. To generate a new component, run:

```bash
ng generate component component-name
```

For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:

```bash
ng generate --help
```

## Building

To build the project run:

```bash
ng build
```

This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.

## Running unit tests

To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:

```bash
ng test
```

## Running end-to-end tests

For end-to-end (e2e) testing, run:

```bash
ng e2e
```

Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.

## Additional Resources

For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
133 changes: 133 additions & 0 deletions starter-apps/angular/angular-template/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-template": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"outputPath": "dist/angular-template",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js", "@angular/localize/init"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": ["src/styles.scss"],
"scripts": [],
"localize": true
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "angular-template:build:production"
},
"development": {
"buildTarget": "angular-template:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "ng-extract-i18n-merge:ng-extract-i18n-merge",
"options": {
"buildTarget": "angular-template:build",
"format": "xlf2",
"outputPath": "src/locale",
"sourceFile": "messages.g.xlf",
"targetFiles": ["messages.fr.xlf"]
}
},
"test": {
"builder": "@angular/build:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing",
"@angular/localize/init"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": ["src/styles.scss"],
"scripts": []
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
}
},
"e2e": {
"builder": "playwright-ng-schematics:playwright",
"options": {
"devServerTarget": "angular-template:serve"
},
"configurations": {
"production": {
"devServerTarget": "angular-template:serve:production"
}
}
}
},
"i18n": {
"sourceLocale": "en",
"locales": {
"fr": {
"translation": "src/locale/messages.fr.xlf"
}
}
}
}
},
"cli": {
"schematicCollections": ["angular-eslint"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect, test } from '@playwright/test';
import path from 'node:path';
import parseXliff, { TranslationMap } from './parseXliff';

let translations: TranslationMap;

test.beforeAll(async () => {
const xliffPath = path.join(__dirname, '..', 'src', 'locale', 'messages.g.xlf');
translations = await parseXliff(xliffPath);
});

test('shows aboutTopic page breadcrumbs', async ({ page }) => {
await page.goto('/about/topic');

await expect(page.locator('gcds-breadcrumbs').locator('gcds-breadcrumbs-item')).toContainText([
translations['common.pageTitle.about'],
translations['common.pageTitle.about.topic'],
]);
});
23 changes: 23 additions & 0 deletions starter-apps/angular/angular-template/e2e/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { test, expect } from '@playwright/test';
import parseXliff, { TranslationMap } from './parseXliff';
import path from 'node:path';

let translations: TranslationMap;

test.beforeAll(async () => {
const xliffPath = path.join(__dirname, '..', 'src', 'locale', 'messages.g.xlf');
translations = await parseXliff(xliffPath);
});

test('visits the app root url', async ({ page }) => {
await page.goto('/');
await expect(page.locator('gcds-heading')).toHaveText(translations['common.pageTitle.home']);

await expect(page.locator('gcds-text').first()).toHaveText(translations['page.home.welcome']);
});

test('switches language', async ({ page }) => {
await page.goto('/');
await page.click('text=Français');
await page.waitForURL('/fr');
});
Loading