mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] move overlay component (#2192)
This commit is contained in:
parent
996c67b4fc
commit
89ff50944c
@ -6,7 +6,15 @@ const fs = require('fs-extra');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const components = require('./get-components')();
|
const components = require('./get-components')();
|
||||||
const dependencyTree = require('dependency-tree');
|
const dependencyTree = require('dependency-tree');
|
||||||
const whiteList = ['info', 'icon', 'loading', 'cell', 'cell-group', 'button'];
|
const whiteList = [
|
||||||
|
'info',
|
||||||
|
'icon',
|
||||||
|
'loading',
|
||||||
|
'cell',
|
||||||
|
'cell-group',
|
||||||
|
'button',
|
||||||
|
'overlay'
|
||||||
|
];
|
||||||
const dir = path.join(__dirname, '../es');
|
const dir = path.join(__dirname, '../es');
|
||||||
|
|
||||||
components.forEach(component => {
|
components.forEach(component => {
|
||||||
@ -22,7 +30,12 @@ function destEntryFile(component, filename, ext = '') {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const esEntry = path.join(dir, component, `style/${filename}`);
|
const esEntry = path.join(dir, component, `style/${filename}`);
|
||||||
const libEntry = path.join(__dirname, '../lib', component, `style/${filename}`);
|
const libEntry = path.join(
|
||||||
|
__dirname,
|
||||||
|
'../lib',
|
||||||
|
component,
|
||||||
|
`style/${filename}`
|
||||||
|
);
|
||||||
const esContent = deps.map(dep => `import '${dep}';`).join('\n');
|
const esContent = deps.map(dep => `import '${dep}';`).join('\n');
|
||||||
const libContent = deps.map(dep => `require('${dep}');`).join('\n');
|
const libContent = deps.map(dep => `require('${dep}');`).join('\n');
|
||||||
|
|
||||||
|
@ -42,8 +42,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import Field from '../field';
|
import Field from '../field';
|
||||||
import VanButton from '../button';
|
import VanButton from '../button';
|
||||||
import Dialog from '../dialog';
|
|
||||||
import Toast from '../toast';
|
import Toast from '../toast';
|
||||||
|
import Dialog from '../dialog';
|
||||||
import validateMobile from '../utils/validate/mobile';
|
import validateMobile from '../utils/validate/mobile';
|
||||||
import create from '../utils/create';
|
import create from '../utils/create';
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import NavBar from './nav-bar';
|
|||||||
import NoticeBar from './notice-bar';
|
import NoticeBar from './notice-bar';
|
||||||
import Notify from './notify';
|
import Notify from './notify';
|
||||||
import NumberKeyboard from './number-keyboard';
|
import NumberKeyboard from './number-keyboard';
|
||||||
|
import Overlay from './overlay';
|
||||||
import Pagination from './pagination';
|
import Pagination from './pagination';
|
||||||
import Panel from './panel';
|
import Panel from './panel';
|
||||||
import PasswordInput from './password-input';
|
import PasswordInput from './password-input';
|
||||||
@ -109,6 +110,7 @@ const components = [
|
|||||||
NoticeBar,
|
NoticeBar,
|
||||||
Notify,
|
Notify,
|
||||||
NumberKeyboard,
|
NumberKeyboard,
|
||||||
|
Overlay,
|
||||||
Pagination,
|
Pagination,
|
||||||
Panel,
|
Panel,
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
@ -194,6 +196,7 @@ export {
|
|||||||
NoticeBar,
|
NoticeBar,
|
||||||
Notify,
|
Notify,
|
||||||
NumberKeyboard,
|
NumberKeyboard,
|
||||||
|
Overlay,
|
||||||
Pagination,
|
Pagination,
|
||||||
Panel,
|
Panel,
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
@import './list/index';
|
@import './list/index';
|
||||||
@import './nav-bar/index';
|
@import './nav-bar/index';
|
||||||
@import './notice-bar/index';
|
@import './notice-bar/index';
|
||||||
|
@import './overlay/index';
|
||||||
@import './popup/index';
|
@import './popup/index';
|
||||||
@import './search/index';
|
@import './search/index';
|
||||||
@import './pagination/index';
|
@import './pagination/index';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import Modal from './Modal';
|
|
||||||
import context from './context';
|
import context from './context';
|
||||||
|
import Overlay from '../../overlay';
|
||||||
|
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
className: '',
|
className: '',
|
||||||
@ -35,7 +35,7 @@ export default {
|
|||||||
let { modal } = context;
|
let { modal } = context;
|
||||||
|
|
||||||
if (!modal) {
|
if (!modal) {
|
||||||
modal = new (Vue.extend(Modal))({
|
modal = new (Vue.extend(Overlay))({
|
||||||
el: document.createElement('div')
|
el: document.createElement('div')
|
||||||
});
|
});
|
||||||
modal.$on('click', this.onClick);
|
modal.$on('click', this.onClick);
|
||||||
|
10
packages/overlay/index.less
Normal file
10
packages/overlay/index.less
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
@import '../style/var';
|
||||||
|
|
||||||
|
.van-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: @overlay-background-color;
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
<transition name="van-fade">
|
<transition name="van-fade">
|
||||||
<div
|
<div
|
||||||
v-show="visible"
|
v-show="visible"
|
||||||
class="van-modal"
|
class="van-overlay"
|
||||||
:class="className"
|
:class="className"
|
||||||
:style="style"
|
:style="style"
|
||||||
@touchmove.prevent.stop
|
@touchmove.prevent.stop
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'modal',
|
name: 'overlay',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
zIndex: Number,
|
zIndex: Number,
|
@ -1,15 +1,6 @@
|
|||||||
@import '../style/var';
|
@import '../style/var';
|
||||||
|
|
||||||
.van {
|
.van {
|
||||||
&-modal {
|
|
||||||
position: fixed;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
background-color: rgba(0, 0, 0, 0.7);
|
|
||||||
}
|
|
||||||
|
|
||||||
&-overflow-hidden {
|
&-overflow-hidden {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ test('render overlay', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(div.querySelector('.van-modal')).toBeTruthy();
|
expect(div.querySelector('.van-overlay')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('close on click modal', () => {
|
test('close on click modal', () => {
|
||||||
@ -136,7 +136,7 @@ test('close on click modal', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const modal = div.querySelector('.van-modal');
|
const modal = div.querySelector('.van-overlay');
|
||||||
triggerDrag(modal, 0, -30);
|
triggerDrag(modal, 0, -30);
|
||||||
modal.click();
|
modal.click();
|
||||||
expect(wrapper.vm.value).toBeFalsy();
|
expect(wrapper.vm.value).toBeFalsy();
|
||||||
|
@ -14,3 +14,4 @@
|
|||||||
@import '../button/index';
|
@import '../button/index';
|
||||||
@import '../cell/index';
|
@import '../cell/index';
|
||||||
@import '../cell-group/index';
|
@import '../cell-group/index';
|
||||||
|
@import '../overlay/index';
|
||||||
|
@ -66,6 +66,9 @@
|
|||||||
@number-keyboard-key-height: 54px;
|
@number-keyboard-key-height: 54px;
|
||||||
@number-keyboard-key-background: #ebedf0;
|
@number-keyboard-key-background: #ebedf0;
|
||||||
|
|
||||||
|
// Overlay
|
||||||
|
@overlay-background-color: rgba(0, 0, 0, 0.7);
|
||||||
|
|
||||||
// Radio
|
// Radio
|
||||||
@radio-size: 20px;
|
@radio-size: 20px;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user