mirror of
https://github.com/penpot/penpot.git
synced 2025-06-14 07:51:38 +02:00
✨ Remove add image modal, upload image directly
This commit is contained in:
parent
bee4e5177c
commit
bbf3bc7909
5 changed files with 81 additions and 231 deletions
39
frontend/src/uxbox/main/ui/components/file_uploader.cljs
Normal file
39
frontend/src/uxbox/main/ui/components/file_uploader.cljs
Normal file
|
@ -0,0 +1,39 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
(ns uxbox.main.ui.components.file-uploader
|
||||
(:require
|
||||
[rumext.alpha :as mf]
|
||||
[uxbox.main.data.workspace :as dw]
|
||||
[uxbox.main.store :as st]
|
||||
[uxbox.util.dom :as dom]))
|
||||
|
||||
(mf/defc file-uploader
|
||||
[{:keys [accept multi label-text label-class input-id input-ref on-selected] :as props}]
|
||||
(let [opt-pick-one #(if multi % (first %))
|
||||
|
||||
on-files-selected (fn [event] (st/emit!
|
||||
(-> (dom/get-target event)
|
||||
(dom/get-files)
|
||||
(array-seq)
|
||||
(opt-pick-one)
|
||||
(on-selected))))]
|
||||
[:*
|
||||
(when label-text
|
||||
[:label {:for input-id :class-name label-class} label-text])
|
||||
|
||||
[:input
|
||||
{:style {:display "none"}
|
||||
:id input-id
|
||||
:multiple multi
|
||||
:accept accept
|
||||
:type "file"
|
||||
:ref input-ref
|
||||
:on-change on-files-selected}]]))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue