Improve file thumbnails.

This commit is contained in:
Andrey Antukh 2020-01-08 11:12:12 +01:00
parent ab4171b8ec
commit 97d49e53b7
4 changed files with 38 additions and 37 deletions

View file

@ -69,25 +69,25 @@
;; (mf/defc grid-item-thumbnail
;; [{:keys [file] :as props}]
;; [:div.grid-item-th
;; [:img.img-th {:src "/images/project-placeholder.svg"}]])
;; (let [url (mf/use-memo
;; {:fn #(let [content (exports/render file)
;; blob (js/Blob. #js [content] #js {:type "image/svg+xml"})]
;; (js/URL.createObjectURL blob))
;; :deps (mf/deps (:id file))})]
;; (mf/use-effect
;; {:fn (fn []
;; #(js/URL.revokeObjectURL url))
;; :deps (mf/deps (:id file))})
;; [:div.grid-item-th
;; [:img.img-th {:src url}]]))
;; (defn use-thumbnail
;; [file]
(mf/defc grid-item-thumbnail
[{:keys [file] :as props}]
(let [url (mf/use-memo
{:fn #(let [content (exports/render file)
blob (js/Blob. #js [content] #js {:type "image/svg+xml"})]
(js/URL.createObjectURL blob))
:deps (mf/deps (:id file))})]
(mf/use-effect
{:fn (fn []
#(js/URL.revokeObjectURL url))
:deps (mf/deps (:id file))})
[:div.grid-item-th
[:img.img-th {:src url}]]))
[:div.grid-item-th
[:& exports/page-svg2 {:data (:data file)
:width "290"
:height "150"}]])
;; --- Grid Item