From d862935dfb4474311a71894c5e1eb031236c1468 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 13:58:08 -0400 Subject: [PATCH 1/8] stop logging STATE so much --- src/core/Core.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/Core.js b/src/core/Core.js index b15fccc1d7..517dcf71fb 100644 --- a/src/core/Core.js +++ b/src/core/Core.js @@ -137,7 +137,6 @@ class Uppy { * @param {patch} object */ setState (patch) { - console.log('STATE') const prevState = Object.assign({}, this.state) const nextState = Object.assign({}, this.state, patch) From f2261be74ebdced7341819a51726039aab28c5f4 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 14:12:20 -0400 Subject: [PATCH 2/8] redesign DragDrop, add `note`, width/height options, arrow icon --- src/plugins/DragDrop/index.js | 63 +++++++++------- src/scss/_dragdrop.scss | 138 +++++++++++++++++----------------- 2 files changed, 104 insertions(+), 97 deletions(-) diff --git a/src/plugins/DragDrop/index.js b/src/plugins/DragDrop/index.js index 40cea2dc44..29b2013feb 100644 --- a/src/plugins/DragDrop/index.js +++ b/src/plugins/DragDrop/index.js @@ -24,13 +24,12 @@ module.exports = class DragDrop extends Plugin { const defaultLocale = { strings: { - chooseFile: 'Choose a file', - orDragDrop: 'or drop it here', - upload: 'Upload', - selectedFiles: { - 0: '%{smart_count} file selected', - 1: '%{smart_count} files selected' - } + dropHere: 'Drop files here', + orBrowse: 'or browse' + // selectedFiles: { + // 0: '%{smart_count} file selected', + // 1: '%{smart_count} files selected' + // } } } @@ -38,6 +37,9 @@ module.exports = class DragDrop extends Plugin { const defaultOpts = { target: null, getMetaFromForm: true, + width: '100%', + height: '100%', + note: '', locale: defaultLocale } @@ -84,7 +86,7 @@ module.exports = class DragDrop extends Plugin { } handleDrop (files) { - this.core.log('All right, someone dropped something...') + this.core.log('[DragDrop] Files dropped') files.forEach((file) => { this.core.addFile({ @@ -97,7 +99,7 @@ module.exports = class DragDrop extends Plugin { } handleInputChange (ev) { - this.core.log('All right, something selected through input...') + this.core.log('[DragDrop] Files selected through input') const files = toArray(ev.target.files) @@ -113,36 +115,41 @@ module.exports = class DragDrop extends Plugin { render (state) { const onSelect = (ev) => { - const input = this.target.querySelector('.UppyDragDrop-input') + const input = this.target.querySelector('.uppy-DragDrop-input') input.click() } - const selectedFilesCount = Object.keys(state.files).length + // const selectedFilesCount = Object.keys(state.files).length return html` -
-
ev.preventDefault()}> - + ev.preventDefault()}> + + -
` } + // ${selectedFilesCount > 0 + // ? html`
+ // ${this.i18n('selectedFiles', {'smart_count': selectedFilesCount})} + //
` + // : ''} + install () { const target = this.opts.target const plugin = this @@ -151,10 +158,14 @@ module.exports = class DragDrop extends Plugin { } } + uninstall () { + this.unmount() + } + mount (...args) { super.mount(...args) - const dndContainer = this.target.querySelector('.UppyDragDrop-container') + const dndContainer = this.target.querySelector('.uppy-DragDrop-container') this.removeDragDropListener = dragDrop(dndContainer, (files) => { this.handleDrop(files) this.core.log(files) @@ -166,8 +177,4 @@ module.exports = class DragDrop extends Plugin { super.unmount(...args) } - - uninstall () { - this.unmount() - } } diff --git a/src/scss/_dragdrop.scss b/src/scss/_dragdrop.scss index 034c9f39af..1c37dde748 100644 --- a/src/scss/_dragdrop.scss +++ b/src/scss/_dragdrop.scss @@ -1,76 +1,76 @@ -// @import '_variables.scss'; -// @import '_utils.scss'; -// @import '_animation.scss'; -// @import '_common.scss'; +// .Uppy { -.UppyDragDrop-container { - min-height: 100px; - display: flex; - align-items: center; - justify-content: center; - border-radius: 10px; -} - -.UppyDragDrop-inner { - margin: 0; -} - - .UppyDragDrop-container.is-dragdrop-supported { - border: 2px dashed; - border-color: lighten($color-gray, 20%); + .uppy-DragDrop-container { + display: flex; + align-items: center; + justify-content: center; + border-radius: 10px; + background-color: $color-white; } - - .UppyDragDrop-container.is-dragdrop-supported .UppyDragDrop-dragText { - display: inline; + + .uppy-DragDrop-inner { + margin: 0; + text-align: center; + padding: 80px 0; } - - .UppyDragDrop-container.drag { - border-color: $color-gray; - // background-color: #dbf5f3; + + .uppy-DragDrop-arrow { + width: 60px; + height: 60px; + fill: lighten($color-gray, 30%); + margin-bottom: 25px; } + + .uppy-DragDrop-container.is-dragdrop-supported { + border: 2px dashed; + border-color: lighten($color-gray, 10%); + } + + // .uppy-DragDrop-container.is-dragdrop-supported .uppy-DragDrop-dragText { + // display: inline; + // } + + .uppy-DragDrop-container.drag { + border-color: $color-gray; + background-color: darken($color-white, 10%); + } -/* http://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/ */ -.UppyDragDrop-input { - width: 0.1px; - height: 0.1px; - opacity: 0; - overflow: hidden; - position: absolute; - z-index: -1; -} - -.UppyDragDrop-label { - display: block; - cursor: pointer; - font-size: 1.2em; -} - -.UppyDragDrop-selectedCount { - text-align: center; - font-size: 0.75em; - text-transform: uppercase; - letter-spacing: 1px; - margin-top: 10px; -} + .uppy-DragDrop-container.drag .uppy-DragDrop-arrow { + fill: $color-gray; + } + + /* http://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/ */ + .uppy-DragDrop-input { + width: 0.1px; + height: 0.1px; + opacity: 0; + overflow: hidden; + position: absolute; + z-index: -1; + } + + .uppy-DragDrop-label { + display: block; + cursor: pointer; + font-size: 1.15em; + margin-bottom: 10px; + } -.UppyDragDrop-dragText { - display: none; -} + .uppy-DragDrop-note { + font-size: 1em; + color: lighten($color-gray, 10%); + } + + // .uppy-DragDrop-selectedCount { + // text-align: center; + // font-size: 0.75em; + // text-transform: uppercase; + // letter-spacing: 1px; + // margin-top: 10px; + // } + + .uppy-DragDrop-dragText { + color: $color-cornflower-blue; + } -// .UppyDragDrop-uploadBtn { -// display: block; -// margin: auto; -// padding: 5px 15px; -// font-size: 12px; -// text-transform: uppercase; -// letter-spacing: 1px; -// border: 0; -// border: 1px solid $color-gray; -// background: none; -// cursor: pointer; -// margin-top: 15px; -// -// &:hover { -// background: $color-gray; -// } -// } +// } \ No newline at end of file From 561c16aa0a7890992012e625dbf3e39875c10852 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 14:17:19 -0400 Subject: [PATCH 3/8] update DragDrop acceptance test --- test/acceptance/dragdrop.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/acceptance/dragdrop.spec.js b/test/acceptance/dragdrop.spec.js index de2e21a2ce..a99b3a977c 100644 --- a/test/acceptance/dragdrop.spec.js +++ b/test/acceptance/dragdrop.spec.js @@ -26,11 +26,11 @@ module.exports = function (driver, platform, host) { } else { console.log('selecting a real file') // Make file input “visible” - driver.executeScript('document.querySelector(".UppyDragDrop-One .UppyDragDrop-input").style.opacity = 1') + driver.executeScript('document.querySelector(".UppyDragDrop-One .uppy-DragDrop-input").style.opacity = 1') // Find input by css selector & pass absolute image path to it driver - .findElement({css: '.UppyDragDrop-One .UppyDragDrop-input'}) + .findElement({css: '.UppyDragDrop-One .uppy-DragDrop-input'}) .sendKeys(path.join(__dirname, 'image.jpg')) } From cac58579b6189180a1ae93263c356050d0a650e1 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 14:28:11 -0400 Subject: [PATCH 4/8] fix i18n test --- test/acceptance/i18n.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/acceptance/i18n.spec.js b/test/acceptance/i18n.spec.js index 23e8aa69b9..8a675bd147 100644 --- a/test/acceptance/i18n.spec.js +++ b/test/acceptance/i18n.spec.js @@ -13,7 +13,7 @@ module.exports = function (driver, platform, host) { tools.setSauceTestName(driver, testName) function findLabelTextElement () { - return driver.findElements({css: '.UppyDragDrop-label'}).then(function (result) { + return driver.findElements({css: '.uppy-DragDrop-label'}).then(function (result) { return result[0] }) } From 8071579833ae5a6f0f5d8571b16a31563c46ded4 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 14:43:17 -0400 Subject: [PATCH 5/8] fix i18n --- website/src/examples/i18n/app.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/src/examples/i18n/app.html b/website/src/examples/i18n/app.html index 7763cf3a7a..d69be69188 100644 --- a/website/src/examples/i18n/app.html +++ b/website/src/examples/i18n/app.html @@ -11,8 +11,8 @@ target: '.UppyDragDrop', locale: { strings: { - chooseFile: 'Выберите файл', - orDragDrop: 'или перенесите его сюда' + dropHere: 'Перенесите файлы сюда', + orBrowse: 'или выберите' } } }); From 6c1253f75e8672a890bb329a14a586a18c179865 Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 16:41:47 -0400 Subject: [PATCH 6/8] tweak styles --- src/scss/_dragdrop.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scss/_dragdrop.scss b/src/scss/_dragdrop.scss index 1c37dde748..b71e913e1d 100644 --- a/src/scss/_dragdrop.scss +++ b/src/scss/_dragdrop.scss @@ -4,7 +4,7 @@ display: flex; align-items: center; justify-content: center; - border-radius: 10px; + border-radius: 7px; background-color: $color-white; } @@ -18,7 +18,7 @@ width: 60px; height: 60px; fill: lighten($color-gray, 30%); - margin-bottom: 25px; + margin-bottom: 20px; } .uppy-DragDrop-container.is-dragdrop-supported { From d9485b44d0e9a34b89688672cc7d8d07e4b724ef Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 16:41:59 -0400 Subject: [PATCH 7/8] alter locale a little --- src/plugins/DragDrop/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/DragDrop/index.js b/src/plugins/DragDrop/index.js index 29b2013feb..a209c3109f 100644 --- a/src/plugins/DragDrop/index.js +++ b/src/plugins/DragDrop/index.js @@ -24,8 +24,8 @@ module.exports = class DragDrop extends Plugin { const defaultLocale = { strings: { - dropHere: 'Drop files here', - orBrowse: 'or browse' + dropHereOr: 'Drop files here or', + browse: 'browse' // selectedFiles: { // 0: '%{smart_count} file selected', // 1: '%{smart_count} files selected' @@ -135,8 +135,8 @@ module.exports = class DragDrop extends Plugin { value="" onchange=${this.handleInputChange.bind(this)} /> ${this.opts.note} From 8b4f8d4da02ca0756ba924723514ba9cc5c6ff1e Mon Sep 17 00:00:00 2001 From: Artur Paikin Date: Tue, 3 Oct 2017 16:42:08 -0400 Subject: [PATCH 8/8] fix tests for locale --- test/acceptance/i18n.spec.js | 4 ++-- website/src/examples/i18n/app.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/acceptance/i18n.spec.js b/test/acceptance/i18n.spec.js index 8a675bd147..d9ee97b064 100644 --- a/test/acceptance/i18n.spec.js +++ b/test/acceptance/i18n.spec.js @@ -2,7 +2,7 @@ var test = require('tape') var tools = require('./tools') module.exports = function (driver, platform, host) { - var testName = 'i18n: load with Russian language pack' + var testName = 'i18n: load DragDrop with Russian localization strings' test(tools.prettyTestName(testName, platform), function (t) { t.plan(1) @@ -24,7 +24,7 @@ module.exports = function (driver, platform, host) { // why trim? Microsoft Edge: // expected: 'Выберите файл или перенесите его сюда' // actual: 'Выберите файл или перенесите его сюда ' - var expectedValue = 'Выберите файл или перенесите его сюда' + var expectedValue = 'Перенесите файлы сюда или выберите' console.log(value, '/', expectedValue) tools.testEqual(driver, t, value.trim() === expectedValue) driver.quit() diff --git a/website/src/examples/i18n/app.html b/website/src/examples/i18n/app.html index d69be69188..35a83ee84d 100644 --- a/website/src/examples/i18n/app.html +++ b/website/src/examples/i18n/app.html @@ -11,8 +11,8 @@ target: '.UppyDragDrop', locale: { strings: { - dropHere: 'Перенесите файлы сюда', - orBrowse: 'или выберите' + dropHereOr: 'Перенесите файлы сюда или', + browse: 'выберите' } } });