tag component

This commit is contained in:
pangxie1991 2017-02-28 21:08:50 +08:00
parent 5cb93982b4
commit 474a324988
12 changed files with 220 additions and 2 deletions

View File

@ -14,5 +14,6 @@
"loading": "./packages/loading/index.js",
"panel": "./packages/panel/index.js",
"card": "./packages/card/index.js",
"steps": "./packages/steps/index.js"
"steps": "./packages/steps/index.js",
"tag": "./packages/tag/index.js"
}

28
docs/examples-docs/tag.md Normal file
View File

@ -0,0 +1,28 @@
## Tag 组件
### 基础用法
```html
<z-tag>返现</z-tag>
<z-tag :plain="true">返现</z-tag>
```
### 高级用法
```html
<z-tag type="danger">返现</z-tag>
<z-tag type="success">返现</z-tag>
<z-tag type="success" :plain="true">返现</z-tag>
```
### API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| plain | 是否是空心tag | boolean | false | '' |
| mark | 是否是标记 | boolean | false | '' |
| type | tag类型 | string | '' | 'primary', 'success', 'danger' |
### Slot
| name | 描述 |
|-----------|-----------|
| - | 自定义tag显示内容 |

52
docs/examples/tag.vue Normal file
View File

@ -0,0 +1,52 @@
<template>
<div class="page-cell">
<h1 class="page-title">Tag</h1>
<h2 class="page-sub-title">基础用法</h2>
<div>
<div class="tags-container">
<z-tag>返现</z-tag>
<z-tag :plain="true">返现</z-tag>
</div>
<div class="tags-container">
<z-tag type="danger">返现</z-tag>
<z-tag type="danger">四字标签</z-tag>
<z-tag type="danger"></z-tag>
</div>
<div class="tags-container">
<z-tag type="danger">返现</z-tag>
<z-tag :plain="true" type="danger">返现</z-tag>
</div>
<div class="tags-container">
<z-tag type="primary">返现</z-tag>
<z-tag :plain="true" type="primary">返现</z-tag>
</div>
<div class="tags-container">
<z-tag type="success">返现</z-tag>
<z-tag :plain="true" type="success">返现</z-tag>
</div>
<div class="tags-container">
<z-tag type="danger" :mark="true">返现</z-tag>
</div>
</div>
</div>
</template>
<script>
export default {
methods: {}
};
</script>
<style>
.page-sub-title {
padding: 25px 15px;
}
.tags-container {
padding: 5px 15px;
.z-tag + .z-tag {
margin-left: 10px;
}
}
</style>

View File

@ -34,6 +34,10 @@
"path": "/steps",
"title": "Steps"
},
{
"path": "/tag",
"title": "Tag"
},
{
"path": "/badge",
"title": "Badge"

View File

@ -0,0 +1,8 @@
## 0.0.2 (2017-01-20)
* 改了bug A
* 加了功能B
## 0.0.1 (2017-01-10)
* 第一版

26
packages/tag/README.md Normal file
View File

@ -0,0 +1,26 @@
# @youzan/<%= name %>
!!! 请在此处填写你的文档最简单描述 !!!
[![version][version-image]][download-url]
[![download][download-image]][download-url]
[version-image]: http://npm.qima-inc.com/badge/v/@youzan/<%= name %>.svg?style=flat-square
[download-image]: http://npm.qima-inc.com/badge/d/@youzan/<%= name %>.svg?style=flat-square
[download-url]: http://npm.qima-inc.com/package/@youzan/<%= name %>
## Demo
## Usage
## API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| className | 自定义额外类名 | string | '' | '' |
## License
[MIT](https://opensource.org/licenses/MIT)

3
packages/tag/index.js Normal file
View File

@ -0,0 +1,3 @@
import Tag from './src/main';
export default Tag;

10
packages/tag/package.json Normal file
View File

@ -0,0 +1,10 @@
{
"name": "<%= name %>",
"version": "<%= version %>",
"description": "<%= description %>",
"main": "./lib/index.js",
"author": "<%= author %>",
"license": "<%= license %>",
"devDependencies": {},
"dependencies": {}
}

16
packages/tag/src/main.vue Normal file
View File

@ -0,0 +1,16 @@
<template>
<span class="z-tag" :class="[type ? `z-tag--${type}`: '', { 'is-plain': plain, 'is-mark': mark }]">
<slot></slot>
</span>
</template>
<script>
export default {
name: 'z-tag',
props: {
type: String,
mark: Boolean,
plain: Boolean
}
};
</script>

View File

@ -15,3 +15,4 @@
@import './switch.css';
@import './panel.css';
@import './steps.css';
@import './tag.css';

View File

@ -0,0 +1,66 @@
@import "./common/var.css";
@import "./mixins/border_retina.css";
@component-namespace z {
@b tag {
position: relative;
display: inline-block;
line-height: 14px;
padding: 1px 5px;
border-radius: 2px;
font-size: 10px;
background: $c-gray;
color: $c-white;
&::after {
@mixin border-retina (top, right, bottom, left), $c-gray;
border-radius: 4px;
}
@m success {
background: $c-green;
&::after {
border-color: $c-green;
}
@when plain {
color: $c-green;
}
}
@m danger {
background: $button-danger-background-color;
&::after {
border-color: $button-danger-background-color;
}
@when plain {
color: $button-danger-background-color;
}
}
@m primary {
background: $c-blue;
&::after {
border-color: $c-blue;
}
@when plain {
color: $c-blue;
}
}
@when plain {
background: $c-white;
color: $c-gray;
}
@when mark {
border-radius: 0 8px 8px 0;
&::after {
border-radius: 0 16px 16px 0;
}
}
}
}

View File

@ -14,6 +14,7 @@ import Loading from '../packages/loading/index.js';
import Panel from '../packages/panel/index.js';
import Card from '../packages/card/index.js';
import Steps from '../packages/steps/index.js';
import Tag from '../packages/tag/index.js';
const install = function(Vue) {
if (install.installed) return;
@ -32,6 +33,7 @@ const install = function(Vue) {
Vue.component(Panel.name, Panel);
Vue.component(Card.name, Card);
Vue.component(Steps.name, Steps);
Vue.component(Tag.name, Tag);
};
// auto install
@ -57,5 +59,6 @@ export default {
Loading,
Panel,
Card,
Steps
Steps,
Tag
};