Skip to content

Commit 5046c9a

Browse files
committed
feat: add animation in login and sso variants
1 parent b9c0828 commit 5046c9a

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/components/login/Login.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useEffect, useState } from 'react'
1818
import { Redirect, Route, Switch, useHistory, useLocation } from 'react-router-dom'
1919

2020
import {
21+
AnimatePresence,
2122
Button,
2223
ButtonComponentType,
2324
ButtonStyleType,
@@ -27,6 +28,7 @@ import {
2728
Host,
2829
Icon,
2930
LoginBanner,
31+
MotionDiv,
3032
SSOProviderIcon,
3133
ToastManager,
3234
ToastVariantType,
@@ -40,7 +42,7 @@ import { importComponentFromFELibrary } from '@Components/common'
4042
import { TOKEN_COOKIE_NAME, URLS } from '../../config'
4143
import { getSSOConfigList } from '../../Pages/GlobalConfigurations/Authorization/SSOLoginServices/service'
4244
import { dashboardAccessed } from '../../services/service'
43-
import { SSOProvider } from './constants'
45+
import { ANIMATION_VARIANTS, SSOProvider } from './constants'
4446
import { SSOConfigLoginList } from './login.types'
4547
import { LoginForm } from './LoginForm'
4648

@@ -171,7 +173,7 @@ const Login = () => {
171173
)
172174

173175
const renderLoginContent = () => (
174-
<Switch>
176+
<Switch location={location}>
175177
<Route path={URLS.LOGIN_SSO} component={renderSSOLoginPage} />
176178
<Route path={URLS.LOGIN_ADMIN} component={renderAdminLoginPage} />
177179
<Redirect to={URLS.LOGIN_SSO} />
@@ -187,7 +189,20 @@ const Login = () => {
187189
<div className="login-card__wrapper dc__overflow-hidden br-12 mw-420 bg__primary dc__border">
188190
<div className="flexbox-col">
189191
{renderDevtronLogo()}
190-
{renderLoginContent()}
192+
{/* do we need initial */}
193+
<AnimatePresence initial={false}>
194+
<MotionDiv
195+
key={location.pathname}
196+
variants={ANIMATION_VARIANTS}
197+
initial="initial"
198+
animate="animate"
199+
exit="exit"
200+
transition={{ duration: 0.25, ease: 'easeInOut' }}
201+
style={{ overflow: 'hidden' }}
202+
>
203+
{renderLoginContent()}
204+
</MotionDiv>
205+
</AnimatePresence>
191206
</div>
192207
{getTermsAndConditions && getTermsAndConditions()}
193208
</div>

src/components/login/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ export const ssoProviderToDisplayNameMap: Record<SSOProvider, string> = {
5959
[SSOProvider.oidc]: 'OIDC',
6060
[SSOProvider.openshift]: 'OpenShift',
6161
} as const
62+
63+
export const ANIMATION_VARIANTS = {
64+
initial: { opacity: 0, y: 40, height: 0 },
65+
animate: { opacity: 1, y: 0, height: 'auto' },
66+
exit: { opacity: 0, y: -40, height: 0 },
67+
}

0 commit comments

Comments
 (0)