[new feature] support addGlobalClass (#449)

This commit is contained in:
neverland 2018-08-21 15:53:31 +08:00 committed by GitHub
parent e2d428d8cd
commit db76bdeef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 127 additions and 35 deletions

View File

@ -1,3 +1,3 @@
.content {
padding: 20px;
}
}

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
properties: {
show: Boolean,
title: String,

View File

@ -1,6 +1,10 @@
const BADGE_PATH = '../badge/index';
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
relations: {

View File

@ -1,6 +1,10 @@
const BADGE_GROUP_PATH = '../badge-group/index';
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
relations: {

View File

@ -6,6 +6,10 @@ const observer = function() {
};
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class', 'loading-class'],
behaviors: [nativeBehaviors],

View File

@ -1,6 +1,7 @@
Component({
options: {
multipleSlots: true
multipleSlots: true,
addGlobalClass: true
},
externalClasses: [

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {

View File

@ -9,7 +9,8 @@ Component({
],
options: {
multipleSlots: true
multipleSlots: true,
addGlobalClass: true
},
properties: {

View File

@ -1,6 +1,10 @@
const ROW_PATH = '../row/index';
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
relations: {

View File

@ -6,7 +6,8 @@ Component({
],
options: {
multipleSlots: true
multipleSlots: true,
addGlobalClass: true
},
properties: {

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {

View File

@ -5,7 +5,8 @@ Component({
],
options: {
multipleSlots: true
multipleSlots: true,
addGlobalClass: true
},
properties: {

View File

@ -3,6 +3,10 @@ const FONT_COLOR = '#f60';
const BG_COLOR = '#fff7cc';
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {

View File

@ -1,4 +1,10 @@
import Notify from './notify';
Component({
options: {
addGlobalClass: true
},
properties: {
text: String,
color: {
@ -40,28 +46,4 @@ Component({
}
});
const defaultOptions = {
selector: '#van-notify',
duration: 3000
};
export default function Notify(options = {}) {
const pages = getCurrentPages();
const ctx = pages[pages.length - 1];
options = Object.assign({}, defaultOptions, parseParam(options));
const el = ctx.selectComponent(options.selector);
delete options.selector;
if (el) {
el.setData({
...options
});
el.show();
}
}
function parseParam(params = '') {
return typeof params === 'object' ? params : { text: params };
}
export default Notify;

25
packages/notify/notify.js Normal file
View File

@ -0,0 +1,25 @@
const defaultOptions = {
selector: '#van-notify',
duration: 3000
};
export default function Notify(options = {}) {
const pages = getCurrentPages();
const ctx = pages[pages.length - 1];
options = Object.assign({}, defaultOptions, parseParam(options));
const el = ctx.selectComponent(options.selector);
delete options.selector;
if (el) {
el.setData({
...options
});
el.show();
}
}
function parseParam(params = '') {
return typeof params === 'object' ? params : { text: params };
}

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
properties: {
show: Boolean,
mask: Boolean,

View File

@ -5,7 +5,8 @@ Component({
],
options: {
multipleSlots: true
multipleSlots: true,
addGlobalClass: true
},
properties: {

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: [
'custom-class',
'overlay-class'

View File

@ -1,6 +1,10 @@
const COL_PATH = '../col/index';
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
relations: {

View File

@ -2,7 +2,8 @@ Component({
externalClasses: ['custom-class', 'cancel-class'],
options: {
multipleSlots: true
multipleSlots: true,
addGlobalClass: true
},
properties: {

View File

@ -3,6 +3,10 @@
const MAX = 2147483647;
Component({
options: {
addGlobalClass: true
},
externalClasses: [
'custom-class',
'input-class',

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: [
'custom-class'
],

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class', 'node-class'],
properties: {

View File

@ -1,8 +1,6 @@
const TABBAR_PATH = '../tabbar/index';
Component({
name: 'tabbar-item',
properties: {
info: null,
icon: String,
@ -10,7 +8,8 @@ Component({
},
options: {
multipleSlots: true
multipleSlots: true,
addGlobalClass: true
},
relations: {

View File

@ -1,6 +1,10 @@
const ITEM_PATH = '../tabbar-item/index';
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {

View File

@ -1,6 +1,10 @@
import Toast from './toast';
Component({
options: {
addGlobalClass: true
},
properties: {
show: Boolean,
mask: Boolean,

View File

@ -1,4 +1,8 @@
Component({
options: {
addGlobalClass: true
},
externalClasses: ['custom-class'],
properties: {

View File

@ -1,6 +1,10 @@
const ITEM_HEIGHT = 44;
Component({
options: {
addGlobalClass: true
},
properties: {
items: {
type: Array,