popup component

This commit is contained in:
cookfront
2017-02-15 21:03:07 +08:00
parent 8f474da314
commit 82bb27896e
15 changed files with 673 additions and 4 deletions
+8
View File
@@ -0,0 +1,8 @@
## 0.0.2 (2017-01-20)
* 改了bug A
* 加了功能B
## 0.0.1 (2017-01-10)
* 第一版
+26
View File
@@ -0,0 +1,26 @@
# @youzan/<%= name %>
!!! 请在此处填写你的文档最简单描述 !!!
[![version][version-image]][download-url]
[![download][download-image]][download-url]
[version-image]: http://npm.qima-inc.com/badge/v/@youzan/<%= name %>.svg?style=flat-square
[download-image]: http://npm.qima-inc.com/badge/d/@youzan/<%= name %>.svg?style=flat-square
[download-url]: http://npm.qima-inc.com/package/@youzan/<%= name %>
## Demo
## Usage
## API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|-----------|-----------|-----------|-------------|-------------|
| className | 自定义额外类名 | string | '' | '' |
## License
[MIT](https://opensource.org/licenses/MIT)
+3
View File
@@ -0,0 +1,3 @@
import Popup from './src/popup';
export default Popup;
+10
View File
@@ -0,0 +1,10 @@
{
"name": "<%= name %>",
"version": "<%= version %>",
"description": "<%= description %>",
"main": "./lib/index.js",
"author": "<%= author %>",
"license": "<%= license %>",
"devDependencies": {},
"dependencies": {}
}
+71
View File
@@ -0,0 +1,71 @@
<template>
<transition :name="currentTransition">
<div v-show="currentValue" class="o2-popup" :class="[position ? 'o2-popup--' + position : '']">
<slot></slot>
</div>
</transition>
</template>
<script>
import Popup from 'src/mixins/popup';
export default {
name: 'o2-popup',
mixins: [Popup],
props: {
overlay: {
default: true
},
lockOnScroll: {
default: false
},
closeOnClickOverlay: {
default: true
},
transition: {
type: String,
default: 'popup-slide'
},
position: {
type: String,
default: ''
}
},
data() {
return {
currentValue: false,
currentTransition: this.transition
};
},
watch: {
currentValue(val) {
this.$emit('input', val);
},
value(val) {
this.currentValue = val;
}
},
beforeMount() {
if (this.transition !== 'popup-fade') {
this.currentTransition = `popup-slide-${ this.position }`;
}
},
mounted() {
if (this.value) {
this.currentValue = true;
this.open();
}
}
};
</script>
+1
View File
@@ -5,4 +5,5 @@
@import './cell.pcss';
@import './field.pcss';
@import './icon.pcss';
@import './popup.pcss';
@import './switch.pcss';
+75
View File
@@ -0,0 +1,75 @@
.v-modal {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.701961);
}
@component-namespace o2 {
@component popup {
position: fixed;
background-color: #fff;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0);
backface-visibility: hidden;
transition: .2s ease-out;
@modifier top {
top: 0;
right: auto;
bottom: auto;
left: 50%;
transform: translate3d(-50%, 0, 0);
}
@modifier right {
top: 50%;
right: 0;
bottom: auto;
left: auto;
transform: translate3d(0, -50%, 0);
}
@modifier bottom {
top: auto;
bottom: 0;
right: auto;
left: 50%;
transform: translate3d(-50%, 0, 0);
}
@modifier left {
top: 50%;
right: auto;
bottom: auto;
left: 0;
transform: translate3d(0, -50%, 0);
}
}
}
.popup-slide-top-enter,
.popup-slide-top-leave-active {
transform: translate3d(-50%, -100%, 0);
}
.popup-slide-right-enter,
.popup-slide-right-leave-active {
transform: translate3d(100%, -50%, 0);
}
.popup-slide-bottom-enter,
.popup-slide-bottom-leave-active {
transform: translate3d(-50%, 100%, 0);
}
.popup-slide-left-enter, .popup-slide-left-leave-active {
transform: translate3d(-100%, -50%, 0);
}
.popup-fade-enter, .popup-fade-leave-active {
opacity: 0;
}