From 0aaf2df436118f0e0170af6173165f2b539c9ddc Mon Sep 17 00:00:00 2001 From: baiyaaaaa Date: Sat, 20 Aug 2016 18:27:37 +0800 Subject: [PATCH] update upload --- examples/docs/upload.md | 122 ++++--- .../theme-default/src/common/transition.css | 50 ++- packages/theme-default/src/common/var.css | 5 + packages/theme-default/src/upload.css | 69 +++- packages/upload/index.js | 2 +- packages/upload/src/index.vue | 204 ++++++++++++ packages/upload/src/upload-list.vue | 37 ++ packages/upload/src/upload.vue | 315 +++++++----------- 8 files changed, 530 insertions(+), 274 deletions(-) create mode 100644 packages/upload/src/index.vue create mode 100644 packages/upload/src/upload-list.vue diff --git a/examples/docs/upload.md b/examples/docs/upload.md index 939af4eb4..d9a8bc84f 100644 --- a/examples/docs/upload.md +++ b/examples/docs/upload.md @@ -7,33 +7,6 @@ .demo-box { margin-bottom: 24px; } - .el-draggeer__uploaded-image__btns { - margin-top: 45px; - color: #fff; - font-size: 14px; - - & .btn { - display: inline-block; - - & span { - opacity: 0; - transition: opacity .15s linear; - } - - &:not(:first-child) { - margin-left: 35px; - } - - &:hover span { - opacity: 1; - } - } - & i { - display: block; - font-size: 26px; - margin-bottom: 5px; - } - } ``` ## 拖拽文件上传
- +
只能上传jpg/png文件,且不超过500kb
```html - +
只能上传jpg/png文件,且不超过500kb
+ ``` ## 图片缩略图模式 @@ -83,23 +101,39 @@ 上传文件类型限制为只能上传图片,并可展示本地缩略图,该模式暂不支持多选
- -
- 分享图片 - 删除 -
+
只能上传jpg/png文件,且不超过500kb
```html - -
- 分享图片 - 删除 -
+
只能上传jpg/png文件,且不超过500kb
+ ``` ## API @@ -113,6 +147,8 @@ | showUploadList | 是否显示已上传文件列表 | boolean | | true | | type | 上传控件类型 | string | select,drag | select | | accept | 可选参数, 接受上传的[文件类型](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept), 拖拽文件上传时不受此参数影响 | string | | | -| filechange | 可选参数, 上传文件改变时的回调 | function(file, fileList, event) | | | -| fileremove | 可选参数, 文件列表移除文件时的回调 | function(file, fileList) | | | +| onPreview | 可选参数, 点击已上传的文件链接时的钩子 | function(file) | | | +| onRemove | 可选参数, 文件列表移除文件时的钩子 | function(file, fileList) | | | +| beforeUpload | 可选参数, 上传文件之前的钩子,参数为上传的文件,若返回 false 或者 Promise 则停止上传。 | function(file) | | | +| thumbnailMode | 是否设置为图片模式,该模式下会显示图片缩略图 | boolean | | false | | type | 上传控件类型 | string | select,drag | select | diff --git a/packages/theme-default/src/common/transition.css b/packages/theme-default/src/common/transition.css index 402b4c10c..bc522d3ff 100644 --- a/packages/theme-default/src/common/transition.css +++ b/packages/theme-default/src/common/transition.css @@ -1,25 +1,24 @@ @charset "UTF-8"; @import './var.css'; -.fade-in-transition { - opacity: 1; - transition: var(--fade-transition); -} - -.fade-in-linear-enter-active { - opacity: 1; +.fade-in-linear-enter-active, +.fade-in-linear-leave-active { transition: var(--fade-linear-transition); } +.fade-in-linear-enter, +.fade-in-linear-leave, .fade-in-linear-leave-active { opacity: 0; - transition: var(--fade-linear-transition); +} + +.fade-in-enter-active, +.fade-in-leave-active { + transition: all .3s cubic-bezier(.55,0,.1,1); } .fade-in-enter, -.fade-in-leave, -.fade-in-linear-enter, -.fade-in-linear-leave { +.fade-in-leave-active { opacity: 0; } @@ -96,28 +95,19 @@ transition: opacity .3s cubic-bezier(.645,.045,.355,1); } .fade-enter, -.fade-leave, .fade-leave-active { opacity: 0; } -.slide-in-bottom-enter { - animation: slideInBottomEnter .3s; +.list-move, .list-enter-active, .list-leave-active { + transition: all .5s cubic-bezier(.55,0,.1,1); } -.slide-in-bottom-leave { - animation: slideInBottomLeave .3s; -} - -@keyframes slideInBottomEnter { - 0% { - opacity: 0; - transform: translate3d(0,50%,0); - } -} - -@keyframes slideInBottomLeave { - to { - opacity: 0; - transform: translate3d(0,50%,0); - } +.list-enter, .list-leave-active { + opacity: 0; + transform: translate(0, -30px); } +/*.list-leave-active { + position: absolute; + opacity: 0; + transform: scaleY(0.01) translate(30px, 0); +}*/ diff --git a/packages/theme-default/src/common/var.css b/packages/theme-default/src/common/var.css index 0fd174f67..e213d2463 100644 --- a/packages/theme-default/src/common/var.css +++ b/packages/theme-default/src/common/var.css @@ -23,6 +23,11 @@ --color-black: #000; --color-grey: #C0CCDA; + /* Link + -------------------------- */ + --link-color: #475669; + --link-hover-color: var(--color-primary); + /* Border -------------------------- */ --border-width-base: 1px; diff --git a/packages/theme-default/src/upload.css b/packages/theme-default/src/upload.css index d5125c888..bdd287fab 100644 --- a/packages/theme-default/src/upload.css +++ b/packages/theme-default/src/upload.css @@ -19,6 +19,7 @@ margin-bottom: 10px; } @e file { + transition: all .5s cubic-bezier(.55,0,.1,1); font-size: 14px; color: #475669; line-height: 32px; @@ -33,21 +34,16 @@ text-overflow: ellipsis; position: relative; + a { + color: #475669; + transition: color .3s; + } [class^="el-icon"] { color: #99a9bf; margin-right: 7px; height: 100%; line-height: inherit; } - - &:hover { - background-color: #eff2f7; - - .el-upload__btn-delete { - display: block; - cursor: pointer; - } - } & .el-progress { position: absolute; bottom: 0; @@ -61,6 +57,21 @@ top: 0; height: 100%; } + &:hover { + background-color: #eff2f7; + } + @when finished { + & a:hover { + color: var(--link-hover-color); + cursor: pointer; + } + &:hover { + .el-upload__btn-delete { + display: block; + cursor: pointer; + } + } + } } @e tip { font-size: 12px; @@ -125,6 +136,7 @@ height: 100%; overflow: hidden; z-index: 10; + cursor: default; & img { display: block; @@ -140,6 +152,45 @@ height: 100%; background-color: rgba(#000, .72); text-align: center; + + & .btn { + display: inline-block; + color: #fff; + font-size: 14px; + cursor: pointer; + vertical-align: middle; + transition: var(--md-fade-transition); + margin-top: 60px; + + & i { + margin-top: 0; + } + + & span { + opacity: 0; + transition: opacity .15s linear; + } + + &:not(:first-child) { + margin-left: 35px; + } + + &:hover { + transform: translateY(-13px); + + & span { + opacity: 1; + } + } + + & i { + color: #fff; + display: block; + font-size: 24px; + line-height: inherit; + margin: 0 auto 5px; + } + } } @e title { diff --git a/packages/upload/index.js b/packages/upload/index.js index 5c575d081..479df11f1 100644 --- a/packages/upload/index.js +++ b/packages/upload/index.js @@ -1,4 +1,4 @@ -const Upload = require('./src/upload'); +const Upload = require('./src/index'); Upload.install = function(Vue) { Vue.component(Upload.name, Upload); diff --git a/packages/upload/src/index.vue b/packages/upload/src/index.vue new file mode 100644 index 000000000..59127e0f1 --- /dev/null +++ b/packages/upload/src/index.vue @@ -0,0 +1,204 @@ + diff --git a/packages/upload/src/upload-list.vue b/packages/upload/src/upload-list.vue new file mode 100644 index 000000000..d23b130f1 --- /dev/null +++ b/packages/upload/src/upload-list.vue @@ -0,0 +1,37 @@ + + diff --git a/packages/upload/src/upload.vue b/packages/upload/src/upload.vue index 3fc7ef2e5..b50df404a 100644 --- a/packages/upload/src/upload.vue +++ b/packages/upload/src/upload.vue @@ -1,187 +1,103 @@