1- import styled , { keyframes , css } from 'styled-components' ;
1+ import React from 'react' ;
2+ import styled from 'styled-components' ;
23
34export const BottomSheetWrapper = styled . div < { $isOpenBottomSheet : boolean } > `
45 position: fixed;
@@ -8,21 +9,22 @@ export const BottomSheetWrapper = styled.div<{ $isOpenBottomSheet: boolean }>`
89 height: 100%;
910 z-index: 999;
1011 background-color: rgba(0, 0, 0, 0.3);
11- animation: ${ ( props ) =>
12- props . $isOpenBottomSheet
13- ? css `
14- ${ fadeIn } 0.2s ease-out forwards
15- `
16- : css `
17- ${ fadeOut } 0.2s ease-out forwards
18- ` } ;
12+ opacity: ${ ( { $isOpenBottomSheet } ) => ( $isOpenBottomSheet ? 1 : 0 ) } ;
13+ visibility: ${ ( { $isOpenBottomSheet } ) => ( $isOpenBottomSheet ? 'visible' : 'hidden' ) } ;
14+ transition:
15+ opacity 0.2s ease-out,
16+ visibility 0.3s ease-out;
1917` ;
2018
21- export const BottomSheetLayout = styled . div . attrs < { $currentTranslateY : number } > ( ( { $currentTranslateY } ) => ( {
22- style : {
23- transform : `translate(-50%, ${ $currentTranslateY } px)` ,
24- } ,
25- } ) ) < { $isOpenBottomSheet : boolean ; $currentTranslateY : number ; $isHandlerVisible : boolean } > `
19+ export const BottomSheetLayout = styled . div . attrs < { $currentTranslateY : number ; $isOpenBottomSheet : boolean } > (
20+ ( { $currentTranslateY, $isOpenBottomSheet } ) => ( {
21+ style : {
22+ transform : `translate(-50%, ${ $isOpenBottomSheet ? `${ $currentTranslateY } px` : '100%' } )` ,
23+ } ,
24+ } ) ,
25+ ) < {
26+ $isHandlerVisible : boolean ;
27+ } > `
2628 position: fixed;
2729 bottom: 0;
2830 flex-direction: column;
@@ -31,21 +33,14 @@ export const BottomSheetLayout = styled.div.attrs<{ $currentTranslateY: number }
3133 left: 50%;
3234 border-radius: 0.938rem 0.938rem 0 0;
3335 background-color: ${ ( { theme } ) => theme . colors . white } ;
34- padding-top: ${ ( props ) => ( props . $isHandlerVisible ? '1.3rem' : '0.9375rem' ) } ;
36+ padding-top: ${ ( { $isHandlerVisible } ) => ( $isHandlerVisible ? '1.3rem' : '0.9375rem' ) } ;
3537 z-index: 200;
3638 user-select: none;
3739 touch-action: none;
38- animation: ${ ( props ) =>
39- props . $isOpenBottomSheet
40- ? css `
41- ${ slideUp } 0.2s ease-out
42- `
43- : css `
44- ${ slideDown } 0.2s ease-out forwards
45- ` } ;
40+ transition: transform 0.3s;
4641` ;
4742
48- export const Handler = styled . hr `
43+ export const Handler = React . memo ( styled . hr `
4944 width: 3rem;
5045 margin: 0 auto;
5146 height: 0.25rem;
@@ -54,40 +49,4 @@ export const Handler = styled.hr`
5449 border-radius: 0.125rem;
5550 z-index: 300;
5651 cursor: pointer;
57- ` ;
58-
59- const fadeIn = keyframes `
60- from {
61- opacity: 0;
62- }
63- to {
64- opacity: 1;
65- }
66- ` ;
67-
68- const fadeOut = keyframes `
69- from {
70- opacity: 1;
71- visibility: visible;
72- }
73- to {
74- opacity: 0;
75- visibility: hidden;
76- }
77- ` ;
78-
79- const slideUp = keyframes `
80- from {
81- transform: translate(-50%, 100%);
82- }
83- to {
84- transform: translate(-50%, 0);
85- }
86- ` ;
87-
88- const slideDown = keyframes `
89- to {
90- transform: translate(-50%, 100%);
91- visibility: hidden;
92- }
93- ` ;
52+ ` ) ;
0 commit comments