Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add left panel hierarchy support #1329

Merged
merged 16 commits into from
Jun 25, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix a few related codebeat issues
  • Loading branch information
igor committed Jun 21, 2017
commit ad32ffabbbd114083d19d6305e4f8c96dffd5ae6
18 changes: 11 additions & 7 deletions lib/ui/example/client/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ export default class ReactProvider extends Provider {
});

// set stories
this.api.setStories([
this.api.setStories(this.createStories());

// listen to the story change and update the preview.
this.api.onStory((kind, story) => {
this.globalState.emit('change', kind, story);
});
}

createStories() {
return [
{
kind: 'some.name.Component 1',
stories: ['State 1', 'State 2'],
Expand Down Expand Up @@ -115,12 +124,7 @@ export default class ReactProvider extends Provider {
kind: 'Bla 2',
stories: ['State 1', 'State 2'],
}
]);

// listen to the story change and update the preview.
this.api.onStory((kind, story) => {
this.globalState.emit('change', kind, story);
});
]
}

_handlePreviewEvents() {
Expand Down
30 changes: 12 additions & 18 deletions lib/ui/src/modules/ui/components/left_panel/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ class Stories extends React.Component {
return hierarchyRoot;
}

renderMenuItem(item, style, onClick, displayName) {
return (
<a title={`Open ${item}`} style={style} onClick={onClick} role="menuitem" tabIndex="0">
{displayName}
</a>
);
}

renderStory(story) {
const { selectedStory } = this.props;
const style = { display: 'block', ...storyStyle };
Expand All @@ -106,15 +114,7 @@ class Stories extends React.Component {

return (
<li key={story}>
<a
title={`Open ${story}`}
style={style}
onClick={props.onClick}
role="menuitem"
tabIndex="0"
>
{story}
</a>
{this.renderMenuItem(story, style, props.onClick, story)}
</li>
);
}
Expand All @@ -129,9 +129,7 @@ class Stories extends React.Component {
style.fontWeight = 'bold';
return (
<li key={kind}>
<a title={`Open ${kind}`} style={style} onClick={onClick} role="menuitem" tabIndex="0">
{displayName}
</a>
{this.renderMenuItem(kind, style, onClick, displayName)}
<div>
<ul style={listStyleType} role="menu">
{stories.map(this.renderStory)}
Expand All @@ -143,9 +141,7 @@ class Stories extends React.Component {

return (
<li key={kind}>
<a title={`Open ${kind}`} style={style} onClick={onClick} role="menuitem" tabIndex="0">
{displayName}
</a>
{this.renderMenuItem(kind, style, onClick, displayName)}
</li>
);
}
Expand Down Expand Up @@ -174,9 +170,7 @@ class Stories extends React.Component {
children.push(
<ul style={listStyleType} role="menu" key={`${value.current}_container`}>
<li key={value.current}>
<a title={`Open ${key}`} style={style} onClick={onClick} role="menuitem" tabIndex="0">
{key}
</a>
{this.renderMenuItem(key, style, onClick, key)}
</li>
{isSelectedHierarchy &&
<li key={`${value.current}_children`} style={nestedListStyle}>
Expand Down