diff --git a/components.json b/components.json index 9a639f624..1625ebdda 100644 --- a/components.json +++ b/components.json @@ -28,5 +28,6 @@ "image-preview": "./packages/image-preview/index.js", "col": "./packages/col/index.js", "row": "./packages/row/index.js", - "actionsheet": "./packages/actionsheet/index.js" + "actionsheet": "./packages/actionsheet/index.js", + "quantity": "./packages/quantity/index.js" } diff --git a/docs/ExamplesDocsApp.vue b/docs/ExamplesDocsApp.vue index 1e1a9133e..45fceb877 100644 --- a/docs/ExamplesDocsApp.vue +++ b/docs/ExamplesDocsApp.vue @@ -72,6 +72,12 @@ export default { color: #5e6d82; margin: 14px 0; } + + p > code { + background-color: #eee; + padding: 2px 4px; + color: #26a2ff; + } } .demo-page { diff --git a/docs/examples-docs/quantity.md b/docs/examples-docs/quantity.md new file mode 100644 index 000000000..f43c15da4 --- /dev/null +++ b/docs/examples-docs/quantity.md @@ -0,0 +1,65 @@ + + + + +## Quantity + +### 基础用法 + +:::demo 基础用法 +```html + +

当前值:{{ quantity1 }}

+``` +::: + +### 禁用Quantity + +:::demo 禁用Quantity +```html + +``` +::: + +### 高级用法 + +默认是每次加减为1,可以对组件设置`step`、`min`、`max`、`defaultValue`属性。 + +:::demo 高级用法 +```html + +

当前值:{{ quantity2 }}

+``` +::: + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| min | 最小值 | string/number | 1 | '' | +| max | 最大值 | string/number | '' | '' | +| step | 步数 | string/number | 1 | '' | +| disabled | 是否被禁用了 | boolean | false | '' | +| defaultValue | 默认值 | string/number | 1 | '' | + diff --git a/docs/nav.config.json b/docs/nav.config.json index 498fc0ef2..bee4487f5 100644 --- a/docs/nav.config.json +++ b/docs/nav.config.json @@ -133,6 +133,10 @@ "path": "/swipe", "title": "Swipe" }, + { + "path": "/quantity", + "title": "Quantity" + }, { "path": "/waterfall", "title": "Waterfall" diff --git a/packages/quantity/CHANGELOG.md b/packages/quantity/CHANGELOG.md new file mode 100644 index 000000000..e88c472b3 --- /dev/null +++ b/packages/quantity/CHANGELOG.md @@ -0,0 +1,8 @@ +## 0.0.2 (2017-01-20) + +* 改了bug A +* 加了功能B + +## 0.0.1 (2017-01-10) + +* 第一版 diff --git a/packages/quantity/README.md b/packages/quantity/README.md new file mode 100644 index 000000000..4c6172563 --- /dev/null +++ b/packages/quantity/README.md @@ -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) diff --git a/packages/quantity/index.js b/packages/quantity/index.js new file mode 100644 index 000000000..31f90beb3 --- /dev/null +++ b/packages/quantity/index.js @@ -0,0 +1,3 @@ +import Quantity from './src/quantity'; + +export default Quantity; diff --git a/packages/quantity/package.json b/packages/quantity/package.json new file mode 100644 index 000000000..7dbfa2900 --- /dev/null +++ b/packages/quantity/package.json @@ -0,0 +1,10 @@ +{ + "name": "<%= name %>", + "version": "<%= version %>", + "description": "<%= description %>", + "main": "./lib/index.js", + "author": "<%= author %>", + "license": "<%= license %>", + "devDependencies": {}, + "dependencies": {} +} diff --git a/packages/quantity/src/quantity.vue b/packages/quantity/src/quantity.vue new file mode 100644 index 000000000..469f75ed1 --- /dev/null +++ b/packages/quantity/src/quantity.vue @@ -0,0 +1,104 @@ + + + diff --git a/packages/zanui-css/src/index.css b/packages/zanui-css/src/index.css index 765d285c2..84f8532f6 100644 --- a/packages/zanui-css/src/index.css +++ b/packages/zanui-css/src/index.css @@ -23,3 +23,4 @@ @import './row.css'; @import './image_preview.css'; @import './actionsheet.css'; +@import './quantity.css'; diff --git a/packages/zanui-css/src/quantity.css b/packages/zanui-css/src/quantity.css new file mode 100644 index 000000000..1bc6a2df4 --- /dev/null +++ b/packages/zanui-css/src/quantity.css @@ -0,0 +1,77 @@ +@import './common/var.css'; + +@component-namespace zan { + @b quantity { + font-size: 0; + + @e stepper { + width: 40px; + height: 30px; + box-sizing: border-box; + background-color: $c-white; + border: 1px solid $c-gray-dark; + position: relative; + outline: 0; + padding: 5px; + vertical-align: middle; + + &::before { + width: 9px; + height: 1px; + } + + &::after { + width: 1px; + height: 9px; + } + + &::before, + &::after { + content: ''; + position: absolute; + margin: auto; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #6c6c6c; + } + } + + @e minus { + border-radius: 2px 0 0 2px; + + &::after { + display: none; + } + + @m disabled { + background-color: #f8f8f8; + border-color: #e8e8e8 #999 #e8e8e8 #e8e8e8; + } + } + + @e plus { + border-radius: 0 2px 2px 0; + + @m disabled { + background-color: #f8f8f8; + border-color: #e8e8e8 #e8e8e8 #e8e8e8 #999; + } + } + + @e input { + width: 33px; + height: 26px; + padding: 1px; + border: 1px solid $c-gray-dark; + border-width: 1px 0; + box-sizing: content-box; + color: $c-gray-darker; + font-size: 14px; + outline: 0; + vertical-align: middle; + text-align: center; + } + } +} diff --git a/src/index.js b/src/index.js index ffd4368c3..0091f1599 100644 --- a/src/index.js +++ b/src/index.js @@ -28,6 +28,7 @@ import ImagePreview from '../packages/image-preview/index.js'; import Col from '../packages/col/index.js'; import Row from '../packages/row/index.js'; import Actionsheet from '../packages/actionsheet/index.js'; +import Quantity from '../packages/quantity/index.js'; const install = function(Vue) { if (install.installed) return; @@ -58,6 +59,7 @@ const install = function(Vue) { Vue.component(Col.name, Col); Vue.component(Row.name, Row); Vue.component(Actionsheet.name, Actionsheet); + Vue.component(Quantity.name, Quantity); }; // auto install @@ -97,5 +99,6 @@ module.exports = { ImagePreview, Col, Row, - Actionsheet + Actionsheet, + Quantity };