1 |
|
2 | import _get from 'lodash/get';
|
3 | import styled, { css, palette, space, theme } from '../styled';
|
4 | import { Box, Flex } from '../primitives';
|
5 | import { Container } from '../Container';
|
6 | import { Sidebar as _Sidebar, SidebarProps } from '../Sidebar';
|
7 | import { PageContentProps } from './PageContent';
|
8 |
|
9 | export const getWidth = (props: any) => {
|
10 | if (props.isMinimized) {
|
11 | return theme('fannypack.Page.WithSidebar.minimizedSidebarWidth')(props);
|
12 | }
|
13 | return props.sidebarWidth || theme('fannypack.Page.WithSidebar.sidebarWidth')(props);
|
14 | };
|
15 |
|
16 | export const PageContent = styled(Container)<PageContentProps>`
|
17 | padding: ${space(4, 'major')}rem ${space(2, 'major')}rem;
|
18 |
|
19 | @media (max-width: ${theme('fannypack.layout.tabletBreakpoint')}px) {
|
20 | padding-top: ${space(2, 'major')}rem;
|
21 | padding-bottom: ${space(2, 'major')}rem;
|
22 |
|
23 | & {
|
24 | ${theme('fannypack.Page.Content.mobile')};
|
25 | }
|
26 | }
|
27 |
|
28 | ${props =>
|
29 | props.isFluid &&
|
30 | css`
|
31 | padding-top: ${space(2, 'major')}rem;
|
32 | padding-bottom: ${space(2, 'major')}rem;
|
33 |
|
34 | & {
|
35 | ${theme('fannypack.Page.Content.fluid')};
|
36 | }
|
37 | `}
|
38 |
|
39 | & {
|
40 | ${theme('fannypack.Page.Content.base')};
|
41 | }
|
42 | `;
|
43 |
|
44 | export const PageContentWrapper = styled(Box)`
|
45 | & {
|
46 | ${theme('fannypack.Page.Content.wrapper')};
|
47 | }
|
48 | `;
|
49 |
|
50 | export const Spacer = styled(Box)<{ sidebarWidth?: string; hideSidebarOnDesktop?: string; isMinimized?: boolean }>`
|
51 | width: ${getWidth};
|
52 | min-width: ${getWidth};
|
53 |
|
54 | @media screen and (max-width: ${props =>
|
55 | theme(`fannypack.layout.${_get(props, 'theme.fannypack.Page.collapseBreakpoint')}Breakpoint`)}px) {
|
56 | width: 0px;
|
57 | min-width: 0px;
|
58 |
|
59 | & {
|
60 | ${theme('fannypack.Page.WithSidebar.Spacer.mobile')};
|
61 | }
|
62 | }
|
63 |
|
64 | ${props =>
|
65 | props.hideSidebarOnDesktop &&
|
66 | css`
|
67 | width: 0px;
|
68 | min-width: 0px;
|
69 | `}
|
70 |
|
71 | & {
|
72 | ${theme('fannypack.Page.WithSidebar.Spacer.base')};
|
73 | }
|
74 | `;
|
75 |
|
76 | export const Sidebar = styled(Box)<{ sidebarWidth?: string; isMinimized?: boolean }>`
|
77 | background-color: ${palette('white700')};
|
78 | height: 100vh;
|
79 | min-width: ${getWidth};
|
80 | width: ${getWidth};
|
81 | overflow-y: auto;
|
82 | transform: translateX(0px);
|
83 |
|
84 | ${props =>
|
85 | props.isMinimized &&
|
86 | css`
|
87 | overflow: visible;
|
88 | `}
|
89 |
|
90 | & {
|
91 | ${theme('fannypack.Page.WithSidebar.Sidebar.base')};
|
92 | }
|
93 | `;
|
94 |
|
95 | export const DesktopSidebarWrapper = styled(Box)`
|
96 | position: fixed;
|
97 |
|
98 | @media screen and (max-width: ${props =>
|
99 | theme(`fannypack.layout.${_get(props, 'theme.fannypack.Page.collapseBreakpoint')}Breakpoint`)}px) {
|
100 | display: none;
|
101 | }
|
102 |
|
103 | & {
|
104 | ${theme('fannypack.Page.WithSidebar.DesktopSidebarWrapper.base')};
|
105 | }
|
106 | `;
|
107 |
|
108 | export const MobileSidebarWrapper = styled(_Sidebar)<{ sidebarWidth?: string }>`
|
109 | @media screen and (min-width: ${props =>
|
110 | theme(`fannypack.layout.${_get(props, 'theme.fannypack.Page.collapseBreakpoint')}Breakpoint`)(props) + 1}px) {
|
111 | display: none;
|
112 | }
|
113 | width: ${props => props.sidebarWidth || theme('fannypack.Page.WithSidebar.sidebarWidth')};
|
114 |
|
115 | & {
|
116 | ${theme('fannypack.Page.WithSidebar.MobileSidebarWrapper.base')};
|
117 | }
|
118 | `;
|
119 |
|
120 | export const PageWithSidebar = styled(Flex)`
|
121 | & {
|
122 | ${theme('fannypack.Page.WithSidebar.base')};
|
123 | }
|
124 | `;
|
125 |
|
\ | No newline at end of file |