Commit 8afa9bb 1 parent 7f3db83 commit 8afa9bb Copy full SHA for 8afa9bb
File tree 6 files changed +43
-10
lines changed
6 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,21 @@ export const pageVariants = {
12
12
x : '-100vw' ,
13
13
} ,
14
14
} ;
15
+
16
+ export const menuVariants = {
17
+ open : {
18
+ opacity : 1 ,
19
+ scale : 1 ,
20
+ y : 100 ,
21
+ transition : {
22
+ opacity : { duration : 0.1 } ,
23
+ scale : { type : 'spring' , stiffness : 260 , damping : 20 } ,
24
+ } ,
25
+ } ,
26
+ closed : {
27
+ y : 100 ,
28
+ opacity : 0 ,
29
+ scale : 0.95 ,
30
+ transition : { duration : 0.1 } ,
31
+ } ,
32
+ } ;
Original file line number Diff line number Diff line change 7
7
position : absolute ;
8
8
bottom : 0 ;
9
9
right : 0 ;
10
- width : 200 px ;
10
+ width : 150 px ;
11
11
padding : 8px 0 ;
12
12
border-radius : 8px ;
13
13
background-color : $color-bg ;
14
- transform : translateY ( 100 % );
14
+ box-shadow : 0 px 2 px 5 px rgba ( 0 , 0 , 0 , 0.1 );
15
15
}
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import styles from './ContextMenu.module.scss';
3
3
import { useOutsideClickRef } from 'rooks' ;
4
4
import DropdownToggle from './ContextMenuToggle' ;
5
5
import type { IContextMenuItem } from './ContextMenuItem' ;
6
+ import { AnimatePresence , motion } from 'framer-motion' ;
7
+ import { menuVariants } from '@/animations/variants' ;
6
8
7
9
interface IContextMenu {
8
10
children : ReactElement < IContextMenuItem > | ReactElement < IContextMenuItem > [ ] ;
@@ -20,7 +22,19 @@ const ContextMenu = ({ children }: IContextMenu) => {
20
22
return (
21
23
< div className = { styles . menu } ref = { ref } >
22
24
< DropdownToggle onClick = { toggleHandler } />
23
- { isOpen && < ul className = { styles . list } > { children } </ ul > }
25
+ < AnimatePresence >
26
+ { isOpen && (
27
+ < motion . ul
28
+ className = { styles . list }
29
+ initial = 'closed'
30
+ animate = 'open'
31
+ exit = 'closed'
32
+ variants = { menuVariants }
33
+ >
34
+ { children }
35
+ </ motion . ul >
36
+ ) }
37
+ </ AnimatePresence >
24
38
</ div >
25
39
) ;
26
40
} ;
Original file line number Diff line number Diff line change 1
1
.item {
2
2
display : flex ;
3
3
align-items : center ;
4
- padding : 4 px 16px ;
4
+ padding : 8 px 16px ;
5
5
cursor : pointer ;
6
6
7
7
& :hover {
8
- background-color : $color-bg ;
8
+ background-color : $color-hover ; ;
9
9
}
10
10
11
- & [data-variant = ' danger ' ] {
11
+ & [data-variant = ' info ' ] {
12
12
color : $color-text ;
13
13
fill : $color-text ;
14
14
}
20
20
}
21
21
22
22
.label {
23
- margin-left : 20 px ;
23
+ margin-left : 8 px ;
24
24
}
Original file line number Diff line number Diff line change 1
1
.toggle {
2
- background-color : red ;
3
2
background-color : transparent ;
4
3
border : none ;
5
- }
4
+ cursor : pointer ;
5
+ fill :$color-text ;
6
+ }
Original file line number Diff line number Diff line change 22
22
--color-button-text : #ffffff ;
23
23
24
24
/* Other */
25
- --color-hover : #f1f1f1 ;
25
+ --color-hover : #f1f1f1d9 ;
26
26
}
27
27
28
28
& [data-theme = ' dark' ] {
You can’t perform that action at this time.
0 commit comments