Skip to content

Commit

Permalink
feat(ComponentDoc): add virtual whitespace for sidebar (Semantic-Org#…
Browse files Browse the repository at this point in the history
…2492)

* fix(CompoentSidebar): fix propType warnings

* feat(DocsRoot): render PageNotFound when not found

* feat(ComponentDoc): add virtual whitespace for sidebar
  • Loading branch information
levithomason authored and Brandon Lawrence committed Mar 14, 2018
1 parent ed2386b commit c418c20
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
13 changes: 10 additions & 3 deletions docs/app/Components/ComponentDoc/ComponentDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react'
import DocumentTitle from 'react-document-title'
import { withRouter } from 'react-router'
import { Grid } from 'semantic-ui-react'
import { Grid, Icon } from 'semantic-ui-react'

import withDocInfo from 'docs/app/HOC/withDocInfo'
import { scrollToAnchor } from 'docs/app/utils'
Expand All @@ -14,8 +14,12 @@ import ComponentExamples from './ComponentExamples'
import ComponentProps from './ComponentProps'
import ComponentSidebar from './ComponentSidebar'

const gridStyle = { paddingBottom: '10em' }
const topRowStyle = { margin: '1em' }
const exampleEndStyle = {
textAlign: 'center',
opacity: 0.5,
paddingTop: '50vh',
}

class ComponentDoc extends Component {
static childContextTypes = {
Expand Down Expand Up @@ -76,7 +80,7 @@ class ComponentDoc extends Component {

return (
<DocumentTitle title={`${componentName} | Semantic UI React`}>
<Grid style={gridStyle}>
<Grid>
<Grid.Row columns='equal' style={topRowStyle}>
<Grid.Column>
<ComponentDocHeader componentName={componentName} description={description} />
Expand All @@ -97,6 +101,9 @@ class ComponentDoc extends Component {
<div ref={this.handleExamplesRef}>
<ComponentExamples componentName={componentName} />
</div>
<div style={exampleEndStyle}>
This is the bottom <Icon name='pointing down' />
</div>
</Grid.Column>
<Grid.Column computer={5} largeScreen={4} widescreen={4}>
<ComponentSidebar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ComponentSidebar extends Component {
static propTypes = {
activePath: PropTypes.string,
componentName: PropTypes.string,
examplesRef: PropTypes.func,
examplesRef: PropTypes.object,
onItemClick: PropTypes.func,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import ComponentSidebarItem from './ComponentSidebarItem'
class ComponentSidebarSection extends Component {
static propTypes = {
activePath: PropTypes.string,
examples: PropTypes.object,
examples: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string,
path: PropTypes.string,
})),
name: PropTypes.string,
onItemClick: PropTypes.func,
onTitleClick: PropTypes.func,
Expand All @@ -19,7 +22,7 @@ class ComponentSidebarSection extends Component {

componentWillReceiveProps(nextProps) {
const { activePath, examples } = nextProps
const isActiveByProps = _.find(examples, { path: activePath })
const isActiveByProps = !!_.find(examples, { path: activePath })

const didCloseByProps = this.state.isActiveByProps && !isActiveByProps

Expand Down
4 changes: 3 additions & 1 deletion docs/app/Components/DocsRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import React from 'react'
import { META } from 'src/lib'
import * as semanticUIReact from 'src'
import ComponentDoc from '../Components/ComponentDoc'
import PageNotFound from '../Views/PageNotFound'

const DocsRoot = (props) => {
const { name } = props.match.params
const componentName = _.startCase(name).replace(/ /g, '')
const component = semanticUIReact[componentName]

if (!component || !component._meta || !META.isParent(component)) return null
if (!component || !component._meta || !META.isParent(component)) return <PageNotFound />

return (
<ComponentDoc
name={component._meta.name}
Expand Down

0 comments on commit c418c20

Please sign in to comment.