Skip to content

Commit b8d2950

Browse files
committed
chore: improve side drawer sliding motion
1 parent 3ab2401 commit b8d2950

File tree

2 files changed

+41
-29
lines changed

2 files changed

+41
-29
lines changed

packages/frontend/src/components/Editor/index.tsx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,29 @@ export default function Editor(props: EditorProps): React.ReactElement {
151151
)
152152
}
153153

154-
const getStepPadding = () => {
155-
if (isDrawerOpen) {
156-
if (isMobile) {
157-
return 0
158-
}
159-
return '5rem'
160-
}
161-
return 0
162-
}
154+
const leftStepPadding = isDrawerOpen ? (isMobile ? 0 : '5rem') : 0
155+
const rightDrawerTransform = isDrawerOpen
156+
? 'translateX(0)'
157+
: 'translateX(100%)'
158+
const rightDrawerWidth = isDrawerOpen
159+
? isMobile
160+
? '100vw'
161+
: EDITOR_RIGHT_DRAWER_WIDTH
162+
: '0'
163163

164164
return (
165165
<Flex
166-
w="full"
167-
justifyContent="center"
168-
overflowX="hidden"
166+
{...editorStyles.editorWrapper}
169167
sx={{
170168
backgroundImage: 'radial-gradient(#f5f5f5 2px, transparent 2px)',
171169
backgroundSize: '30px 30px',
172170
}}
173171
>
174172
<StepExecutionsToIncludeProvider value={stepExecutionsToInclude}>
175173
<Flex
176-
{...editorStyles.container}
174+
{...editorStyles.stepHeaderContainer}
177175
flex={isDrawerOpen ? (isMobile ? 0 : 1) : undefined}
178-
px={getStepPadding()}
176+
px={leftStepPadding}
179177
maxWidth={`calc(100% - ${
180178
isDrawerOpen ? EDITOR_RIGHT_DRAWER_WIDTH : '0px'
181179
})`}
@@ -211,19 +209,19 @@ export default function Editor(props: EditorProps): React.ReactElement {
211209
/>
212210
)}
213211
</Flex>
214-
212+
{/** HACKFIX (kevinkim-ogp): to ensure that the transitions are smooth */}
213+
<Flex
214+
{...editorStyles.dummyRightContainer}
215+
w={rightDrawerWidth}
216+
transform={rightDrawerTransform}
217+
/>
215218
<Flex
216219
{...editorStyles.rightDrawerContainer}
217-
w={
218-
isDrawerOpen
219-
? isMobile
220-
? '100vw'
221-
: EDITOR_RIGHT_DRAWER_WIDTH
222-
: '0'
223-
}
220+
w={rightDrawerWidth}
224221
visibility={isDrawerOpen ? 'visible' : 'hidden'}
225222
opacity={isDrawerOpen ? 1 : 0}
226-
transform={isDrawerOpen ? 'translateX(0)' : 'translateX(100%)'}
223+
transform={rightDrawerTransform}
224+
borderLeft={isDrawerOpen ? '1px solid base.divider.medium' : 'none'}
227225
>
228226
<EditorRightDrawer
229227
flowStepGroupIconUrl={flowStepGroupIconUrl}
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { FlexProps } from '@chakra-ui/react'
22

3-
import { EDITOR_MAX_HEIGHT } from './constants'
3+
import { EDITOR_MAX_HEIGHT, EDITOR_RIGHT_DRAWER_WIDTH } from './constants'
44

55
export const editorStyles = {
6-
container: {
6+
editorWrapper: {
7+
w: 'full',
8+
overflowX: 'hidden' as FlexProps['overflowX'],
9+
justifyContent: 'center',
10+
pos: 'relative' as FlexProps['pos'],
11+
},
12+
stepHeaderContainer: {
713
display: 'block',
814
flexDir: 'column' as FlexProps['flexDir'],
915
alignItems: 'center',
@@ -16,18 +22,26 @@ export const editorStyles = {
1622
transition: 'transform 0.4s cubic-bezier(0.3, 0, 0.2, 1)',
1723
w: '100%',
1824
},
25+
dummyRightContainer: {
26+
pos: 'relative' as FlexProps['pos'],
27+
maxHeight: EDITOR_MAX_HEIGHT,
28+
h: EDITOR_MAX_HEIGHT,
29+
overflow: 'hidden' as FlexProps['overflow'],
30+
transition: 'all 0.4s cubic-bezier(0.4, 0, 0.2, 1)',
31+
border: 'none',
32+
},
1933
rightDrawerContainer: {
2034
flexDir: 'column' as FlexProps['flexDir'],
21-
position: 'relative' as FlexProps['position'],
35+
position: 'absolute' as FlexProps['position'],
2236
bg: 'white',
2337
borderRadius: 'none',
24-
borderLeft: '1px',
25-
borderColor: 'base.divider.medium',
2638
boxShadow: 'lg',
2739
opacity: 0,
40+
right: 0,
41+
minWidth: EDITOR_RIGHT_DRAWER_WIDTH,
2842
maxHeight: EDITOR_MAX_HEIGHT,
2943
h: EDITOR_MAX_HEIGHT,
3044
overflowY: 'auto' as FlexProps['overflowY'],
31-
transition: 'all 0.4s cubic-bezier(0.4, 0, 0.2, 1)',
45+
transition: 'transform 0.4s cubic-bezier(0.4, 0, 0.2, 1)',
3246
},
3347
}

0 commit comments

Comments
 (0)