From 4d92a557d20884430bb652f42739e0e5bd639b25 Mon Sep 17 00:00:00 2001 From: TheDiaval Date: Thu, 3 Oct 2019 14:37:56 +0300 Subject: [PATCH] refactor(theme-shared): add angular animations --- .../src/lib/animations/bounce.animations.ts | 2 +- .../src/lib/animations/fade.animations.ts | 64 ++++++++++ .../src/lib/components/modal/README.md | 25 ---- .../lib/components/modal/modal.animations.ts | 14 +++ .../lib/components/modal/modal.component.html | 29 +---- .../lib/components/modal/modal.component.ts | 119 ++++++------------ 6 files changed, 123 insertions(+), 130 deletions(-) delete mode 100644 npm/ng-packs/packages/theme-shared/src/lib/components/modal/README.md create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.animations.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/animations/bounce.animations.ts b/npm/ng-packs/packages/theme-shared/src/lib/animations/bounce.animations.ts index ccdc62c491..c539725a0a 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/animations/bounce.animations.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/animations/bounce.animations.ts @@ -1,4 +1,4 @@ -import { animation, animate, style, trigger, transition, state, useAnimation, keyframes } from '@angular/animations'; +import { animate, animation, keyframes, style } from '@angular/animations'; export const bounceIn = animation( [ diff --git a/npm/ng-packs/packages/theme-shared/src/lib/animations/fade.animations.ts b/npm/ng-packs/packages/theme-shared/src/lib/animations/fade.animations.ts index 60be602291..7eb513522d 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/animations/fade.animations.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/animations/fade.animations.ts @@ -13,3 +13,67 @@ export const fadeOut = animation( ], { params: { time: '350ms', easing: 'ease' } } ); + +export const fadeInDown = animation( + [ + style({ opacity: '0', display: '{{ display }}', transform: '{{ transform }} translateY(-20px)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '1', transform: '{{ transform }} translateY(0)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); + +export const fadeInUp = animation( + [ + style({ opacity: '0', display: '{{ display }}', transform: '{{ transform }} translateY(20px)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '1', transform: '{{ transform }} translateY(0)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); + +export const fadeInLeft = animation( + [ + style({ opacity: '0', display: '{{ display }}', transform: '{{ transform }} translateX(20px)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '1', transform: '{{ transform }} translateX(0)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); + +export const fadeInRight = animation( + [ + style({ opacity: '0', display: '{{ display }}', transform: '{{ transform }} translateX(-20px)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '1', transform: '{{ transform }} translateX(0)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); + +export const fadeOutDown = animation( + [ + style({ opacity: '1', display: '{{ display }}', transform: '{{ transform }} translateY(0)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '0', transform: '{{ transform }} translateY(20px)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); + +export const fadeOutUp = animation( + [ + style({ opacity: '1', display: '{{ display }}', transform: '{{ transform }} translateY(0)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '0', transform: '{{ transform }} translateY(-20px)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); + +export const fadeOutLeft = animation( + [ + style({ opacity: '1', display: '{{ display }}', transform: '{{ transform }} translateX(0)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '0', transform: '{{ transform }} translateX(20px)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); + +export const fadeOutRight = animation( + [ + style({ opacity: '1', display: '{{ display }}', transform: '{{ transform }} translateX(0)' }), + animate('{{ time }} {{ easing }}', style({ opacity: '0', transform: '{{ transform }} translateX(-20px)' })) + ], + { params: { time: '350ms', easing: 'ease', display: 'block', transform: 'translate(-50%, -50%)' } } +); diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/modal/README.md b/npm/ng-packs/packages/theme-shared/src/lib/components/modal/README.md deleted file mode 100644 index cf51e03845..0000000000 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/modal/README.md +++ /dev/null @@ -1,25 +0,0 @@ -

 Abp Modal

- -Example Usage: - -```html - - -

Modal Title

-
- - -
- - -
-
- - - - - -
- - -``` diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.animations.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.animations.ts new file mode 100644 index 0000000000..c686bec552 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.animations.ts @@ -0,0 +1,14 @@ +import { trigger, state, style, transition, useAnimation } from '@angular/animations'; +import { fadeInDown, fadeOut, fadeIn } from '../../animations'; + +export const backdropAnimation = trigger('backdrop', [ + state('void', style({ opacity: '0' })), + state('*', style({ opacity: '1' })), + transition('void => *', useAnimation(fadeIn)), + transition('* => void', useAnimation(fadeOut)) +]); + +export const dialogAnimation = trigger('dialog', [ + transition('void => *', useAnimation(fadeInDown)), + transition('* => void', useAnimation(fadeOut)) +]); diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html b/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html index 75c48d2d15..c6eb6bf839 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/modal/modal.component.html @@ -1,31 +1,15 @@ -