1
1
import { useNavigation } from '@remix-run/react' ;
2
2
import { useNProgress } from '@tanem/react-nprogress' ;
3
-
4
- import { cn } from '~/lib/utils' ;
3
+ import { AnimatePresence , m } from 'framer-motion' ;
5
4
6
5
export function NavigationProgressBar ( ) {
7
6
const navigation = useNavigation ( ) ;
@@ -11,27 +10,37 @@ export function NavigationProgressBar() {
11
10
} ) ;
12
11
13
12
return (
14
- < div
15
- className = { cn ( [ isFinished ? 'opacity-0' : 'opacity-100' ] ) }
16
- style = { {
17
- transition : `opacity ${ animationDuration } ms linear` ,
18
- } }
19
- >
20
- < div
21
- className = "fixed left-0 top-0 z-[1042] h-[3px] w-full rounded-r-full bg-primary"
22
- style = { {
23
- marginLeft : `${ ( - 1 + progress ) * 100 } %` ,
24
- transition : `margin-left ${ animationDuration } ms linear` ,
25
- } }
26
- >
27
- < div
28
- className = "absolute right-0 block h-full w-[100px] translate-y-[-4px] rotate-3 opacity-100"
29
- style = { {
30
- boxShadow :
31
- '0 0 10px rgb(var(--primary)), 0 0 5px rgb(var(--primary))' ,
13
+ < AnimatePresence >
14
+ { ! isFinished && (
15
+ < m . div
16
+ animate = { { opacity : 1 } }
17
+ exit = { { opacity : 0 } }
18
+ initial = { { opacity : 0 } }
19
+ transition = { {
20
+ delay : 0.15 ,
21
+ duration : animationDuration / 1000 ,
32
22
} }
33
- />
34
- </ div >
35
- </ div >
23
+ >
24
+ < m . div
25
+ animate = { {
26
+ marginLeft : `${ ( - 1 + progress ) * 100 } %` ,
27
+ transition : {
28
+ duration : animationDuration / 1000 ,
29
+ ease : 'linear' ,
30
+ } ,
31
+ } }
32
+ className = "fixed left-0 top-0 z-[1042] h-[3px] w-full rounded-r-full bg-primary"
33
+ >
34
+ < div
35
+ className = "absolute right-0 block h-full w-[100px] translate-y-[-4px] rotate-3 opacity-100"
36
+ style = { {
37
+ boxShadow :
38
+ '0 0 10px rgb(var(--primary)), 0 0 5px rgb(var(--primary))' ,
39
+ } }
40
+ />
41
+ </ m . div >
42
+ </ m . div >
43
+ ) }
44
+ </ AnimatePresence >
36
45
) ;
37
46
}
0 commit comments