Skip to content

Commit 5953e6d

Browse files
committed
feat(docs): add UI state to docs website
1 parent d9e6120 commit 5953e6d

File tree

9 files changed

+39
-50
lines changed

9 files changed

+39
-50
lines changed

docs/gatsby-browser.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import React from 'react'
2+
import Layout from './src/components/layout'
13
require('prismjs/themes/prism-tomorrow.css')
24
require('./src/main.css')
35

4-
/**
5-
* Implement Gatsby's Browser APIs in this file.
6-
*
7-
* See: https://www.gatsbyjs.org/docs/browser-apis/
8-
*/
9-
10-
// You can delete this file if you're not using it
6+
export const wrapPageElement = ({ element, props }) => {
7+
return <Layout {...props} >{element}</Layout>
8+
}

docs/gatsby-ssr.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react'
2+
import Layout from './src/components/layout'
3+
4+
export const wrapPageElement = ({ element, props }) => {
5+
return <Layout {...props} >{element}</Layout>
6+
}

docs/src/components/FoundTypo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Container = styled.div`
1010
const FoundTypo = () => {
1111
return (
1212
<Container>
13-
<p>👀 Found a typo? <a href='https://github.com/npm/cli/'>Let us know!</a></p>
13+
<p><span role='img' aria-label='eyes-emoji'>👀</span> Found a typo? <a href='https://github.com/npm/cli/'>Let us know!</a></p>
1414
<p>The current stable version of npm is <a href='https://github.com/npm/cli/'>here</a>. To upgrade, run: <code className='language-text'>npm install npm@latest -g</code></p>
1515
<p>
1616
To report bugs or submit feature requests for the docs, please post <a href='https://npm.community/c/support/docs-needed'>here</a>.

docs/src/components/home/DarkBlock.js

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const DarkBlock = () => {
3030
<Text>
3131
<p>The current stable version of npm is <a href={'https://github.com/npm/cli/releases/latest'} style={aStyle}>available on GitHub.</a></p>
3232
<p>To upgrade, run: <code className={'language-text'} style={{color: 'white'}}>npm install npm@latest -g</code></p>
33-
<p>To report bugs or submit feature requests, <a href={'#'} style={aStyle}>please XXX.</a></p>
3433
</Text>
3534
<Box pt={4}><LinkButton to='cli-commands/npm' w={'120px'}>read docs</LinkButton></Box>
3635
</ContentWrapper>

docs/src/components/home/Terminal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const Bracket = styled.span`
7878
margin-top: 10px;
7979
`
8080

81-
const Text = styled.strong`
81+
const Text = styled.span`
8282
font-size: 15px;
8383
font-weight: 400;
8484
letter-spacing: 1px;

docs/src/components/layout.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ import React from 'react'
22
import Navbar from './Navbar'
33
import Sidebar from './Sidebar'
44
import {Flex, Box} from 'rebass'
5+
import { theme } from 'src/theme'
6+
import { ThemeProvider } from 'styled-components'
7+
8+
const IS_STATIC = process.env.GATSBY_IS_STATIC
9+
10+
const Layout = ({children, path}) => {
11+
const showSidebar = IS_STATIC || path.match(/cli-commands|configuring-npm|using-npm/)
512

6-
const Layout = ({children, showSidebar}) => {
713
return (
8-
<React.Fragment>
14+
<ThemeProvider theme={theme}>
915
<Navbar />
1016
<Flex w={1}>
1117
{showSidebar && <Sidebar />}
1218
<Box width={1}>{children}</Box>
1319
</Flex>
14-
</React.Fragment>
20+
</ThemeProvider>
1521
)
1622
}
1723

docs/src/pages/404.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import React from 'react'
2-
3-
import Layout from 'src/components/Layout'
42
import SEO from 'src/components/seo'
53

6-
import {ThemeProvider} from 'styled-components'
7-
import {theme} from 'src/theme'
8-
94
const NotFoundPage = () => (
10-
<ThemeProvider theme={theme}>
11-
<Layout>
12-
<SEO title='404: Not found' />
13-
<h1>NOT FOUND</h1>
14-
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
15-
</Layout>
16-
</ThemeProvider>
5+
<React.Fragment>
6+
<SEO title='404: Not found' />
7+
<h1>NOT FOUND</h1>
8+
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
9+
</React.Fragment>
1710
)
1811

1912
export default NotFoundPage

docs/src/pages/index.js

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
import React from 'react'
2-
import Layout from 'src/components/Layout'
32
import Features from 'src/components/home/Features'
43
import SEO from 'src/components/seo'
54
import Hero from 'src/components/home/Hero'
65
import DarkBlock from 'src/components/home/DarkBlock'
7-
import Footer from 'src/components/home/footer'
8-
import {ThemeProvider} from 'styled-components'
9-
import {theme} from 'src/theme'
106

117
const IndexPage = () => (
12-
<ThemeProvider theme={theme}>
13-
<Layout showSidebar={false}>
14-
<SEO title='npm cli' />
15-
<Hero />
16-
<Features />
17-
<DarkBlock />
18-
<Footer />
19-
</Layout>
20-
</ThemeProvider>
8+
<React.Fragment>
9+
<SEO title='npm cli' />
10+
<Hero />
11+
<Features />
12+
<DarkBlock />
13+
</React.Fragment>
2114
)
2215

2316
export default IndexPage

docs/src/templates/Page.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React from 'react'
2-
import Layout from 'src/components/Layout'
32
import {graphql} from 'gatsby'
4-
import styled, { ThemeProvider } from 'styled-components'
5-
import {theme} from 'src/theme'
3+
import styled from 'styled-components'
64
import FoundTypo from 'src/components/FoundTypo'
75
import Scripts from 'src/components/Scripts'
86
const version = require('../../../package.json').version
@@ -20,15 +18,11 @@ const Page = ({data}) => {
2018
.replace(/([a-zA-Z\\.-]*)(\((1|5|7)\))<\/h1>/, '$1</h1>')
2119

2220
return (
23-
<ThemeProvider theme={theme}>
24-
<Layout showSidebar>
25-
<Content className='documentation'>
26-
<div dangerouslySetInnerHTML={{ __html: html }} />
27-
<FoundTypo />
28-
<Scripts />
29-
</Content>
30-
</Layout>
31-
</ThemeProvider>
21+
<Content className='documentation'>
22+
<div dangerouslySetInnerHTML={{ __html: html }} />
23+
<FoundTypo />
24+
<Scripts />
25+
</Content>
3226
)
3327
}
3428

0 commit comments

Comments
 (0)