Skip to content

Commit 4121d78

Browse files
authored
Documentation layout fixes (#39)
Refactor documentation layout for better scrolling and viewing on smaller screens
1 parent 86ce09f commit 4121d78

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## UNRELEASED
99

1010
### Changed
11-
11+
- Improvements to documentation layout and scrolling behavior
1212
- SVG for `ApplicationSelect`,`ArrowChange`,`Beaker`,`BrowseTable`,`ChangeHistory`,`DimensionFill`,`Explore`,`LogoRings`,`NoteOutline`,`Notes`,`Reports`,`SqlRunner`,`User`,`UserAttributes`,`Users`,`ViewGrid`,`VisArea`,`VisBar`,`VisColumn`,`VisLine`,`VisMap`,`VisPie`,`VisScatter`,`VisSingleValue`,`VisTable` icons resized redrawn to fit on the correct icon grid.
1313
- Implement a vertical layout for the Code Sandbox toolbar to prevent unintentional obfuscation of code samples
1414

packages/www/src/Layout/Documentation.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ import { graphql } from 'gatsby'
2929
import React, { FC } from 'react'
3030
import Helmet from 'react-helmet'
3131
import styled from 'styled-components'
32-
import { Heading, Divider, ListItem, Link, List } from '@looker/components'
32+
import {
33+
Heading,
34+
Divider,
35+
Flex,
36+
ListItem,
37+
Link,
38+
List,
39+
} from '@looker/components'
3340
import { ComponentResources, ComponentStatus, Props } from '../Shared'
3441
import Layout, { LayoutMain } from './Layout'
3542

@@ -88,7 +95,7 @@ const DocumentationLayout = (props: DocQuery) => {
8895

8996
return (
9097
<Layout>
91-
<Grid>
98+
<Flex>
9299
<LayoutMain>
93100
<Helmet title={`${title} - ${site.siteMetadata.title}`} />
94101
<Heading as="h1" fontSize="xxxxlarge" fontWeight="light">
@@ -106,27 +113,26 @@ const DocumentationLayout = (props: DocQuery) => {
106113
/>
107114
<TableOfContents toc={mdx.tableOfContents} />
108115
</Meta>
109-
</Grid>
116+
</Flex>
110117
</Layout>
111118
)
112119
}
113120

114121
export default DocumentationLayout
115122

116123
const Meta = styled.div`
117-
padding: ${props => props.theme.space.large};
118-
height: 100%;
119124
background: ${props => props.theme.colors.palette.charcoal000};
120-
`
121-
122-
const Grid = styled.div`
123-
display: grid;
124-
grid-template-columns: 1fr 18rem;
125-
grid-template-rows: 1fr;
126-
127125
height: 100vh;
128-
`
126+
overflow-y: auto;
127+
padding: ${props => props.theme.space.large};
128+
position: sticky;
129+
top: 0;
130+
width: 17rem;
129131
132+
@media screen and (max-width: ${props => props.theme.breakpoints[3]}) {
133+
display: none;
134+
}
135+
`
130136
export const pageQuery = graphql`
131137
query Doc($id: String) {
132138
site {

packages/www/src/Layout/Layout.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
MIT License
44
55
Copyright (c) 2019 Looker Data Sciences, Inc.
6-
6+
77
Permission is hereby granted, free of charge, to any person obtaining a copy
88
of this software and associated documentation files (the "Software"), to deal
99
in the Software without restriction, including without limitation the rights
1010
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1111
copies of the Software, and to permit persons to whom the Software is
1212
furnished to do so, subject to the following conditions:
13-
13+
1414
The above copyright notice and this permission notice shall be included in all
1515
copies or substantial portions of the Software.
16-
16+
1717
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1818
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1919
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -67,13 +67,16 @@ export const PageLayout = styled.div<SidebarStyleProps>`
6767
display: grid;
6868
grid-template-rows: 1fr;
6969
grid-template-columns: ${({ open }) =>
70-
open ? '18.75rem 0 1fr' : '1.5rem 0 1fr'};
70+
open ? '17.5rem 0 1fr' : '1.5rem 0 1fr'};
7171
grid-template-areas: 'sidebar divider main';
7272
`
7373

74-
const LayoutSidebar = styled.nav`
74+
const LayoutSidebar = styled.aside`
7575
grid-area: sidebar;
76-
overflow-y: auto;
76+
height: 100vh;
77+
position: fixed;
78+
top: 0;
79+
width: 17.5rem;
7780
`
7881

7982
const ContentArea = styled.div`
@@ -85,7 +88,7 @@ export const LayoutMain = styled.main`
8588
overflow: auto;
8689
margin: 0 auto;
8790
padding: ${({ theme: { space } }) =>
88-
`${space.xxlarge} ${space.xxlarge} ${space.xxxxlarge}`};
91+
`${space.xxlarge} ${space.xxxlarge} ${space.xxxxlarge}`};
8992
`
9093

9194
const SidebarDivider = styled.div<SidebarStyleProps>`

packages/www/src/Layout/Navigation/Navigation.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface NavigationProps {
4242
const Navigation: FC<NavigationProps> = ({ sitemap, headerHeight }) => (
4343
<StyledSidebar>
4444
<Header height={headerHeight} />
45-
<Box>
45+
<SidebarNavWrapper height={`calc(100% - ${headerHeight})`}>
4646
<Location>
4747
{({ location }) => (
4848
<LocationContext.Provider value={location.pathname}>
@@ -52,10 +52,14 @@ const Navigation: FC<NavigationProps> = ({ sitemap, headerHeight }) => (
5252
</LocationContext.Provider>
5353
)}
5454
</Location>
55-
</Box>
55+
</SidebarNavWrapper>
5656
</StyledSidebar>
5757
)
5858

59+
const SidebarNavWrapper = styled(Box)`
60+
overflow-y: auto;
61+
`
62+
5963
const StyledSidebar = styled(Sidebar)<SidebarProps>`
6064
background: ${props => lighten(0.6, props.theme.colors.palette.purple000)};
6165
height: 100%;

packages/www/src/Layout/SidebarToggle/SidebarToggle.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ const SidebarToggleWrapper = styled.div<WrapperProps>`
6666
${IconButton} {
6767
background: #fff;
6868
transform: translateX(-50%) translateY(-50%);
69+
position: fixed;
6970
}
7071
`
7172

0 commit comments

Comments
 (0)