Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split docs into pages, update examples and other details (#304)
* Ignore Visual Studio Code configuration in git * Add .yml extension to ESLint config files They are already written in YAML format, so this gives us syntax highlighting. * Fix ESLint errors in documentation files * Implement Prettier through ESLint Currently only for documentation files. * Split components into pages - use react-bootstrap to add navigation - auto-generate component pages using Gatsby Node API * Fix transition state names in the docs * Update CodeSandbox examples * Document CSSTransition's reflow hack
- Loading branch information
Showing
21 changed files
with
503 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/node_modules | ||
www/.cache/ | ||
www/public/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,6 @@ jspm_packages | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Visual Studio Code configuration | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
globals: | ||
graphql: false | ||
extends: | ||
- prettier | ||
- prettier/react | ||
plugins: | ||
- prettier | ||
rules: | ||
prettier/prettier: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
singleQuote: true | ||
trailingComma: es5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const path = require('path'); | ||
const config = require('./gatsby-config'); | ||
|
||
exports.createPages = ({ boundActionCreators, graphql }) => { | ||
const { createPage } = boundActionCreators; | ||
const componentTemplate = path.join( | ||
__dirname, | ||
'src', | ||
'templates', | ||
'component.js' | ||
); | ||
return new Promise((resolve, reject) => { | ||
resolve( | ||
graphql(` | ||
{ | ||
allComponentMetadata { | ||
edges { | ||
node { | ||
displayName | ||
} | ||
} | ||
} | ||
} | ||
`).then(result => { | ||
if (result.errors) { | ||
reject(result.errors); | ||
} | ||
const { componentPages } = config.siteMetadata; | ||
result.data.allComponentMetadata.edges | ||
.filter(({ node: { displayName } }) => | ||
componentPages.some(page => page.displayName === displayName) | ||
) | ||
.forEach(({ node: { displayName } }) => { | ||
createPage({ | ||
path: componentPages.find( | ||
page => page.displayName === displayName | ||
).path, | ||
component: componentTemplate, | ||
context: { | ||
displayName, | ||
}, | ||
}); | ||
}); | ||
}) | ||
); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
|
||
@import '~bootstrap/dist/css/bootstrap.css'; | ||
@import 'variables.scss'; | ||
|
||
$body-bg: $syntax-bg; | ||
$code-bg: $syntax-bg; | ||
$code-color: $hue-3; | ||
$headings-margin-bottom: 2rem; | ||
html { | ||
font-size: 16px; | ||
} | ||
|
||
@import '~bootstrap/scss/bootstrap.scss'; | ||
body { | ||
background: $syntax-bg; | ||
font-size: 1rem; | ||
} | ||
|
||
pre { | ||
border: 0; | ||
background: transparent; | ||
} | ||
|
||
code { | ||
background: transparent; | ||
color: $hue-3; | ||
a & { | ||
padding: 0; | ||
} | ||
} | ||
|
||
section { | ||
margin-bottom: 3rem; | ||
margin-bottom: 2rem; | ||
} | ||
|
||
h1, h2, h3, h4, h5 { | ||
margin-bottom: 2rem; | ||
|
||
& > a, | ||
& > a:hover { | ||
color: $headings-color; | ||
color: inherit; | ||
} | ||
} | ||
} | ||
|
||
iframe[src*=codesandbox] + p { | ||
margin-top: 1rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import Link from 'gatsby-link'; | ||
import { Grid, Navbar, Nav } from 'react-bootstrap'; | ||
|
||
import '../css/bootstrap.scss'; | ||
import '../css/prism-theme.scss'; | ||
|
||
const propTypes = { | ||
data: PropTypes.shape({ | ||
site: PropTypes.shape({ | ||
siteMetadata: PropTypes.shape({ | ||
componentPages: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
path: PropTypes.string.isRequired, | ||
displayName: PropTypes.string.isRequired, | ||
}) | ||
).isRequired, | ||
}).isRequired, | ||
}).isRequired, | ||
}).isRequired, | ||
location: PropTypes.object.isRequired, | ||
}; | ||
|
||
const NavItem = ({ active, to, children }) => ( | ||
<li role="presentation" className={active ? 'active' : null}> | ||
<Link aria-selected={active} to={to}> | ||
{children} | ||
</Link> | ||
</li> | ||
); | ||
|
||
NavItem.propTypes = { | ||
active: PropTypes.bool, | ||
to: PropTypes.string.isRequired, | ||
}; | ||
|
||
class BaseLayout extends React.Component { | ||
render() { | ||
const { data, location, children } = this.props; | ||
return ( | ||
<div> | ||
<Navbar fixedTop inverse collapseOnSelect> | ||
<Navbar.Header> | ||
<Navbar.Brand> | ||
<Link to="/">React Transition Group</Link> | ||
</Navbar.Brand> | ||
<Navbar.Toggle /> | ||
</Navbar.Header> | ||
<Navbar.Collapse> | ||
<Nav pullRight> | ||
{data.site.siteMetadata.componentPages.map( | ||
({ path, displayName }) => ( | ||
<NavItem | ||
key={path} | ||
active={path === location.pathname} | ||
to={path} | ||
> | ||
{displayName} | ||
</NavItem> | ||
) | ||
)} | ||
</Nav> | ||
</Navbar.Collapse> | ||
</Navbar> | ||
<Grid style={{ paddingTop: '4rem', paddingBottom: '1rem' }}> | ||
{children()} | ||
</Grid> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
BaseLayout.propTypes = propTypes; | ||
|
||
export default BaseLayout; | ||
|
||
export const exposedComponentsFragment = graphql` | ||
fragment ComponentPages on RootQueryType { | ||
site { | ||
siteMetadata { | ||
componentPages { | ||
path | ||
displayName | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export const query = graphql` | ||
query BaseLayout { | ||
...ComponentPages | ||
} | ||
`; |
Oops, something went wrong.