diff --git a/v2/.eslintrc.js b/v2/.eslintrc.js
index 3945fc85bb..f46f89afb2 100644
--- a/v2/.eslintrc.js
+++ b/v2/.eslintrc.js
@@ -13,11 +13,12 @@ module.exports = {
rules: {
'no-console': OFF,
'func-names': OFF,
+ 'react/jsx-closing-bracket-location': OFF, // Conflicts with Prettier.
'react/jsx-filename-extension': OFF,
'react/jsx-one-expression-per-line': OFF,
'react/prop-types': OFF,
- 'react/destructuring-assignment': OFF, // too many lines
- 'import/no-unresolved': WARNING, // because it couldn't resolve webpack alias
+ 'react/destructuring-assignment': OFF, // Too many lines.
+ 'import/no-unresolved': WARNING, // Because it couldn't resolve webpack alias.
'react/prefer-stateless-function': WARNING,
},
};
diff --git a/v2/lib/theme/Docs/index.js b/v2/lib/theme/Docs/index.js
index 4e311f4cde..cb6881797d 100644
--- a/v2/lib/theme/Docs/index.js
+++ b/v2/lib/theme/Docs/index.js
@@ -3,50 +3,13 @@ import React from 'react';
import {Link} from 'react-router-dom';
import Helmet from 'react-helmet';
-import Layout from '@theme/Layout'; // eslint-disable-line
import DocsPaginator from '@theme/DocsPaginator'; // eslint-disable-line
+import Layout from '@theme/Layout'; // eslint-disable-line
+import Sidebar from '@theme/Sidebar'; // eslint-disable-line
import styles from './styles.css';
export default class Docs extends React.Component {
- renderSidebar(metadata, docsSidebars, docsMetadatas) {
- const {sidebar, language, id: thisID} = metadata;
- if (!sidebar || !docsSidebars) {
- return null;
- }
- const thisSidebar = docsSidebars[sidebar];
- return (
- thisSidebar &&
- Object.keys(thisSidebar).map(categoryName => {
- return (
-
-
{categoryName}
-
- {thisSidebar[categoryName].map(rawLinkID => {
- const linkID = (language ? `${language}-` : '') + rawLinkID;
- const linkMetadata = docsMetadatas[linkID];
- if (!linkMetadata) {
- throw new Error(
- `Improper sidebars.json file, document with id '${linkID}' not found.`,
- );
- }
- const linkClassName =
- linkID === thisID ? 'navListItemActive' : 'navListItem';
- return (
- -
-
- {linkMetadata.sidebar_label || linkMetadata.title}
-
-
- );
- })}
-
-
- );
- })
- );
- }
-
render() {
const {
route,
@@ -64,9 +27,17 @@ export default class Docs extends React.Component {
{language && }
{version && }
- {this.renderSidebar(metadata, docsSidebars, docsMetadatas)}
- {this.props.children}
-
+
+
+
+ {this.props.children}
+
+
+
);
}
diff --git a/v2/lib/theme/Docs/styles.css b/v2/lib/theme/Docs/styles.css
index 52f2cff165..fbc2185b31 100644
--- a/v2/lib/theme/Docs/styles.css
+++ b/v2/lib/theme/Docs/styles.css
@@ -1,10 +1,13 @@
.mainContainer {
display: flex;
flex-direction: row;
- flex-wrap: wrap;
- margin-top: 40px;
margin-bottom: 30px;
margin-left: auto;
margin-right: auto;
- justify-content: center;
-}
\ No newline at end of file
+ margin-top: 40px;
+ justify-content: space-between;
+}
+
+.docContent {
+ flex-grow: 1;
+}
diff --git a/v2/lib/theme/Layout/index.js b/v2/lib/theme/Layout/index.js
index dcec995176..d1e473176d 100644
--- a/v2/lib/theme/Layout/index.js
+++ b/v2/lib/theme/Layout/index.js
@@ -1,6 +1,8 @@
import React from 'react';
import Footer from '@theme/Footer'; // eslint-disable-line
+import './styles.css';
+
/* eslint-disable react/prefer-stateless-function */
export default class Layout extends React.Component {
render() {
diff --git a/v2/lib/theme/Layout/styles.css b/v2/lib/theme/Layout/styles.css
new file mode 100644
index 0000000000..4646c10513
--- /dev/null
+++ b/v2/lib/theme/Layout/styles.css
@@ -0,0 +1,4 @@
+:global(body) {
+ margin: 0;
+ padding: 0;
+}
diff --git a/v2/lib/theme/Sidebar/index.js b/v2/lib/theme/Sidebar/index.js
new file mode 100644
index 0000000000..30aa6c09f5
--- /dev/null
+++ b/v2/lib/theme/Sidebar/index.js
@@ -0,0 +1,51 @@
+import React from 'react';
+import {Link} from 'react-router-dom';
+
+import classnames from 'classnames';
+
+import styles from './styles.css';
+
+function Sidebar(props) {
+ const {metadata, docsSidebars, docsMetadatas} = props;
+ const {sidebar, language, id: thisID} = metadata;
+ if (!sidebar || !docsSidebars) {
+ return null;
+ }
+ const thisSidebar = docsSidebars[sidebar];
+ return (
+ thisSidebar && (
+
+ {Object.keys(thisSidebar).map(categoryName => (
+
+
{categoryName}
+
+ {thisSidebar[categoryName].map(rawLinkID => {
+ const linkID = (language ? `${language}-` : '') + rawLinkID;
+ const linkMetadata = docsMetadatas[linkID];
+ if (!linkMetadata) {
+ throw new Error(
+ `Improper sidebars.json file, document with id '${linkID}' not found.`,
+ );
+ }
+ const activeItem = linkID === thisID;
+ return (
+ -
+
+ {linkMetadata.sidebar_label || linkMetadata.title}
+
+
+ );
+ })}
+
+
+ ))}
+
+ )
+ );
+}
+
+export default Sidebar;
diff --git a/v2/lib/theme/Sidebar/styles.css b/v2/lib/theme/Sidebar/styles.css
new file mode 100644
index 0000000000..804e7636b9
--- /dev/null
+++ b/v2/lib/theme/Sidebar/styles.css
@@ -0,0 +1,30 @@
+.sidebar {
+ width: 300px;
+ padding: 0 20px;
+}
+
+.sidebarGroup {
+ margin-bottom: 20px;
+}
+
+.sidebarGroupTitle {
+ margin: 0;
+}
+
+.sidebarList {
+ list-style-type: none;
+ padding-left: 0;
+}
+
+.sidebarLink {
+ color: #717171;
+ display: block;
+ padding: 8px 0;
+ text-decoration: none;
+ transition: color .3s;
+}
+
+.sidebarLink:hover,
+.sidebarLinkActive {
+ color: #2e8555;
+}