File tree 4 files changed +57
-20
lines changed
4 files changed +57
-20
lines changed Original file line number Diff line number Diff line change 5
5
}
6
6
7
7
/* prettier-ignore */
8
- @keyframes in {
8
+ @keyframes flip- in {
9
9
from { opacity : 0 ; transform : rotateX (-10deg ); }
10
10
to { opacity : 1 ; transform : rotateX (0deg ); }
11
11
}
12
12
13
13
/* prettier-ignore */
14
- @keyframes out {
14
+ @keyframes flip- out {
15
15
from { opacity : 1 ; transform : rotateX (0deg ); }
16
16
to { opacity : 0 ; transform : rotateX (-10deg ); }
17
17
}
18
18
19
19
.flip [data-state = "open" ] {
20
- animation-name : in;
21
- animation-duration : 200 ms ;
20
+ animation-name : flip- in;
21
+ animation-duration : 0.2 s ;
22
22
}
23
23
24
24
.flip [data-state = "closed" ] {
25
- animation-name : out;
26
- animation-duration : 600ms ;
25
+ animation-name : flip-out;
26
+ animation-duration : 0.6s ;
27
+ }
28
+
29
+ /* Fade */
30
+
31
+ .fade {
32
+ will-change : opacity;
33
+ animation-timing-function : var (--ease );
34
+ }
35
+
36
+ /* prettier-ignore */
37
+ @keyframes fade-in { from { opacity : 0 ; } to { opacity : 1 ; } }
38
+
39
+ /* prettier-ignore */
40
+ @keyframes fade-out { from { opacity : 1 ; } to { opacity : 0 ; } }
41
+
42
+ .fade [data-state = "open" ] {
43
+ animation-name : fade-in;
44
+ animation-duration : 0.4s ;
45
+ }
46
+
47
+ .fade [data-state = "closed" ] {
48
+ animation-name : fade-out;
49
+ animation-duration : 0.8s ;
27
50
}
Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ import * as s from "./animation.module.css";
2
2
3
3
export const animation = {
4
4
flip : s . flip ,
5
+ fade : s . fade ,
5
6
} ;
Original file line number Diff line number Diff line change 1
1
.overlay {
2
- background-color : var (--color-base );
2
+ background-color : rgba ( var (--color-base-rgb ) , 0.8 );
3
3
position : fixed;
4
4
inset : 0 ;
5
- opacity : 0.8 ;
6
5
}
7
6
8
- .content {
7
+ .container {
9
8
position : fixed;
10
- top : 50% ;
11
- left : 50% ;
12
- transform : translate (-50% , -50% );
9
+ inset : 0 ;
10
+
11
+ display : flex;
12
+ align-items : center;
13
+ justify-content : center;
14
+
15
+ perspective : 100vh ;
16
+ }
13
17
18
+ .content {
14
19
padding : 18px ;
15
20
display : flex;
16
21
flex-direction : column;
Original file line number Diff line number Diff line change 1
1
import * as Radix from "@radix-ui/react-alert-dialog" ;
2
2
import { ReactNode } from "react" ;
3
+ import { animation } from "../animation/animation" ;
3
4
import { Card } from "../card/card" ;
4
5
import * as s from "./dialog.module.css" ;
5
6
@@ -15,14 +16,21 @@ const Content = (props: Props): JSX.Element => {
15
16
const { title, description, buttons } = props ;
16
17
return (
17
18
< Radix . Portal >
18
- < Radix . Overlay className = { s . overlay } />
19
- < Radix . Content className = { [ s . content , Card . glass ] . join ( " " ) } >
20
- < Radix . Title className = { s . title } > { title } </ Radix . Title >
21
- < Radix . Description className = { s . description } >
22
- { description }
23
- </ Radix . Description >
24
- < div className = { s . footer } > { buttons } </ div >
25
- </ Radix . Content >
19
+ < Radix . Overlay
20
+ className = { [ s . overlay , animation . fade ] . join ( " " ) }
21
+ > </ Radix . Overlay >
22
+ { /* Container to apply transform animation to Content */ }
23
+ < div className = { s . container } >
24
+ < Radix . Content
25
+ className = { [ s . content , Card . glass , animation . flip ] . join ( " " ) }
26
+ >
27
+ < Radix . Title className = { s . title } > { title } </ Radix . Title >
28
+ < Radix . Description className = { s . description } >
29
+ { description }
30
+ </ Radix . Description >
31
+ < div className = { s . footer } > { buttons } </ div >
32
+ </ Radix . Content >
33
+ </ div >
26
34
</ Radix . Portal >
27
35
) ;
28
36
} ;
You can’t perform that action at this time.
0 commit comments