add el-tag

This commit is contained in:
1921622004 2018-10-25 17:34:50 +08:00
parent 935cadbe0e
commit 625010b455
5 changed files with 109 additions and 0 deletions

1
packages/omi-element-ui/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build/

View File

@ -0,0 +1,3 @@
el-tag{
margin: 10px;
}

View File

@ -0,0 +1,64 @@
import { tag, WeElement } from "omi";
import "../../omi-element-ui/el-tag";
import style from "./_index.css";
@tag('my-app', true)
class MyApp extends WeElement {
static get data() {
return {
tags:['标签1','标签2','标签3']
}
}
css() {
return style
}
close = item => {
this.data.tags = this.data.tags.filter(tag => {
return tag != item
});
this.update();
}
render(props,data) {
console.log(data);
return (
<div>
<div>
<h3></h3>
<el-tag></el-tag>
<el-tag type="success"></el-tag>
<el-tag type="info" ></el-tag>
<el-tag type="waring" ></el-tag>
<el-tag type="danger"></el-tag>
</div>
<div>
<h3></h3>
<el-tag closeable></el-tag>
<el-tag type="success" closeable></el-tag>
<el-tag type="info" closeable></el-tag>
<el-tag type="waring" closeable></el-tag>
<el-tag type="danger" closeable></el-tag>
</div>
<div>
<h3></h3>
{data.tags.map(item => {
return <el-tag key={item} closeable onClose={() => {
this.close(item)
}}>{item}</el-tag>
})}
</div>
<div>
<h3></h3>
<el-tag closeable></el-tag>
<el-tag size="medium" closeable></el-tag>
<el-tag size="small" closeable></el-tag>
<el-tag size="mini" closeable></el-tag>
</div>
</div>
)
}
}

View File

@ -0,0 +1,36 @@
import { tag, WeElement } from "omi";
import "../style/global/index.css";
import style from "../style/_tag.scss";
@tag('el-tag', true)
class ElTag extends WeElement {
css() {
return style
}
render(props) {
let classStr = "el-tag";
if (props.type) {
classStr += ` el-tag--${props.type}`
};
if (props.size) {
classStr += ` el-tag--${props.size}`
};
if(props.hit) {
classStr += ' is-hit';
};
return (
<span className={classStr} style={{'background-color':props.color}}>
{props.children}
{
props.closeable ?
<i
className="el-tag__close el-icon-close"
onClick={props.onClose}
/> :
null
}
</span>
)
}
}

View File

@ -0,0 +1,5 @@
import { render } from 'omi'
import './assets/index.css'
import './elements/tag'
render(<my-app />, '#root')