|
1 | 1 | import { useMemo } from 'react'
|
2 |
| -import { useMediaQuery } from 'react-responsive' |
3 | 2 | import { useSpring } from 'react-spring'
|
4 | 3 |
|
5 | 4 | import { useTheme } from 'styled-components'
|
6 | 5 |
|
7 |
| -import { OverlaySidebarWindowWidth, size } from '@mexit/shared' |
8 |
| - |
9 | 6 | import { useLayoutStore } from '../Stores/useLayoutStore'
|
10 | 7 |
|
11 | 8 | export const useSidebarTransition = () => {
|
12 | 9 | const rhSidebar = useLayoutStore((state) => state.rhSidebar)
|
13 | 10 | const theme = useTheme()
|
14 | 11 |
|
15 |
| - const isDesktop = useMediaQuery({ minWidth: size.wide }) |
16 |
| - const overlaySidebar = useMediaQuery({ maxWidth: OverlaySidebarWindowWidth }) |
17 |
| - |
18 | 12 | const rhSidebarStyle = useMemo(() => {
|
19 | 13 | const showRHSidebar = rhSidebar.show && rhSidebar.expanded
|
20 |
| - const visibleEndColumnWidth = `${isDesktop ? '600px' : '415px'}` |
| 14 | + const visibleEndColumnWidth = '415px' |
21 | 15 | const endColumnWidth = `${showRHSidebar ? visibleEndColumnWidth : '0px'}`
|
22 |
| - if (!overlaySidebar) { |
23 |
| - const style = { |
24 |
| - width: endColumnWidth |
25 |
| - } |
26 |
| - return style |
27 |
| - } else { |
28 |
| - const style = { |
29 |
| - width: endColumnWidth |
30 |
| - } |
31 |
| - return style |
| 16 | + const style = { |
| 17 | + width: endColumnWidth |
32 | 18 | }
|
33 |
| - }, [rhSidebar, overlaySidebar, isDesktop]) |
| 19 | + |
| 20 | + return style |
| 21 | + }, [rhSidebar]) |
| 22 | + |
34 | 23 | const rhSidebarSpringProps = useSpring(rhSidebarStyle)
|
35 | 24 |
|
36 | 25 | const { style: gridStyle, endColumnWidth } = useMemo(() => {
|
37 | 26 | const showRHSidebar = rhSidebar.show && rhSidebar.expanded
|
38 |
| - const visibleEndColumnWidth = `${isDesktop ? '600px' : '415px'}` |
| 27 | + const visibleEndColumnWidth = '415px' |
39 | 28 | const endColumnWidth = `${showRHSidebar ? visibleEndColumnWidth : '0px'}`
|
40 |
| - const themeGap = `${theme.additional.hasBlocks ? '4rem' : '0rem'}` |
41 | 29 | // mog('Overlay', { overlaySidebar, showSidebar, showRHSidebar })
|
42 |
| - if (!overlaySidebar) { |
43 |
| - const style = { |
44 |
| - gridTemplateColumns: `calc(100vw - ${endColumnWidth} - ${themeGap}) ${endColumnWidth}` |
45 |
| - } |
46 |
| - // if (!sidebar.expanded || !sidebar.show) style.gridTemplateColumns = `${sidebarCollapsedWidth} 2fr auto` |
47 |
| - return { style, endColumnWidth } |
48 |
| - } else { |
49 |
| - const style = { |
50 |
| - gridTemplateColumns: ` calc(100vw - 0px - ${themeGap}) 0px` |
51 |
| - } |
52 |
| - return { style, endColumnWidth } |
| 30 | + const style = { |
| 31 | + gridTemplateColumns: `90vw` |
53 | 32 | }
|
54 |
| - }, [isDesktop, rhSidebar, overlaySidebar, theme]) |
| 33 | + return { style, endColumnWidth } |
| 34 | + }, [rhSidebar, theme]) |
55 | 35 |
|
56 | 36 | const gridSpringProps = useSpring({ to: gridStyle, immediate: !rhSidebar.show })
|
57 | 37 |
|
58 | 38 | return {
|
59 | 39 | rhSidebarSpringProps,
|
60 | 40 | gridStyle,
|
61 | 41 | gridSpringProps,
|
62 |
| - endColumnWidth, |
63 |
| - overlaySidebar |
| 42 | + endColumnWidth |
64 | 43 | }
|
65 | 44 | }
|
0 commit comments