11import styled from 'styled-components'
2- import { contains } from 'ramda'
32
43import type { TActive } from '@/spec'
54import css , { theme , zIndex } from '@/utils/css'
5+ import { pixelAdd } from '@/utils/dom'
66
77import type { TDrawer , TSwipe } from '../spec'
88import {
9- WIDE_CASE ,
10- WIDE_WIDTH ,
11- NARROW_WIDTH ,
129 getTransform ,
1310 getMobileContentHeight ,
1411 getContentLinearGradient ,
1512 getDim ,
13+ isViewerMode ,
14+ getDrawerWidth ,
15+ getDrawerMinWidth ,
1616} from './metrics'
1717
1818export const DrawerOverlay = styled . div < TActive > `
@@ -61,27 +61,23 @@ export const DrawerWrapper = styled.div.attrs(
6161) < TDrawer > `
6262 ${ css . flex ( ) } ;
6363 position: fixed;
64- right: ${ ( { rightOffset } ) => rightOffset } ;
65- top: 0px;
64+ right: ${ ( { rightOffset, type } ) =>
65+ isViewerMode ( type ) ? rightOffset : pixelAdd ( rightOffset , - 25 ) } ;
66+ top: ${ ( { type } ) => ( isViewerMode ( type ) ? 0 : '25px' ) } ;
6667
6768 color: ${ theme ( 'drawer.font' ) } ;
6869 box-sizing: border-box;
6970 font-family: Roboto, sans-serif;
7071 -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
71- border-radius: 0px;
7272 height: 100%;
73- width: ${ ( { type } ) =>
74- contains ( type , WIDE_CASE ) ? WIDE_WIDTH : NARROW_WIDTH } ;
75-
76- min-width: ${ ( { type } ) => ( contains ( type , WIDE_CASE ) ? '700px' : '450px' ) } ;
73+ width: ${ ( { type } ) => getDrawerWidth ( type ) } ;
74+ min-width: ${ ( { type } ) => getDrawerMinWidth ( type ) } ;
7775 z-index: ${ ( { visible } ) => ( visible ? zIndex . drawer : - 1 ) } ;
7876
7977 visibility: ${ ( { visible } ) => ( visible ? 'visible' : 'hidden' ) } ;
8078 opacity: ${ ( { visible, fromContentEdge } ) =>
8179 ! visible && ! fromContentEdge ? 0 : 1 } ;
8280
83- /* max-width: ${ ( { visible, fromContentEdge } ) =>
84- ! visible && ! fromContentEdge ? '60%' : '985px' } ; */
8581 max-width: 985px;
8682
8783 ${ ( { fromContentEdge } ) =>
@@ -102,12 +98,16 @@ export const DrawerWrapper = styled.div.attrs(
10298 ` } ;
10399`
104100
105- export const DrawerContent = styled . div `
101+ export const DrawerContent = styled . div < { type : string } > `
102+ position: relative;
106103 /* 60 is the width of addon */
107104 width: calc(100% - 60px);
108105 background-color: ${ theme ( 'drawer.bg' ) } ;
109- height: 100vh;
110- box-shadow: ${ theme ( 'drawer.shadow' ) } ;
106+ height: ${ ( { type } ) =>
107+ isViewerMode ( type ) ? '100vh' : 'calc(100vh - 50px)' } ;
108+ border-radius: ${ ( { type } ) => ( isViewerMode ( type ) ? 0 : '10px' ) } ;
109+ box-shadow: ${ ( { type } ) =>
110+ isViewerMode ( type ) ? theme ( 'drawer.shadow' ) : theme ( 'drawer.shadowLite' ) } ;
111111`
112112type TDrawerMobile = { options : Record < string , unknown > ; bgColor : string }
113113export const DrawerMobileContent = styled . div < TDrawerMobile > `
0 commit comments