调整目录结构

This commit is contained in:
Nino 2016-12-19 17:06:08 +08:00
parent 6224c000eb
commit 486981c741
25 changed files with 136 additions and 67 deletions

20
.editorconfig Normal file
View File

@ -0,0 +1,20 @@
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.wxml]
indent_size = 2
[*.wxss]
indent_size = 2
[*.js]
indent_size = 2
[*.json]
indent_size = 2

43
.eslintrc Normal file
View File

@ -0,0 +1,43 @@
{
"extends": "airbnb",
"globals": {
"getApp": false,
"Page": false,
"App": false,
"wx": false
},
"parser": "babel-eslint",
"rules": {
"no-extend-native": 0,
"no-shadow": 0,
"no-loop-func": 0,
"no-console": 0,
"no-var": 0,
"vars-on-top": 0,
"new-cap": 0,
"no-used-var": 0,
"semi": [
1,
"always",
{
"omitLastInOneLineBlock": true
}
],
"camelcase": 1,
"prefer-template": 0,
"eqeqeq": 0,
"max-len": 0,
"react/prefer-stateless-function": 0,
"comma-dangle": 0,
"func-names": 0,
"prefer-const": 0,
"arrow-body-style": 0,
"no-param-reassign": 0,
"no-return-assign": 0,
"consistent-return": 0,
"no-unused-expressions": 0,
"no-underscore-dangle": 0,
"no-use-before-define": 0,
"no-new": 0
}
}

View File

@ -1,4 +1,6 @@
Page({
var ZUI = require('../../zui/index');
Page(Object.assign({}, ZUI.Tab, {
data: {
tab1: {
list: [{
@ -45,26 +47,13 @@ Page({
}
},
_handleComponentTabChange(e) {
var dataset = e.currentTarget.dataset;
var componentId = dataset.componentId;
var selectedId = dataset.itemId;
if (this.handleComponentTabChange) {
this.handleComponentTabChange({
componentId,
selectedId
});
}
},
handleComponentTabChange(e) {
console.log('[handleComponentTabChange]', e);
var componentId = e.componentId;
handleZuiTabChange(e) {
console.info('[ZUI:Tab:Change]', e);
var id = e.id;
var selectedId = e.selectedId;
this.setData({
[`${componentId}.selectedId`]: selectedId
[`${id}.selectedId`]: selectedId
});
}
});
}));

View File

@ -1,36 +1,10 @@
<template name="component-tab">
<view class="zui-tab">
<block wx:if="{{tab.scroll}}">
<scroll-view class="zui-tab__bd zui-tab__bd--scroll {{fixed ? 'zui-tab__bd--fixed' : ''}}" scroll-x="true">
<template is="component-tab-list" data="{{ tab, componentId }}"></template>
</scroll-view>
</block>
<block wx:else>
<view class="zui-tab__bd">
<template is="component-tab-list" data="{{ tab, componentId }}"></template>
</view>
</block>
</view>
</template>
<template name="component-tab-list">
<view
wx:for="{{tab.list}}"
wx:key="id"
class="zui-tab__item {{tab.selectedId == item.id ? 'zui-tab__item--selected' : ''}}"
data-component-id="{{componentId}}"
data-item-id="{{item.id}}"
bindtap="_handleComponentTabChange"
>
<view class="zui-tab__title">{{item.title}}</view>
</view>
</template>
<import src="/zui/tab/index.wxml" />
<view class="container">
<view style="margin: 20px 0">
<template is="component-tab" data="{{tab: tab1, componentId: 'tab1'}}"></template>
<template is="zui-tab" data="{{tab: tab1, id: 'tab1'}}"></template>
</view>
<view style="margin: 20px 0">
<template is="component-tab" data="{{tab: tab2, componentId: 'tab2'}}"></template>
<template is="zui-tab" data="{{tab: tab2, id: 'tab2'}}"></template>
</view>
</view>

View File

@ -18,6 +18,9 @@
.zui-btn::after {
display: none;
}
.zui-btns {
margin: 15px;
}
/* type */
.zui-btn--primary {

View File

@ -1,3 +0,0 @@
.zui-btns {
margin: 15px;
}

1
zui/index.js Normal file
View File

@ -0,0 +1 @@
exports.Tab = require('./tab/index');

View File

@ -1,16 +1,15 @@
@import "loadmore.wxss";
@import "color.wxss";
@import "helper.wxss";
@import "panel.wxss";
@import "btn.wxss";
@import "btns.wxss";
@import "cell.wxss";
@import "namecard.wxss";
@import "badge.wxss";
@import "dialog.wxss";
@import "form.wxss";
@import "tab.wxss";
@import "label.wxss";
@import "quantity.wxss";
@import "steps.wxss";
@import "toast.wxss";
@import "loadmore/index.wxss";
@import "color/index.wxss";
@import "helper/index.wxss";
@import "panel/index.wxss";
@import "btn/index.wxss";
@import "cell/index.wxss";
@import "namecard/index.wxss";
@import "badge/index.wxss";
@import "dialog/index.wxss";
@import "form/index.wxss";
@import "tab/index.wxss";
@import "label/index.wxss";
@import "quantity/index.wxss";
@import "steps/index.wxss";
@import "toast/index.wxss";

16
zui/tab/index.js Normal file
View File

@ -0,0 +1,16 @@
var Tab = {
_handleZuiTabChange(e) {
var dataset = e.currentTarget.dataset;
var id = dataset.id;
var selectedId = dataset.itemId;
if (this.handleZuiTabChange) {
this.handleZuiTabChange({
id,
selectedId
});
}
}
};
module.exports = Tab;

27
zui/tab/index.wxml Normal file
View File

@ -0,0 +1,27 @@
<template name="zui-tab">
<view class="zui-tab">
<block wx:if="{{tab.scroll}}">
<scroll-view class="zui-tab__bd zui-tab__bd--scroll {{fixed ? 'zui-tab__bd--fixed' : ''}}" scroll-x="true">
<template is="zui-tab-list" data="{{ tab, id }}"></template>
</scroll-view>
</block>
<block wx:else>
<view class="zui-tab__bd">
<template is="zui-tab-list" data="{{ tab, id }}"></template>
</view>
</block>
</view>
</template>
<template name="zui-tab-list">
<view
wx:for="{{tab.list}}"
wx:key="id"
class="zui-tab__item {{tab.selectedId == item.id ? 'zui-tab__item--selected' : ''}}"
data-id="{{id}}"
data-item-id="{{item.id}}"
bindtap="_handleZuiTabChange"
>
<view class="zui-tab__title">{{item.title}}</view>
</view>
</template>