From 7f0563eb6ea5f6a28d0f8ff220abb9f2016fee05 Mon Sep 17 00:00:00 2001 From: Mark Thompson <2554588+MarkTechson@users.noreply.github.com> Date: Wed, 16 Aug 2023 12:12:17 -0500 Subject: [PATCH] docs(animations): update animation docs to be standalone first (#51390) Update the animation example files to be standalone and use boostrap application, update the documentation to prioritize standalone PR Close #51390 --- .../animations/src/app/about.component.html | 0 .../animations/src/app/about.component.ts | 1 + .../examples/animations/src/app/animations.ts | 20 ++-- .../animations/src/app/app.component.1.ts | 1 + .../animations/src/app/app.component.ts | 4 +- .../examples/animations/src/app/app.config.ts | 15 +++ .../src/app/{app.module.ts => app.routes.ts} | 101 ++++++------------ .../src/app/hero-list-auto-page.component.ts | 5 +- .../src/app/hero-list-auto.component.ts | 3 + .../hero-list-enter-leave-page.component.ts | 5 +- .../app/hero-list-enter-leave.component.ts | 3 + .../src/app/hero-list-group-page.component.ts | 5 +- .../src/app/hero-list-groups.component.ts | 3 + .../src/app/hero-list-page.component.ts | 3 + .../animations/src/app/home.component.ts | 1 + .../src/app/insert-remove.component.ts | 3 + .../src/app/open-close-page.component.ts | 5 +- .../src/app/open-close.component.1.ts | 1 + .../src/app/open-close.component.2.ts | 1 + .../src/app/open-close.component.3.ts | 1 + .../src/app/open-close.component.4.ts | 1 + .../src/app/open-close.component.ts | 1 + .../animations/src/app/querying.component.ts | 3 + .../src/app/status-slider-page.component.ts | 5 +- .../src/app/status-slider.component.ts | 1 + .../app/toggle-animations-page.component.ts | 5 +- aio/content/examples/animations/src/main.ts | 9 +- aio/content/guide/add-an-animation.md | 22 ++-- aio/content/guide/animations.md | 14 ++- aio/content/guide/route-animations.md | 24 +++-- 30 files changed, 155 insertions(+), 111 deletions(-) mode change 100644 => 100755 aio/content/examples/animations/src/app/about.component.html mode change 100644 => 100755 aio/content/examples/animations/src/app/about.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/animations.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/app.component.1.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/app.component.ts create mode 100644 aio/content/examples/animations/src/app/app.config.ts rename aio/content/examples/animations/src/app/{app.module.ts => app.routes.ts} (54%) mode change 100644 => 100755 aio/content/examples/animations/src/app/hero-list-auto-page.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/hero-list-auto.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/hero-list-enter-leave-page.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/hero-list-enter-leave.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/hero-list-group-page.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/hero-list-groups.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/hero-list-page.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/home.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/insert-remove.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/open-close-page.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/open-close.component.3.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/open-close.component.4.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/open-close.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/querying.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/status-slider-page.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/status-slider.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/app/toggle-animations-page.component.ts mode change 100644 => 100755 aio/content/examples/animations/src/main.ts diff --git a/aio/content/examples/animations/src/app/about.component.html b/aio/content/examples/animations/src/app/about.component.html old mode 100644 new mode 100755 diff --git a/aio/content/examples/animations/src/app/about.component.ts b/aio/content/examples/animations/src/app/about.component.ts old mode 100644 new mode 100755 index 118de933711..ce81010d0bd --- a/aio/content/examples/animations/src/app/about.component.ts +++ b/aio/content/examples/animations/src/app/about.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; @Component({ + standalone: true, selector: 'app-about', templateUrl: './about.component.html', styleUrls: ['./about.component.css'] diff --git a/aio/content/examples/animations/src/app/animations.ts b/aio/content/examples/animations/src/app/animations.ts old mode 100644 new mode 100755 index 0549fafce38..163417d3563 --- a/aio/content/examples/animations/src/app/animations.ts +++ b/aio/content/examples/animations/src/app/animations.ts @@ -31,15 +31,15 @@ export const slideInAnimation = // #docregion query query(':enter', [ style({ left: '-100%' }) - ]), - query(':leave', animateChild()), + ], { optional: true }), + query(':leave', animateChild(), { optional: true }), group([ query(':leave', [ animate('300ms ease-out', style({ left: '100%' })) - ]), + ], { optional: true }), query(':enter', [ animate('300ms ease-out', style({ left: '0%' })) - ]), + ], { optional: true }), ]), ]), transition('* <=> *', [ @@ -51,19 +51,19 @@ export const slideInAnimation = left: 0, width: '100%' }) - ]), + ], { optional: true }), query(':enter', [ style({ left: '-100%' }) - ]), - query(':leave', animateChild()), + ], { optional: true }), + query(':leave', animateChild(), { optional: true }), group([ query(':leave', [ animate('200ms ease-out', style({ left: '100%', opacity: 0 })) - ]), + ], { optional: true }), query(':enter', [ animate('300ms ease-out', style({ left: '0%' })) - ]), - query('@*', animateChild()) + ], { optional: true }), + query('@*', animateChild(), { optional: true }) ]), ]) // #enddocregion query diff --git a/aio/content/examples/animations/src/app/app.component.1.ts b/aio/content/examples/animations/src/app/app.component.1.ts old mode 100644 new mode 100755 index 11b497be1c0..3b2d7b14599 --- a/aio/content/examples/animations/src/app/app.component.1.ts +++ b/aio/content/examples/animations/src/app/app.component.1.ts @@ -2,6 +2,7 @@ import { Component, HostBinding } from '@angular/core'; @Component({ + standalone: true, selector: 'app-root', templateUrl: 'app.component.html', styleUrls: ['app.component.css'], diff --git a/aio/content/examples/animations/src/app/app.component.ts b/aio/content/examples/animations/src/app/app.component.ts old mode 100644 new mode 100755 index 39b2c72e6b2..da38efa951d --- a/aio/content/examples/animations/src/app/app.component.ts +++ b/aio/content/examples/animations/src/app/app.component.ts @@ -11,14 +11,16 @@ import { } from '@angular/animations'; // #enddocregion imports -import { ChildrenOutletContexts, RouterOutlet } from '@angular/router'; +import { ChildrenOutletContexts, RouterLink, RouterOutlet } from '@angular/router'; import { slideInAnimation } from './animations'; // #docregion decorator, toggle-app-animations, define @Component({ + standalone: true, selector: 'app-root', templateUrl: 'app.component.html', styleUrls: ['app.component.css'], + imports: [RouterLink, RouterOutlet], animations: [ // #enddocregion decorator slideInAnimation diff --git a/aio/content/examples/animations/src/app/app.config.ts b/aio/content/examples/animations/src/app/app.config.ts new file mode 100644 index 00000000000..ebcf6bad161 --- /dev/null +++ b/aio/content/examples/animations/src/app/app.config.ts @@ -0,0 +1,15 @@ +import { ApplicationConfig } from '@angular/core'; +import { routes } from './app.routes'; +import { provideRouter } from '@angular/router'; +import { provideProtractorTestingSupport } from '@angular/platform-browser'; +import { provideAnimations } from '@angular/platform-browser/animations'; + + +export const appConfig: ApplicationConfig = { + providers: [ + // needed for supporting e2e tests + provideProtractorTestingSupport(), + provideRouter(routes), + provideAnimations(), + ] +}; diff --git a/aio/content/examples/animations/src/app/app.module.ts b/aio/content/examples/animations/src/app/app.routes.ts similarity index 54% rename from aio/content/examples/animations/src/app/app.module.ts rename to aio/content/examples/animations/src/app/app.routes.ts index 8be60aa8f9d..ae0b88a7952 100644 --- a/aio/content/examples/animations/src/app/app.module.ts +++ b/aio/content/examples/animations/src/app/app.routes.ts @@ -1,112 +1,73 @@ -// #docregion route-animation-data -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { RouterModule } from '@angular/router'; -import { AppComponent } from './app.component'; -import { OpenCloseComponent } from './open-close.component'; +import { Routes } from '@angular/router'; import { OpenClosePageComponent } from './open-close-page.component'; -import { OpenCloseChildComponent } from './open-close.component.4'; -import { ToggleAnimationsPageComponent } from './toggle-animations-page.component'; -import { StatusSliderComponent } from './status-slider.component'; import { StatusSliderPageComponent } from './status-slider-page.component'; +import { ToggleAnimationsPageComponent } from './toggle-animations-page.component'; import { HeroListPageComponent } from './hero-list-page.component'; import { HeroListGroupPageComponent } from './hero-list-group-page.component'; -import { HeroListGroupsComponent } from './hero-list-groups.component'; import { HeroListEnterLeavePageComponent } from './hero-list-enter-leave-page.component'; -import { HeroListEnterLeaveComponent } from './hero-list-enter-leave.component'; import { HeroListAutoCalcPageComponent } from './hero-list-auto-page.component'; -import { HeroListAutoComponent } from './hero-list-auto.component'; -import { HomeComponent } from './home.component'; -import { AboutComponent } from './about.component'; import { InsertRemoveComponent } from './insert-remove.component'; import { QueryingComponent } from './querying.component'; +import { HomeComponent } from './home.component'; +import { AboutComponent } from './about.component'; - -@NgModule({ - imports: [ - BrowserModule, - BrowserAnimationsModule, - RouterModule.forRoot([ - { path: '', pathMatch: 'full', redirectTo: '/enter-leave' }, - { +// #docregion route-animation-data +export const routes: Routes = [ + { path: '', pathMatch: 'full', redirectTo: '/enter-leave' }, + { path: 'open-close', component: OpenClosePageComponent, data: { animation: 'openClosePage' } - }, - { + }, + { path: 'status', component: StatusSliderPageComponent, data: { animation: 'statusPage' } - }, - { + }, + { path: 'toggle', component: ToggleAnimationsPageComponent, data: { animation: 'togglePage' } - }, - { + }, + { path: 'heroes', component: HeroListPageComponent, data: { animation: 'filterPage' } - }, - { + }, + { path: 'hero-groups', component: HeroListGroupPageComponent, data: { animation: 'heroGroupPage' } - }, - { + }, + { path: 'enter-leave', component: HeroListEnterLeavePageComponent, data: { animation: 'enterLeavePage' } - }, - { + }, + { path: 'auto', component: HeroListAutoCalcPageComponent, data: { animation: 'autoPage' } - }, - { + }, + { path: 'insert-remove', component: InsertRemoveComponent, data: { animation: 'insertRemovePage' } - }, - { + }, + { path: 'querying', component: QueryingComponent, data: { animation: 'queryingPage' } - }, - { + }, + { path: 'home', component: HomeComponent, data: { animation: 'HomePage' } - }, - { + }, + { path: 'about', component: AboutComponent, data: { animation: 'AboutPage' } - }, - ]) - ], - // #enddocregion route-animation-data - declarations: [ - AppComponent, - StatusSliderComponent, - OpenCloseComponent, - OpenCloseChildComponent, - OpenClosePageComponent, - StatusSliderPageComponent, - ToggleAnimationsPageComponent, - HeroListPageComponent, - HeroListGroupsComponent, - HeroListGroupPageComponent, - HeroListEnterLeavePageComponent, - HeroListEnterLeaveComponent, - HeroListAutoCalcPageComponent, - HeroListAutoComponent, - HomeComponent, - InsertRemoveComponent, - QueryingComponent, - AboutComponent - ], - bootstrap: [AppComponent] -}) -export class AppModule { } + }, +]; +// #enddocregion route-animation-data diff --git a/aio/content/examples/animations/src/app/hero-list-auto-page.component.ts b/aio/content/examples/animations/src/app/hero-list-auto-page.component.ts old mode 100644 new mode 100755 index 78f17da64b0..8356f946bd5 --- a/aio/content/examples/animations/src/app/hero-list-auto-page.component.ts +++ b/aio/content/examples/animations/src/app/hero-list-auto-page.component.ts @@ -1,7 +1,9 @@ import { Component } from '@angular/core'; import { HEROES } from './mock-heroes'; +import { HeroListAutoComponent } from './hero-list-auto.component'; @Component({ + standalone: true, selector: 'app-hero-list-auto-page', template: `
@@ -9,7 +11,8 @@ import { HEROES } from './mock-heroes';
- ` + `, + imports: [HeroListAutoComponent] }) export class HeroListAutoCalcPageComponent { heroes = HEROES.slice(); diff --git a/aio/content/examples/animations/src/app/hero-list-auto.component.ts b/aio/content/examples/animations/src/app/hero-list-auto.component.ts old mode 100644 new mode 100755 index e77814b8f7f..4d891b04df0 --- a/aio/content/examples/animations/src/app/hero-list-auto.component.ts +++ b/aio/content/examples/animations/src/app/hero-list-auto.component.ts @@ -13,11 +13,14 @@ import { } from '@angular/animations'; import { Hero } from './hero'; +import { NgFor } from '@angular/common'; @Component({ + standalone: true, selector: 'app-hero-list-auto', templateUrl: 'hero-list-auto.component.html', styleUrls: ['./hero-list-page.component.css'], + imports: [NgFor], // #docregion auto-calc animations: [ trigger('shrinkOut', [ diff --git a/aio/content/examples/animations/src/app/hero-list-enter-leave-page.component.ts b/aio/content/examples/animations/src/app/hero-list-enter-leave-page.component.ts old mode 100644 new mode 100755 index ea816245271..d615f906be2 --- a/aio/content/examples/animations/src/app/hero-list-enter-leave-page.component.ts +++ b/aio/content/examples/animations/src/app/hero-list-enter-leave-page.component.ts @@ -1,7 +1,9 @@ import { Component } from '@angular/core'; import { HEROES } from './mock-heroes'; +import { HeroListEnterLeaveComponent } from './hero-list-enter-leave.component'; @Component({ + standalone: true, selector: 'app-hero-list-enter-leave-page', template: `
@@ -9,7 +11,8 @@ import { HEROES } from './mock-heroes';
- ` + `, + imports: [HeroListEnterLeaveComponent] }) export class HeroListEnterLeavePageComponent { heroes = HEROES.slice(); diff --git a/aio/content/examples/animations/src/app/hero-list-enter-leave.component.ts b/aio/content/examples/animations/src/app/hero-list-enter-leave.component.ts old mode 100644 new mode 100755 index b0b5878b1e4..d787d584b31 --- a/aio/content/examples/animations/src/app/hero-list-enter-leave.component.ts +++ b/aio/content/examples/animations/src/app/hero-list-enter-leave.component.ts @@ -13,8 +13,10 @@ import { } from '@angular/animations'; import { Hero } from './hero'; +import { NgFor } from '@angular/common'; @Component({ + standalone: true, selector: 'app-hero-list-enter-leave', template: ` `, styleUrls: ['./hero-list-page.component.css'], + imports: [NgFor], // #docregion animationdef animations: [ trigger('flyInOut', [ diff --git a/aio/content/examples/animations/src/app/hero-list-group-page.component.ts b/aio/content/examples/animations/src/app/hero-list-group-page.component.ts old mode 100644 new mode 100755 index b400126ff0d..083f7a40156 --- a/aio/content/examples/animations/src/app/hero-list-group-page.component.ts +++ b/aio/content/examples/animations/src/app/hero-list-group-page.component.ts @@ -1,7 +1,9 @@ import { Component } from '@angular/core'; import { HEROES } from './mock-heroes'; +import { HeroListGroupsComponent } from './hero-list-groups.component'; @Component({ + standalone: true, selector: 'app-hero-list-groups-page', template: `
@@ -9,7 +11,8 @@ import { HEROES } from './mock-heroes';
- ` + `, + imports: [HeroListGroupsComponent] }) export class HeroListGroupPageComponent { heroes = HEROES.slice(); diff --git a/aio/content/examples/animations/src/app/hero-list-groups.component.ts b/aio/content/examples/animations/src/app/hero-list-groups.component.ts old mode 100644 new mode 100755 index 961a2a327da..87cf915e9b0 --- a/aio/content/examples/animations/src/app/hero-list-groups.component.ts +++ b/aio/content/examples/animations/src/app/hero-list-groups.component.ts @@ -14,8 +14,10 @@ import { } from '@angular/animations'; import { Hero } from './hero'; +import { NgFor } from '@angular/common'; @Component({ + standalone: true, selector: 'app-hero-list-groups', template: ` `, styleUrls: ['./hero-list-page.component.css'], + imports: [NgFor], // #docregion animationdef animations: [ trigger('flyInOut', [ diff --git a/aio/content/examples/animations/src/app/hero-list-page.component.ts b/aio/content/examples/animations/src/app/hero-list-page.component.ts old mode 100644 new mode 100755 index 9829642cbde..cc490ec0fcf --- a/aio/content/examples/animations/src/app/hero-list-page.component.ts +++ b/aio/content/examples/animations/src/app/hero-list-page.component.ts @@ -4,10 +4,13 @@ import { Component, HostBinding, OnInit } from '@angular/core'; import { trigger, transition, animate, style, query, stagger } from '@angular/animations'; import { HEROES } from './mock-heroes'; import { Hero } from './hero'; +import { NgFor } from '@angular/common'; // #docregion filter-animations @Component({ // #enddocregion filter-animations + standalone: true, + imports: [NgFor], selector: 'app-hero-list-page', templateUrl: 'hero-list-page.component.html', styleUrls: ['hero-list-page.component.css'], diff --git a/aio/content/examples/animations/src/app/home.component.ts b/aio/content/examples/animations/src/app/home.component.ts old mode 100644 new mode 100755 index 8d631e9face..81acda4cdd2 --- a/aio/content/examples/animations/src/app/home.component.ts +++ b/aio/content/examples/animations/src/app/home.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; @Component({ + standalone: true, selector: 'app-home', templateUrl: './home.component.html', styleUrls: ['./home.component.css'] diff --git a/aio/content/examples/animations/src/app/insert-remove.component.ts b/aio/content/examples/animations/src/app/insert-remove.component.ts old mode 100644 new mode 100755 index 012b02ad5cd..760c81748b3 --- a/aio/content/examples/animations/src/app/insert-remove.component.ts +++ b/aio/content/examples/animations/src/app/insert-remove.component.ts @@ -1,9 +1,12 @@ // #docplaster import { Component } from '@angular/core'; import { trigger, transition, animate, style } from '@angular/animations'; +import { NgIf } from '@angular/common'; @Component({ + standalone: true, selector: 'app-insert-remove', + imports: [NgIf], animations: [ // #docregion enter-leave-trigger trigger('myInsertRemoveTrigger', [ diff --git a/aio/content/examples/animations/src/app/open-close-page.component.ts b/aio/content/examples/animations/src/app/open-close-page.component.ts old mode 100644 new mode 100755 index 85ece6c3131..d9b23597055 --- a/aio/content/examples/animations/src/app/open-close-page.component.ts +++ b/aio/content/examples/animations/src/app/open-close-page.component.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; +import { OpenCloseComponent } from './open-close.component'; @Component({ + standalone: true, selector: 'app-open-close-page', template: `
@@ -10,7 +12,8 @@ import { Component } from '@angular/core';
- ` + `, + imports: [OpenCloseComponent] }) export class OpenClosePageComponent { logging = false; diff --git a/aio/content/examples/animations/src/app/open-close.component.1.ts b/aio/content/examples/animations/src/app/open-close.component.1.ts index 77e33258ea7..4285b0ffdc9 100644 --- a/aio/content/examples/animations/src/app/open-close.component.1.ts +++ b/aio/content/examples/animations/src/app/open-close.component.1.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { trigger, transition, state, animate, style, keyframes } from '@angular/animations'; @Component({ + standalone: true, selector: 'app-open-close', animations: [ // #docregion trigger diff --git a/aio/content/examples/animations/src/app/open-close.component.2.ts b/aio/content/examples/animations/src/app/open-close.component.2.ts index 5f13d0d8389..65fbf72f5c8 100644 --- a/aio/content/examples/animations/src/app/open-close.component.2.ts +++ b/aio/content/examples/animations/src/app/open-close.component.2.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import { trigger, transition, state, animate, style } from '@angular/animations'; @Component({ + standalone: true, selector: 'app-open-close-boolean', // #docregion trigger-boolean animations: [ diff --git a/aio/content/examples/animations/src/app/open-close.component.3.ts b/aio/content/examples/animations/src/app/open-close.component.3.ts old mode 100644 new mode 100755 index 5bda8f9d9ef..6dec541700d --- a/aio/content/examples/animations/src/app/open-close.component.3.ts +++ b/aio/content/examples/animations/src/app/open-close.component.3.ts @@ -5,6 +5,7 @@ import { transition, trigger, useAnimation } from '@angular/animations'; import { transitionAnimation } from './animations'; @Component({ + standalone: true, selector: 'app-open-close-reusable', animations: [ trigger('openClose', [ diff --git a/aio/content/examples/animations/src/app/open-close.component.4.ts b/aio/content/examples/animations/src/app/open-close.component.4.ts old mode 100644 new mode 100755 index e5f591c085d..854412ea317 --- a/aio/content/examples/animations/src/app/open-close.component.4.ts +++ b/aio/content/examples/animations/src/app/open-close.component.4.ts @@ -6,6 +6,7 @@ import { trigger, transition, state, animate, style } from '@angular/animations' // #docregion toggle-animation @Component({ // #enddocregion toggle-animation + standalone: true, selector: 'app-open-close-toggle', templateUrl: 'open-close.component.4.html', styleUrls: ['open-close.component.css'], diff --git a/aio/content/examples/animations/src/app/open-close.component.ts b/aio/content/examples/animations/src/app/open-close.component.ts old mode 100644 new mode 100755 index 571df8f7ea5..5d6032f089c --- a/aio/content/examples/animations/src/app/open-close.component.ts +++ b/aio/content/examples/animations/src/app/open-close.component.ts @@ -4,6 +4,7 @@ import { trigger, transition, state, animate, style, AnimationEvent } from '@ang // #docregion component, events1 @Component({ + standalone: true, selector: 'app-open-close', // #docregion trigger-wildcard1, trigger-transition animations: [ diff --git a/aio/content/examples/animations/src/app/querying.component.ts b/aio/content/examples/animations/src/app/querying.component.ts old mode 100644 new mode 100755 index f582a0c0a80..65db2ecf960 --- a/aio/content/examples/animations/src/app/querying.component.ts +++ b/aio/content/examples/animations/src/app/querying.component.ts @@ -13,8 +13,10 @@ import { } from '@angular/animations'; import { HEROES } from './mock-heroes'; +import { NgIf } from '@angular/common'; @Component({ + standalone: true, selector: 'app-querying', template: `