forked from streamlit/streamlit
/
styled-components.ts
143 lines (123 loc) · 3.74 KB
/
styled-components.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* @license
* Copyright 2018-2021 Streamlit Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import styled from "@emotion/styled"
export const StyledSidebar = styled.section(({ theme }) => ({
[`@media (max-width: ${theme.breakpoints.md})`]: {
marginLeft: theme.spacing.none,
// Instead of 100% width and height, we want to make sure
// the sidebar takes all available space when viewports change
position: "absolute",
top: 0,
left: 0,
right: 0,
bottom: 0,
},
// Scrollbars can look ugly, so we try to style them to look better
[`::-webkit-scrollbar-thumb:vertical,
::-webkit-scrollbar-thumb:horizontal,
::-webkit-scrollbar-thumb:vertical:active,
::-webkit-scrollbar-thumb:horizontal:active`]: {
background: theme.colors.transparent,
},
"&:hover": {
[`::-webkit-scrollbar-thumb:vertical,
::-webkit-scrollbar-thumb:horizontal`]: {
background: "rgba(0, 0, 0, 0.5)",
},
[`::-webkit-scrollbar-thumb:vertical:active,
::-webkit-scrollbar-thumb:horizontal:active`]: {
background: "rgba(0, 0, 0, 0.61)",
borderRadius: "100px",
},
},
}))
export interface StyledSidebarContentProps {
isCollapsed: boolean
}
export const StyledSidebarContent = styled.div<StyledSidebarContentProps>(
({ isCollapsed, theme }) => ({
backgroundColor: theme.colors.bgColor,
backgroundAttachment: "fixed",
flexShrink: 0,
height: "100vh",
overflow: "auto",
padding: `6rem ${theme.spacing.lg}`,
position: "relative",
transition: "margin-left 300ms, box-shadow 300ms",
width: theme.sizes.sidebar,
zIndex: theme.zIndices.sidebar,
marginLeft: isCollapsed ? `-${theme.sizes.sidebar}` : theme.spacing.none,
"&:focus": {
outline: "none",
},
[`@media (max-width: ${theme.breakpoints.md})`]: {
boxShadow: `-2rem 0 2rem 2rem ${
isCollapsed ? "transparent" : "#00000029"
}`,
zIndex: theme.zIndices.sidebarMobile,
},
"& h1": {
fontSize: theme.fontSizes.xl,
fontWeight: 600,
},
"& h2": {
fontSize: theme.fontSizes.lg,
fontWeight: 600,
},
"& h3": {
fontSize: theme.fontSizes.mdLg,
fontWeight: 600,
},
"& h4": {
fontSize: theme.fontSizes.md,
fontWeight: 600,
},
"& h5": {
fontSize: theme.fontSizes.sm,
fontWeight: 600,
},
"& h6": {
fontSize: theme.fontSizes.twoSm,
fontWeight: 600,
},
})
)
export const StyledSidebarCloseButton = styled.div(({ theme }) => ({
position: "absolute",
top: theme.spacing.sm,
right: theme.spacing.sm,
zIndex: 1,
color: theme.colors.fadedText40,
}))
export interface StyledSidebarCollapsedControlProps {
chevronDownshift: number
isCollapsed: boolean
}
export const StyledSidebarCollapsedControl = styled.div<
StyledSidebarCollapsedControlProps
>(({ chevronDownshift, isCollapsed, theme }) => ({
position: "fixed",
top: chevronDownshift ? `${chevronDownshift}px` : theme.spacing.sm,
left: isCollapsed ? theme.spacing.sm : `-${theme.spacing.sm}`,
zIndex: theme.zIndices.sidebar - 1,
transition: "left 300ms",
transitionDelay: "left 300ms",
color: theme.colors.fadedText40,
[`@media (max-width: ${theme.breakpoints.md})`]: {
color: theme.colors.bodyText,
},
}))