diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..e6e1f2fe2 --- /dev/null +++ b/.babelrc @@ -0,0 +1,8 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "transform-vue-jsx" + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5306c013b..4c1cab8de 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ lib/* !lib/style.css node_modules example/dist +dist diff --git a/Makefile b/Makefile index bf8f2f463..ab0038d6a 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ init: node build/bin/init.js $(filter-out $@,$(MAKECMDGOALS)) dev: - npm run docs + npm run dev diff --git a/README.md b/README.md index e69de29bb..cb6383067 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,35 @@ +## 下载项目 +```bash +git@gitlab.qima-inc.com:fe/oxygen.git +cd oxygen +``` + +## 安装组件依赖库 +```bash +ynpm i +``` + +## 新建组件(以waterfall为例) +新建一个Vue组件,比如 waterfall +```bash +make init waterfall +``` +就可以在 packages目录 里面看到waterfall初始化的组件代码了。记得更新package.json和README.md里的组件描述信息 + +## 示例预览(以waterfall为例) +在 docs/nav.config.json 文件里合适的地方写入组件声明,根据组件类型(JS组件,CSS组件,Form等)进行区分 +在 docs/examples 目录里新建 同名的md文件,如 waterfall.md +在项目的根目录下执行以下命令,启动server +``` +make dev +``` +浏览器访问 http://localhost:8080/#/ 就可以看到所有组件的示例了 + + + + + + + + + diff --git a/build/bin/build-all.js b/build/bin/build-all.js index e1014ed74..97927ee70 100644 --- a/build/bin/build-all.js +++ b/build/bin/build-all.js @@ -10,15 +10,15 @@ let componentPaths = []; delete components.font; Object.keys(components).forEach(key => { - const filePath = path.join(__dirname, `../../packages/${key}/cooking.conf.js`); + const filePath = path.join(__dirname, `../../packages/${key}/webpack.conf.js`); if (existsSync(filePath)) { - componentPaths.push(`packages/${key}/cooking.conf.js`); + componentPaths.push(`packages/${key}/webpack.conf.js`); } }); const paths = componentPaths.join(','); -const cli = `node_modules/.bin/cooking build -c ${paths} -p`; +const cli = `node_modules/.bin/webpack build -c ${paths} -p`; execSync(cli, { stdio: 'inherit' diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index fffd532e8..a3a9a1a35 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -8,8 +8,6 @@ var OUTPUT_PATH = path.join(__dirname, '../../src/index.js'); var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';'; var ISNTALL_COMPONENT_TEMPLATE = ' Vue.component({{name}}.name, {{name}});'; var MAIN_TEMPLATE = `{{include}} -// zanui -import '../packages/zanui-css/src/index.pcss'; const install = function(Vue) { if (install.installed) return; diff --git a/build/release.sh b/build/release.sh new file mode 100644 index 000000000..a738c9f18 --- /dev/null +++ b/build/release.sh @@ -0,0 +1,38 @@ +git checkout master +git merge dev + +#!/usr/bin/env sh +set -e +echo "Enter release version: " +read VERSION + +read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r +echo # (optional) move to a new line +if [[ $REPLY =~ ^[Yy]$ ]] +then + echo "Releasing $VERSION ..." + + # build + VERSION=$VERSION npm run dist + + # publish zanui-css + echo "Releasing zanui-css $VERSION ..." + cd packages/zanui-css + npm version $VERSION --message "[release] $VERSION" + npm publish + cd ../.. + + # commit + git add -A + git commit -m "[build] $VERSION" + npm version $VERSION --message "[release] $VERSION" + + # publish + git push origin master + git push origin refs/tags/v$VERSION + git checkout dev + git rebase master + git push origin dev + + npm publish +fi diff --git a/build/webpack.build.js b/build/webpack.build.js index 4222eae61..7963aad45 100644 --- a/build/webpack.build.js +++ b/build/webpack.build.js @@ -1,13 +1,19 @@ -var config = require('./webpack.config.js') +var config = require('./webpack.config.js'); config.entry = { - 'oxygen': './src/index.js' -} + 'zanui': './src/index.js' +}; config.output = { - filename: './dist/[name].js', - library: 'Oxygen', + filename: './lib/[name].js', + library: 'zanui', libraryTarget: 'umd' -} +}; -module.exports = config +config.externals = { + vue: 'Vue' +}; + +delete config.devtool; + +module.exports = config; diff --git a/build/webpack.build.min.js b/build/webpack.build.min.js index d8a978bc0..be17f3f93 100644 --- a/build/webpack.build.min.js +++ b/build/webpack.build.min.js @@ -1,19 +1,20 @@ -var config = require('./webpack.build.js') -var webpack = require('webpack') +var config = require('./webpack.build.js'); +var webpack = require('webpack'); - -config.output.filename = config.output.filename.replace(/\.js$/, '.min.js') - -delete config.devtool +config.output.filename = config.output.filename.replace(/\.js$/, '.min.js'); config.plugins = [ + new webpack.LoaderOptionsPlugin({ + minimize: true, + debug: false + }), new webpack.optimize.UglifyJsPlugin({ - sourceMap: false, - drop_console: true, + comments: false, compress: { + drop_console: true, warnings: false } }) -] +]; -module.exports = config +module.exports = config; diff --git a/build/webpack.config.js b/build/webpack.config.js index 5d28befbf..111fe99b4 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -24,7 +24,8 @@ function wrap(render) { module.exports = { entry: { - 'build-docs': './docs/index.js' + 'zanui-docs': './docs/index.js', + 'zanui-examples': './docs/examples.js' }, output: { path: './docs/build', @@ -39,7 +40,7 @@ module.exports = { extensions: ['.js', '.vue', '.pcss'], alias: { 'vue$': 'vue/dist/vue.runtime.common.js', - 'oxygen': path.join(__dirname, '..'), + 'zanui': path.join(__dirname, '..'), 'src': path.join(__dirname, '../src'), 'packages': path.join(__dirname, '../packages') } @@ -57,10 +58,6 @@ module.exports = { }, { test: /\.css$/, - loader: 'style-loader!css-loader?root=./docs/' - }, - { - test: /\.pcss$/, loader: 'style-loader!css-loader!postcss-loader' }, { @@ -91,8 +88,12 @@ if (process.env.NODE_ENV === 'production') { }), new ExtractTextPlugin(`yzvue_base_${version}_min.css`), new webpack.optimize.UglifyJsPlugin({ - compress: {warnings: false}, - output: {comments: false}, + compress: { + warnings: false + }, + output: { + comments: false + }, sourceMap: false }), new webpack.LoaderOptionsPlugin({ diff --git a/components.json b/components.json index bd59720a9..3b1dc2789 100644 --- a/components.json +++ b/components.json @@ -10,5 +10,8 @@ "dialog": "./packages/dialog/index.js", "picker": "./packages/picker/index.js", "radio-group": "./packages/radio-group/index.js", - "waterfall": "./packages/waterfall/index.js" + "waterfall": "./packages/waterfall/index.js", + "loading": "./packages/loading/index.js", + "panel": "./packages/panel/index.js", + "card": "./packages/card/index.js" } diff --git a/packages/switch/CHANGELOG.md b/docs/ExamplesApp.vue similarity index 100% rename from packages/switch/CHANGELOG.md rename to docs/ExamplesApp.vue diff --git a/docs/App.vue b/docs/ExamplesDocsApp.vue similarity index 98% rename from docs/App.vue rename to docs/ExamplesDocsApp.vue index c0b8380c3..648a9b356 100644 --- a/docs/App.vue +++ b/docs/ExamplesDocsApp.vue @@ -21,6 +21,8 @@ export default { + +## Panel 面板 + +面板只是一个容器,里面可以放入自定义的内容。 + +### 基础用法 + +:::demo +```html + + +
+

商品名称是什么,两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余

+ ¥ 2.00 +
+
+

商品sku

+ x 2 +
+ +
+
+ 合计:¥ 1999.90 +
+
+``` +::: + +### 高级用法 + +使用具名`slot`自定义内容。 + +:::demo +```html + + +
+

商品名称是什么,两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余

+ ¥ 2.00 +
+
+

商品sku

+ x 2 +
+ +
+
+ 合计:¥ 1999.90 +
+
+ 按钮一 + 按钮二 +
+
+``` +::: + +### API + +| 参数 | 说明 | 类型 | 默认值 | 可选值 | +|-----------|-----------|-----------|-------------|-------------| +| title | 标题 | string | '' | '' | +| desc | 描述 | string | '' | '' | +| status | 状态 | string | '' | '' | + + +### Slot + +| name | 描述 | +|-----------|-----------| +| - | 自定义内容 | +| header | 自定义header | +| footer | 自定义footer | diff --git a/docs/examples/picker.md b/docs/examples-docs/picker.md similarity index 100% rename from docs/examples/picker.md rename to docs/examples-docs/picker.md diff --git a/docs/examples/popup.md b/docs/examples-docs/popup.md similarity index 100% rename from docs/examples/popup.md rename to docs/examples-docs/popup.md diff --git a/docs/examples/radio.md b/docs/examples-docs/radio.md similarity index 100% rename from docs/examples/radio.md rename to docs/examples-docs/radio.md diff --git a/docs/examples/switch.md b/docs/examples-docs/switch.md similarity index 81% rename from docs/examples/switch.md rename to docs/examples-docs/switch.md index 400912c95..b77773cb3 100644 --- a/docs/examples/switch.md +++ b/docs/examples-docs/switch.md @@ -43,13 +43,17 @@ export default { :::demo 样例代码 ```html
-
+
-
{{switchStateText}}
+
{{switchStateText}}
-
+
-
OFF, DISABLED
+
ON, DISABLED
+
+
+ +
OFF, DISABLED
``` diff --git a/docs/examples/waterfall.md b/docs/examples-docs/waterfall.md similarity index 100% rename from docs/examples/waterfall.md rename to docs/examples-docs/waterfall.md diff --git a/docs/examples.js b/docs/examples.js new file mode 100644 index 000000000..e69de29bb diff --git a/docs/examples/button.vue b/docs/examples/button.vue new file mode 100644 index 000000000..3574db362 --- /dev/null +++ b/docs/examples/button.vue @@ -0,0 +1,10 @@ + + + diff --git a/docs/index.js b/docs/index.js index dfbaf47a3..212561ff8 100644 --- a/docs/index.js +++ b/docs/index.js @@ -1,12 +1,13 @@ -import './assets/docs.css'; import Vue from 'vue'; import VueRouter from 'vue-router'; -import App from './App'; +import App from './ExamplesDocsApp'; import routes from './router.config'; import demoBlock from './components/demo-block'; import SideNav from './components/side-nav'; import Oxygen from '../src/index'; +import 'packages/zanui-css/src/index.css'; + Vue.use(Oxygen); Vue.use(VueRouter); Vue.component('demo-block', demoBlock); diff --git a/docs/nav.config.json b/docs/nav.config.json index 6046705d1..c7e8e536f 100644 --- a/docs/nav.config.json +++ b/docs/nav.config.json @@ -14,17 +14,33 @@ "path": "/cell", "title": "Cell" }, - { - "path": "/loading", - "title": "Loading" - }, { "path": "/progress", "title": "Progress" }, + { + "path": "/panel", + "title": "Panel" + }, { "path": "/card", "title": "Card" + }, + { + "path": "/loading", + "title": "Loading" + }, + { + "path": "/steps", + "title": "Steps" + }, + { + "path": "/badge", + "title": "Badge" + }, + { + "path": "/search", + "title": "Search" } ] }, @@ -92,10 +108,6 @@ "path": "/waterfall", "title": "Waterfall" }, - { - "path": "/dialog", - "title": "Dialog" - }, { "path": "/img-preview", "title": "Img Preview" diff --git a/docs/router.config.js b/docs/router.config.js index 3aaeb1002..6bc6286cf 100644 --- a/docs/router.config.js +++ b/docs/router.config.js @@ -23,7 +23,7 @@ const registerRoute = (navConfig) => { route.push({ path: '/component' + page.path, component: function(resolve) { - require([`./examples${page.path}.md`], resolve); + require([`./examples-docs${page.path}.md`], resolve); } }); } diff --git a/examples.html b/examples.html new file mode 100644 index 000000000..3de3e8494 --- /dev/null +++ b/examples.html @@ -0,0 +1,16 @@ + + + + + + Oxygen + + + +
+ +
+ + + + diff --git a/index.html b/index.html index 2a1d2e4be..b44af6e28 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,6 @@
- + diff --git a/package.json b/package.json index f10b62000..f48796625 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "@youzan/oxygen", "version": "0.0.1", "description": "有赞vue wap组件库", - "main": "lib/oxygen.js", - "style": "lib/style.css", + "main": "lib/zanui.js", + "style": "lib/zanui-css/index.css", "files": [ "lib", "src", @@ -11,11 +11,13 @@ ], "scripts": { "bootstrap": "npm i --registry=http://registry.npm.qima-inc.com", + "dev": "npm run bootstrap && npm run build:file && webpack-dev-server --inline --hot --config build/webpack.config.js", "build:file": "node build/bin/build-entry.js", - "build": "npm run clean && npm run lint && npm run build:file && npm run concat:dev && npm run concat:prod", - "dev": "npm run bootstrap && npm run build:file", + "build:utils": "cross-env BABEL_ENV=utils babel src --out-dir lib --ignore src/index.js", + "build:zanui-css": "gulp build --gulpfile packages/zanui-css/gulpfile.js && cp-cli packages/zanui-css/lib lib/zanui-css", + "build:zanui": "webpack --progress --hide-modules --config build/webpack.build.js && webpack --progress --hide-modules --config build/webpack.build.min.js", + "dist": "npm run clean && npm run build:file && npm run lint && npm run build:zanui && npm run build:utils && npm run build:zanui-css", "builddocs": "webpack --progress --hide-modules --config build/webpack.config.js && set NODE_ENV=production webpack --progress --hide-modules --config build/webpack.config.js", - "docs": "npm run dev && webpack-dev-server --inline --hot --config build/webpack.config.js", "clean": "rimraf lib && rimraf packages/*/lib", "lint": "eslint src/**/*.js packages/**/*.{js,vue} --quiet" }, diff --git a/packages/button/package.json b/packages/button/package.json index a2d28bd49..c9dfa4dc9 100644 --- a/packages/button/package.json +++ b/packages/button/package.json @@ -2,7 +2,7 @@ "name": "@youzan/z-button", "version": "0.0.1", "description": "button component", - "main": "./lib/index.js", + "main": "./index.js", "author": "niunai", "license": "MIT", "devDependencies": {}, diff --git a/packages/button/src/button.js b/packages/button/src/button.js index b3d912e3c..fa62244c4 100644 --- a/packages/button/src/button.js +++ b/packages/button/src/button.js @@ -42,6 +42,12 @@ export default { } }, + methods: { + handleClick() { + this.$emit('click'); + } + }, + render(h) { let { type, nativeType, size, disabled, loading, block } = this; let Tag = this.tag; @@ -60,6 +66,7 @@ export default { 'is-block': block } ]} + onClick={this.handleClick} > { loading ? : null diff --git a/packages/radio-group/CHANGELOG.md b/packages/card/CHANGELOG.md similarity index 100% rename from packages/radio-group/CHANGELOG.md rename to packages/card/CHANGELOG.md diff --git a/packages/radio-group/README.md b/packages/card/README.md similarity index 100% rename from packages/radio-group/README.md rename to packages/card/README.md diff --git a/packages/card/index.js b/packages/card/index.js new file mode 100644 index 000000000..84dfc6611 --- /dev/null +++ b/packages/card/index.js @@ -0,0 +1,3 @@ +import Card from './src/card'; + +export default Card; diff --git a/packages/radio-group/package.json b/packages/card/package.json similarity index 100% rename from packages/radio-group/package.json rename to packages/card/package.json diff --git a/packages/card/src/card.vue b/packages/card/src/card.vue new file mode 100644 index 000000000..90732293f --- /dev/null +++ b/packages/card/src/card.vue @@ -0,0 +1,31 @@ + + + diff --git a/packages/cell/package.json b/packages/cell/package.json index 7dbfa2900..b812f955d 100644 --- a/packages/cell/package.json +++ b/packages/cell/package.json @@ -1,10 +1,10 @@ { - "name": "<%= name %>", - "version": "<%= version %>", - "description": "<%= description %>", - "main": "./lib/index.js", - "author": "<%= author %>", - "license": "<%= license %>", + "name": "@youzan/z-cell", + "version": "0.0.1", + "description": "cell component", + "main": "./index.js", + "author": "zhangmin ", + "license": "MIT", "devDependencies": {}, "dependencies": {} } diff --git a/packages/cell/src/cell.vue b/packages/cell/src/cell.vue index 996bf3a12..411ee7cc2 100644 --- a/packages/cell/src/cell.vue +++ b/packages/cell/src/cell.vue @@ -1,15 +1,15 @@ diff --git a/packages/panel/CHANGELOG.md b/packages/panel/CHANGELOG.md new file mode 100644 index 000000000..e88c472b3 --- /dev/null +++ b/packages/panel/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/panel/README.md b/packages/panel/README.md new file mode 100644 index 000000000..4c6172563 --- /dev/null +++ b/packages/panel/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/panel/index.js b/packages/panel/index.js new file mode 100644 index 000000000..35f2b3d2c --- /dev/null +++ b/packages/panel/index.js @@ -0,0 +1,3 @@ +import Panel from './src/panel'; + +export default Panel; diff --git a/packages/panel/package.json b/packages/panel/package.json new file mode 100644 index 000000000..1da2d27ee --- /dev/null +++ b/packages/panel/package.json @@ -0,0 +1,10 @@ +{ + "name": "@youzan/z-panel", + "version": "0.0.1", + "description": "picker component", + "main": "./index.js", + "author": "zhangmin ", + "license": "MIT", + "devDependencies": {}, + "dependencies": {} +} diff --git a/packages/panel/src/panel.vue b/packages/panel/src/panel.vue new file mode 100644 index 000000000..c82d273b9 --- /dev/null +++ b/packages/panel/src/panel.vue @@ -0,0 +1,28 @@ + + + diff --git a/packages/picker/package.json b/packages/picker/package.json index 7dbfa2900..b4162fbf9 100644 --- a/packages/picker/package.json +++ b/packages/picker/package.json @@ -1,10 +1,10 @@ { - "name": "<%= name %>", - "version": "<%= version %>", - "description": "<%= description %>", - "main": "./lib/index.js", - "author": "<%= author %>", - "license": "<%= license %>", + "name": "@youzan/z-picker", + "version": "0.0.1", + "description": "picker component", + "main": "./index.js", + "author": "zhangmin ", + "license": "MIT", "devDependencies": {}, "dependencies": {} } diff --git a/packages/picker/src/picker-column.vue b/packages/picker/src/picker-column.vue index 81b387db2..19c83e984 100644 --- a/packages/picker/src/picker-column.vue +++ b/packages/picker/src/picker-column.vue @@ -154,7 +154,9 @@ export default { var el = this.$refs.wrapper; var dragState = {}; - var velocityTranslate, prevTranslate, pickerItems; + var velocityTranslate; + var prevTranslate; + var pickerItems; // eslint-disable-line draggable(el, { start: (event) => { @@ -166,7 +168,7 @@ export default { startTop: event.pageY, startTranslateTop: translateUtil.getElementTranslate(el).top }; - pickerItems = el.querySelectorAll('.z-picker-item'); + pickerItems = el.querySelectorAll('.z-picker-item'); // eslint-disable-line }, drag: (event) => { diff --git a/packages/picker/src/picker.vue b/packages/picker/src/picker.vue index 6be3a5821..0a9f6b9c0 100644 --- a/packages/picker/src/picker.vue +++ b/packages/picker/src/picker.vue @@ -98,7 +98,6 @@ export default { */ getColumnValue(index) { let column = this.getColumn(index); - console.log(column) return column && column.values[column.valueIndex]; }, diff --git a/packages/popup/package.json b/packages/popup/package.json index 7dbfa2900..af6b57711 100644 --- a/packages/popup/package.json +++ b/packages/popup/package.json @@ -1,10 +1,10 @@ { - "name": "<%= name %>", - "version": "<%= version %>", - "description": "<%= description %>", - "main": "./lib/index.js", - "author": "<%= author %>", - "license": "<%= license %>", + "name": "@youzan/z-popup", + "version": "0.0.1", + "description": "popup component", + "main": "./index.js", + "author": "zhangmin ", + "license": "MIT", "devDependencies": {}, "dependencies": {} } diff --git a/packages/radio/package.json b/packages/radio/package.json index 7dbfa2900..92e6a4320 100644 --- a/packages/radio/package.json +++ b/packages/radio/package.json @@ -1,10 +1,10 @@ { - "name": "<%= name %>", - "version": "<%= version %>", - "description": "<%= description %>", - "main": "./lib/index.js", - "author": "<%= author %>", - "license": "<%= license %>", + "name": "@youzan/z-radio", + "version": "0.0.1", + "description": "radio component", + "main": "./index.js", + "author": "zhangmin ", + "license": "MIT", "devDependencies": {}, "dependencies": {} } diff --git a/packages/radio/src/radio.vue b/packages/radio/src/radio.vue index cae6c3e9d..e51e1db7c 100644 --- a/packages/radio/src/radio.vue +++ b/packages/radio/src/radio.vue @@ -1,5 +1,5 @@