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 components = require('./get-components')();
|
||||
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');
|
||||
|
||||
components.forEach(component => {
|
||||
@ -22,7 +30,12 @@ function destEntryFile(component, filename, ext = '') {
|
||||
);
|
||||
|
||||
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 libContent = deps.map(dep => `require('${dep}');`).join('\n');
|
||||
|
||||
|
@ -42,8 +42,8 @@
|
||||
<script>
|
||||
import Field from '../field';
|
||||
import VanButton from '../button';
|
||||
import Dialog from '../dialog';
|
||||
import Toast from '../toast';
|
||||
import Dialog from '../dialog';
|
||||
import validateMobile from '../utils/validate/mobile';
|
||||
import create from '../utils/create';
|
||||
|
||||
|
@ -37,6 +37,7 @@ import NavBar from './nav-bar';
|
||||
import NoticeBar from './notice-bar';
|
||||
import Notify from './notify';
|
||||
import NumberKeyboard from './number-keyboard';
|
||||
import Overlay from './overlay';
|
||||
import Pagination from './pagination';
|
||||
import Panel from './panel';
|
||||
import PasswordInput from './password-input';
|
||||
@ -109,6 +110,7 @@ const components = [
|
||||
NoticeBar,
|
||||
Notify,
|
||||
NumberKeyboard,
|
||||
Overlay,
|
||||
Pagination,
|
||||
Panel,
|
||||
PasswordInput,
|
||||
@ -194,6 +196,7 @@ export {
|
||||
NoticeBar,
|
||||
Notify,
|
||||
NumberKeyboard,
|
||||
Overlay,
|
||||
Pagination,
|
||||
Panel,
|
||||
PasswordInput,
|
||||
|
@ -15,6 +15,7 @@
|
||||
@import './list/index';
|
||||
@import './nav-bar/index';
|
||||
@import './notice-bar/index';
|
||||
@import './overlay/index';
|
||||
@import './popup/index';
|
||||
@import './search/index';
|
||||
@import './pagination/index';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Vue from 'vue';
|
||||
import Modal from './Modal';
|
||||
import context from './context';
|
||||
import Overlay from '../../overlay';
|
||||
|
||||
const defaultConfig = {
|
||||
className: '',
|
||||
@ -35,7 +35,7 @@ export default {
|
||||
let { modal } = context;
|
||||
|
||||
if (!modal) {
|
||||
modal = new (Vue.extend(Modal))({
|
||||
modal = new (Vue.extend(Overlay))({
|
||||
el: document.createElement('div')
|
||||
});
|
||||
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">
|
||||
<div
|
||||
v-show="visible"
|
||||
class="van-modal"
|
||||
class="van-overlay"
|
||||
:class="className"
|
||||
:style="style"
|
||||
@touchmove.prevent.stop
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'modal',
|
||||
name: 'overlay',
|
||||
|
||||
props: {
|
||||
zIndex: Number,
|
@ -1,15 +1,6 @@
|
||||
@import '../style/var';
|
||||
|
||||
.van {
|
||||
&-modal {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
&-overflow-hidden {
|
||||
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', () => {
|
||||
@ -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);
|
||||
modal.click();
|
||||
expect(wrapper.vm.value).toBeFalsy();
|
||||
|
@ -14,3 +14,4 @@
|
||||
@import '../button/index';
|
||||
@import '../cell/index';
|
||||
@import '../cell-group/index';
|
||||
@import '../overlay/index';
|
||||
|
@ -66,6 +66,9 @@
|
||||
@number-keyboard-key-height: 54px;
|
||||
@number-keyboard-key-background: #ebedf0;
|
||||
|
||||
// Overlay
|
||||
@overlay-background-color: rgba(0, 0, 0, 0.7);
|
||||
|
||||
// Radio
|
||||
@radio-size: 20px;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user