mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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
48 lines
No EOL
1.3 KiB
TypeScript
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;
|
|
}
|
|
} |