mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
Change toggle icon and delete other icons to make the tree look cleaner 😢
This commit is contained in:
parent
48ee2cd9cf
commit
889ea2b88f
@ -1,15 +1,26 @@
|
|||||||
import { decorators } from 'react-treebeard';
|
import { decorators } from 'react-treebeard';
|
||||||
import { IoFolder, IoDocumentText, IoCode } from 'react-icons/lib/io';
|
import { IoChevronRight } from 'react-icons/lib/io';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import treeNodeTypes from './tree_node_type';
|
|
||||||
|
|
||||||
const iconsColor = '#7d8890';
|
function ToggleDecorator({ style }) {
|
||||||
|
const { height, width, arrow } = style;
|
||||||
|
|
||||||
const iconsMap = {
|
return (
|
||||||
[treeNodeTypes.NAMESPACE]: IoFolder,
|
<div style={style.base}>
|
||||||
[treeNodeTypes.COMPONENT]: IoDocumentText,
|
<div style={style.wrapper}>
|
||||||
[treeNodeTypes.STORY]: IoCode,
|
<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) {
|
function ContainerDecorator(props) {
|
||||||
@ -55,15 +66,12 @@ function createHeaderDecoratorScope(parent) {
|
|||||||
...style.title,
|
...style.title,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Icon = iconsMap[node.type];
|
|
||||||
|
|
||||||
if (!node.children || !node.children.length) {
|
if (!node.children || !node.children.length) {
|
||||||
newStyleTitle.fontSize = '13px';
|
newStyleTitle.fontSize = '13px';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={style.base} role="menuitem" tabIndex="0" onKeyDown={this.onKeyDown}>
|
<div style={style.base} role="menuitem" tabIndex="0" onKeyDown={this.onKeyDown}>
|
||||||
{Icon && <Icon color={iconsColor} />}
|
|
||||||
<a style={newStyleTitle}>
|
<a style={newStyleTitle}>
|
||||||
{node.name}
|
{node.name}
|
||||||
</a>
|
</a>
|
||||||
@ -90,5 +98,6 @@ export default function(parent) {
|
|||||||
...decorators,
|
...decorators,
|
||||||
Header: createHeaderDecoratorScope(parent),
|
Header: createHeaderDecoratorScope(parent),
|
||||||
Container: ContainerDecorator,
|
Container: ContainerDecorator,
|
||||||
|
Toggle: ToggleDecorator,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,12 @@ export default {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: '50%',
|
top: '50%',
|
||||||
left: '50%',
|
left: '50%',
|
||||||
margin: '-10px 0 0 -4px',
|
margin: '-12px 0 0 -4px',
|
||||||
},
|
},
|
||||||
height: 10,
|
height: 10,
|
||||||
width: 10,
|
width: 10,
|
||||||
arrow: {
|
arrow: {
|
||||||
fill: '#9DA5AB',
|
fill: '#9DA5AB',
|
||||||
strokeWidth: 0,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user