diff --git a/.eslintrc.js b/.eslintrc.js index 15ae2f995..892f6e1db 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -44,7 +44,7 @@ module.exports = { 'generator-star-spacing': [2, { 'before': true, 'after': true }], 'handle-callback-err': [2, '^(err|error)$' ], 'indent': [2, 2, { 'SwitchCase': 1 }], - 'jsx-quotes': [2, 'prefer-single'], + 'jsx-quotes': [2, 'prefer-double'], 'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }], 'keyword-spacing': [2, { 'before': true, 'after': true }], 'new-cap': [2, { 'newIsCap': true, 'capIsNew': false }], diff --git a/build/bin/build-entry.js b/build/bin/build-entry.js index 3343ac7a6..b58e200be 100644 --- a/build/bin/build-entry.js +++ b/build/bin/build-entry.js @@ -3,6 +3,7 @@ var fs = require('fs'); var render = require('json-templater/string'); var uppercamelcase = require('uppercamelcase'); var path = require('path'); +var chalk = require('chalk'); var OUTPUT_PATH = path.join(__dirname, '../../src/index.js'); var IMPORT_TEMPLATE = 'import {{name}} from \'../packages/{{package}}/index.js\';'; @@ -70,5 +71,5 @@ var template = render(MAIN_TEMPLATE, { }); fs.writeFileSync(OUTPUT_PATH, template); -console.log('[build entry] DONE:', OUTPUT_PATH); +console.log(chalk.green('[build entry] DONE:' + OUTPUT_PATH)); diff --git a/build/genExamples.js b/build/genExamples.js index 5db7e8244..3152b4f4d 100644 --- a/build/genExamples.js +++ b/build/genExamples.js @@ -3,8 +3,10 @@ var markdownItContainer = require('markdown-it-container'); var fs = require('fs'); var path = require('path'); var cheerio = require('cheerio'); +var chalk = require('chalk'); var striptags = require('./strip-tags'); -var Components = require('../components.json'); +var navs = require('../docs/src/nav.config.js'); +navs = navs['zh-CN']; var parser = markdownIt('default', { html: true @@ -29,9 +31,9 @@ var renderVueTemplate = function (html, componentName) { var script = ''; if (output.script) { - script = output.script.replace(''; + script = ''; } result = `\n' + @@ -69,18 +71,34 @@ parser.use(markdownItContainer, 'demo', { }); var docsDir = path.resolve(__dirname, '../docs'); -for (var item in Components) { - var itemMdFile = `${docsDir}/examples-docs/${item}.md`; +var components = []; +for (var i = 0; i < navs.length; i++) { + var navItem = navs[i]; + + if (!navItem.showInMobile) continue; + + if (!navItem.groups) { + components.push(navs[i]); + } else { + for (var j = 0; j < navItem.groups.length; j++) { + components = components.concat(navItem.groups[j].list); + } + } +} +for (var i = 0; i < components.length; i++) { + var item = components[i]; + var itemMdFile = `${docsDir}/examples-docs${item.path}.md`; if (!fs.existsSync(itemMdFile)) { continue; } - var itemMd = fs.readFileSync(`${docsDir}/examples-docs/${item}.md`).toString(); + var itemMd = fs.readFileSync(`${docsDir}/examples-docs${item.path}.md`).toString(); var content = parser.render(itemMd); - var result = renderVueTemplate(content, item); + var result = renderVueTemplate(content, item.path.slice(1)); - var exampleVueName = `${docsDir}/examples-dist/${item}.vue`; + var exampleVueName = `${docsDir}/examples-dist/${item.path}.vue`; + // 新建一个文件 if (!fs.existsSync(exampleVueName)) { fs.closeSync(fs.openSync(exampleVueName, 'w')); } @@ -89,5 +107,5 @@ for (var item in Components) { }); } -console.log('generate examples success!'); +console.log(chalk.green('generate examples success!')); diff --git a/build/webpack.config.js b/build/webpack.config.js index 56b140900..32f2bf8d5 100644 --- a/build/webpack.config.js +++ b/build/webpack.config.js @@ -9,6 +9,7 @@ var getPoastcssPlugin = require('./utils/postcss_pipe'); var ProgressBarPlugin = require('progress-bar-webpack-plugin'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); var HtmlWebpackPlugin = require('html-webpack-plugin'); +var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); var StyleExtractPlugin; if (process.env.NODE_ENV === 'production') { @@ -35,8 +36,8 @@ function wrap(render) { module.exports = { entry: { 'vendor': ['vue', 'vue-router'], - 'docs': './docs/index.js', - 'examples': './docs/examples.js' + 'zan-docs': './docs/src/index.js', + 'zan-examples': './docs/src/examples.js' }, output: { path: path.join(__dirname, '../docs/dist'), @@ -48,14 +49,14 @@ module.exports = { path.join(__dirname, '../node_modules'), 'node_modules' ], - extensions: ['.js', '.vue', '.pcss'], + extensions: ['.js', '.vue', '.css'], alias: { 'vue$': 'vue/dist/vue.runtime.common.js', 'zanui': path.join(__dirname, '..'), 'src': path.join(__dirname, '../src'), 'packages': path.join(__dirname, '../packages'), 'lib': path.join(__dirname, '../lib'), - 'components': path.join(__dirname, '../docs/components') + 'components': path.join(__dirname, '../docs/src/components') } }, module: { @@ -97,20 +98,7 @@ module.exports = { }, devtool: 'source-map', plugins: [ - StyleExtractPlugin, new ProgressBarPlugin(), - new HtmlWebpackPlugin({ - chunks: ['vendor', 'docs'], - template: 'docs/index.tpl', - filename: 'index.html', - inject: true - }), - new HtmlWebpackPlugin({ - chunks: ['vendor', 'examples'], - template: 'docs/index.tpl', - filename: 'examples.html', - inject: true - }), new webpack.LoaderOptionsPlugin({ minimize: true, options: { @@ -160,7 +148,21 @@ module.exports = { } } } - }) + }), + new HtmlWebpackPlugin({ + chunks: ['vendor', 'zan-docs'], + template: 'docs/src/index.tpl', + filename: 'index.html', + inject: true + }), + new HtmlWebpackPlugin({ + chunks: ['vendor', 'zan-examples'], + template: 'docs/src/index.tpl', + filename: 'examples.html', + inject: true + }), + new OptimizeCssAssetsPlugin(), + StyleExtractPlugin ] }; @@ -168,7 +170,7 @@ if (process.env.NODE_ENV === 'production') { delete module.exports.devtool; module.exports.output = { path: path.join(__dirname, '../docs/dist'), - publicPath: './', + publicPath: '/vue', filename: '[name].[hash:8].js' }; module.exports.plugins = module.exports.plugins.concat([ diff --git a/docs/ExamplesDocsApp.vue b/docs/ExamplesDocsApp.vue deleted file mode 100644 index 31f8d5860..000000000 --- a/docs/ExamplesDocsApp.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - diff --git a/docs/assets/docs.css b/docs/assets/docs.css index 3ab54888d..9c18a759c 100644 --- a/docs/assets/docs.css +++ b/docs/assets/docs.css @@ -41,13 +41,13 @@ ul, ol { list-style: none; } -.hljs { - line-height: 1.8; +code.hljs { + line-height: 1.5; font-family: Menlo, Monaco, Consolas, Courier, monospace; font-size: 12px; - padding: 18px 24px; - background-color: #f9fafc; - border: solid 1px #eaeefb; + padding: 20px; + background-color: #f8f8f8; + border: solid 1px #E5E5E5; margin-bottom: 25px; border-radius: 4px; -webkit-font-smoothing: auto; @@ -66,29 +66,26 @@ ul, ol { } } -.page-header { - height: 60px; - background-color: #fff; -} - .main-content { - margin: 40px 15px; + margin: 110px 20px 40px; + padding-top: 20px; } .page-container { background-color: #fff; position: relative; - display: table; + display: flex; width: 100%; + overflow: hidden; } .page-content { box-sizing: border-box; - margin-left: 220px; - padding: 0 40px; - display: table-cell; + flex: 1; section { + padding: 0 40px; + > h1, > h2, > h3, @@ -211,9 +208,3 @@ ul, ol { padding: 10px; } } - -.page-footer { - height: 150px; - margin-top: 40px; - background-color: #fff; -} diff --git a/docs/components/mobile-computed.js b/docs/components/mobile-computed.js deleted file mode 100644 index b59fb80e9..000000000 --- a/docs/components/mobile-computed.js +++ /dev/null @@ -1,19 +0,0 @@ -import MobilePopup from 'components/mobile-popup.vue'; - -export default { - components: { - MobilePopup - }, - - computed: { - mobileUrl() { - return '/examples.html#' + location.pathname.slice(4); - } - }, - - data() { - return { - mobileShow: false - }; - } -}; diff --git a/docs/examples-dist/actionsheet.vue b/docs/examples-dist/actionsheet.vue index 7a2418f86..8fe60d92a 100644 --- a/docs/examples-dist/actionsheet.vue +++ b/docs/examples-dist/actionsheet.vue @@ -5,6 +5,8 @@ + +
弹出带取消按钮的actionsheet @@ -12,6 +14,8 @@ + +
弹出带标题的actionsheet @@ -39,7 +43,7 @@ } \ No newline at end of file diff --git a/docs/examples-dist/badge.vue b/docs/examples-dist/badge.vue index 842d0937c..9d0eba259 100644 --- a/docs/examples-dist/badge.vue +++ b/docs/examples-dist/badge.vue @@ -1,15 +1,23 @@ \ No newline at end of file +import Vue from "vue";import ExampleBlock from "components/example-block";Vue.component("example-block", ExampleBlock); \ No newline at end of file diff --git a/docs/examples-dist/card.vue b/docs/examples-dist/card.vue index 7545736c2..df1e123ae 100644 --- a/docs/examples-dist/card.vue +++ b/docs/examples-dist/card.vue @@ -20,4 +20,4 @@ \ No newline at end of file +import Vue from "vue";import ExampleBlock from "components/example-block";Vue.component("example-block", ExampleBlock); \ No newline at end of file diff --git a/docs/examples-dist/cell.vue b/docs/examples-dist/cell.vue index c0649e6a0..7e3a8026b 100644 --- a/docs/examples-dist/cell.vue +++ b/docs/examples-dist/cell.vue @@ -4,11 +4,6 @@ - - - - - @@ -32,22 +27,16 @@ - + \ No newline at end of file +import Vue from "vue";import ExampleBlock from "components/example-block";Vue.component("example-block", ExampleBlock); \ No newline at end of file diff --git a/docs/examples-dist/image-preview.vue b/docs/examples-dist/image-preview.vue index 37389b507..37d71469b 100644 --- a/docs/examples-dist/image-preview.vue +++ b/docs/examples-dist/image-preview.vue @@ -14,15 +14,19 @@ } \ No newline at end of file diff --git a/docs/examples-dist/lazyload.vue b/docs/examples-dist/lazyload.vue new file mode 100644 index 000000000..637093324 --- /dev/null +++ b/docs/examples-dist/lazyload.vue @@ -0,0 +1,78 @@ + + + \ No newline at end of file diff --git a/docs/examples-dist/loading.vue b/docs/examples-dist/loading.vue index ff83d7b07..e2fc134ae 100644 --- a/docs/examples-dist/loading.vue +++ b/docs/examples-dist/loading.vue @@ -1,41 +1,36 @@ - \ No newline at end of file +import Vue from "vue";import ExampleBlock from "components/example-block";Vue.component("example-block", ExampleBlock); \ No newline at end of file diff --git a/docs/examples-dist/quantity.vue b/docs/examples-dist/quantity.vue index 6e9cd6075..939fa032b 100644 --- a/docs/examples-dist/quantity.vue +++ b/docs/examples-dist/quantity.vue @@ -24,7 +24,7 @@ } \ No newline at end of file +import Vue from "vue";import ExampleBlock from "components/example-block";Vue.component("example-block", ExampleBlock); +export default { + data() { + return { + autoImages: [ + 'https://img.yzcdn.cn/upload_files/2017/03/09/FvkZahKoq1vkxLQFdVWeLf2UCqDz.png', + 'https://img.yzcdn.cn/upload_files/2017/03/09/Fk0rpe_svu9d5Xk3MUCWd1QeMXOu.png' + ], + images: [ + 'https://img.yzcdn.cn/upload_files/2017/03/14/FmTPs0SeyQaAOSK1rRe1sL8RcwSY.jpeg', + 'https://img.yzcdn.cn/upload_files/2017/03/15/FvexrWlG_WxtCE9Omo5l27n_mAG_.jpeg' + ] + }; + }, + + methods: { + handlePageEnd(page, index) { + console.log(page, index); + } + } +}; + \ No newline at end of file diff --git a/docs/examples-dist/switch.vue b/docs/examples-dist/switch.vue index 2c07c2cac..cb89d3c1d 100644 --- a/docs/examples-dist/switch.vue +++ b/docs/examples-dist/switch.vue @@ -1,24 +1,32 @@ + + diff --git a/docs/src/components/page-header.vue b/docs/src/components/page-header.vue new file mode 100644 index 000000000..4d333391d --- /dev/null +++ b/docs/src/components/page-header.vue @@ -0,0 +1,123 @@ + + + + + diff --git a/docs/components/side-nav.vue b/docs/src/components/side-nav.vue similarity index 86% rename from docs/components/side-nav.vue rename to docs/src/components/side-nav.vue index fe786fbbf..dd15b876c 100644 --- a/docs/components/side-nav.vue +++ b/docs/src/components/side-nav.vue @@ -2,7 +2,7 @@