Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try template-css in DragDrop plugin #239

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/bundled-example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1>Uppy is here</h1>
</form>
</div>

<link href="uppy.min.css" rel="stylesheet">
<!--link href="uppy.min.css" rel="stylesheet"-->
<script src="bundle.js"></script>
</body>
</html>
47 changes: 25 additions & 22 deletions examples/bundled-example/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const Uppy = require('../../src/core/Core.js')
const Dashboard = require('../../src/plugins/Dashboard')
const GoogleDrive = require('../../src/plugins/GoogleDrive')
const Dropbox = require('../../src/plugins/Dropbox')
const Webcam = require('../../src/plugins/Webcam')
// const Dashboard = require('../../src/plugins/Dashboard')
// const GoogleDrive = require('../../src/plugins/GoogleDrive')
// const Dropbox = require('../../src/plugins/Dropbox')
// const Webcam = require('../../src/plugins/Webcam')
const Tus10 = require('../../src/plugins/Tus10')
// const Multipart = require('../../src/plugins/Multipart')
const MetaData = require('../../src/plugins/MetaData')
// const Informer = require('../../src/plugins/Informer')
// const StatusBar = require('../../src/plugins/StatusBar')
// const DragDrop = require('../../src/plugins/DragDrop')
const DragDrop = require('../../src/plugins/DragDrop')

const PROTOCOL = location.protocol === 'https:' ? 'https' : 'http'
const TUS_ENDPOINT = PROTOCOL + '://master.tus.io/files/'
Expand All @@ -18,29 +18,32 @@ const TUS_ENDPOINT = PROTOCOL + '://master.tus.io/files/'
// import PersistentState from '../../src/plugins/PersistentState'

const uppy = Uppy({debug: true, autoProceed: false})
.use(Dashboard, {
trigger: '#uppyModalOpener',
// maxWidth: 350,
// maxHeight: 400,
// inline: false,
// disableStatusBar: true,
// disableInformer: true,
// .use(Dashboard, {
// trigger: '#uppyModalOpener',
// // maxWidth: 350,
// // maxHeight: 400,
// // inline: false,
// // disableStatusBar: true,
// // disableInformer: true,
// target: 'body',
// locale: {
// strings: {browse: 'wow'}
// }
// })
// .use(GoogleDrive, {target: Dashboard, host: 'http://localhost:3020'})
// .use(Dropbox, {target: Dashboard, host: 'http://localhost:3020'})
// .use(FileInput, {target: '.Uppy', locale: {
// strings: {selectToUpload: 'Выберите файл для загрузки'}
// }})
.use(DragDrop, {
target: 'body',
locale: {
strings: {browse: 'wow'}
strings: {chooseFile: 'Выберите файл'}
}
})
.use(GoogleDrive, {target: Dashboard, host: 'http://localhost:3020'})
.use(Dropbox, {target: Dashboard, host: 'http://localhost:3020'})
// .use(FileInput, {target: '.Uppy', locale: {
// strings: {selectToUpload: 'Выберите файл для загрузки'}
// }})
// .use(DragDrop, {target: 'body', locale: {
// strings: {chooseFile: 'Выберите файл'}
// }})
// .use(ProgressBar, {target: 'body'})
// .use(dummy)
.use(Webcam, {target: Dashboard})
// .use(Webcam, {target: Dashboard})
// .use(Multipart, {endpoint: '//api2.transloadit.com'})
.use(Tus10, {endpoint: TUS_ENDPOINT, resume: true})
// .use(Informer, {target: Dashboard})
Expand Down
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"on-load": "3.2.0",
"prettier-bytes": "1.0.4",
"socket.io-client": "2.0.1",
"template-css": "github:arturi/template-css",
"tus-js-client": "1.4.3",
"url-parse": "1.1.9",
"whatwg-fetch": "2.0.3",
Expand Down
71 changes: 71 additions & 0 deletions src/plugins/DragDrop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Translator = require('../../core/Translator')
const { toArray } = require('../../core/Utils')
const dragDrop = require('drag-drop')
const html = require('yo-yo')
const css = require('template-css')

/**
* Drag & Drop plugin
Expand Down Expand Up @@ -110,6 +111,74 @@ module.exports = class DragDrop extends Plugin {
})
}

style () {
// these will be global styles variables,
// with an option to override them to support themes
const settings = {
fontSizes: {
normal: '1.2em'
},
colors: {
gray: '#ccc'
}
}

css`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder why Github isn't highlighting this, I thought it also did that for css tags 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I remember that too.

.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: ${settings.colors.gray};
}

.UppyDragDrop-container.is-dragdrop-supported .UppyDragDrop-dragText {
display: inline;
}

.UppyDragDrop-container.drag {
border-color: ${settings.colors.gray};
}

/* 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: ${settings.fontSizes.normal};
}

.UppyDragDrop-selectedCount {
text-align: center;
font-size: 0.75em;
text-transform: uppercase;
letter-spacing: 1px;
margin-top: 10px;
}

.UppyDragDrop-dragText {
display: none;
}
`
}

render (state) {
const onSelect = (ev) => {
const input = this.target.querySelector('.UppyDragDrop-input')
Expand Down Expand Up @@ -143,6 +212,8 @@ module.exports = class DragDrop extends Plugin {
}

install () {
this.style()

const target = this.opts.target
const plugin = this
this.target = this.mount(target, plugin)
Expand Down
18 changes: 0 additions & 18 deletions src/scss/_dragdrop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,3 @@
.UppyDragDrop-dragText {
display: none;
}

// .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;
// }
// }
2 changes: 1 addition & 1 deletion src/scss/uppy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@import '_fileinput.scss';
@import '_informer.scss';
@import '_dashboard.scss';
@import '_dragdrop.scss';
// @import '_dragdrop.scss';
@import '_provider.scss';
@import '_progressbar.scss';
@import '_statusbar.scss';
Expand Down