Skip to content

Commit 26a62a0

Browse files
authored
feat(Breadcrumb): add styleType
close #183
1 parent 082c127 commit 26a62a0

File tree

6 files changed

+693
-68
lines changed

6 files changed

+693
-68
lines changed

src/components/Breadcrumb/Breadcrumb.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ import PropTypes from 'prop-types';
33

44
import { SeparatorWrap, BreadcrumbWrap } from './style';
55

6+
const StyleType = ['block-hover', 'hover', 'active'];
7+
68
class Breadcrumb extends Component {
79
static propTypes = {
810
/** 自定义分隔符 */
911
separator: PropTypes.node,
12+
/** 展示项激活样式的方式 */
13+
styleType: PropTypes.oneOf(StyleType),
1014
/** @ignore */
1115
children: PropTypes.node
1216
};
1317
static defaultProps = {
14-
separator: '/'
18+
separator: '/',
19+
styleType: 'block-hover'
1520
};
1621
render() {
1722
const { separator, children, ...rest } = this.props;
@@ -32,4 +37,6 @@ class Breadcrumb extends Component {
3237
}
3338
}
3439

40+
Breadcrumb.StyleType = StyleType;
41+
3542
export default Breadcrumb;

src/components/Breadcrumb/Breadcrumb.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@
1313

1414
```js {"codepath": "breadcrumb-separator.jsx"}
1515
```
16+
17+
* styleType
18+
19+
```js {"codepath": "breadcrumb-styleType.jsx"}
20+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
3+
import Breadcrumb from 'src/components/Breadcrumb';
4+
import Icon from 'src/components/Icon';
5+
6+
// demo start
7+
class Demo extends React.Component {
8+
render() {
9+
return (
10+
<div>
11+
{Breadcrumb.StyleType.map((styleType, i) => (
12+
<div className="demo-wrap" key={i}>
13+
<Breadcrumb styleType={styleType}>
14+
<Breadcrumb.BackButton type="left" onClick={() => window.history.back()} />
15+
<Breadcrumb.Item noAction>
16+
<Icon type="home" />
17+
</Breadcrumb.Item>
18+
<Breadcrumb.Item onClick={() => window.location.reload()}>
19+
<Icon type="uhost" />
20+
</Breadcrumb.Item>
21+
<Breadcrumb.Item href="https://www.google.com" target="_blank">
22+
google
23+
</Breadcrumb.Item>
24+
<Breadcrumb.Item onClick={() => window.location.reload()}>reload</Breadcrumb.Item>
25+
<Breadcrumb.Item current>current</Breadcrumb.Item>
26+
</Breadcrumb>
27+
</div>
28+
))}
29+
</div>
30+
);
31+
}
32+
}
33+
// demo end
34+
35+
export default Demo;

src/components/Breadcrumb/__demo__/breadcrumb.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22

33
import Breadcrumb from 'src/components/Breadcrumb';
44
import Form from 'src/components/Form';
5+
import Radio from 'src/components/Radio';
56
import Input from 'src/components/Input';
67
import Icon from 'src/components/Icon';
78

@@ -14,24 +15,33 @@ const itemLayout = {
1415
span: 9
1516
}
1617
};
18+
const StyleType = Breadcrumb.StyleType;
1719
class Demo extends React.Component {
1820
constructor(props) {
1921
super(props);
2022
this.state = {
21-
separator: Breadcrumb.defaultProps.separator
23+
separator: Breadcrumb.defaultProps.separator,
24+
styleType: Breadcrumb.defaultProps.styleType
2225
};
2326
}
2427
render() {
25-
const { separator } = this.state;
28+
const { separator, styleType } = this.state;
2629
return (
2730
<div>
2831
<Form className="demo-form">
2932
<Form.Item label="separator" {...itemLayout}>
3033
<Input value={separator} onChange={e => this.setState({ separator: e.target.value })} />
3134
</Form.Item>
35+
<Form.Item label="styleType" {...itemLayout}>
36+
<Radio.Group
37+
options={StyleType.map(styleType => ({ value: styleType }))}
38+
value={styleType}
39+
onChange={styleType => this.setState({ styleType })}
40+
/>
41+
</Form.Item>
3242
</Form>
3343
<div className="demo-wrap">
34-
<Breadcrumb separator={separator}>
44+
<Breadcrumb separator={separator} styleType={styleType}>
3545
<Breadcrumb.BackButton type="left" onClick={() => window.history.back()} />
3646
<Breadcrumb.Item noAction>
3747
<Icon type="home" />

0 commit comments

Comments
 (0)