-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
This PR silently tries to utilize [template-css](https://github.com/arturi/template-css) in DragDrop plugin only. DragDrop styles are removed from uppy.css bundle and added through JS instead. This also opens a door to themable UI and shared (style) variables in JS, so we can use them for inline CSS or regular class-css or wherever: ```js style () { const settings = { fontSizes: { normal: '1.2em' }, colors: { gray: '#ccc' } } css` .UppyDragDrop-container.drag { border-color: ${settings.colors.gray}; } .UppyDragDrop-label { display: block; cursor: pointer; font-size: ${settings.fontSizes.normal}; } ` } ``` Preprocessors via babel plugin and postcss are not utilized yet.
} | ||
} | ||
|
||
css` |
There was a problem hiding this comment.
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 😕
There was a problem hiding this comment.
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.
Some potential issues with this approach:
Maybe we could do something like this, splitting up the base styles and the themed styles: // Add base CSS once on load
css`
.UppyDragDrop {
// default styles
}
`
class DragDrop extends Plugin {
constructor () {
// …
this.themeId = somethingUnpredictable()
}
style () {
// add themed stuff here
this.css = css`
.UppyDragDrop-${this.themeId} {
border-color: ${this.opts.theme.borderColor};
}
`
}
render () {
return `<div className="UppyDragDrop UppyDragDrop-${this.themeId}"> ... </div>`
}
install () {
this.style()
// ...
}
uninstall () {
this.css.removeTheThemeCssSomehow()
}
} Or we could keep it simpler without the JS-based theming for a start … or maybe there's a way to do it that I'm not seeing 🤷♀️ |
Yes, valid points. Thanks! I’ll get back to this after the release then, it seems we better hold this off for a little longer. |
Dropping this here so we remember: https://www.npmjs.com/package/postcss-prefix-selector |
Closing for now, it’s been open for two long with no activity. |
This PR tries to silently utilize template-css in DragDrop
plugin only. DragDrop styles are removed from uppy.css bundle and added through JS instead.
This also opens a door to themeable UI and shared (style) variables in JS, so we can use them for inline CSS or regular class-css or wherever:
Preprocessors via babel plugin and postcss are not utilized yet.