From 498c1694b9fb0fa74686cdd75f3c02e8b571b426 Mon Sep 17 00:00:00 2001 From: Fadi Khadra Date: Tue, 1 Nov 2022 08:25:17 +0100 Subject: [PATCH] shorten declaration --- src/components/Transitions.tsx | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/components/Transitions.tsx b/src/components/Transitions.tsx index 82847d8c..30139594 100644 --- a/src/components/Transitions.tsx +++ b/src/components/Transitions.tsx @@ -1,25 +1,17 @@ import { Default, cssTransition } from '../utils'; -const Bounce = cssTransition({ - enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__bounce-enter`, - exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__bounce-exit`, - appendPosition: true +const getConfig = (animationName: string, appendPosition = false) => ({ + enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__${animationName}-enter`, + exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__${animationName}-exit`, + appendPosition }); -const Slide = cssTransition({ - enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__slide-enter`, - exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__slide-exit`, - appendPosition: true -}); +const Bounce = cssTransition(getConfig('bounce', true)); -const Zoom = cssTransition({ - enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__zoom-enter`, - exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__zoom-exit` -}); +const Slide = cssTransition(getConfig('slide', true)); -const Flip = cssTransition({ - enter: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__flip-enter`, - exit: `${Default.CSS_NAMESPACE}--animate ${Default.CSS_NAMESPACE}__flip-exit` -}); +const Zoom = cssTransition(getConfig('zoom')); + +const Flip = cssTransition(getConfig('flip')); export { Bounce, Slide, Zoom, Flip };