Skip to content

Commit 19bb87b

Browse files
lekterablehuv1k
authored andcommitted
Restyle ProjectsSideNav (#956)
1 parent 4570bc4 commit 19bb87b

File tree

2 files changed

+64
-86
lines changed

2 files changed

+64
-86
lines changed

packages/graphql-playground-react/src/components/ProjectsSideNav.tsx

Lines changed: 57 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,33 @@ class ProjectsSideNav extends React.Component<Props & ReduxProps, {}> {
3636
const projects = config.projects
3737
return (
3838
<SideNav>
39-
<DraggableHeader isElectron={isElectron} />
40-
<List>
41-
<div>
42-
<TitleRow>
43-
<Title>{folderName}</Title>
44-
<SettingsIcon
45-
width={18}
46-
height={18}
47-
onClick={this.props.openConfigTab}
48-
title="Project settings"
49-
/>
50-
</TitleRow>
51-
{endpoints && this.renderEndpoints(endpoints)}
52-
{projects &&
53-
Object.keys(projects).map(projectName => {
54-
const project = projects[projectName]
55-
const projectEndpoints =
56-
project.extensions && project.extensions.endpoints
57-
if (!projectEndpoints) {
58-
return null
59-
}
60-
61-
return (
62-
<Project key={projectName}>
63-
<ProjectName>{projectName}</ProjectName>
64-
{this.renderEndpoints(projectEndpoints, projectName)}
65-
</Project>
66-
)
67-
})}
68-
</div>
39+
<List isElectron={isElectron}>
40+
<TitleRow>
41+
<Title>{folderName}</Title>
42+
<SettingsIcon
43+
width={18}
44+
height={18}
45+
onClick={this.props.openConfigTab}
46+
title="Project settings"
47+
/>
48+
</TitleRow>
49+
{endpoints && this.renderEndpoints(endpoints)}
50+
{projects &&
51+
Object.keys(projects).map(projectName => {
52+
const project = projects[projectName]
53+
const projectEndpoints =
54+
project.extensions && project.extensions.endpoints
55+
if (!projectEndpoints) {
56+
return null
57+
}
58+
59+
return (
60+
<Project key={projectName}>
61+
<ProjectName>{projectName}</ProjectName>
62+
{this.renderEndpoints(projectEndpoints, projectName)}
63+
</Project>
64+
)
65+
})}
6966
</List>
7067
{isElectron && (
7168
<Footer>
@@ -118,81 +115,74 @@ export default connect(
118115
{ openConfigTab },
119116
)(ProjectsSideNav)
120117

121-
const Project = styled.div`
122-
margin-bottom: 12px;
123-
`
124-
125118
const SideNav = styled.div`
126-
position: relative;
119+
display: flex;
120+
flex-direction: column;
121+
justify-content: space-between;
127122
background: ${p => p.theme.editorColours.sidebar};
128-
flex: 0 222px;
123+
flex-basis: 222px;
129124
color: ${p => p.theme.editorColours.text};
130125
border-right: 6px solid ${p => p.theme.editorColours.background};
131126
`
132127

133-
const DraggableHeader = styled.div`
134-
padding-top: ${(p: any) => (p.isElectron ? 48 : 20)}px;
135-
background: ${p => p.theme.editorColours.sidebarTop};
136-
-webkit-app-region: drag;
137-
max-width: 222px;
138-
overflow: hidden;
139-
` as any
140-
141128
const List = styled.div`
142-
padding-bottom: 32px;
143-
max-width: 222px;
144-
overflow: hidden;
129+
-webkit-app-region: drag;
130+
padding-top: ${(p: any) => (p.isElectron ? 48 : 20)}px;
131+
display: flex;
132+
flex-direction: column;
145133
background: ${p => p.theme.editorColours.sidebarTop};
146134
`
147135

148136
const Title = styled.div`
149137
font-size: 16px;
150138
font-weight: 600;
151139
color: ${p => p.theme.editorColours.text};
140+
word-break: break-word;
152141
`
153142

154143
const TitleRow = styled.div`
155144
display: flex;
156145
align-items: center;
157-
padding-left: 20px;
158-
padding-right: 10px;
159-
padding-bottom: 20px;
160-
justify-content: space-between;
161-
146+
justify-content: space-evenly;
147+
margin: 0 15px 20px 15px;
162148
svg {
149+
min-width: 18px;
150+
min-height: 18px;
163151
cursor: pointer;
164-
}
165-
166-
svg {
167152
fill: ${p => p.theme.editorColours.icon};
168153
transition: 0.1s linear fill;
169154
}
170-
171155
&:hover {
172156
svg {
173157
fill: ${p => p.theme.editorColours.iconHover};
174158
}
175159
}
176160
`
177161

162+
const Project = styled.div`
163+
display: flex;
164+
flex-direction: column;
165+
& + & {
166+
margin-top: 12px;
167+
}
168+
&:last-child {
169+
margin-bottom: 32px;
170+
}
171+
`
172+
178173
const ProjectName = styled.div`
179174
font-size: 14px;
180175
color: ${p => p.theme.editorColours.text};
181176
font-weight: 600;
182177
letter-spacing: 0.53px;
183-
margin-left: 30px;
184-
margin-bottom: 6px;
178+
margin: 0 10px 6px 30px;
179+
word-break: break-word;
185180
`
186181

187182
const Footer = styled.div`
188-
position: absolute;
189-
bottom: 0;
190-
width: 100%;
191-
box-sizing: border-box;
192183
display: flex;
193-
align-items: center;
194-
justify-content: space-between;
195-
padding: 20px;
184+
justify-content: center;
185+
margin: 32px 0;
196186
background: ${p => p.theme.editorColours.sidebarBottom};
197187
`
198188

@@ -215,6 +205,8 @@ const WorkspaceButton = styled.button`
215205
margin-right: 6px;
216206
}
217207
svg {
208+
min-width: 18px;
209+
min-height: 18px;
218210
stroke: ${p => p.theme.editorColours.buttonWorkspaceText};
219211
}
220212
`

packages/graphql-playground-react/src/components/ProjectsSideNavItem.tsx

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,19 @@ interface SidebarItemProps {
4242
}
4343

4444
const ListItem = styled<SidebarItemProps, 'div'>('div')`
45-
position: relative;
46-
padding: 10px 10px;
45+
padding: 10px 10px 10px ${p => (p.deep ? '43px' : '38px')};
46+
word-break: break-word;
4747
font-weight: 600;
48-
text-overflow: ellipsis;
49-
white-space: nowrap;
5048
cursor: pointer;
51-
padding-left: ${p => (p.deep ? '43px' : '38px')};
52-
padding-right: 10px;
5349
font-size: 12px;
5450
display: flex;
5551
justify-content: space-between;
5652
align-items: center;
5753
background: ${p =>
5854
p.active ? p.theme.editorColours.sidebarItemActive : 'transparent'};
59-
60-
&:before {
61-
content: '';
62-
border-radius: 2px;
63-
background: ${p =>
64-
p.active ? p.theme.editorColours.sidebarItemSide : 'transparent'};
65-
position: absolute;
66-
top: -2px;
67-
bottom: -2px;
68-
left: -2px;
69-
width: 6px;
70-
}
55+
border-left: 4px solid
56+
${p => (p.active ? p.theme.editorColours.sidebarItemSide : 'transparent')};
57+
border-radius: 2px;
7158
7259
&:hover {
7360
background: ${p => p.theme.editorColours.sidebarItemActive};
@@ -76,9 +63,8 @@ const ListItem = styled<SidebarItemProps, 'div'>('div')`
7663

7764
const Count = styled<SidebarItemProps, 'div'>('div')`
7865
border-radius: 6px;
79-
width: 18px;
80-
height: 18px;
81-
line-height: 18px;
66+
min-width: 18px;
67+
min-height: 18px;
8268
display: flex;
8369
align-items: center;
8470
justify-content: center;

0 commit comments

Comments
 (0)