-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37832c2
commit bff7924
Showing
16 changed files
with
373 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,4 +106,4 @@ | |
&.btn-dashed { | ||
border: 1px dashed; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ | |
pointer-events: none; | ||
animation: cuke-mask-fade-out @default-transition forwards; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,4 @@ | |
animation: cuke-slide-right @default-transition; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,4 +162,4 @@ | |
pointer-events: none; | ||
animation: cuke-mask-fade-out @default-transition forwards; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,79 @@ | ||
.btn-hover(@color: @default-color, @lighten: 5%, @font-color: #fff) { | ||
color: @font-color; | ||
background-color: @color; | ||
border: 1px solid @color; | ||
&:not(.btn-disabled):not(.btn-default) { | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
background-color: lighten(@color, @lighten); | ||
} | ||
color: @font-color; | ||
background-color: @color; | ||
border: 1px solid @color; | ||
&:not(.btn-disabled):not(.btn-default) { | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
background-color: lighten(@color, @lighten); | ||
} | ||
} | ||
} | ||
|
||
.btn-hollow(@color,@lighten : 5%) { | ||
color: @color; | ||
background: transparent; | ||
.tag-hover(@color: @default-color, @lighten: 5%, @font-color: #fff) { | ||
color: @font-color; | ||
background-color: @color; | ||
border: 1px solid @color; | ||
&:not(.cuke-tag-disabled):not(.cuke-tag-default) { | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
background-color: lighten(@color, @lighten); | ||
} | ||
} | ||
} | ||
|
||
&:not(.btn-disabled) { | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
background-color: transparent; | ||
border-color: lighten(@color, @lighten); | ||
color: lighten(@color, @lighten); | ||
} | ||
.btn-hollow(@color, @lighten : 5%) { | ||
color: @color; | ||
background: transparent; | ||
&:not(.btn-disabled) { | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
background-color: transparent; | ||
border-color: lighten(@color, @lighten); | ||
color: lighten(@color, @lighten); | ||
} | ||
} | ||
} | ||
|
||
.flex-center(@justify:center,@align:center) { | ||
display: flex; | ||
justify-content: @justify; | ||
align-items: @align; | ||
.tag-hollow(@color, @lighten : 5%) { | ||
color: @color; | ||
background: transparent; | ||
&:not(.cuke-tag-disabled) { | ||
&:hover, | ||
&:active, | ||
&:focus { | ||
background-color: transparent; | ||
border-color: lighten(@color, @lighten); | ||
color: lighten(@color, @lighten); | ||
} | ||
} | ||
} | ||
|
||
.flex-center(@justify: center, @align: center) { | ||
display: flex; | ||
justify-content: @justify; | ||
align-items: @align; | ||
} | ||
|
||
.add-alert-style(@color: @default-color,@opacity: 10%) { | ||
border-color: @color; | ||
background-color: fade(@color, @opacity); | ||
.add-alert-style(@color: @default-color, @opacity: 10%) { | ||
border-color: @color; | ||
background-color: fade(@color, @opacity); | ||
} | ||
|
||
.clearfix() { | ||
&::before, | ||
&::after { | ||
clear: both; | ||
content: ""; | ||
display: table; | ||
zoom: 1; | ||
} | ||
&::before, | ||
&::after { | ||
clear: both; | ||
content: ""; | ||
display: table; | ||
zoom: 1; | ||
} | ||
} | ||
|
||
|
||
.set-progress-bar-bg(@primaryColor: @primary-color) { | ||
background: repeating-linear-gradient(-45deg, @bg-color 25%, @primaryColor 0, @primaryColor 50%, @bg-color 0, @bg-color 75%, @primaryColor 0); | ||
background-size: @progress-bg-offset; | ||
background: repeating-linear-gradient(-45deg, @bg-color 25%, @primaryColor 0, @primaryColor 50%, @bg-color 0, @bg-color 75%, @primaryColor 0); | ||
background-size: @progress-bg-offset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Tag/> should render tag 1`] = ` | ||
<div> | ||
<span | ||
class="cuke-tag cuke-tag-default" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
<span | ||
class="cuke-tag cuke-tag-primary" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
<span | ||
class="cuke-tag cuke-tag-info" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
<span | ||
class="cuke-tag cuke-tag-success" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
<span | ||
class="cuke-tag cuke-tag-error" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
<span | ||
class="cuke-tag cuke-tag-warning" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
<span | ||
class="cuke-tag cuke-tag-default cuke-tag-dashed" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
<span | ||
class="cuke-tag cuke-tag-default cuke-tag-disabled" | ||
style="background-color:" | ||
> | ||
黄瓜 ui | ||
</span> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import assert from "power-assert"; | ||
import React from "react"; | ||
import { render, shallow } from "enzyme"; | ||
import toJson from "enzyme-to-json"; | ||
import Tag from "../index"; | ||
|
||
describe("<Tag/>", () => { | ||
it("should render tag", () => { | ||
const wrapper = render( | ||
<div> | ||
<Tag>黄瓜 ui</Tag> | ||
<Tag type="primary">黄瓜 ui</Tag> | ||
<Tag type="info">黄瓜 ui</Tag> | ||
<Tag type="success">黄瓜 ui</Tag> | ||
<Tag type="error">黄瓜 ui</Tag> | ||
<Tag type="warning">黄瓜 ui</Tag> | ||
<Tag dashed>黄瓜 ui</Tag> | ||
<Tag disabled>黄瓜 ui</Tag> | ||
</div> | ||
); | ||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
it.skip("should find cuke-tag classnames", () => { | ||
const wrapper = shallow( | ||
<div> | ||
<Tag>黄瓜 ui</Tag> | ||
<Tag type="primary">黄瓜 ui</Tag> | ||
<Tag type="info">黄瓜 ui</Tag> | ||
<Tag type="success">黄瓜 ui</Tag> | ||
<Tag type="error">黄瓜 ui</Tag> | ||
<Tag type="warning">黄瓜 ui</Tag> | ||
<Tag dashed>黄瓜 ui</Tag> | ||
<Tag disabled>黄瓜 ui</Tag> | ||
</div> | ||
); | ||
assert(wrapper.find(".cuke-tag").length >= 1); | ||
assert(wrapper.find(".cuke-tag-primary").length === 1); | ||
assert(wrapper.find(".cuke-tag-info").length === 1); | ||
assert(wrapper.find(".cuke-tag-success").length === 1); | ||
assert(wrapper.find(".cuke-tag-error").length === 1); | ||
assert(wrapper.find(".cuke-tag-warning").length === 1); | ||
assert(wrapper.find(".cuke-tag-dashed").length === 1); | ||
assert(wrapper.find(".cuke-tag-disabled").length === 1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { PureComponent } from "react"; | ||
import cls from "classnames"; | ||
import PropTypes from "prop-types"; | ||
|
||
const types = [ | ||
"default", | ||
"primary", | ||
"warning", | ||
"success", | ||
"error", | ||
"info", | ||
"loading" | ||
]; | ||
|
||
export default class Tag extends PureComponent { | ||
static defaultProps = { | ||
prefixCls: "cuke-tag", | ||
type: types[0], | ||
color: "", | ||
hollow: false, | ||
dashed: false, | ||
disabled: false, | ||
size: "default" | ||
}; | ||
|
||
static propTypes = { | ||
prefixCls: PropTypes.string.isRequired, | ||
types: PropTypes.oneOf(types), | ||
color: PropTypes.string, | ||
hollow: PropTypes.bool, | ||
disabled: PropTypes.bool, | ||
dashed: PropTypes.bool, | ||
size: PropTypes.oneOf(["small", "default", "large"]) | ||
}; | ||
|
||
render() { | ||
const { | ||
prefixCls, | ||
className, | ||
children, | ||
type, | ||
disabled, | ||
hollow, | ||
dashed, | ||
size, | ||
style, | ||
color, | ||
...attr | ||
} = this.props; | ||
|
||
return ( | ||
<span | ||
className={cls(prefixCls, className, { | ||
[`${prefixCls}-${type}`]: type, | ||
[`${prefixCls}-hollow`]: hollow, | ||
[`${prefixCls}-disabled`]: disabled, | ||
[`${prefixCls}-large`]: size === "large", | ||
[`${prefixCls}-small`]: size === "small", | ||
[`${prefixCls}-dashed`]: dashed | ||
})} | ||
style={{ | ||
backgroundColor: color, | ||
...style | ||
}} | ||
{...attr} | ||
> | ||
{children} | ||
</span> | ||
); | ||
} | ||
} |
Oops, something went wrong.