Fix linter issues on frontend (part 3).

This commit is contained in:
Andrey Antukh 2021-06-17 16:06:32 +02:00 committed by Andrés Moya
parent 3e4e54870b
commit 30e77556db
42 changed files with 183 additions and 307 deletions

View file

@ -15,7 +15,6 @@
"app/util/perf.cljs" "app/util/perf.cljs"
"app/util/import/.*" "app/util/import/.*"
"app/worker/.*" "app/worker/.*"
"app/main/ui.*"
"app/libs/.*" "app/libs/.*"
"app/main/data/workspace/path/selection.cljs" "app/main/data/workspace/path/selection.cljs"
"app/main/data/workspace/transforms.cljs" "app/main/data/workspace/transforms.cljs"

View file

@ -6,38 +6,27 @@
(ns app.main.ui.auth (ns app.main.ui.auth
(:require (:require
[app.common.uuid :as uuid]
[app.main.data.messages :as dm]
[app.main.data.users :as du]
[app.main.repo :as rp]
[app.main.store :as st]
[app.main.ui.auth.login :refer [login-page]] [app.main.ui.auth.login :refer [login-page]]
[app.main.ui.auth.recovery :refer [recovery-page]] [app.main.ui.auth.recovery :refer [recovery-page]]
[app.main.ui.auth.recovery-request :refer [recovery-request-page]] [app.main.ui.auth.recovery-request :refer [recovery-request-page]]
[app.main.ui.auth.register :refer [register-page register-success-page register-validate-page]] [app.main.ui.auth.register :refer [register-page register-success-page register-validate-page]]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.forms :as fm] [app.util.i18n :as i18n :refer [tr]]
[app.util.i18n :as i18n :refer [t]]
[app.util.router :as rt]
[app.util.timers :as ts]
[beicon.core :as rx]
[cljs.spec.alpha :as s]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc auth (mf/defc auth
[{:keys [route] :as props}] [{:keys [route] :as props}]
(let [section (get-in route [:data :name]) (let [section (get-in route [:data :name])
locale (mf/deref i18n/locale)
params (:query-params route)] params (:query-params route)]
(mf/use-effect (mf/use-effect
#(dom/set-html-title (t locale "title.default"))) #(dom/set-html-title (tr "title.default")))
[:div.auth [:div.auth
[:section.auth-sidebar [:section.auth-sidebar
[:a.logo {:href "#/"} i/logo] [:a.logo {:href "https://penpot.app"} i/logo]
[:span.tagline (t locale "auth.sidebar-tagline")]] [:span.tagline (tr "auth.sidebar-tagline")]]
[:section.auth-content [:section.auth-content
(case section (case section
@ -54,10 +43,10 @@
[:& login-page {:params params}] [:& login-page {:params params}]
:auth-recovery-request :auth-recovery-request
[:& recovery-request-page {:locale locale}] [:& recovery-request-page]
:auth-recovery :auth-recovery
[:& recovery-page {:locale locale :params params}]) [:& recovery-page {:params params}])
[:div.terms-login [:div.terms-login
[:a {:href "https://penpot.app/terms.html" :target "_blank"} "Terms of service"] [:a {:href "https://penpot.app/terms.html" :target "_blank"} "Terms of service"]

View file

@ -16,8 +16,7 @@
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.main.ui.messages :as msgs] [app.main.ui.messages :as msgs]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :refer [tr t]] [app.util.i18n :refer [tr]]
[app.util.object :as obj]
[app.util.router :as rt] [app.util.router :as rt]
[beicon.core :as rx] [beicon.core :as rx]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
@ -74,7 +73,7 @@
on-submit on-submit
(mf/use-callback (mf/use-callback
(mf/deps form) (mf/deps form)
(fn [event] (fn [_]
(reset! error nil) (reset! error nil)
(let [params (with-meta (:clean-data @form) (let [params (with-meta (:clean-data @form)
{:on-error on-error})] {:on-error on-error})]

View file

@ -11,12 +11,9 @@
[app.main.data.users :as du] [app.main.data.users :as du]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.forms :as fm] [app.main.ui.components.forms :as fm]
[app.main.ui.icons :as i] [app.util.i18n :as i18n :refer [tr]]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [t tr]]
[app.util.router :as rt] [app.util.router :as rt]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(s/def ::password-1 ::us/not-empty-string) (s/def ::password-1 ::us/not-empty-string)
@ -40,7 +37,7 @@
(assoc :password-1 {:message "errors.password-too-short"})))) (assoc :password-1 {:message "errors.password-too-short"}))))
(defn- on-error (defn- on-error
[form error] [_form _error]
(st/emit! (dm/error (tr "auth.notifications.invalid-token-error")))) (st/emit! (dm/error (tr "auth.notifications.invalid-token-error"))))
(defn- on-success (defn- on-success
@ -49,7 +46,7 @@
(rt/nav :auth-login))) (rt/nav :auth-login)))
(defn- on-submit (defn- on-submit
[form event] [form _event]
(let [mdata {:on-error on-error (let [mdata {:on-error on-error
:on-success on-success} :on-success on-success}
params {:token (get-in @form [:clean-data :token]) params {:token (get-in @form [:clean-data :token])
@ -57,7 +54,7 @@
(st/emit! (du/recover-profile (with-meta params mdata))))) (st/emit! (du/recover-profile (with-meta params mdata)))))
(mf/defc recovery-form (mf/defc recovery-form
[{:keys [locale params] :as props}] [{:keys [params] :as props}]
(let [form (fm/use-form :spec ::recovery-form (let [form (fm/use-form :spec ::recovery-form
:validators [password-equality] :validators [password-equality]
:initial params)] :initial params)]
@ -66,28 +63,28 @@
[:div.fields-row [:div.fields-row
[:& fm/input {:type "password" [:& fm/input {:type "password"
:name :password-1 :name :password-1
:label (t locale "auth.new-password")}]] :label (tr "auth.new-password")}]]
[:div.fields-row [:div.fields-row
[:& fm/input {:type "password" [:& fm/input {:type "password"
:name :password-2 :name :password-2
:label (t locale "auth.confirm-password")}]] :label (tr "auth.confirm-password")}]]
[:& fm/submit-button [:& fm/submit-button
{:label (t locale "auth.recovery-submit")}]])) {:label (tr "auth.recovery-submit")}]]))
;; --- Recovery Request Page ;; --- Recovery Request Page
(mf/defc recovery-page (mf/defc recovery-page
[{:keys [locale params] :as props}] [{:keys [params] :as props}]
[:section.generic-form [:section.generic-form
[:div.form-container [:div.form-container
[:h1 "Forgot your password?"] [:h1 "Forgot your password?"]
[:div.subtitle "Please enter your new password"] [:div.subtitle "Please enter your new password"]
[:& recovery-form {:locale locale :params params}] [:& recovery-form {:params params}]
[:div.links [:div.links
[:div.link-entry [:div.link-entry
[:a {:on-click #(st/emit! (rt/nav :auth-login))} [:a {:on-click #(st/emit! (rt/nav :auth-login))}
(t locale "profile.recovery.go-to-login")]]]]]) (tr "profile.recovery.go-to-login")]]]]])

View file

@ -12,12 +12,10 @@
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.forms :as fm] [app.main.ui.components.forms :as fm]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]]
[app.util.i18n :as i18n :refer [tr t]]
[app.util.router :as rt] [app.util.router :as rt]
[beicon.core :as rx] [beicon.core :as rx]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(s/def ::email ::us/email) (s/def ::email ::us/email)
@ -30,7 +28,7 @@
on-success on-success
(mf/use-callback (mf/use-callback
(fn [data] (fn [_ _]
(reset! submitted false) (reset! submitted false)
(st/emit! (dm/info (tr "auth.notifications.recovery-token-sent")) (st/emit! (dm/info (tr "auth.notifications.recovery-token-sent"))
(rt/nav :auth-login)))) (rt/nav :auth-login))))

View file

@ -8,21 +8,18 @@
(:require (:require
[app.common.spec :as us] [app.common.spec :as us]
[app.config :as cf] [app.config :as cf]
[app.main.data.users :as du]
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
[app.main.store :as st] [app.main.data.users :as du]
[app.main.repo :as rp] [app.main.repo :as rp]
[app.main.store :as st]
[app.main.ui.auth.login :as login]
[app.main.ui.components.forms :as fm] [app.main.ui.components.forms :as fm]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.main.ui.messages :as msgs] [app.main.ui.messages :as msgs]
[app.main.ui.auth.login :as login] [app.util.i18n :refer [tr]]
[app.util.dom :as dom]
[app.util.i18n :refer [tr t]]
[app.util.router :as rt] [app.util.router :as rt]
[app.util.timers :as tm]
[beicon.core :as rx] [beicon.core :as rx]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc demo-warning (mf/defc demo-warning
@ -84,7 +81,7 @@
on-submit on-submit
(mf/use-callback (mf/use-callback
(fn [form event] (fn [form _event]
(reset! submitted? true) (reset! submitted? true)
(let [params (:clean-data @form)] (let [params (:clean-data @form)]
(->> (rp/mutation :prepare-register-profile params) (->> (rp/mutation :prepare-register-profile params)

View file

@ -6,23 +6,16 @@
(ns app.main.ui.auth.verify-token (ns app.main.ui.auth.verify-token
(:require (:require
[app.common.uuid :as uuid]
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
[app.main.data.users :as du] [app.main.data.users :as du]
[app.main.repo :as rp] [app.main.repo :as rp]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.auth.login :refer [login-page]]
[app.main.ui.auth.recovery :refer [recovery-page]]
[app.main.ui.auth.recovery-request :refer [recovery-request-page]]
[app.main.ui.auth.register :refer [register-page]]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.forms :as fm]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt] [app.util.router :as rt]
[app.util.timers :as ts] [app.util.timers :as ts]
[beicon.core :as rx] [beicon.core :as rx]
[cljs.spec.alpha :as s]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(defmulti handle-token (fn [token] (:iss token))) (defmulti handle-token (fn [token] (:iss token)))
@ -34,7 +27,7 @@
(st/emit! (du/login-from-token data)))) (st/emit! (du/login-from-token data))))
(defmethod handle-token :change-email (defmethod handle-token :change-email
[data] [_data]
(let [msg (tr "dashboard.notifications.email-changed-successfully")] (let [msg (tr "dashboard.notifications.email-changed-successfully")]
(ts/schedule 100 #(st/emit! (dm/success msg))) (ts/schedule 100 #(st/emit! (dm/success msg)))
(st/emit! (rt/nav :settings-profile) (st/emit! (rt/nav :settings-profile)
@ -57,7 +50,7 @@
(st/emit! (rt/nav :auth-register {} {:invitation-token token}))))) (st/emit! (rt/nav :auth-register {} {:invitation-token token})))))
(defmethod handle-token :default (defmethod handle-token :default
[tdata] [_tdata]
(st/emit! (st/emit!
(rt/nav :auth-login) (rt/nav :auth-login)
(dm/warn (tr "errors.unexpected-token")))) (dm/warn (tr "errors.unexpected-token"))))

View file

@ -11,16 +11,13 @@
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
[app.main.streams :as ms]
[app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.context :as ctx]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [t tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[app.util.object :as obj] [app.util.object :as obj]
[app.util.time :as dt] [app.util.time :as dt]
[cuerdas.core :as str]
[okulary.core :as l] [okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
@ -105,7 +102,7 @@
:on-focus on-focus :on-focus on-focus
:on-change on-change}] :on-change on-change}]
(when (or @show-buttons? (when (or @show-buttons?
(not (empty? @content))) (seq @content))
[:div.buttons [:div.buttons
[:input.btn-primary {:type "button" :value "Post" :on-click on-submit}] [:input.btn-primary {:type "button" :value "Post" :on-click on-submit}]
[:input.btn-secondary {:type "button" :value "Cancel" :on-click on-cancel}]])])) [:input.btn-secondary {:type "button" :value "Cancel" :on-click on-cancel}]])]))
@ -323,7 +320,7 @@
(mf/defc thread-bubble (mf/defc thread-bubble
{::mf/wrap [mf/memo]} {::mf/wrap [mf/memo]}
[{:keys [thread zoom open? on-click] :as params}] [{:keys [thread zoom on-click] :as params}]
(let [pos (:position thread) (let [pos (:position thread)
pos-x (* (:x pos) zoom) pos-x (* (:x pos) zoom)
pos-y (* (:y pos) zoom) pos-y (* (:y pos) zoom)

View file

@ -6,9 +6,9 @@
(ns app.main.ui.components.color-bullet (ns app.main.ui.components.color-bullet
(:require (:require
[rumext.alpha :as mf] [app.util.color :as uc]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.color :as uc])) [rumext.alpha :as mf]))
(mf/defc color-bullet [{:keys [color on-click]}] (mf/defc color-bullet [{:keys [color on-click]}]
(if (uc/multiple? color) (if (uc/multiple? color)
@ -31,7 +31,7 @@
(mf/defc color-name [{:keys [color size on-click on-double-click]}] (mf/defc color-name [{:keys [color size on-click on-double-click]}]
(let [color (if (string? color) {:color color :opacity 1} color) (let [color (if (string? color) {:color color :opacity 1} color)
{:keys [name color opacity gradient]} color {:keys [name color gradient]} color
color-str (or name color (gradient-type->string (:type gradient)))] color-str (or name color (gradient-type->string (:type gradient)))]
(when (or (not size) (= size :big)) (when (or (not size) (= size :big))
[:span.color-text {:on-click #(when on-click (on-click %)) [:span.color-text {:on-click #(when on-click (on-click %))

View file

@ -6,16 +6,11 @@
(ns app.main.ui.components.color-input (ns app.main.ui.components.color-input
(:require (:require
[app.common.data :as d]
[app.common.math :as math]
[app.common.spec :as us]
[app.common.uuid :as uuid]
[app.util.color :as uc] [app.util.color :as uc]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[app.util.object :as obj] [app.util.object :as obj]
[app.util.simple-math :as sm]
[app.util.i18n :as i18n :refer [tr]]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc color-input (mf/defc color-input
@ -80,7 +75,7 @@
handle-blur handle-blur
(mf/use-callback (mf/use-callback
(mf/deps parse-value apply-value update-input) (mf/deps parse-value apply-value update-input)
(fn [event] (fn [_]
(let [new-value (parse-value)] (let [new-value (parse-value)]
(if new-value (if new-value
(apply-value new-value) (apply-value new-value)

View file

@ -6,13 +6,12 @@
(ns app.main.ui.components.context-menu (ns app.main.ui.components.context-menu
(:require (:require
[rumext.alpha :as mf]
[goog.object :as gobj]
[app.main.ui.components.dropdown :refer [dropdown']] [app.main.ui.components.dropdown :refer [dropdown']]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.common.uuid :as uuid]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.object :as obj])) [app.util.object :as obj]
[goog.object :as gobj]
[rumext.alpha :as mf]))
(mf/defc context-menu (mf/defc context-menu
{::mf/wrap-props false} {::mf/wrap-props false}
@ -52,7 +51,7 @@
(- node-height) (- node-height)
0)] 0)]
(if (not= target-offset (:offset @local)) (when (not= target-offset (:offset @local))
(swap! local assoc :offset target-offset)))))) (swap! local assoc :offset target-offset))))))
enter-submenu enter-submenu

View file

@ -6,11 +6,11 @@
(ns app.main.ui.components.copy-button (ns app.main.ui.components.copy-button
(:require (:require
[beicon.core :as rx] [app.main.ui.icons :as i]
[rumext.alpha :as mf]
[app.util.webapi :as wapi]
[app.util.timers :as timers] [app.util.timers :as timers]
[app.main.ui.icons :as i])) [app.util.webapi :as wapi]
[beicon.core :as rx]
[rumext.alpha :as mf]))
(mf/defc copy-button [{:keys [data]}] (mf/defc copy-button [{:keys [data]}]
(let [just-copied (mf/use-state false)] (let [just-copied (mf/use-state false)]
@ -24,9 +24,8 @@
[:button.copy-button [:button.copy-button
{:on-click #(when-not @just-copied {:on-click #(when-not @just-copied
(do (reset! just-copied true)
(reset! just-copied true) (wapi/write-to-clipboard data))}
(wapi/write-to-clipboard data)))}
(if @just-copied (if @just-copied
i/tick i/tick
i/copy)])) i/copy)]))

View file

@ -1,11 +1,16 @@
;; 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/.
;;
;; Copyright (c) UXBOX Labs SL
(ns app.main.ui.components.dropdown (ns app.main.ui.components.dropdown
(:require (:require
[rumext.alpha :as mf]
[app.common.uuid :as uuid]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[goog.events :as events] [goog.events :as events]
[goog.object :as gobj]) [goog.object :as gobj]
[rumext.alpha :as mf])
(:import goog.events.EventType)) (:import goog.events.EventType))
(mf/defc dropdown' (mf/defc dropdown'

View file

@ -7,7 +7,6 @@
(ns app.main.ui.components.editable-label (ns app.main.ui.components.editable-label
(:require (:require
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.data :refer [classnames]]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[app.util.timers :as timers] [app.util.timers :as timers]
@ -32,7 +31,7 @@
cancel-editing (fn [] cancel-editing (fn []
(stop-editing) (stop-editing)
(when on-cancel (on-cancel))) (when on-cancel (on-cancel)))
on-dbl-click (fn [e] (when (not disable-dbl-click?) (start-editing))) on-dbl-click (fn [_] (when (not disable-dbl-click?) (start-editing)))
on-key-up (fn [e] on-key-up (fn [e]
(cond (cond
(kbd/esc? e) (kbd/esc? e)

View file

@ -6,13 +6,13 @@
(ns app.main.ui.components.editable-select (ns app.main.ui.components.editable-select
(:require (:require
[rumext.alpha :as mf]
[app.common.uuid :as uuid]
[app.common.data :as d] [app.common.data :as d]
[app.common.uuid :as uuid]
[app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.timers :as timers] [app.util.timers :as timers]
[app.main.ui.icons :as i] [rumext.alpha :as mf]))
[app.main.ui.components.dropdown :refer [dropdown]]))
(mf/defc editable-select [{:keys [value type options class on-change placeholder]}] (mf/defc editable-select [{:keys [value type options class on-change placeholder]}]
(let [state (mf/use-state {:id (uuid/next) (let [state (mf/use-state {:id (uuid/next)
@ -24,7 +24,7 @@
open-dropdown #(swap! state assoc :is-open? true) open-dropdown #(swap! state assoc :is-open? true)
close-dropdown #(swap! state assoc :is-open? false) close-dropdown #(swap! state assoc :is-open? false)
select-item (fn [value] select-item (fn [value]
(fn [event] (fn [_]
(swap! state assoc :current-value value) (swap! state assoc :current-value value)
(when on-change (on-change value)))) (when on-change (on-change value))))

View file

@ -6,10 +6,9 @@
(ns app.main.ui.components.file-uploader (ns app.main.ui.components.file-uploader
(:require (:require
[rumext.alpha :as mf]
[app.main.data.workspace :as dw]
[app.main.store :as st] [app.main.store :as st]
[app.util.dom :as dom])) [app.util.dom :as dom]
[rumext.alpha :as mf]))
(mf/defc file-uploader (mf/defc file-uploader
{::mf/forward-ref true} {::mf/forward-ref true}

View file

@ -8,7 +8,6 @@
(:require (:require
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.webapi :as wapi] [app.util.webapi :as wapi]
[beicon.core :as rx]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(def fullscreen-context (def fullscreen-context
@ -21,7 +20,7 @@
change change
(mf/use-callback (mf/use-callback
(fn [event] (fn [_]
(let [val (dom/fullscreen?)] (let [val (dom/fullscreen?)]
(reset! state val)))) (reset! state val))))

View file

@ -132,7 +132,7 @@
handle-blur handle-blur
(mf/use-callback (mf/use-callback
(mf/deps parse-value apply-value update-input) (mf/deps parse-value apply-value update-input)
(fn [event] (fn [_]
(let [new-value (parse-value)] (let [new-value (parse-value)]
(if new-value (if new-value
(apply-value new-value) (apply-value new-value)

View file

@ -6,10 +6,10 @@
(ns app.main.ui.components.select (ns app.main.ui.components.select
(:require (:require
[rumext.alpha :as mf]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.main.ui.components.dropdown :refer [dropdown]])) [rumext.alpha :as mf]))
(mf/defc select [{:keys [default-value options class on-change]}] (mf/defc select [{:keys [default-value options class on-change]}]
(let [state (mf/use-state {:id (uuid/next) (let [state (mf/use-state {:id (uuid/next)
@ -17,9 +17,10 @@
:current-value default-value}) :current-value default-value})
open-dropdown #(swap! state assoc :is-open? true) open-dropdown #(swap! state assoc :is-open? true)
close-dropdown #(swap! state assoc :is-open? false) close-dropdown #(swap! state assoc :is-open? false)
select-item (fn [value] (fn [event] select-item (fn [value]
(swap! state assoc :current-value value) (fn [_]
(when on-change (on-change value)))) (swap! state assoc :current-value value)
(when on-change (on-change value))))
as-key-value (fn [item] (if (map? item) [(:value item) (:label item)] [item item])) as-key-value (fn [item] (if (map? item) [(:value item) (:label item)] [item item]))
value->label (into {} (->> options value->label (into {} (->> options
(map as-key-value))) ] (map as-key-value))) ]

View file

@ -8,7 +8,7 @@
(:require [rumext.alpha :as mf])) (:require [rumext.alpha :as mf]))
(mf/defc tab-element (mf/defc tab-element
[{:keys [children id title]}] [{:keys [children]}]
[:div.tab-element [:div.tab-element
[:div.tab-element-content children]]) [:div.tab-element-content children]])

View file

@ -57,10 +57,10 @@
(let [on-keydown (let [on-keydown
(fn [event] (fn [event]
(when (k/enter? event) (when (k/enter? event)
(do (dom/prevent-default event) (dom/prevent-default event)
(dom/stop-propagation event) (dom/stop-propagation event)
(st/emit! (modal/hide)) (st/emit! (modal/hide))
(on-accept props)))) (on-accept props)))
key (events/listen js/document EventType.KEYDOWN on-keydown)] key (events/listen js/document EventType.KEYDOWN on-keydown)]
#(events/unlistenByKey key)))) #(events/unlistenByKey key))))

View file

@ -6,9 +6,9 @@
(ns app.main.ui.cursors (ns app.main.ui.cursors
(:require (:require
[app.common.uri :as u]
[clojure.java.io :as io] [clojure.java.io :as io]
[cuerdas.core :as str] [cuerdas.core :as str]))
[app.common.uri :as u]))
(def cursor-folder "images/cursors") (def cursor-folder "images/cursors")

View file

@ -6,9 +6,10 @@
(ns app.main.ui.cursors (ns app.main.ui.cursors
(:require-macros [app.main.ui.cursors :refer [cursor-ref cursor-fn]]) (:require-macros [app.main.ui.cursors :refer [cursor-ref cursor-fn]])
(:require [rumext.alpha :as mf] (:require
[cuerdas.core :as str] [app.util.timers :as ts]
[app.util.timers :as ts])) [cuerdas.core :as str]
[rumext.alpha :as mf]))
;; Static cursors ;; Static cursors
(def comments (cursor-ref :comments 0 2 20)) (def comments (cursor-ref :comments 0 2 20))
@ -40,7 +41,7 @@
(mf/defc debug-preview (mf/defc debug-preview
{::mf/wrap-props false} {::mf/wrap-props false}
[props] []
(let [rotation (mf/use-state 0)] (let [rotation (mf/use-state 0)]
(mf/use-effect (fn [] (ts/interval 100 #(reset! rotation inc)))) (mf/use-effect (fn [] (ts/interval 100 #(reset! rotation inc))))

View file

@ -6,9 +6,7 @@
(ns app.main.ui.dashboard (ns app.main.ui.dashboard
(:require (:require
[app.common.exceptions :as ex]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.uuid :as uuid]
[app.config :as cf] [app.config :as cf]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
@ -16,19 +14,13 @@
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.context :as ctx] [app.main.ui.context :as ctx]
[app.main.ui.dashboard.files :refer [files-section]] [app.main.ui.dashboard.files :refer [files-section]]
[app.main.ui.dashboard.fonts :refer [fonts-page font-providers-page]]
[app.main.ui.dashboard.libraries :refer [libraries-page]] [app.main.ui.dashboard.libraries :refer [libraries-page]]
[app.main.ui.dashboard.projects :refer [projects-section]] [app.main.ui.dashboard.projects :refer [projects-section]]
[app.main.ui.dashboard.fonts :refer [fonts-page font-providers-page]]
[app.main.ui.dashboard.search :refer [search-page]] [app.main.ui.dashboard.search :refer [search-page]]
[app.main.ui.dashboard.sidebar :refer [sidebar]] [app.main.ui.dashboard.sidebar :refer [sidebar]]
[app.main.ui.dashboard.team :refer [team-settings-page team-members-page]] [app.main.ui.dashboard.team :refer [team-settings-page team-members-page]]
[app.main.ui.icons :as i]
[app.util.i18n :as i18n :refer [t]]
[app.util.router :as rt]
[app.util.timers :as tm] [app.util.timers :as tm]
[beicon.core :as rx]
[cuerdas.core :as str]
[okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(defn ^boolean uuid-str? (defn ^boolean uuid-str?
@ -37,9 +29,8 @@
(boolean (re-seq us/uuid-rx s)))) (boolean (re-seq us/uuid-rx s))))
(defn- parse-params (defn- parse-params
[route profile] [route]
(let [route-name (get-in route [:data :name]) (let [search-term (get-in route [:params :query :search-term])
search-term (get-in route [:params :query :search-term])
team-id (get-in route [:params :path :team-id]) team-id (get-in route [:params :path :team-id])
project-id (get-in route [:params :path :project-id])] project-id (get-in route [:params :path :project-id])]
(cond-> (cond->
@ -87,7 +78,7 @@
[{:keys [route] :as props}] [{:keys [route] :as props}]
(let [profile (mf/deref refs/profile) (let [profile (mf/deref refs/profile)
section (get-in route [:data :name]) section (get-in route [:data :name])
params (parse-params route profile) params (parse-params route)
project-id (:project-id params) project-id (:project-id params)
team-id (:team-id params) team-id (:team-id params)

View file

@ -6,29 +6,15 @@
(ns app.main.ui.dashboard.comments (ns app.main.ui.dashboard.comments
(:require (:require
[okulary.core :as l]
[app.common.data :as d]
[app.common.spec :as us]
[app.config :as cfg]
[app.main.data.dashboard :as dd]
[app.main.data.workspace :as dw]
[app.main.data.workspace.comments :as dwcm]
[app.main.data.comments :as dcm] [app.main.data.comments :as dcm]
[app.main.data.workspace.comments :as dwcm]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.comments :as cmt] [app.main.ui.comments :as cmt]
[app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [t tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.object :as obj]
[app.util.router :as rt]
[app.util.time :as dt]
[app.util.timers :as tm]
[beicon.core :as rx]
[cljs.spec.alpha :as s]
[cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc comments-section (mf/defc comments-section

View file

@ -7,7 +7,6 @@
(ns app.main.ui.dashboard.files (ns app.main.ui.dashboard.files
(:require (:require
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.modal :as modal]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.dashboard.grid :refer [grid]] [app.main.ui.dashboard.grid :refer [grid]]
@ -16,18 +15,12 @@
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[app.util.router :as rt]
[okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc header (mf/defc header
[{:keys [team project] :as props}] [{:keys [project] :as props}]
(let [local (mf/use-state {:menu-open false (let [local (mf/use-state {:menu-open false
:edition false}) :edition false})
project-id (:id project)
team-id (:id team)
on-menu-click on-menu-click
(mf/use-callback (mf/use-callback
(fn [event] (fn [event]

View file

@ -6,27 +6,22 @@
(ns app.main.ui.dashboard.fonts (ns app.main.ui.dashboard.fonts
(:require (:require
[app.common.data :as d]
[app.common.media :as cm] [app.common.media :as cm]
[app.common.uuid :as uuid]
[app.main.data.dashboard :as dd]
[app.main.data.fonts :as df] [app.main.data.fonts :as df]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.ui.components.file-uploader :refer [file-uploader]]
[app.main.ui.components.context-menu :refer [context-menu]]
[app.main.store :as st]
[app.main.repo :as rp]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st]
[app.main.ui.components.context-menu :refer [context-menu]]
[app.main.ui.components.file-uploader :refer [file-uploader]]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.logging :as log]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[app.util.router :as rt] [app.util.logging :as log]
[app.util.webapi :as wa] ;; [app.util.router :as rt]
[cuerdas.core :as str]
[beicon.core :as rx] [beicon.core :as rx]
[okulary.core :as l] [cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(log/set-level! :trace) (log/set-level! :trace)
@ -47,29 +42,29 @@
(mf/defc header (mf/defc header
{::mf/wrap [mf/memo]} {::mf/wrap [mf/memo]}
[{:keys [section team] :as props}] [{:keys [section team] :as props}]
(let [go-fonts ;; (let [go-fonts
(mf/use-callback ;; (mf/use-callback
(mf/deps team) ;; (mf/deps team)
(st/emitf (rt/nav :dashboard-fonts {:team-id (:id team)}))) ;; (st/emitf (rt/nav :dashboard-fonts {:team-id (:id team)})))
go-providers ;; go-providers
(mf/use-callback ;; (mf/use-callback
(mf/deps team) ;; (mf/deps team)
(st/emitf (rt/nav :dashboard-font-providers {:team-id (:id team)})))] ;; (st/emitf (rt/nav :dashboard-font-providers {:team-id (:id team)})))]
(use-set-page-title team section) (use-set-page-title team section)
[:header.dashboard-header [:header.dashboard-header
[:div.dashboard-title [:div.dashboard-title
[:h1 (tr "labels.fonts")]] [:h1 (tr "labels.fonts")]]
[:nav [:nav
#_[:ul #_[:ul
[:li {:class (when (= section :fonts) "active")} [:li {:class (when (= section :fonts) "active")}
[:a {:on-click go-fonts} (tr "labels.custom-fonts")]] [:a {:on-click go-fonts} (tr "labels.custom-fonts")]]
[:li {:class (when (= section :providers) "active")} [:li {:class (when (= section :providers) "active")}
[:a {:on-click go-providers} (tr "labels.font-providers")]]]] [:a {:on-click go-providers} (tr "labels.font-providers")]]]]
[:div]])) [:div]])
(mf/defc font-variant-display-name (mf/defc font-variant-display-name
[{:keys [variant]}] [{:keys [variant]}]
@ -88,9 +83,6 @@
on-click on-click
(mf/use-callback #(dom/click (mf/ref-val input-ref))) (mf/use-callback #(dom/click (mf/ref-val input-ref)))
font-key-fn
(mf/use-callback (juxt :font-family :font-weight :font-style))
on-selected on-selected
(mf/use-callback (mf/use-callback
(mf/deps team installed-fonts) (mf/deps team installed-fonts)
@ -190,7 +182,7 @@
(reset! state (dom/get-target-val event))) (reset! state (dom/get-target-val event)))
on-save on-save
(fn [event] (fn [_]
(let [font-family @state] (let [font-family @state]
(when-not (str/blank? font-family) (when-not (str/blank? font-family)
(st/emit! (df/update-font (st/emit! (df/update-font
@ -204,7 +196,7 @@
(on-save event))) (on-save event)))
on-cancel on-cancel
(fn [event] (fn [_]
(reset! edit? false) (reset! edit? false)
(reset! state (:font-family font))) (reset! state (:font-family font)))
@ -221,8 +213,7 @@
:title (tr "modals.delete-font.title") :title (tr "modals.delete-font.title")
:message (tr "modals.delete-font.message") :message (tr "modals.delete-font.message")
:accept-label (tr "labels.delete") :accept-label (tr "labels.delete")
:on-accept (fn [props] :on-accept (fn [_props] (delete-font-fn))})))
(delete-font-fn))})))
on-delete-variant on-delete-variant
(fn [id] (fn [id]
@ -231,7 +222,7 @@
:title (tr "modals.delete-font-variant.title") :title (tr "modals.delete-font-variant.title")
:message (tr "modals.delete-font-variant.message") :message (tr "modals.delete-font-variant.message")
:accept-label (tr "labels.delete") :accept-label (tr "labels.delete")
:on-accept (fn [props] :on-accept (fn [_props]
(delete-variant-fn id))})))] (delete-variant-fn id))})))]
[:div.font-item.table-row [:div.font-item.table-row
@ -276,7 +267,7 @@
(mf/defc installed-fonts (mf/defc installed-fonts
[{:keys [team fonts] :as props}] [{:keys [fonts] :as props}]
(let [sterm (mf/use-state "") (let [sterm (mf/use-state "")
matches? matches?

View file

@ -7,11 +7,8 @@
(ns app.main.ui.dashboard.grid (ns app.main.ui.dashboard.grid
(:require (:require
[app.common.math :as mth] [app.common.math :as mth]
[app.common.uuid :as uuid]
[app.config :as cfg]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
[app.main.data.modal :as modal]
[app.main.fonts :as fonts] [app.main.fonts :as fonts]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
@ -23,12 +20,10 @@
[app.util.dom.dnd :as dnd] [app.util.dom.dnd :as dnd]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[app.util.router :as rt]
[app.util.time :as dt] [app.util.time :as dt]
[app.util.timers :as ts] [app.util.timers :as ts]
[app.util.webapi :as wapi] [app.util.webapi :as wapi]
[beicon.core :as rx] [beicon.core :as rx]
[cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
;; --- Grid Item Thumbnail ;; --- Grid Item Thumbnail
@ -59,7 +54,7 @@
(str (tr "ds.updated-at" time)))) (str (tr "ds.updated-at" time))))
(defn create-counter-element (defn create-counter-element
[element file-count] [_element file-count]
(let [counter-el (dom/create-element "div")] (let [counter-el (dom/create-element "div")]
(dom/set-property! counter-el "class" "drag-counter") (dom/set-property! counter-el "class" "drag-counter")
(dom/set-text! counter-el (str file-count)) (dom/set-text! counter-el (str file-count))
@ -215,7 +210,7 @@
[:div.text (tr "dashboard.loading-files")]]) [:div.text (tr "dashboard.loading-files")]])
(mf/defc grid (mf/defc grid
[{:keys [id opts files] :as props}] [{:keys [files] :as props}]
[:section.dashboard-grid [:section.dashboard-grid
(cond (cond
(nil? files) (nil? files)
@ -233,7 +228,7 @@
[:& empty-placeholder])]) [:& empty-placeholder])])
(mf/defc line-grid-row (mf/defc line-grid-row
[{:keys [files team-id selected-files on-load-more dragging?] :as props}] [{:keys [files selected-files on-load-more dragging?] :as props}]
(let [rowref (mf/use-ref) (let [rowref (mf/use-ref)
width (mf/use-state nil) width (mf/use-state nil)
@ -288,7 +283,7 @@
(tr "dashboard.show-all-files")]])])) (tr "dashboard.show-all-files")]])]))
(mf/defc line-grid (mf/defc line-grid
[{:keys [project-id team-id opts files on-load-more] :as props}] [{:keys [project-id team-id files on-load-more] :as props}]
(let [dragging? (mf/use-state false) (let [dragging? (mf/use-state false)
selected-files (mf/deref refs/dashboard-selected-files) selected-files (mf/deref refs/dashboard-selected-files)
@ -326,7 +321,7 @@
on-drop on-drop
(mf/use-callback (mf/use-callback
(mf/deps files selected-files) (mf/deps files selected-files)
(fn [e] (fn [_]
(reset! dragging? false) (reset! dragging? false)
(when (not= selected-project project-id) (when (not= selected-project project-id)
(let [data {:ids (into #{} (keys selected-files)) (let [data {:ids (into #{} (keys selected-files))

View file

@ -7,7 +7,6 @@
(ns app.main.ui.dashboard.import (ns app.main.ui.dashboard.import
(:require (:require
[app.main.ui.components.file-uploader :refer [file-uploader]] [app.main.ui.components.file-uploader :refer [file-uploader]]
[app.main.ui.icons :as i]
[app.main.worker :as uw] [app.main.worker :as uw]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.logging :as log] [app.util.logging :as log]

View file

@ -7,14 +7,11 @@
(ns app.main.ui.dashboard.libraries (ns app.main.ui.dashboard.libraries
(:require (:require
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.dashboard.grid :refer [grid]] [app.main.ui.dashboard.grid :refer [grid]]
[app.main.ui.icons :as i]
[app.main.refs :as refs]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt]
[okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc libraries-page (mf/defc libraries-page

View file

@ -10,7 +10,6 @@
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.context-menu :refer [context-menu]] [app.main.ui.components.context-menu :refer [context-menu]]
[app.main.ui.context :as ctx] [app.main.ui.context :as ctx]
@ -19,7 +18,6 @@
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt] [app.util.router :as rt]
[beicon.core :as rx]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc project-menu (mf/defc project-menu
@ -62,7 +60,7 @@
(dd/move-project (with-meta data mdata))))) (dd/move-project (with-meta data mdata)))))
delete-fn delete-fn
(fn [event] (fn [_]
(st/emit! (dm/success (tr "dashboard.success-delete-project")) (st/emit! (dm/success (tr "dashboard.success-delete-project"))
(dd/delete-project project) (dd/delete-project project)
(dd/go-to-projects (:team-id project)))) (dd/go-to-projects (:team-id project))))

View file

@ -6,8 +6,6 @@
(ns app.main.ui.dashboard.projects (ns app.main.ui.dashboard.projects
(:require (:require
[app.common.exceptions :as ex]
[app.main.constants :as c]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
@ -16,8 +14,7 @@
[app.main.ui.dashboard.project-menu :refer [project-menu]] [app.main.ui.dashboard.project-menu :refer [project-menu]]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [t tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[app.util.router :as rt] [app.util.router :as rt]
[app.util.time :as dt] [app.util.time :as dt]
[okulary.core :as l] [okulary.core :as l]
@ -38,7 +35,6 @@
[{:keys [project first? files] :as props}] [{:keys [project first? files] :as props}]
(let [locale (mf/deref i18n/locale) (let [locale (mf/deref i18n/locale)
project-id (:id project)
team-id (:team-id project) team-id (:team-id project)
file-count (or (:count project) 0) file-count (or (:count project) 0)

View file

@ -13,7 +13,6 @@
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc search-page (mf/defc search-page

View file

@ -9,13 +9,11 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.spec :as us] [app.common.spec :as us]
[app.config :as cfg] [app.config :as cfg]
[app.main.data.comments :as dcm]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.data.users :as du] [app.main.data.users :as du]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.repo :as rp]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.components.forms :as fm] [app.main.ui.components.forms :as fm]
@ -24,23 +22,17 @@
[app.main.ui.dashboard.project-menu :refer [project-menu]] [app.main.ui.dashboard.project-menu :refer [project-menu]]
[app.main.ui.dashboard.team-form] [app.main.ui.dashboard.team-form]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.avatars :as avatars]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.dom.dnd :as dnd] [app.util.dom.dnd :as dnd]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[app.util.object :as obj] [app.util.object :as obj]
[app.util.router :as rt] [app.util.router :as rt]
[app.util.time :as dt]
[beicon.core :as rx]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[cuerdas.core :as str]
[goog.functions :as f] [goog.functions :as f]
[okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc sidebar-project (mf/defc sidebar-project
[{:keys [item team-id selected?] :as props}] [{:keys [item selected?] :as props}]
(let [dstate (mf/deref refs/dashboard-local) (let [dstate (mf/deref refs/dashboard-local)
selected-files (:selected-files dstate) selected-files (:selected-files dstate)
selected-project (:selected-project dstate) selected-project (:selected-project dstate)
@ -111,7 +103,7 @@
on-drop on-drop
(mf/use-callback (mf/use-callback
(mf/deps item selected-files) (mf/deps item selected-files)
(fn [e] (fn [_]
(swap! local assoc :dragging? false) (swap! local assoc :dragging? false)
(when (not= selected-project (:id item)) (when (not= selected-project (:id item))
(let [data {:ids selected-files (let [data {:ids selected-files
@ -157,7 +149,7 @@
on-search-blur on-search-blur
(mf/use-callback (mf/use-callback
(fn [event] (fn [_]
(reset! focused? false))) (reset! focused? false)))
on-search-change on-search-change
@ -170,7 +162,7 @@
on-clear-click on-clear-click
(mf/use-callback (mf/use-callback
(mf/deps team-id) (mf/deps team-id)
(fn [event] (fn [_]
(let [search-input (dom/get-element "search-input")] (let [search-input (dom/get-element "search-input")]
(dom/clean-value! search-input) (dom/clean-value! search-input)
(dom/focus! search-input) (dom/focus! search-input)
@ -189,7 +181,7 @@
:on-change on-search-change :on-change on-search-change
:ref #(when % (set! (.-value %) search-term))}] :ref #(when % (set! (.-value %) search-term))}]
(if (or @focused? (not (empty? search-term))) (if (or @focused? (seq search-term))
[:div.clear-search [:div.clear-search
{:on-click on-clear-click} {:on-click on-clear-click}
i/close] i/close]
@ -199,9 +191,8 @@
i/search])])) i/search])]))
(mf/defc teams-selector-dropdown (mf/defc teams-selector-dropdown
[{:keys [team profile] :as props}] [{:keys [profile] :as props}]
(let [show-dropdown? (mf/use-state false) (let [teams (mf/deref refs/teams)
teams (mf/deref refs/teams)
on-create-clicked on-create-clicked
(mf/use-callback (mf/use-callback
@ -246,7 +237,7 @@
on-cancel (st/emitf (modal/hide)) on-cancel (st/emitf (modal/hide))
on-accept on-accept
(fn [event] (fn [_]
(let [member-id (get-in @form [:clean-data :member-id])] (let [member-id (get-in @form [:clean-data :member-id])]
(accept member-id)))] (accept member-id)))]
@ -291,9 +282,6 @@
members-map (mf/deref refs/dashboard-team-members) members-map (mf/deref refs/dashboard-team-members)
members (vals members-map) members (vals members-map)
on-create-clicked
(st/emitf (modal/show :team-form {}))
on-rename-clicked on-rename-clicked
(st/emitf (modal/show :team-form {:team team})) (st/emitf (modal/show :team-form {:team team}))
@ -358,9 +346,7 @@
(mf/defc sidebar-team-switch (mf/defc sidebar-team-switch
[{:keys [team profile] :as props}] [{:keys [team profile] :as props}]
(let [show-dropdown? (mf/use-state false) (let [show-team-opts-ddwn? (mf/use-state false)
show-team-opts-ddwn? (mf/use-state false)
show-teams-ddwn? (mf/use-state false)] show-teams-ddwn? (mf/use-state false)]
[:div.sidebar-team-switch [:div.sidebar-team-switch

View file

@ -7,10 +7,8 @@
(ns app.main.ui.dashboard.team (ns app.main.ui.dashboard.team
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.exceptions :as ex]
[app.common.spec :as us] [app.common.spec :as us]
[app.config :as cfg] [app.config :as cfg]
[app.main.constants :as c]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
@ -23,15 +21,12 @@
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt]
[app.util.time :as dt]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[okulary.core :as l]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(mf/defc header (mf/defc header
{::mf/wrap [mf/memo]} {::mf/wrap [mf/memo]}
[{:keys [section team] :as props}] [{:keys [section] :as props}]
(let [go-members (st/emitf (dd/go-to-team-members)) (let [go-members (st/emitf (dd/go-to-team-members))
go-settings (st/emitf (dd/go-to-team-settings)) go-settings (st/emitf (dd/go-to-team-settings))
invite-member (st/emitf (modal/show {:type ::invite-member})) invite-member (st/emitf (modal/show {:type ::invite-member}))
@ -43,7 +38,7 @@
[:h1 (cond [:h1 (cond
members-section? (tr "labels.members") members-section? (tr "labels.members")
settings-section? (tr "labels.settings") settings-section? (tr "labels.settings")
nil)]] :else nil)]]
[:nav [:nav
[:ul [:ul
[:li {:class (when members-section? "active")} [:li {:class (when members-section? "active")}
@ -96,7 +91,7 @@
(dm/error (tr "errors.member-is-muted")) (dm/error (tr "errors.member-is-muted"))
(and (= :validation type) (and (= :validation type)
(= :email-has-permanent-bounces)) (= :email-has-permanent-bounces code))
(dm/error (tr "errors.email-has-permanent-bounces" email)) (dm/error (tr "errors.email-has-permanent-bounces" email))
:else :else
@ -136,7 +131,7 @@
set-owner-fn (partial set-role :owner) set-owner-fn (partial set-role :owner)
set-admin (partial set-role :admin) set-admin (partial set-role :admin)
set-editor (partial set-role :editor) set-editor (partial set-role :editor)
set-viewer (partial set-role :viewer) ;; set-viewer (partial set-role :viewer)
set-owner set-owner
(st/emitf (modal/show (st/emitf (modal/show
@ -242,7 +237,7 @@
:members-map members-map}]]])) :members-map members-map}]]]))
(mf/defc team-settings-page (mf/defc team-settings-page
[{:keys [team profile] :as props}] [{:keys [team] :as props}]
(let [finput (mf/use-ref) (let [finput (mf/use-ref)
members-map (mf/deref refs/dashboard-team-members) members-map (mf/deref refs/dashboard-team-members)

View file

@ -6,7 +6,6 @@
(ns app.main.ui.dashboard.team-form (ns app.main.ui.dashboard.team-form
(:require (:require
[app.common.data :as d]
[app.common.spec :as us] [app.common.spec :as us]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
@ -14,13 +13,10 @@
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.components.forms :as fm] [app.main.ui.components.forms :as fm]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.object :as obj]
[app.util.router :as rt] [app.util.router :as rt]
[beicon.core :as rx] [beicon.core :as rx]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[cuerdas.core :as str]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(s/def ::name ::us/not-empty-string) (s/def ::name ::us/not-empty-string)
@ -28,20 +24,20 @@
(s/keys :req-un [::name])) (s/keys :req-un [::name]))
(defn- on-create-success (defn- on-create-success
[form response] [_form response]
(let [msg "Team created successfuly"] (let [msg "Team created successfuly"]
(st/emit! (dm/success msg) (st/emit! (dm/success msg)
(modal/hide) (modal/hide)
(rt/nav :dashboard-projects {:team-id (:id response)})))) (rt/nav :dashboard-projects {:team-id (:id response)}))))
(defn- on-update-success (defn- on-update-success
[form response] [_form _response]
(let [msg "Team created successfuly"] (let [msg "Team created successfuly"]
(st/emit! (dm/success msg) (st/emit! (dm/success msg)
(modal/hide)))) (modal/hide))))
(defn- on-error (defn- on-error
[form response] [form _response]
(let [id (get-in @form [:clean-data :id])] (let [id (get-in @form [:clean-data :id])]
(if id (if id
(rx/of (dm/error "Error on updating team.")) (rx/of (dm/error "Error on updating team."))

View file

@ -6,7 +6,6 @@
(ns app.main.ui.handoff (ns app.main.ui.handoff
(:require (:require
[app.common.exceptions :as ex]
[app.main.data.viewer :as dv] [app.main.data.viewer :as dv]
[app.main.data.viewer.shortcuts :as sc] [app.main.data.viewer.shortcuts :as sc]
[app.main.refs :as refs] [app.main.refs :as refs]
@ -15,15 +14,12 @@
[app.main.ui.handoff.render :refer [render-frame-svg]] [app.main.ui.handoff.render :refer [render-frame-svg]]
[app.main.ui.handoff.right-sidebar :refer [right-sidebar]] [app.main.ui.handoff.right-sidebar :refer [right-sidebar]]
[app.main.ui.hooks :as hooks] [app.main.ui.hooks :as hooks]
[app.main.ui.icons :as i]
[app.main.ui.viewer.header :refer [header]] [app.main.ui.viewer.header :refer [header]]
[app.main.ui.viewer.thumbnails :refer [thumbnails-panel]] [app.main.ui.viewer.thumbnails :refer [thumbnails-panel]]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [t tr]] [app.util.i18n :as i18n :refer [t tr]]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[beicon.core :as rx]
[goog.events :as events] [goog.events :as events]
[okulary.core :as l]
[rumext.alpha :as mf]) [rumext.alpha :as mf])
(:import goog.events.EventType)) (:import goog.events.EventType))

View file

@ -6,18 +6,18 @@
(ns app.main.ui.handoff.attributes (ns app.main.ui.handoff.attributes
(:require (:require
[rumext.alpha :as mf]
[app.util.i18n :as i18n]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.main.ui.handoff.exports :refer [exports]]
[app.main.ui.handoff.attributes.layout :refer [layout-panel]]
[app.main.ui.handoff.attributes.fill :refer [fill-panel]]
[app.main.ui.handoff.attributes.stroke :refer [stroke-panel]]
[app.main.ui.handoff.attributes.shadow :refer [shadow-panel]]
[app.main.ui.handoff.attributes.blur :refer [blur-panel]] [app.main.ui.handoff.attributes.blur :refer [blur-panel]]
[app.main.ui.handoff.attributes.fill :refer [fill-panel]]
[app.main.ui.handoff.attributes.image :refer [image-panel]] [app.main.ui.handoff.attributes.image :refer [image-panel]]
[app.main.ui.handoff.attributes.layout :refer [layout-panel]]
[app.main.ui.handoff.attributes.shadow :refer [shadow-panel]]
[app.main.ui.handoff.attributes.stroke :refer [stroke-panel]]
[app.main.ui.handoff.attributes.svg :refer [svg-panel]]
[app.main.ui.handoff.attributes.text :refer [text-panel]] [app.main.ui.handoff.attributes.text :refer [text-panel]]
[app.main.ui.handoff.attributes.svg :refer [svg-panel]])) [app.main.ui.handoff.exports :refer [exports]]
[app.util.i18n :as i18n]
[rumext.alpha :as mf]))
(def type->options (def type->options
{:multiple [:fill :stroke :image :text :shadow :blur] {:multiple [:fill :stroke :image :text :shadow :blur]

View file

@ -6,12 +6,11 @@
(ns app.main.ui.handoff.attributes.blur (ns app.main.ui.handoff.attributes.blur
(:require (:require
[rumext.alpha :as mf] [app.main.ui.components.copy-button :refer [copy-button]]
[cuerdas.core :as str]
[app.util.i18n :refer [t]]
[app.main.ui.icons :as i]
[app.util.code-gen :as cg] [app.util.code-gen :as cg]
[app.main.ui.components.copy-button :refer [copy-button]])) [app.util.i18n :refer [t]]
[cuerdas.core :as str]
[rumext.alpha :as mf]))
(defn has-blur? [shape] (defn has-blur? [shape]
(:blur shape)) (:blur shape))

View file

@ -6,19 +6,16 @@
(ns app.main.ui.handoff.attributes.common (ns app.main.ui.handoff.attributes.common
(:require (:require
[rumext.alpha :as mf]
[cuerdas.core :as str]
[okulary.core :as l]
[app.common.math :as mth] [app.common.math :as mth]
[app.main.store :as st]
[app.main.ui.components.color-bullet :refer [color-bullet color-name]]
[app.main.ui.components.copy-button :refer [copy-button]]
[app.util.color :as uc]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :refer [t] :as i18n] [app.util.i18n :refer [t] :as i18n]
[app.util.color :as uc] [cuerdas.core :as str]
[app.util.code-gen :as cg] [okulary.core :as l]
[app.util.webapi :as wapi] [rumext.alpha :as mf]))
[app.main.ui.icons :as i]
[app.main.store :as st]
[app.main.ui.components.copy-button :refer [copy-button]]
[app.main.ui.components.color-bullet :refer [color-bullet color-name]]))
(def file-colors-ref (def file-colors-ref

View file

@ -6,13 +6,12 @@
(ns app.main.ui.handoff.attributes.fill (ns app.main.ui.handoff.attributes.fill
(:require (:require
[rumext.alpha :as mf]
[app.util.i18n :refer [t]]
[app.util.color :as uc]
[app.main.ui.icons :as i]
[app.util.code-gen :as cg]
[app.main.ui.components.copy-button :refer [copy-button]] [app.main.ui.components.copy-button :refer [copy-button]]
[app.main.ui.handoff.attributes.common :refer [color-row]])) [app.main.ui.handoff.attributes.common :refer [color-row]]
[app.util.code-gen :as cg]
[app.util.color :as uc]
[app.util.i18n :refer [tr]]
[rumext.alpha :as mf]))
(def fill-attributes [:fill-color :fill-color-gradient]) (def fill-attributes [:fill-color :fill-color-gradient])
@ -36,7 +35,7 @@
{:to-prop "background" {:to-prop "background"
:format #(uc/color->background (shape->color shape))})) :format #(uc/color->background (shape->color shape))}))
(mf/defc fill-block [{:keys [shape locale]}] (mf/defc fill-block [{:keys [shape]}]
(let [color-format (mf/use-state :hex) (let [color-format (mf/use-state :hex)
color (shape->color shape)] color (shape->color shape)]
@ -46,16 +45,15 @@
:copy-data (copy-data shape)}])) :copy-data (copy-data shape)}]))
(mf/defc fill-panel (mf/defc fill-panel
[{:keys [shapes locale]}] [{:keys [shapes]}]
(let [shapes (->> shapes (filter has-color?))] (let [shapes (->> shapes (filter has-color?))]
(when (seq shapes) (when (seq shapes)
[:div.attributes-block [:div.attributes-block
[:div.attributes-block-title [:div.attributes-block-title
[:div.attributes-block-title-text (t locale "handoff.attributes.fill")] [:div.attributes-block-title-text (tr "handoff.attributes.fill")]
(when (= (count shapes) 1) (when (= (count shapes) 1)
[:& copy-button {:data (copy-data (first shapes))}])] [:& copy-button {:data (copy-data (first shapes))}])]
(for [shape shapes] (for [shape shapes]
[:& fill-block {:key (str "fill-block-" (:id shape)) [:& fill-block {:key (str "fill-block-" (:id shape))
:shape shape :shape shape}])])))
:locale locale}])])))

View file

@ -6,19 +6,17 @@
(ns app.main.ui.handoff.attributes.image (ns app.main.ui.handoff.attributes.image
(:require (:require
[rumext.alpha :as mf]
[cuerdas.core :as str]
[app.config :as cfg] [app.config :as cfg]
[app.util.i18n :refer [t]] [app.main.ui.components.copy-button :refer [copy-button]]
[app.util.dom :as dom]
[app.main.ui.icons :as i]
[app.util.code-gen :as cg] [app.util.code-gen :as cg]
[app.main.ui.components.copy-button :refer [copy-button]])) [app.util.dom :as dom]
[app.util.i18n :refer [tr]]
[rumext.alpha :as mf]))
(defn has-image? [shape] (defn has-image? [shape]
(and (= (:type shape) :image))) (= (:type shape) :image))
(mf/defc image-panel [{:keys [shapes locale]}] (mf/defc image-panel [{:keys [shapes]}]
(let [shapes (->> shapes (filter has-image?))] (let [shapes (->> shapes (filter has-image?))]
(for [shape shapes] (for [shape shapes]
[:div.attributes-block {:key (str "image-" (:id shape))} [:div.attributes-block {:key (str "image-" (:id shape))}
@ -27,12 +25,12 @@
[:img {:src (cfg/resolve-file-media (-> shape :metadata))}]]] [:img {:src (cfg/resolve-file-media (-> shape :metadata))}]]]
[:div.attributes-unit-row [:div.attributes-unit-row
[:div.attributes-label (t locale "handoff.attributes.image.width")] [:div.attributes-label (tr "handoff.attributes.image.width")]
[:div.attributes-value (-> shape :metadata :width) "px"] [:div.attributes-value (-> shape :metadata :width) "px"]
[:& copy-button {:data (cg/generate-css-props shape :width)}]] [:& copy-button {:data (cg/generate-css-props shape :width)}]]
[:div.attributes-unit-row [:div.attributes-unit-row
[:div.attributes-label (t locale "handoff.attributes.image.height")] [:div.attributes-label (tr "handoff.attributes.image.height")]
[:div.attributes-value (-> shape :metadata :height) "px"] [:div.attributes-value (-> shape :metadata :height) "px"]
[:& copy-button {:data (cg/generate-css-props shape :height)}]] [:& copy-button {:data (cg/generate-css-props shape :height)}]]
@ -44,4 +42,4 @@
(str name "." extension) (str name "." extension)
name) name)
:href (cfg/resolve-file-media (-> shape :metadata))} :href (cfg/resolve-file-media (-> shape :metadata))}
(t locale "handoff.attributes.image.download")])]))) (tr "handoff.attributes.image.download")])])))