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

Trying to consolidate hierarchy UI (+ some other fixes) #1488

Merged
merged 5 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion lib/ui/example/client/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export default class ReactProvider extends Provider {
this.api.setOptions({
name: 'REACT-STORYBOOK',
sortStoriesByKind: true,
hierarchySeparator: '/'
});

// set stories
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"react-komposer": "^2.0.0",
"react-modal": "^1.7.6",
"react-split-pane": "^0.1.63",
"redux": "^3.6.0",
"storybook-react-treebeard": "^1.1.6"
"react-treebeard": "^2.0.3",
"redux": "^3.6.0"
},
"devDependencies": {
"enzyme": "^2.8.2"
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/modules/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: 'STORYBOOK',
url: 'https://github.com/storybooks/storybook',
sortStoriesByKind: false,
hierarchySeparator: '',
hierarchySeparator: '/',
},
},
load({ clientStore, provider }, _actions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Treebeard } from 'storybook-react-treebeard';
import { Treebeard } from 'react-treebeard';
import PropTypes from 'prop-types';
import React from 'react';
import deepEqual from 'deep-equal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
import { decorators } from 'storybook-react-treebeard';
import { IoFolder, IoDocumentText, IoCode } from 'react-icons/lib/io';
import { decorators } from 'react-treebeard';
import { IoChevronRight } from 'react-icons/lib/io';
import React from 'react';
import PropTypes from 'prop-types';
import treeNodeTypes from './tree_node_type';

const iconsColor = '#7d8890';
function ToggleDecorator({ style }) {
const { height, width, arrow } = style;

const iconsMap = {
[treeNodeTypes.NAMESPACE]: IoFolder,
[treeNodeTypes.COMPONENT]: IoDocumentText,
[treeNodeTypes.STORY]: IoCode,
return (
<div style={style.base}>
<div style={style.wrapper}>
<IoChevronRight height={height} width={width} style={arrow} />
</div>
</div>
);
}

ToggleDecorator.propTypes = {
style: PropTypes.shape({
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
arrow: PropTypes.object.isRequired,
}).isRequired,
};

function ContainerDecorator(props) {
Expand Down Expand Up @@ -55,15 +66,12 @@ function createHeaderDecoratorScope(parent) {
...style.title,
};

const Icon = iconsMap[node.type];

if (!node.children || !node.children.length) {
newStyleTitle.fontSize = '13px';
}

return (
<div style={style.base} role="menuitem" tabIndex="0" onKeyDown={this.onKeyDown}>
{Icon && <Icon color={iconsColor} />}
<a style={newStyleTitle}>
{node.name}
</a>
Expand All @@ -90,5 +98,6 @@ export default function(parent) {
...decorators,
Header: createHeaderDecoratorScope(parent),
Container: ContainerDecorator,
Toggle: ToggleDecorator,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ export default {
position: 'absolute',
top: '50%',
left: '50%',
margin: '-10px 0 0 -4px',
margin: '-12px 0 0 -4px',
},
height: 10,
width: 10,
arrow: {
fill: '#9DA5AB',
strokeWidth: 0,
},
},
header: {
Expand Down