From 90e4d4320d4d0e22841e3fcd86ad6ef8bc8a2ed3 Mon Sep 17 00:00:00 2001 From: summer Date: Fri, 4 Aug 2017 18:01:59 +0800 Subject: [PATCH 01/87] =?UTF-8?q?misk:jira#KJDS-59474=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E6=96=87=E6=A1=A3=E7=9A=84=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/source/demo.wrap/index.js | 20 ++++++ doc/source/doc.js | 63 +++++++++++------- doc/themes/nekui/layout/page.ejs | 79 ++++++++++++++++++++++- doc/themes/nekui/source/css/_common.styl | 49 ++++++++++++-- doc/themes/nekui/source/css/page.styl | 2 +- src/js/components/form/KLButton/index.md | 27 ++++++-- src/js/components/layout/KLTable/index.md | 66 +++++++++---------- 7 files changed, 238 insertions(+), 68 deletions(-) create mode 100644 doc/source/demo.wrap/index.js diff --git a/doc/source/demo.wrap/index.js b/doc/source/demo.wrap/index.js new file mode 100644 index 00000000..084a9163 --- /dev/null +++ b/doc/source/demo.wrap/index.js @@ -0,0 +1,20 @@ +/* + demowrap组件,用来包裹组件demo的显示,实现组件代码展开和收缩 + by:wangtan@corp.netease.com +*/ +const DemoWrap = Regular.extend({ + template: '\ +
\ +
\ +
\ +
', + name: 'demo-wrap', + data: { + htmlTpl: '', + showScript: false, + }, + toggle() { + this.data.showScript = !this.data.showScript; + }, +}); +demo \ No newline at end of file diff --git a/doc/source/doc.js b/doc/source/doc.js index c8b2c579..cdb675aa 100644 --- a/doc/source/doc.js +++ b/doc/source/doc.js @@ -3,7 +3,7 @@ * 1、增加头部信息,用于渲染左侧多级菜单 * 2、把组件内的 jsdoc 注释转为 MD 追加到尾部,用于生成 API 文档 * 3、把 DEMO 代码实例化为组件 - * + * * author: Cody Chan 2017-02-08 */ @@ -14,7 +14,7 @@ const jsdoc2md = require('jsdoc-to-markdown'); // 分类的顺序跟下面保持一致,每个分类下的组件顺序不作保证 const CATES = [ - { cate: 'layout', name: '布局' , startOrder: 100 }, + { cate: 'layout', name: '布局', startOrder: 100 }, { cate: 'form', name: '表单', startOrder: 200 }, { cate: 'notice', name: '通知', startOrder: 300 }, { cate: 'navigation', name: '导航', startOrder: 400 }, @@ -25,33 +25,31 @@ const DOC_PATH = __dirname; const COMPONENTS_PATH = path.join(__dirname, '../../src/js/components'); const COMPONENTS_DEST = path.join(DOC_PATH, 'components'); -const getComponents = cate => { +const getComponents = (cate) => { const fullPath = path.join(COMPONENTS_PATH, cate); - return fs.readdirSync(fullPath).filter(f => { - return fs.statSync(path.join(fullPath, f)).isDirectory() - }) -} + return fs.readdirSync(fullPath).filter(f => fs.statSync(path.join(fullPath, f)).isDirectory()); +}; -const getDemoCode = demo => { +const getDemoCode = (demo) => { const rglMatch = /(```(xml|html))([\s\S]*?)(```)/g.exec(demo); const jsMatch = /(```javascript)([\s\S]*?)(```)/g.exec(demo); return { rgl: rglMatch ? rglMatch[3] : '', js: jsMatch ? jsMatch[2] : 'var component = new NEKUI.Component({template: template});', }; -} +}; -const injectComponents = md => { +const injectComponents = (md) => { const demos = []; const reg = /()([\s\S]*?)()/g; let match = reg.exec(md); while (match) { - demos.push(getDemoCode(match[2])) + demos.push(getDemoCode(match[2])); match = reg.exec(md); } if (demos.length === 0) return md; let demosScript = '\n{% raw %}\n\n{% endraw %}'; return md + demosScript; -} +}; const injectAPI = (md, source) => { const docs = jsdoc2md.renderSync({ @@ -72,20 +89,20 @@ const injectAPI = (md, source) => { 'no-cache': true, configure: path.join(__dirname, 'jsdoc.json'), }); - return md + '\n## API\n' + docs; -} + return `${md}\n## API\n${docs}`; +}; const doc = (isDev, callback) => { // 其它文档 if (!isDev) { const mds = glob.sync(path.join(DOC_PATH, '**/*.md')); - mds.forEach(md => { - fs.writeFileSync(md, injectComponents(fs.readFileSync(md, 'utf8'))) - }) + mds.forEach((md) => { + fs.writeFileSync(md, injectComponents(fs.readFileSync(md, 'utf8'))); + }); } // 组件文档 - CATES.forEach(c => { - const components = getComponents(c.cate).filter(comp => { + CATES.forEach((c) => { + const components = getComponents(c.cate).filter((comp) => { const mdPath = path.join(COMPONENTS_PATH, c.cate, comp, 'index.md'); if (fs.existsSync(mdPath)) return true; return false; @@ -104,11 +121,11 @@ const doc = (isDev, callback) => { md = injectAPI(md, fs.readFileSync(jsPath, 'utf8')); } // 插入实例化组件的脚本 - md = injectComponents(md) + md = injectComponents(md); fs.writeFileSync(path.join(COMPONENTS_DEST, `${c.cate}_${comp}_.md`), md); - }) + }); }); callback && callback(); -} +}; module.exports = doc; diff --git a/doc/themes/nekui/layout/page.ejs b/doc/themes/nekui/layout/page.ejs index 375a5c54..d0258a5c 100644 --- a/doc/themes/nekui/layout/page.ejs +++ b/doc/themes/nekui/layout/page.ejs @@ -7,7 +7,23 @@ <% } %> -
+
+ <% if(page.masonry) { %> + + <% } %> <%- page.content %> + <% if(page.masonry) { %> + + <% } %> +
diff --git a/doc/themes/nekui/source/css/_common.styl b/doc/themes/nekui/source/css/_common.styl index 0efacd2a..96ac4b63 100644 --- a/doc/themes/nekui/source/css/_common.styl +++ b/doc/themes/nekui/source/css/_common.styl @@ -180,8 +180,49 @@ a.button border-left 4px solid transparent border-right 4px solid transparent border-top 5px solid #ccc - +.grid-item + width: auto; + border: 1px solid #E1E6EC; + margin: 20px 10px; + border-radius: 4px; .m-example - border 1px dashed #eee - margin 5px - padding 5px \ No newline at end of file + padding: 10px 10px 30px 10px; +.m-code + .highlight + background-color: #fff; +.m-demowrap + border-top: 1px solid #e1e6ec; + .m-iconLine + position: relative; + text-align: center; + color: #B2BFCF; + top: -10px; + .revert + transform: rotate(180deg); + -ms-transform: rotate(180deg); + -webkit-transform: rotate(180deg); + -o-transform: rotate(180deg); + -moz-transform: rotate(180deg); + color: #E31436; + border: 1px solid #E31436; + .m-iconOuter + display: inline-block; + width: 17px; + height: 17px; + line-height: 20px; + border: 1px solid #B2BFCF; + border-radius: 9px; + background-color: #fff; + transition: transform 0.5s; + -ms-transition: transform 0.5s; + -webkit-transition: transform 0.5s; + -o-transition: transform 0.5s; + -moz-transition: transform 0.5s; + &:hover + color: #E31436; + border: 1px solid #E31436; + .m-codeBlock + overflow: hidden; + .wrap + height: 10px; + \ No newline at end of file diff --git a/doc/themes/nekui/source/css/page.styl b/doc/themes/nekui/source/css/page.styl index ebcdcef3..6480bcfb 100644 --- a/doc/themes/nekui/source/css/page.styl +++ b/doc/themes/nekui/source/css/page.styl @@ -9,7 +9,7 @@ .content position relative padding 2.2em 0 - max-width 800px + max-width 1000px margin 0 auto &.api > a:first-of-type > h2 diff --git a/src/js/components/form/KLButton/index.md b/src/js/components/form/KLButton/index.md index 8eb06623..eefdb96b 100644 --- a/src/js/components/form/KLButton/index.md +++ b/src/js/components/form/KLButton/index.md @@ -1,12 +1,16 @@ --- title: 按钮 +masonry: true --- ## 代码演示 -### 基本形式 +
+ +### 基本形式 +
```xml @@ -34,11 +38,13 @@ var component = new NEKUI.Component({ template: template }); ``` + + + ### 常用的button类型 -
```xml @@ -68,11 +74,13 @@ var component = new NEKUI.Component({
``` + + + ### 圆角的图标按钮 -
```xml @@ -84,11 +92,13 @@ var component = new NEKUI.Component({ ``` + + + ### 图标按钮 -
```xml @@ -100,11 +110,13 @@ var component = new NEKUI.Component({ ``` + + + ### 加载中的按钮 -
```xml @@ -112,11 +124,13 @@ var component = new NEKUI.Component({ ``` + + + ### buttonGroup -
```xml @@ -127,4 +141,5 @@ var component = new NEKUI.Component({ ``` + diff --git a/src/js/components/layout/KLTable/index.md b/src/js/components/layout/KLTable/index.md index add2eb01..793fa8e5 100644 --- a/src/js/components/layout/KLTable/index.md +++ b/src/js/components/layout/KLTable/index.md @@ -4,9 +4,9 @@ title: 表格 ## 代码演示 + ### 基本 -
```xml @@ -37,13 +37,12 @@ var component = new NEKUI.Component({ ``` + ### 显示配置项 1. 无条纹:`strip={false}` 2. 占位符:默认`placeholder="-"` 3. 对齐:默认 `align="center"` - -
```xml @@ -77,11 +76,11 @@ var component = new NEKUI.Component({ ``` + ### 过滤器 `filter` 接收一个 `function`,依次可以取得参数 `val`,`item`,`itemIndex`。 -
```xml @@ -118,9 +117,9 @@ var component = new NEKUI.Component({ ``` + ### 多级表头 -
```xml @@ -160,13 +159,13 @@ var component = new NEKUI.Component({ ``` + ### 悬浮表头和底部 控制表头和底部的悬浮需要对 `scroll` 事件进行监听,在默认的情况下,监听对象是 `window`,即页面的滚动。 如果页面布局比较特殊,需要指定监听的对象,则可以通过 `scrollParent` 指定会发生滚动的容器,如 `scrollParent="#example"`。 -
```xml @@ -202,9 +201,9 @@ var component = new NEKUI.Component({ ``` + ### 表头固定在表格顶部 -
```xml @@ -235,9 +234,9 @@ var component = new NEKUI.Component({ ``` + ### 固定列 -
```xml @@ -270,6 +269,7 @@ var component = new NEKUI.Component({ ``` + ### 自定义模版与filter 通过 `kl-table-template` 组件定义单元格和表头的模版,可以将模版内嵌到组件中,也可以将模版注入到组件的 `template` 属性。 @@ -284,7 +284,6 @@ var component = new NEKUI.Component({ `kl-table-col`上亦可以直接传入对应的模版属性, `template`,`headerTemplate`,`formatter`,`headerFormatter`,`format`,`headerFormat`。 -
```xml @@ -354,11 +353,11 @@ var component = new NEKUI.Component({ ``` + ### 自定义行样式 通过设置 `item.rowClass` 或 `item.rowStyle` 修改每一行的样式。 -
```xml @@ -391,11 +390,11 @@ var component = new NEKUI.Component({ ``` + ### 排序 没有实际的排序效果,请查看 console 打印的事件对象。 -
```xml @@ -433,10 +432,11 @@ var component = new NEKUI.Component({ ``` + ### 分页 分页的配置参考 [分页 Pager](/components/navigation_pager_.html) 。 - +
```xml @@ -475,11 +475,11 @@ var component = new NEKUI.Component({ ``` + ### 多选 通过 `enableCheckAll` -
```xml @@ -514,6 +514,7 @@ var component = new NEKUI.Component({ ``` + ### 数据配置 在进行数据配置时,模版的配置方式更为灵活。 @@ -524,7 +525,6 @@ var component = new NEKUI.Component({ 加上前缀 `header` 成为 `headerTemplate`,`headerFormat`,`headerFormatter`,可作为表头的模版。 -
```xml @@ -598,10 +598,9 @@ var component = new NEKUI.Component({ ``` - + ### 空数据 -
```xml @@ -622,9 +621,9 @@ var component = new NEKUI.Component({ ``` + ### 加载中 -
```xml @@ -645,28 +644,13 @@ var component = new NEKUI.Component({ ``` -### 特殊 - -由于组件内部有部分模版是使用字符串形式存储,只有在使用时才是进行解析,因此当页面对 `Regular` 的插值符号进行修改时,需要进行特殊处理。 - -为了向组件内部传递新修改的插值,需要在 `Regular` 下挂载两个新的属性 `_BEGIN_`, `_END_`。 - -```javascript -Regular._BEGIN_ = '{{'; -Regular._END_ = '}}'; -Regular.config({ - BEGIN: Regular._BEGIN_, - END: Regular._END_ -}); -``` - + ### 模版中获取外部数据的方法 由于组件的设计结构比较特殊,表格中表头和内容分别是两个独立的组件,因此 `kl-table` 上挂载的属性无法直接传递到表头和内容当中。 如有需要取得外部的数据,则需要通过 `this.$table.data` 或者 `this.$tableData` 去获取。 -
```xml @@ -705,3 +689,19 @@ var component = new NEKUI.Component({ ``` +### 特殊 + +由于组件内部有部分模版是使用字符串形式存储,只有在使用时才是进行解析,因此当页面对 `Regular` 的插值符号进行修改时,需要进行特殊处理。 + +为了向组件内部传递新修改的插值,需要在 `Regular` 下挂载两个新的属性 `_BEGIN_`, `_END_`。 + + +```javascript +Regular._BEGIN_ = '{{'; +Regular._END_ = '}}'; +Regular.config({ + BEGIN: Regular._BEGIN_, + END: Regular._END_ +}); +``` + From e2e7ccc84312b26250bc933f9c555c05d64199e3 Mon Sep 17 00:00:00 2001 From: summer Date: Mon, 7 Aug 2017 16:26:00 +0800 Subject: [PATCH 02/87] =?UTF-8?q?misk:jira#KJDS-59474=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E6=96=87=E6=A1=A3=E7=9A=84=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/package.json | 2 +- doc/source/demo.wrap/index.js | 13 +++++++------ doc/themes/nekui/layout/layout.ejs | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/package.json b/doc/package.json index f371e4ff..51889102 100644 --- a/doc/package.json +++ b/doc/package.json @@ -12,4 +12,4 @@ "hexo-renderer-stylus": "^0.3.1", "hexo-server": "^0.2.0" } -} \ No newline at end of file +} diff --git a/doc/source/demo.wrap/index.js b/doc/source/demo.wrap/index.js index 084a9163..c4f7440b 100644 --- a/doc/source/demo.wrap/index.js +++ b/doc/source/demo.wrap/index.js @@ -2,12 +2,14 @@ demowrap组件,用来包裹组件demo的显示,实现组件代码展开和收缩 by:wangtan@corp.netease.com */ +/* eslint no-unused-vars: 0 */ +/* eslint no-undef: 0 */ const DemoWrap = Regular.extend({ - template: '\ -
\ -
\ -
\ -
', + template: ` +
+
+
+
`, name: 'demo-wrap', data: { htmlTpl: '', @@ -17,4 +19,3 @@ const DemoWrap = Regular.extend({ this.data.showScript = !this.data.showScript; }, }); -demo \ No newline at end of file diff --git a/doc/themes/nekui/layout/layout.ejs b/doc/themes/nekui/layout/layout.ejs index 2431e6f7..abc2bbfb 100644 --- a/doc/themes/nekui/layout/layout.ejs +++ b/doc/themes/nekui/layout/layout.ejs @@ -24,6 +24,7 @@ +
> From 150be10df02f4a107e44b1cbb04257480b0747ca Mon Sep 17 00:00:00 2001 From: LzxHahaha Date: Tue, 8 Aug 2017 14:37:48 +0800 Subject: [PATCH 03/87] update footer --- doc/themes/nekui/layout/page.ejs | 12 ++++- doc/themes/nekui/source/css/_settings.styl | 3 ++ doc/themes/nekui/source/css/page.styl | 43 +++++++++++++++--- doc/themes/nekui/source/images/pager-left.png | Bin 0 -> 357 bytes .../nekui/source/images/pager-right.png | Bin 0 -> 359 bytes 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 doc/themes/nekui/source/images/pager-left.png create mode 100644 doc/themes/nekui/source/images/pager-right.png diff --git a/doc/themes/nekui/layout/page.ejs b/doc/themes/nekui/layout/page.ejs index d0258a5c..b3e7ab23 100644 --- a/doc/themes/nekui/layout/page.ejs +++ b/doc/themes/nekui/layout/page.ejs @@ -27,10 +27,18 @@ <%- page.content %>