Skip to content

Commit

Permalink
Merge pull request #59 from times/fix/sidebarRendering
Browse files Browse the repository at this point in the history
Fix for sidebar rendering
  • Loading branch information
Chris Hutchinson committed Nov 17, 2016
2 parents 64c1db7 + 6dc7642 commit 7f250e4
Showing 1 changed file with 59 additions and 23 deletions.
82 changes: 59 additions & 23 deletions src/renderers/dom/ui/elements/Sidebar/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@ class Sidebar extends React.Component {
constructor (props) {
super(props);

let defaultPanel;
if (this.props.templates) {
defaultPanel = 'template';
} else if (this.props.layouts) {
defaultPanel = 'layout';
} else if (this.props.themes) {
defaultPanel = 'theme';
} else {
defaultPanel = 'content';
}

this.state = {
panel: 'template'
panel: defaultPanel
}

this.handleConfigurationChange = this.handleConfigurationChange.bind(this);
Expand Down Expand Up @@ -84,25 +95,41 @@ class Sidebar extends React.Component {
<aside className={'sidebar' + (this.state.panel ? ' sidebar--open' : '')}>

<main className="panels">
<Template templates={this.props.templates}
template={this.props.template}
active={this.isPanel('template')}
onTemplateChange={this.handleTemplateChange} />

<Layout layouts={this.props.layouts}
layout={this.props.layout}
active={this.isPanel('layout')}
onLayoutChange={this.handleLayoutChange} />

<Theme themes={this.props.themes}
theme={this.props.theme}
configuration={this.props.configuration}
active={this.isPanel('theme')}
onThemeChange={this.handleThemeChange} />

<Content configuration={this.props.configuration}
active={this.isPanel('content')}
onConfigurationChange={this.handleConfigurationChange} />
{(() => {
if (this.props.templates) {
return (<Template templates={this.props.templates}
template={this.props.template}
active={this.isPanel('template')}
onTemplateChange={this.handleTemplateChange} />);
}
})()}

{(() => {
if (this.props.layouts) {
return (<Layout layouts={this.props.layouts}
layout={this.props.layout}
active={this.isPanel('layout')}
onLayoutChange={this.handleLayoutChange} />);
}
})()}

{(() => {
if (this.props.themes) {
return (<Theme themes={this.props.themes}
theme={this.props.theme}
configuration={this.props.configuration}
active={this.isPanel('theme')}
onThemeChange={this.handleThemeChange} />);
}
})()}

{(() => {
if (this.props.configuration) {
return (<Content configuration={this.props.configuration}
active={this.isPanel('content')}
onConfigurationChange={this.handleConfigurationChange} />);
}
})()}
</main>

<ul className="buttons">
Expand Down Expand Up @@ -132,11 +159,20 @@ Sidebar.propTypes = {
onTemplateChange: React.PropTypes.func.isRequired,
onLayoutChange: React.PropTypes.func.isRequired,
configuration: React.PropTypes.object.isRequired,
theme: React.PropTypes.string,
theme: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.bool
]),
themes: React.PropTypes.object,
template: React.PropTypes.string,
template: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.bool
]),
templates: React.PropTypes.object,
layout: React.PropTypes.string,
layout: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.bool
]),
layouts: React.PropTypes.object
}

Expand Down

0 comments on commit 7f250e4

Please sign in to comment.