Skip to content

Commit

Permalink
feat(Tag): add support of customStyle
Browse files Browse the repository at this point in the history
close #334
  • Loading branch information
ZxBing0066 committed Apr 19, 2021
1 parent e782775 commit 294f70a
Show file tree
Hide file tree
Showing 8 changed files with 862 additions and 259 deletions.
13 changes: 12 additions & 1 deletion src/components/Tag/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ class Icon extends PureComponent {
/**
* 样式风格
*/
styleType: PropTypes.oneOf(StyleType)
styleType: PropTypes.oneOf(StyleType),
/**
* 自定义样式
*/
customStyle: PropTypes.shape({
/** 字色/图标色 */
color: PropTypes.string,
/** 边框色 */
borderColor: PropTypes.string,
/** 背景色 */
background: PropTypes.string
})
};
render() {
// eslint-disable-next-line no-unused-vars
Expand Down
13 changes: 9 additions & 4 deletions src/components/Tag/Icon.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
### 说明

* 这是只有 Icon 的 Tag 组件,用作纯 Icon 标识
- 这是只有 Icon 的 Tag 组件,用作纯 Icon 标识

### 演示

* 功能演示
#### 功能演示

```js {"codepath": "icon.jsx"}
```

* 样式风格 - styleType
#### 样式风格 - styleType

```js {"codepath": "icon-styleType.jsx"}
```

* 自定义 icon - icon
#### 自定义 icon - icon

```js {"codepath": "icon-icon.jsx"}
```

#### 自定义样式 - customStyle

```js {"codepath": "icon-customStyle.jsx"}
```
15 changes: 14 additions & 1 deletion src/components/Tag/Tag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,20 @@ class Tag extends PureComponent {
/**
* 是否禁用
*/
disabled: PropTypes.bool
disabled: PropTypes.bool,
/**
* 自定义样式
*/
customStyle: PropTypes.shape({
/** 字色/图标色 */
color: PropTypes.string,
/** 边框色 */
borderColor: PropTypes.string,
/** 背景色 */
background: PropTypes.string,
/** 关闭按钮 hover 背景色 */
closeIconHoverBackground: PropTypes.string
})
};
static defaultProps = {
styleType: 'default'
Expand Down
5 changes: 5 additions & 0 deletions src/components/Tag/Tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@

```js {"codepath": "tag-icon.jsx"}
```

#### 自定义样式 - customStyle

```js {"codepath": "tag-customStyle.jsx"}
```
32 changes: 32 additions & 0 deletions src/components/Tag/__demo__/icon-customStyle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';

import Tag from 'src/components/Tag';

// demo start

class Demo extends React.Component {
render() {
return (
<div>
<div className="demo-wrap">
<Tag.Icon icon="circle-fill" styleType="orange" closable></Tag.Icon>
</div>
<div className="demo-wrap">
<Tag.Icon
icon="circle-fill"
styleType="orange"
closable
customStyle={{
color: 'white',
background: 'red',
borderColor: 'orange'
}}
></Tag.Icon>
</div>
</div>
);
}
}
// demo end

export default Demo;
37 changes: 37 additions & 0 deletions src/components/Tag/__demo__/tag-customStyle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';

import Tag from 'src/components/Tag';

// demo start

class Demo extends React.Component {
render() {
return (
<div>
<div className="demo-wrap">
<Tag icon="circle-fill" styleType="orange" closable>
Content
</Tag>
</div>
<div className="demo-wrap">
<Tag
icon="circle-fill"
styleType="orange"
closable
customStyle={{
color: 'white',
background: 'red',
borderColor: 'orange',
closeIconHoverBackground: 'pink'
}}
>
Content
</Tag>
</div>
</div>
);
}
}
// demo end

export default Demo;
Loading

0 comments on commit 294f70a

Please sign in to comment.