mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-25 11:14:05 +00:00
refactor ActionBrowseTagline into a component
This commit is contained in:
parent
0f2258e990
commit
fdffdb0cb8
3 changed files with 34 additions and 35 deletions
|
|
@ -1,33 +1,32 @@
|
|||
const { h } = require('preact')
|
||||
const { h, Component } = require('preact')
|
||||
const hyperx = require('hyperx')
|
||||
const html = hyperx(h)
|
||||
|
||||
let inputEl
|
||||
|
||||
module.exports = (props) => {
|
||||
const input = html`
|
||||
<input class="UppyDashboard-input"
|
||||
hidden="true"
|
||||
aria-hidden="true"
|
||||
tabindex="-1"
|
||||
type="file"
|
||||
name="files[]"
|
||||
multiple="true"
|
||||
onchange=${props.handleInputChange}
|
||||
ref=${(input) => {
|
||||
inputEl = input
|
||||
}} />`
|
||||
|
||||
return html`
|
||||
<span>
|
||||
${props.acquirers.length === 0
|
||||
? props.i18n('dropPaste')
|
||||
: props.i18n('dropPasteImport')
|
||||
}
|
||||
<button type="button"
|
||||
class="UppyDashboard-browse"
|
||||
onclick=${(ev) => inputEl.click()}>${props.i18n('browse')}</button>
|
||||
${input}
|
||||
</span>
|
||||
`
|
||||
class ActionBrowseTagline extends Component {
|
||||
render () {
|
||||
return html`
|
||||
<span>
|
||||
${this.props.acquirers.length === 0
|
||||
? this.props.i18n('dropPaste')
|
||||
: this.props.i18n('dropPasteImport')
|
||||
}
|
||||
<button type="button"
|
||||
class="UppyDashboard-browse"
|
||||
onclick=${(ev) => this.input.click()}>${this.props.i18n('browse')}</button>
|
||||
<input class="UppyDashboard-input"
|
||||
hidden="true"
|
||||
aria-hidden="true"
|
||||
tabindex="-1"
|
||||
type="file"
|
||||
name="files[]"
|
||||
multiple="true"
|
||||
onchange=${this.props.handleInputChange}
|
||||
ref=${(input) => {
|
||||
this.input = input
|
||||
}} />
|
||||
</span>
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ActionBrowseTagline
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module.exports = (props) => {
|
|||
? html`<div class="UppyDashboard-bgIcon">
|
||||
${dashboardBgIcon()}
|
||||
<h3 class="UppyDashboard-dropFilesTitle">
|
||||
${ActionBrowseTagline({
|
||||
${h(ActionBrowseTagline, {
|
||||
acquirers: props.acquirers,
|
||||
handleInputChange: props.handleInputChange,
|
||||
i18n: props.i18n
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ module.exports = (props) => {
|
|||
return html`
|
||||
<div class="UppyDashboardTabs" aria-hidden="${isHidden}">
|
||||
<h3 class="UppyDashboardTabs-title">
|
||||
${ActionBrowseTagline({
|
||||
acquirers: props.acquirers,
|
||||
handleInputChange: props.handleInputChange,
|
||||
i18n: props.i18n
|
||||
})}
|
||||
${h(ActionBrowseTagline, {
|
||||
acquirers: props.acquirers,
|
||||
handleInputChange: props.handleInputChange,
|
||||
i18n: props.i18n
|
||||
})}
|
||||
</h3>
|
||||
</div>
|
||||
`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue