angular/integration/animations-async/src/app/open-close.component.ts
Matthieu Riegler 2c2ccf76e2 refactor(animations): Add integration test for animations/async. (#50738)
This integration test aims to cover that we do not break the code splitting of the animation module when we use `provideAnimationsAsync()`.

PR Close #50738
2023-09-29 10:49:40 -07:00

48 lines
No EOL
1.3 KiB
TypeScript

import {animate, state, style, transition, trigger} from '@angular/animations';
import {Component} from '@angular/core';
@Component({
selector: 'app-open-close',
animations: [
trigger(
'openClose',
[
// ...
state(
'open',
style({height: '200px', opacity: 1, backgroundColor: 'yellow'})),
state(
'closed',
style({height: '100px', opacity: 0.8, backgroundColor: 'blue'})),
transition('open => closed', [animate('1s')]),
transition('closed => open', [animate('0.5s')]),
]),
],
template: `<nav>
<button type="button" (click)="toggle()">Toggle Open/Close</button>
</nav>
<div [@openClose]="isOpen ? 'open' : 'closed'" class="open-close-container">
<p>The box is now {{ isOpen ? 'Open' : 'Closed' }}!</p>
</div>`,
styles: [`:host {
display: block;
margin-top: 1rem;
}
.open-close-container {
border: 1px solid #dddddd;
margin-top: 1em;
padding: 20px 20px 0px 20px;
color: #000000;
font-weight: bold;
font-size: 20px;
}`],
standalone: true,
})
export class OpenCloseComponent {
isOpen = true;
toggle() {
this.isOpen = !this.isOpen;
}
}