-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new-ui): implement smooth loading experience (#608)
* feat(new-ui): implement smooth loading experience
- Loading branch information
Showing
31 changed files
with
518 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {State} from '@/static/new-ui/types/store'; | ||
|
||
export const getTotalLoadingProgress = (state: State): number => { | ||
const progressValues = Object.values(state.app.loading.progress); | ||
|
||
if (progressValues.length === 0) { | ||
return 1; | ||
} | ||
|
||
const totalProgress = progressValues.reduce((acc, currentProgress) => { | ||
return acc + currentProgress; | ||
}, 0); | ||
|
||
return totalProgress / progressValues.length; | ||
}; |
67 changes: 67 additions & 0 deletions
67
lib/static/new-ui/components/Card/AnimatedAppearCard.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
@property --gradient-angle { | ||
syntax: "<angle>"; | ||
inherits: false; | ||
initial-value: 0turn; | ||
} | ||
|
||
@property --from-color { | ||
syntax: "<color>"; | ||
inherits: false; | ||
initial-value: #eee; | ||
} | ||
|
||
@property --to-color { | ||
syntax: "<color>"; | ||
inherits: false; | ||
initial-value: #eee; | ||
} | ||
|
||
.animated-appear-card { | ||
background-color: #eee; | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
z-index: 10; | ||
box-shadow: 0 0 0 2px #eee; | ||
animation: border-pulse 5s ease forwards; | ||
background-image: conic-gradient(from var(--gradient-angle) at -10% 100%, var(--from-color) 0%, var(--to-color) 100%); | ||
padding: 1px; | ||
} | ||
|
||
.background-overlay { | ||
background-color: #eee; | ||
width: 100%; | ||
height: 100%; | ||
border-radius: 10px; | ||
} | ||
|
||
@keyframes border-pulse { | ||
0% { | ||
--from-color: #eee; | ||
--to-color: #eee; | ||
--gradient-angle: 0turn; | ||
visibility: visible; | ||
} | ||
|
||
25% { | ||
--from-color: #00ffff00; | ||
--to-color: #7d7d7d85; | ||
--gradient-angle: 0turn; | ||
} | ||
|
||
50% { | ||
opacity: 1; | ||
} | ||
|
||
100% { | ||
--from-color: #00ffff00; | ||
--to-color: #7d7d7d85; | ||
--gradient-angle: 1turn; | ||
opacity: 0; | ||
visibility: hidden; | ||
} | ||
} | ||
|
||
.hidden { | ||
visibility: hidden !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React, {ReactNode} from 'react'; | ||
|
||
import cardStyles from './index.module.css'; | ||
import styles from './AnimatedAppearCard.module.css'; | ||
import classNames from 'classnames'; | ||
import {useSelector} from 'react-redux'; | ||
import {State} from '@/static/new-ui/types/store'; | ||
|
||
export function AnimatedAppearCard(): ReactNode { | ||
const isInitialized = useSelector((state: State) => state.app.isInitialized); | ||
|
||
return <div className={classNames(cardStyles.commonCard, styles.animatedAppearCard, {[styles.hidden]: isInitialized})}> | ||
<div className={styles.backgroundOverlay}></div> | ||
</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
.container { | ||
height: 30px; | ||
width: 100%; | ||
position: absolute; | ||
z-index: 99; | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
transition: height .2s ease, opacity .1s ease; | ||
box-shadow: rgba(0, 0, 0, 0.11) 1px 1px 8px 0px; | ||
background-color: var(--g-color-base-brand-hover); | ||
} | ||
|
||
.hidden { | ||
height: 0; | ||
} | ||
|
||
.hidden .message { | ||
opacity: 0; | ||
} | ||
|
||
.container::before { | ||
content: ''; | ||
width: 100%; | ||
height: 100%; | ||
position: absolute; | ||
background-color: var(--g-color-base-brand); | ||
top: 0; | ||
left: -100%; | ||
} | ||
|
||
.message-container { | ||
position: relative; | ||
color: white; | ||
font-weight: 450; | ||
flex-grow: 1; | ||
display: flex; | ||
align-items: center; | ||
z-index: 10; | ||
} | ||
|
||
.message { | ||
display: flex; | ||
align-items: baseline; | ||
gap: 1px; | ||
} | ||
|
||
.loader { | ||
width: 12px; | ||
aspect-ratio: 2; | ||
--dot: no-repeat radial-gradient(circle closest-side, #fff 90%, #fff0); | ||
background: | ||
var(--dot) 0% 50%, | ||
var(--dot) 50% 50%, | ||
var(--dot) 100% 50%; | ||
background-size: calc(100%/3) 50%; | ||
animation: l3 1s infinite linear; | ||
} | ||
|
||
@keyframes l3 { | ||
20%{background-position:0% 0%, 50% 50%,100% 50%} | ||
40%{background-position:0% 100%, 50% 0%,100% 50%} | ||
60%{background-position:0% 50%, 50% 100%,100% 0%} | ||
80%{background-position:0% 50%, 50% 50%,100% 100%} | ||
} | ||
.progress-container { | ||
height: 100%; | ||
background-color: var(--g-color-base-brand); | ||
position: absolute; | ||
left: 0; | ||
transition: width 0.2s ease; | ||
} | ||
|
||
.progress-pulse { | ||
position: absolute; | ||
right: 0; | ||
height: 100%; | ||
background-color: #5500ff; | ||
animation: progress-pulse 2s ease infinite; | ||
} | ||
|
||
@keyframes progress-pulse { | ||
0% { | ||
width: 0; | ||
opacity: 1; | ||
} | ||
|
||
100% { | ||
width: 30px; | ||
opacity: 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, {ReactNode, useEffect, useRef} from 'react'; | ||
|
||
import styles from './index.module.css'; | ||
import {useSelector} from 'react-redux'; | ||
import {getTotalLoadingProgress} from '@/static/new-ui/app/selectors'; | ||
import {State} from '@/static/new-ui/types/store'; | ||
import classNames from 'classnames'; | ||
|
||
export function LoadingBar(): ReactNode { | ||
const isLoaded = useSelector((state: State) => state.app.isInitialized); | ||
const isLoadedRef = useRef(isLoaded); | ||
const progress = useSelector(getTotalLoadingProgress); | ||
|
||
const [hidden, setHidden] = React.useState(true); | ||
|
||
// Delay is needed for smoother experience: when loading is fast, it prevents notification bar from appearing and | ||
// hiding immediately. When loading a lot of data, it helps avoid freezes when everything is loaded. | ||
useEffect(() => { | ||
isLoadedRef.current = isLoaded; | ||
const timeoutId = setTimeout(() => { | ||
if (isLoaded === isLoadedRef.current) { | ||
setHidden(isLoaded); | ||
} | ||
}, 500); | ||
|
||
return () => clearTimeout(timeoutId); | ||
}, [isLoaded]); | ||
|
||
return <div className={classNames(styles.container, {[styles.hidden]: hidden})}> | ||
<div className={styles.messageContainer}> | ||
<div className={styles.message}> | ||
<span>Loading Testplane UI</span> | ||
<div className={styles.loader}></div> | ||
</div> | ||
</div> | ||
<div className={styles.progressContainer} style={{width: `${progress * 100}%`}}> | ||
<div className={styles.progressPulse}></div> | ||
</div> | ||
</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.