mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 03:29:39 +08:00
More preseted colors of tag
This commit is contained in:
parent
14a58c9960
commit
e2c4ad3ba7
@ -84,9 +84,8 @@ exports[`renders ./components/tag/demo/colorful.md correctly 1`] = `
|
|||||||
</h4>
|
</h4>
|
||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
class="ant-tag ant-tag-has-color"
|
class="ant-tag ant-tag-magenta"
|
||||||
data-show="true"
|
data-show="true"
|
||||||
style="background-color:magenta"
|
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="ant-tag-text"
|
class="ant-tag-text"
|
||||||
@ -104,6 +103,16 @@ exports[`renders ./components/tag/demo/colorful.md correctly 1`] = `
|
|||||||
red
|
red
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-tag ant-tag-volcano"
|
||||||
|
data-show="true"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-tag-text"
|
||||||
|
>
|
||||||
|
volcano
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class="ant-tag ant-tag-orange"
|
class="ant-tag ant-tag-orange"
|
||||||
data-show="true"
|
data-show="true"
|
||||||
@ -114,6 +123,26 @@ exports[`renders ./components/tag/demo/colorful.md correctly 1`] = `
|
|||||||
orange
|
orange
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-tag ant-tag-gold"
|
||||||
|
data-show="true"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-tag-text"
|
||||||
|
>
|
||||||
|
gold
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-tag ant-tag-lime"
|
||||||
|
data-show="true"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-tag-text"
|
||||||
|
>
|
||||||
|
lime
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class="ant-tag ant-tag-green"
|
class="ant-tag ant-tag-green"
|
||||||
data-show="true"
|
data-show="true"
|
||||||
@ -144,6 +173,16 @@ exports[`renders ./components/tag/demo/colorful.md correctly 1`] = `
|
|||||||
blue
|
blue
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="ant-tag ant-tag-geekblue"
|
||||||
|
data-show="true"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-tag-text"
|
||||||
|
>
|
||||||
|
geekblue
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class="ant-tag ant-tag-purple"
|
class="ant-tag ant-tag-purple"
|
||||||
data-show="true"
|
data-show="true"
|
||||||
|
@ -9,15 +9,11 @@ title:
|
|||||||
|
|
||||||
我们添加了多种预设色彩的标签样式,用作不同场景使用。如果预设值不能满足你的需求,可以设置为具体的色值。
|
我们添加了多种预设色彩的标签样式,用作不同场景使用。如果预设值不能满足你的需求,可以设置为具体的色值。
|
||||||
|
|
||||||
> 预设色彩在 `antd@2.7.0` 之后支持。
|
|
||||||
|
|
||||||
## en-US
|
## en-US
|
||||||
|
|
||||||
After `antd@2.7.0`, We preset a series of colorful tag style for different situation usage.
|
We preset a series of colorful tag style for different situation usage.
|
||||||
And you can always set it to a hex color string for custom color.
|
And you can always set it to a hex color string for custom color.
|
||||||
|
|
||||||
> Preset colors are supported after `antd@2.7.0`.
|
|
||||||
|
|
||||||
````jsx
|
````jsx
|
||||||
import { Tag } from 'antd';
|
import { Tag } from 'antd';
|
||||||
|
|
||||||
@ -27,10 +23,14 @@ ReactDOM.render(
|
|||||||
<div>
|
<div>
|
||||||
<Tag color="magenta">magenta</Tag>
|
<Tag color="magenta">magenta</Tag>
|
||||||
<Tag color="red">red</Tag>
|
<Tag color="red">red</Tag>
|
||||||
|
<Tag color="volcano">volcano</Tag>
|
||||||
<Tag color="orange">orange</Tag>
|
<Tag color="orange">orange</Tag>
|
||||||
|
<Tag color="gold">gold</Tag>
|
||||||
|
<Tag color="lime">lime</Tag>
|
||||||
<Tag color="green">green</Tag>
|
<Tag color="green">green</Tag>
|
||||||
<Tag color="cyan">cyan</Tag>
|
<Tag color="cyan">cyan</Tag>
|
||||||
<Tag color="blue">blue</Tag>
|
<Tag color="blue">blue</Tag>
|
||||||
|
<Tag color="geekblue">geekblue</Tag>
|
||||||
<Tag color="purple">purple</Tag>
|
<Tag color="purple">purple</Tag>
|
||||||
</div>
|
</div>
|
||||||
<h4 style={{ margin: '16px 0' }}>Custom:</h4>
|
<h4 style={{ margin: '16px 0' }}>Custom:</h4>
|
||||||
|
@ -75,7 +75,10 @@ export default class Tag extends React.Component<TagProps, TagState> {
|
|||||||
|
|
||||||
isPresetColor(color?: string): boolean {
|
isPresetColor(color?: string): boolean {
|
||||||
if (!color) { return false; }
|
if (!color) { return false; }
|
||||||
return /^(pink|red|yellow|orange|cyan|green|blue|purple)(-inverse)?$/.test(color);
|
return (
|
||||||
|
/^(pink|red|yellow|orange|cyan|green|blue|purple|geekblue|magenta|volcano|gold|lime)(-inverse)?$/
|
||||||
|
.test(color)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -98,14 +98,14 @@
|
|||||||
animation-fill-mode: both;
|
animation-fill-mode: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
@colors: pink, magenta, red, orange, yellow, cyan, green, blue, purple;
|
@colors: pink, magenta, red, volcano, orange, yellow, gold, cyan, lime, green, blue, geekblue, purple;
|
||||||
|
|
||||||
// mixin to iterate over colors and create CSS class for each one
|
// mixin to iterate over colors and create CSS class for each one
|
||||||
.make-color-classes(@i: length(@colors)) when (@i > 0) {
|
.make-color-classes(@i: length(@colors)) when (@i > 0) {
|
||||||
.make-color-classes(@i - 1);
|
.make-color-classes(@i - 1);
|
||||||
@color: extract(@colors, @i);
|
@color: extract(@colors, @i);
|
||||||
@lightColor: "@{color}-1";
|
@lightColor: "@{color}-1";
|
||||||
@lightBorderColor: "@{color}-2";
|
@lightBorderColor: "@{color}-3";
|
||||||
@darkColor: "@{color}-6";
|
@darkColor: "@{color}-6";
|
||||||
&-@{color} {
|
&-@{color} {
|
||||||
color: @@darkColor;
|
color: @@darkColor;
|
||||||
|
Loading…
Reference in New Issue
Block a user