diff --git a/.circleci/config.yml b/.circleci/config.yml index fc6f86d2e6..09e3e6a893 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,11 +33,20 @@ jobs: # fallback to using the latest cache if no exact match is found - v1-dependencies- - # run backend lint + - run: + name: common lint + working_directory: "./common" + command: "clj-kondo --parallel --lint src/" + + - run: + name: frontend lint + working_directory: "./frontend" + command: "clj-kondo --parallel --lint src/" + - run: name: backend lint working_directory: "./backend" - command: "clj-kondo --lint src/" + command: "clj-kondo --parallel --lint src/" # run backend test - run: @@ -62,11 +71,6 @@ jobs: JAVA_HOME: /usr/lib/jvm/openjdk16 PATH: /usr/local/nodejs/bin/:/usr/local/bin:/bin:/usr/bin:/usr/lib/jvm/openjdk16/bin - # - run: - # name: common lint - # working_directory: "./common" - # command: "clj-kondo --lint src/" - - run: working_directory: "./common" name: common tests diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index 7f0a4e788c..ec3b66f776 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -1,14 +1,30 @@ -{:lint-as {potok.core/reify clojure.core/reify - promesa.core/let clojure.core/let - rumext.alpha/defc clojure.core/defn - app.common.data/export clojure.core/def - app.db/with-atomic clojure.core/with-open} +{:lint-as + {promesa.core/let clojure.core/let + rumext.alpha/defc clojure.core/defn + rumext.alpha/fnc clojure.core/fn + app.common.data/export clojure.core/def + app.db/with-atomic clojure.core/with-open} :hooks - {:analyze-call {app.common.data/export hooks.export/export}} + {:analyze-call + {app.common.data/export hooks.export/export + potok.core/reify hooks.export/potok-reify + cljs.core/specify! hooks.export/clojure-specify + app.util.services/defmethod hooks.export/service-defmethod + }} :output - {:exclude-files ["data_readers.clj"]} + {:exclude-files + ["data_readers.clj" + "app/util/perf.cljs" + "app/common/exceptions.cljc" + "app/util/import/.*" + "app/worker/export.cljs" + "app/worker/import.cljs" + "app/libs/.*" + "app/main/data/workspace/path/selection.cljs" + "app/main/data/workspace/transforms.cljs" + ]} :linters {:unsorted-required-namespaces @@ -21,12 +37,12 @@ :single-key-in {:level :warning} + :redundant-do + {:level :off} + :unused-binding {:exclude-destructured-as true :exclude-destructured-keys-in-fn-args false } - - :unresolved-symbol - {:exclude ['(app.util.services/defmethod) - ]}}} + }} diff --git a/.clj-kondo/hooks/export.clj b/.clj-kondo/hooks/export.clj index bac6996ca6..f29cc1a156 100644 --- a/.clj-kondo/hooks/export.clj +++ b/.clj-kondo/hooks/export.clj @@ -9,3 +9,41 @@ (api/token-node (symbol (name (:value sname)))) sname])] {:node result})) + +(defn potok-reify + [{:keys [:node]}] + (let [[rnode rtype & other] (:children node) + result (api/list-node + (into [(api/token-node (symbol "deftype")) + (api/token-node (gensym (name (:k rtype)))) + (api/vector-node [])] + other))] + {:node result})) + +(defn clojure-specify + [{:keys [:node]}] + (let [[rnode rtype & other] (:children node) + result (api/list-node + (into [(api/token-node (symbol "extend-type")) + (api/token-node (gensym (:string-value rtype)))] + other))] + {:node result})) + + +(defn service-defmethod + [{:keys [:node]}] + (let [[rnode rtype & other] (:children node) + rsym (gensym (name (:k rtype))) + result (api/list-node + [(api/token-node (symbol "do")) + (api/list-node + [(api/token-node (symbol "declare")) + (api/token-node rsym)]) + (api/list-node + (into [(api/token-node (symbol "defmethod")) + (api/token-node rsym) + rtype] + other))])] + {:node result})) + + diff --git a/backend/src/app/rpc/mutations/files.clj b/backend/src/app/rpc/mutations/files.clj index 0b6da5b516..3c266268d3 100644 --- a/backend/src/app/rpc/mutations/files.clj +++ b/backend/src/app/rpc/mutations/files.clj @@ -169,7 +169,7 @@ (s/keys :req-un [::profile-id ::file-id ::library-id])) (sv/defmethod ::unlink-file-from-library - [{:keys [pool] :as cfg} {:keys [profile-id file-id library-id] :as params}] + [{:keys [pool] :as cfg} {:keys [profile-id file-id] :as params}] (db/with-atomic [conn pool] (files/check-edition-permissions! conn profile-id file-id) (unlink-file-from-library conn params))) @@ -189,7 +189,7 @@ (s/keys :req-un [::profile-id ::file-id ::library-id])) (sv/defmethod ::update-sync - [{:keys [pool] :as cfg} {:keys [profile-id file-id library-id] :as params}] + [{:keys [pool] :as cfg} {:keys [profile-id file-id] :as params}] (db/with-atomic [conn pool] (files/check-edition-permissions! conn profile-id file-id) (update-sync conn params))) @@ -209,7 +209,7 @@ (s/keys :req-un [::profile-id ::file-id ::date])) (sv/defmethod ::ignore-sync - [{:keys [pool] :as cfg} {:keys [profile-id file-id date] :as params}] + [{:keys [pool] :as cfg} {:keys [profile-id file-id] :as params}] (db/with-atomic [conn pool] (files/check-edition-permissions! conn profile-id file-id) (ignore-sync conn params))) diff --git a/backend/src/app/rpc/mutations/ldap.clj b/backend/src/app/rpc/mutations/ldap.clj index ec9c7f0c51..d327589d89 100644 --- a/backend/src/app/rpc/mutations/ldap.clj +++ b/backend/src/app/rpc/mutations/ldap.clj @@ -48,7 +48,7 @@ :opt-un [::invitation-token])) (sv/defmethod ::login-with-ldap {:auth false :rlimit :password} - [{:keys [pool session tokens] :as cfg} {:keys [email password invitation-token] :as params}] + [{:keys [pool session tokens] :as cfg} params] (db/with-atomic [conn pool] (let [info (authenticate params) cfg (assoc cfg :conn conn)] diff --git a/backend/src/app/rpc/mutations/management.clj b/backend/src/app/rpc/mutations/management.clj index 7ef6207263..1cf1117292 100644 --- a/backend/src/app/rpc/mutations/management.clj +++ b/backend/src/app/rpc/mutations/management.clj @@ -167,7 +167,7 @@ :opt-un [::name])) (sv/defmethod ::duplicate-file - [{:keys [pool] :as cfg} {:keys [profile-id file-id name] :as params}] + [{:keys [pool] :as cfg} {:keys [profile-id file-id] :as params}] (db/with-atomic [conn pool] (let [file (db/get-by-id conn :file file-id) index {file-id (uuid/next)} @@ -187,7 +187,7 @@ :opt-un [::name])) (sv/defmethod ::duplicate-project - [{:keys [pool] :as cfg} {:keys [profile-id project-id name] :as params}] + [{:keys [pool] :as cfg} {:keys [profile-id project-id] :as params}] (db/with-atomic [conn pool] (let [project (db/get-by-id conn :project project-id)] (teams/check-edition-permissions! conn profile-id (:team-id project)) diff --git a/backend/src/app/rpc/mutations/profile.clj b/backend/src/app/rpc/mutations/profile.clj index 1aa3a8ae47..b40cf802a6 100644 --- a/backend/src/app/rpc/mutations/profile.clj +++ b/backend/src/app/rpc/mutations/profile.clj @@ -131,8 +131,7 @@ :opt-un [::accept-newsletter-subscription])) (sv/defmethod ::register-profile {:auth false :rlimit :password} - [{:keys [pool tokens session] :as cfg} params] - + [{:keys [pool] :as cfg} params] (when-not (:accept-terms-and-privacy params) (ex/raise :type :validation :code :invalid-terms-and-privacy)) @@ -292,7 +291,7 @@ :opt-un [::scope ::invitation-token])) (sv/defmethod ::login {:auth false :rlimit :password} - [{:keys [pool session tokens] :as cfg} {:keys [email password scope] :as params}] + [{:keys [pool session tokens] :as cfg} {:keys [email password] :as params}] (letfn [(check-password [profile password] (when (= (:password profile) "!") (ex/raise :type :validation @@ -343,7 +342,7 @@ (s/keys :req-un [::profile-id])) (sv/defmethod ::logout - [{:keys [pool session] :as cfg} {:keys [profile-id] :as params}] + [{:keys [session] :as cfg} _] (with-meta {} {:transform-response (:delete session)})) @@ -376,7 +375,7 @@ (s/keys :req-un [::profile-id ::password ::old-password])) (sv/defmethod ::update-profile-password {:rlimit :password} - [{:keys [pool] :as cfg} {:keys [password profile-id] :as params}] + [{:keys [pool] :as cfg} {:keys [password] :as params}] (db/with-atomic [conn pool] (let [profile (validate-password! conn params)] (update-profile-password! conn (assoc profile :password password)) diff --git a/backend/src/app/rpc/queries/files.clj b/backend/src/app/rpc/queries/files.clj index 730efe8d5e..74938feb23 100644 --- a/backend/src/app/rpc/queries/files.clj +++ b/backend/src/app/rpc/queries/files.clj @@ -232,7 +232,7 @@ (update data :objects update-objects))) (sv/defmethod ::page - [{:keys [pool] :as cfg} {:keys [profile-id file-id id strip-thumbnails]}] + [{:keys [pool] :as cfg} {:keys [profile-id file-id strip-thumbnails]}] (db/with-atomic [conn pool] (check-edition-permissions! conn profile-id file-id) (let [cfg (assoc cfg :conn conn) @@ -260,7 +260,7 @@ (s/keys :req-un [::profile-id ::team-id])) (sv/defmethod ::shared-files - [{:keys [pool] :as cfg} {:keys [profile-id team-id] :as params}] + [{:keys [pool] :as cfg} {:keys [team-id] :as params}] (into [] decode-row-xf (db/exec! pool [sql:shared-files team-id]))) @@ -285,7 +285,7 @@ (s/keys :req-un [::profile-id ::team-id])) (sv/defmethod ::team-shared-files - [{:keys [pool] :as cfg} {:keys [profile-id team-id] :as params}] + [{:keys [pool] :as cfg} {:keys [team-id] :as params}] (db/exec! pool [sql:team-shared-files team-id])) diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index acc7bc0633..df18739ea4 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -11,8 +11,8 @@ (:require-macros [app.common.data])) (:require [app.common.math :as mth] + [cljs.analyzer.api :as aapi] [clojure.set :as set] - #?(:clj [cljs.analyzer.api :as aapi]) #?(:cljs [cljs.reader :as r] :clj [clojure.edn :as r]) #?(:cljs [cljs.core :as core] @@ -275,7 +275,7 @@ ;; Data Parsing / Conversion ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defn- nan? +(defn nan? [v] (not= v v)) @@ -506,7 +506,7 @@ (defn- extract-numeric-suffix [basename] - (if-let [[match p1 p2] (re-find #"(.*)-([0-9]+)$" basename)] + (if-let [[_ p1 p2] (re-find #"(.*)-([0-9]+)$" basename)] [p1 (+ 1 (parse-integer p2))] [basename 1])) diff --git a/common/src/app/common/geom/matrix.cljc b/common/src/app/common/geom/matrix.cljc index decd12595f..c04c05bb3b 100644 --- a/common/src/app/common/geom/matrix.cljc +++ b/common/src/app/common/geom/matrix.cljc @@ -31,7 +31,7 @@ (defn str->matrix [matrix-str] (let [params (->> (re-seq number-regex matrix-str) - (filter #(-> % first empty? not)) + (filter #(-> % first seq)) (map (comp d/parse-double first)))] (apply matrix params))) @@ -52,12 +52,11 @@ "Given two TRANSLATE matrixes (only e and f have significative values), combine them. Quicker than multiplying them, for this precise case." - ([{m1a :a m1b :b m1c :c m1d :d m1e :e m1f :f} - {m2a :a m2b :b m2c :c m2d :d m2e :e m2f :f}] + ([{m1e :e m1f :f} {m2e :e m2f :f}] (Matrix. - 1 - 0 - 0 + 1 + 0 + 0 1 (+ m1e m2e) (+ m1f m2f))) diff --git a/common/src/app/common/pages/changes.cljc b/common/src/app/common/pages/changes.cljc index e705619814..47eec12ead 100644 --- a/common/src/app/common/pages/changes.cljc +++ b/common/src/app/common/pages/changes.cljc @@ -32,13 +32,10 @@ (when verify? (us/assert ::spec/changes items)) - (let [pages (into #{} (map :page-id) items) - result (->> items - (reduce #(or (process-change %1 %2) %1) data))] - + (let [result (reduce #(or (process-change %1 %2) %1) data items)] ;; Validate result shapes (only on the backend) #?(:clj - (doseq [page-id pages] + (doseq [page-id (into #{} (map :page-id) items)] (let [page (get-in result [:pages-index page-id])] (doseq [[id shape] (:objects page)] (when-not (= shape (get-in data [:pages-index page-id :objects id])) diff --git a/common/src/app/common/pages/spec.cljc b/common/src/app/common/pages/spec.cljc index 32c010cfd8..9c445ce6de 100644 --- a/common/src/app/common/pages/spec.cljc +++ b/common/src/app/common/pages/spec.cljc @@ -395,11 +395,11 @@ :internal.media-object/mtype])) (s/def ::media-object-update - (s/keys :req-un [::id] - :req-opt [::name - :internal.media-object/width - :internal.media-object/height - :internal.media-object/mtype])) + (s/keys :req-un [::id] + :opt-un [::name + :internal.media-object/width + :internal.media-object/height + :internal.media-object/mtype])) (s/def :internal.file/colors (s/map-of ::uuid ::color)) diff --git a/common/src/app/common/spec.cljc b/common/src/app/common/spec.cljc index 2ab5f6a8ee..ca369fb516 100644 --- a/common/src/app/common/spec.cljc +++ b/common/src/app/common/spec.cljc @@ -15,11 +15,11 @@ ;; NOTE: don't remove this, causes exception on advanced build ;; because of some strange interaction with cljs.spec.alpha and ;; modules spliting. - [expound.alpha] [app.common.exceptions :as ex] [app.common.geom.point :as gpt] [app.common.uuid :as uuid] - [cuerdas.core :as str])) + [cuerdas.core :as str] + [expound.alpha])) (s/check-asserts true) diff --git a/common/src/app/common/uuid.cljc b/common/src/app/common/uuid.cljc index 25f9893815..4d0e483590 100644 --- a/common/src/app/common/uuid.cljc +++ b/common/src/app/common/uuid.cljc @@ -7,7 +7,7 @@ (ns app.common.uuid (:refer-clojure :exclude [next uuid zero?]) (:require - [app.common.data :as d] + #?(:clj [app.common.data :as d]) #?(:clj [clj-uuid :as impl]) #?(:clj [clojure.core :as c]) #?(:cljs [app.common.uuid-impl :as impl]) diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index 42b90c26ca..0cc0a34273 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -6,9 +6,8 @@ (ns app.config (:require - [app.common.data :as d] - [app.common.uri :as u] [app.common.spec :as us] + [app.common.uri :as u] [app.common.version :as v] [app.util.avatars :as avatars] [app.util.dom :as dom] diff --git a/frontend/src/app/main.cljs b/frontend/src/app/main.cljs index dc2a58f961..ce862ff133 100644 --- a/frontend/src/app/main.cljs +++ b/frontend/src/app/main.cljs @@ -12,7 +12,6 @@ [app.main.data.events :as ev] [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 :as ui] [app.main.ui.confirm] @@ -21,11 +20,9 @@ [app.util.dom :as dom] [app.util.i18n :as i18n] [app.util.logging :as log] - [app.util.object :as obj] [app.util.router :as rt] [app.util.storage :refer [storage]] [app.util.theme :as theme] - [app.util.timers :as ts] [beicon.core :as rx] [cljs.spec.alpha :as s] [potok.core :as ptk] @@ -81,7 +78,7 @@ (defn initialize [] - (letfn [(on-profile [profile] + (letfn [(on-profile [_profile] (rx/of (rt/initialize-router ui/routes) (rt/initialize-history on-navigate)))] (ptk/reify ::initialize @@ -90,7 +87,7 @@ (assoc state :session-id (uuid/next))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (rx/merge (rx/of (ptk/event ::ev/initialize) diff --git a/frontend/src/app/main/data/comments.cljs b/frontend/src/app/main/data/comments.cljs index 034921fda3..5250b7202d 100644 --- a/frontend/src/app/main/data/comments.cljs +++ b/frontend/src/app/main/data/comments.cljs @@ -6,28 +6,11 @@ (ns app.main.data.comments (:require - [cuerdas.core :as str] [app.common.data :as d] - [app.common.exceptions :as ex] - [app.common.geom.matrix :as gmt] - [app.common.geom.point :as gpt] - [app.common.geom.shapes :as geom] - [app.common.math :as mth] - [app.common.pages :as cp] [app.common.spec :as us] - [app.common.uuid :as uuid] - [app.config :as cfg] - [app.main.constants :as c] [app.main.repo :as rp] - [app.main.store :as st] - [app.main.streams :as ms] - [app.main.worker :as uw] - [app.util.router :as rt] - [app.util.timers :as ts] - [app.util.webapi :as wapi] [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] [potok.core :as ptk])) (s/def ::content ::us/string) @@ -91,7 +74,7 @@ (ptk/reify ::create-thread ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation :create-comment-thread params) (rx/mapcat #(rp/query :comment-thread {:file-id (:file-id %) :id (:id %)})) (rx/map #(partial created %))))))) @@ -101,7 +84,7 @@ (us/assert ::comment-thread thread) (ptk/reify ::update-comment-thread-status ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [done #(d/update-in-when % [:comment-threads id] assoc :count-unread-comments 0)] (->> (rp/mutation :update-comment-thread-status {:id id}) (rx/map (constantly done))))))) @@ -117,7 +100,7 @@ (d/update-in-when state [:comment-threads id] assoc :is-resolved is-resolved)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation :update-comment-thread {:id id :is-resolved is-resolved}) (rx/ignore))))) @@ -130,7 +113,7 @@ (update-in state [:comments (:id thread)] assoc (:id comment) comment))] (ptk/reify ::create-comment ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (rx/concat (->> (rp/mutation :add-comment {:thread-id (:id thread) :content content}) (rx/map #(partial created %))) @@ -145,7 +128,7 @@ (d/update-in-when state [:comments thread-id id] assoc :content content)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation :update-comment {:id id :content content}) (rx/ignore))))) @@ -160,7 +143,7 @@ (update :comment-threads dissoc id))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation :delete-comment-thread {:id id}) (rx/ignore))))) @@ -173,7 +156,7 @@ (d/update-in-when state [:comments thread-id] dissoc id)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation :delete-comment {:id id}) (rx/ignore))))) @@ -184,7 +167,7 @@ (assoc-in state [:comment-threads id] thread))] (ptk/reify ::refresh-comment-thread ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :comment-thread {:file-id file-id :id id}) (rx/map #(partial fetched %))))))) @@ -195,7 +178,7 @@ (assoc state :comment-threads (d/index-by :id data)))] (ptk/reify ::retrieve-comment-threads ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :comment-threads {:file-id file-id}) (rx/map #(partial fetched %))))))) @@ -206,7 +189,7 @@ (update state :comments assoc thread-id (d/index-by :id comments)))] (ptk/reify ::retrieve-comments ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :comments {:thread-id thread-id}) (rx/map #(partial fetched %))))))) @@ -216,7 +199,7 @@ (us/assert ::us/uuid team-id) (ptk/reify ::retrieve-unread-comment-threads ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [fetched #(assoc %2 :comment-threads (d/index-by :id %1))] (->> (rp/query :unread-comment-threads {:team-id team-id}) (rx/map #(partial fetched %))))))) @@ -320,7 +303,7 @@ (defn apply-filters [cstate profile threads] - (let [{:keys [show mode open]} cstate] + (let [{:keys [show mode]} cstate] (cond->> threads (= :pending show) (filter (comp not :is-resolved)) diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index 8bdc4dafe6..b55b5cab0d 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -7,23 +7,16 @@ (ns app.main.data.dashboard (:require [app.common.data :as d] - [app.common.pages :as cp] [app.common.spec :as us] [app.common.uuid :as uuid] - [app.main.repo :as rp] - [app.main.data.events :as ev] - [app.main.data.users :as du] [app.main.data.fonts :as df] + [app.main.data.media :as di] + [app.main.data.users :as du] + [app.main.repo :as rp] [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] - [app.util.time :as dt] - [app.util.timers :as ts] - [app.util.avatars :as avatars] - [app.main.data.media :as di] - [app.main.data.messages :as dm] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [potok.core :as ptk])) ;; --- Specs @@ -44,13 +37,13 @@ ::modified-at])) (s/def ::project - (s/keys ::req-un [::id - ::name - ::team-id - ::profile-id - ::created-at - ::modified-at - ::is-pinned])) + (s/keys :req-un [::id + ::name + ::team-id + ::profile-id + ::created-at + ::modified-at + ::is-pinned])) (s/def ::file (s/keys :req-un [::id @@ -109,7 +102,7 @@ [] (ptk/reify ::fetch-team-members ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/query :team-members {:team-id team-id}) (rx/map team-members-fetched)))))) @@ -127,7 +120,7 @@ [] (ptk/reify ::fetch-team-stats ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/query :team-stats {:team-id team-id}) (rx/map team-stats-fetched)))))) @@ -146,7 +139,7 @@ [] (ptk/reify ::fetch-projects ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/query :projects {:team-id team-id}) (rx/map projects-fetched)))))) @@ -173,7 +166,7 @@ (dissoc state :dashboard-search-result)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state) params (assoc params :team-id team-id)] (->> (rp/query :search-files params) @@ -202,7 +195,7 @@ (us/assert ::us/uuid project-id) (ptk/reify ::fetch-files ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :project-files {:project-id project-id}) (rx/map #(files-fetched project-id %)))))) @@ -219,7 +212,7 @@ [] (ptk/reify ::fetch-shared-files ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/query :team-shared-files {:team-id team-id}) (rx/map shared-files-fetched)))))) @@ -240,7 +233,7 @@ [] (ptk/reify ::fetch-recent-files ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/query :team-recent-files {:team-id team-id}) (rx/map recent-files-fetched)))))) @@ -293,7 +286,7 @@ (us/assert string? name) (ptk/reify ::create-team ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params)] @@ -313,7 +306,7 @@ (assoc-in state [:teams id :name] name)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation! :update-team params) (rx/ignore))))) @@ -322,7 +315,7 @@ (us/assert ::di/file file) (ptk/reify ::update-team-photo ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [on-success di/notify-finished-loading on-error #(do (di/notify-finished-loading) (di/process-error %)) @@ -344,7 +337,7 @@ (us/assert ::us/keyword role) (ptk/reify ::update-team-member-role ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state) params (assoc params :team-id team-id)] (->> (rp/mutation! :update-team-member-role params) @@ -357,7 +350,7 @@ (us/assert ::us/uuid member-id) (ptk/reify ::delete-team-member ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state) params (assoc params :team-id team-id)] (->> (rp/mutation! :delete-team-member params) @@ -370,7 +363,7 @@ (us/assert (s/nilable ::us/uuid) reassign-to) (ptk/reify ::leave-team ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params) @@ -391,7 +384,7 @@ (us/assert ::us/keyword role) (ptk/reify ::invite-team-member ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params) @@ -408,7 +401,7 @@ (us/assert ::team params) (ptk/reify ::delete-team ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params)] @@ -434,7 +427,7 @@ [] (ptk/reify ::create-project ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [name (name (gensym (str (tr "dashboard.new-project-prefix") " "))) team-id (:current-team-id state) params {:name name @@ -461,7 +454,7 @@ (us/assert ::us/uuid id) (ptk/reify ::duplicate-project ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params) @@ -480,7 +473,7 @@ (us/assert ::us/uuid team-id) (ptk/reify ::move-project ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params)] @@ -491,7 +484,7 @@ (rx/catch on-error)))))) (defn toggle-project-pin - [{:keys [id is-pinned team-id] :as project}] + [{:keys [id is-pinned] :as project}] (us/assert ::project project) (ptk/reify ::toggle-project-pin ptk/UpdateEvent @@ -499,7 +492,7 @@ (assoc-in state [:dashboard-projects id :is-pinned] (not is-pinned))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [project (get-in state [:dashboard-projects id]) params (select-keys project [:id :is-pinned :team-id])] (->> (rp/mutation :update-project-pin params) @@ -508,7 +501,7 @@ ;; --- EVENT: rename-project (defn rename-project - [{:keys [id name team-id] :as params}] + [{:keys [id name] :as params}] (us/assert ::project params) (ptk/reify ::rename-project ptk/UpdateEvent @@ -518,7 +511,7 @@ (update :dashboard-local dissoc :project-for-edit))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [params {:id id :name name}] (->> (rp/mutation :rename-project params) (rx/ignore)))))) @@ -526,7 +519,7 @@ ;; --- EVENT: delete-project (defn delete-project - [{:keys [id team-id] :as params}] + [{:keys [id] :as params}] (us/assert ::project params) (ptk/reify ::delete-project ptk/UpdateEvent @@ -534,14 +527,14 @@ (update state :dashboard-projects dissoc id)) ptk/WatchEvent - (watch [_ state s] + (watch [_ _ _] (->> (rp/mutation :delete-project {:id id}) (rx/ignore))))) ;; --- EVENT: delete-file (defn file-deleted - [team-id project-id] + [_team-id project-id] (ptk/reify ::file-deleted ptk/UpdateEvent (update [_ state] @@ -558,7 +551,7 @@ (d/update-when :dashboard-recent-files dissoc id))) ptk/WatchEvent - (watch [_ state s] + (watch [_ state _] (let [team-id (uuid/uuid (get-in state [:route :path-params :team-id]))] (->> (rp/mutation :delete-file {:id id}) (rx/map #(file-deleted team-id project-id))))))) @@ -576,7 +569,7 @@ (d/update-in-when [:dashboard-recent-files id :name] (constantly name)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [params (select-keys params [:id :name])] (->> (rp/mutation :rename-file params) (rx/ignore)))))) @@ -594,7 +587,7 @@ (d/update-in-when [:dashboard-recent-files id :is-shared] (constantly is-shared)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [params {:id id :is-shared is-shared}] (->> (rp/mutation :set-file-shared params) (rx/ignore)))))) @@ -621,7 +614,7 @@ (us/assert ::us/uuid project-id) (ptk/reify ::create-file ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params) @@ -642,7 +635,7 @@ (us/assert ::name name) (ptk/reify ::duplicate-file ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params) @@ -663,7 +656,7 @@ (us/assert ::us/uuid project-id) (ptk/reify ::move-files ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error rx/throw}} (meta params)] @@ -682,7 +675,7 @@ (us/assert ::file file) (ptk/reify ::go-to-workspace ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [pparams {:project-id project-id :file-id id}] (rx/of (rt/nav :workspace pparams)))))) @@ -691,14 +684,14 @@ ([project-id] (ptk/reify ::go-to-files ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (rx/of (rt/nav :dashboard-files {:team-id team-id :project-id project-id})))))) ([team-id project-id] (ptk/reify ::go-to-files ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (rx/of (rt/nav :dashboard-files {:team-id team-id :project-id project-id})))))) @@ -707,7 +700,7 @@ ([term] (ptk/reify ::go-to-search ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (if (empty? term) (rx/of (rt/nav :dashboard-search @@ -720,13 +713,13 @@ ([] (ptk/reify ::go-to-projects ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (rx/of (rt/nav :dashboard-projects {:team-id team-id})))))) ([team-id] (ptk/reify ::go-to-projects ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (du/set-current-team! team-id) (rx/of (rt/nav :dashboard-projects {:team-id team-id})))))) @@ -734,7 +727,7 @@ [] (ptk/reify ::go-to-team-members ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (rx/of (rt/nav :dashboard-team-members {:team-id team-id})))))) @@ -742,6 +735,6 @@ [] (ptk/reify ::go-to-team-settings ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (rx/of (rt/nav :dashboard-team-settings {:team-id team-id})))))) diff --git a/frontend/src/app/main/data/events.cljs b/frontend/src/app/main/data/events.cljs index ca4b99a619..83c2a835f5 100644 --- a/frontend/src/app/main/data/events.cljs +++ b/frontend/src/app/main/data/events.cljs @@ -8,14 +8,14 @@ (:require ["ua-parser-js" :as UAParser] [app.common.data :as d] - [app.main.repo :as rp] [app.config :as cf] + [app.main.repo :as rp] [app.util.globals :as g] [app.util.http :as http] + [app.util.i18n :as i18n] [app.util.object :as obj] [app.util.storage :refer [storage]] [app.util.time :as dt] - [app.util.i18n :as i18n] [beicon.core :as rx] [lambdaisland.uri :as u] [potok.core :as ptk])) @@ -139,7 +139,7 @@ :project-id (:project-id data)}})) (defn- event->generic-action - [event name] + [_ name] {:type "action" :name name :props {}}) @@ -176,7 +176,7 @@ [_ {:keys [buffer] :as params}] (ptk/reify ::persistence ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (let [profile-id (:profile-id state) events (into [] (take max-buffer-size) @buffer)] (when (seq events) @@ -191,7 +191,7 @@ (let [buffer (atom #queue [])] (ptk/reify ::initialize ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (->> (rx/merge (->> (rx/from-atom buffer) (rx/filter #(pos? (count %))) @@ -202,7 +202,7 @@ (rx/map #(ptk/event ::persistence {:buffer buffer})))) ptk/EffectEvent - (effect [_ state stream] + (effect [_ _ stream] (let [events (methods process-event) session (atom nil) diff --git a/frontend/src/app/main/data/fonts.cljs b/frontend/src/app/main/data/fonts.cljs index 41ca36c9ac..74872995b0 100644 --- a/frontend/src/app/main/data/fonts.cljs +++ b/frontend/src/app/main/data/fonts.cljs @@ -8,16 +8,14 @@ (:require ["opentype.js" :as ot] [app.common.data :as d] - [app.common.spec :as us] [app.common.media :as cm] + [app.common.spec :as us] [app.common.uuid :as uuid] [app.main.fonts :as fonts] [app.main.repo :as rp] - [app.util.i18n :as i18n :refer [tr]] [app.util.logging :as log] - [beicon.core :as rx] - [cljs.spec.alpha :as s] [app.util.webapi :as wa] + [beicon.core :as rx] [cuerdas.core :as str] [potok.core :as ptk])) @@ -62,7 +60,7 @@ (assoc state :dashboard-fonts (d/index-by :id fonts))) ptk/EffectEvent - (effect [_ state stream] + (effect [_ _ _] (let [fonts (->> fonts (map adapt-font-id) (group-by :font-id) @@ -73,7 +71,7 @@ [team-id] (ptk/reify ::load-team-fonts ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :font-variants {:team-id team-id}) (rx/map fonts-fetched))))) @@ -121,7 +119,7 @@ (parse-font [{:keys [data] :as params}] (try (assoc params :font (ot/parse data)) - (catch :default e + (catch :default _e (log/warn :msg (str/fmt "skiping file %s, unsupported format" (:name params))) nil))) @@ -204,7 +202,7 @@ fonts)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/mutation! :update-font {:id id :name name :team-id team-id}) (rx/ignore)))))) @@ -218,10 +216,10 @@ (update [_ state] (update state :dashboard-fonts (fn [variants] - (d/removem (fn [[id variant]] + (d/removem (fn [[_id variant]] (= (:font-id variant) font-id)) variants)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/mutation! :delete-font {:id font-id :team-id team-id}) (rx/ignore)))))) @@ -238,7 +236,7 @@ (= (:id variant) id)) variants)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (->> (rp/mutation! :delete-font-variant {:id id :team-id team-id}) (rx/ignore)))))) diff --git a/frontend/src/app/main/data/history.cljs b/frontend/src/app/main/data/history.cljs deleted file mode 100644 index 8da91d3874..0000000000 --- a/frontend/src/app/main/data/history.cljs +++ /dev/null @@ -1,270 +0,0 @@ -;; 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.data.history - (:require - [beicon.core :as rx] - [cljs.spec.alpha :as s] - [potok.core :as ptk] - [app.common.spec :as us] - [app.common.pages :as cp] - [app.main.repo :as rp] - [app.util.data :refer [replace-by-id index-by]])) - -;; --- Schema - -(s/def ::pinned boolean?) -(s/def ::id uuid?) -(s/def ::label string?) -(s/def ::project uuid?) -(s/def ::created-at inst?) -(s/def ::modified-at inst?) -(s/def ::version number?) -(s/def ::user uuid?) - -(s/def ::shapes - (s/every ::cp/minimal-shape :kind vector?)) - -(s/def ::data - (s/keys :req-un [::shapes])) - -(s/def ::history-entry - (s/keys :req-un [::id - ::pinned - ::label - ::project - ::created-at - ::modified-at - ::version - ::user - ::data])) - -(s/def ::history-entries - (s/every ::history-entry)) - -;; --- Initialize History State - -(declare fetch-history) -(declare fetch-pinned-history) - -(defn initialize - [id] - (us/verify ::us/uuid id) - (ptk/reify ::initialize - ptk/UpdateEvent - (update [_ state] - (update-in state [:workspace id] - assoc :history {:selected nil - :pinned #{} - :items #{} - :byver {}})) - - ptk/WatchEvent - (watch [_ state stream] - (rx/of (fetch-history id) - (fetch-pinned-history id))))) - -;; --- Watch Page Changes - -(defn watch-page-changes - [id] - (us/verify ::us/uuid id) - (reify - ptk/WatchEvent - (watch [_ state stream] - #_(let [stopper (rx/filter #(= % ::stop-page-watcher) stream)] - (->> stream - (rx/filter dp/page-persisted?) - (rx/debounce 1000) - (rx/flat-map #(rx/of (fetch-history id) - (fetch-pinned-history id))) - (rx/take-until stopper)))))) - -;; --- Pinned Page History Fetched - -(defn pinned-history-fetched - [items] - (us/verify ::history-entries items) - (ptk/reify ::pinned-history-fetched - ptk/UpdateEvent - (update [_ state] - (let [pid (get-in state [:workspace :current]) - items-map (index-by :version items) - items-set (into #{} items)] - (update-in state [:workspace pid :history] - (fn [history] - (-> history - (assoc :pinned items-set) - (update :byver merge items-map)))))))) - -;; --- Fetch Pinned Page History - -(defn fetch-pinned-history - [id] - (us/verify ::us/uuid id) - (ptk/reify ::fetch-pinned-history - ptk/WatchEvent - (watch [_ state s] - (let [params {:page id :pinned true}] - #_(->> (rp/req :fetch/page-history params) - (rx/map :payload) - (rx/map pinned-history-fetched)))))) - -;; --- Page History Fetched - -(defn history-fetched - [items] - (us/verify ::history-entries items) - (ptk/reify ::history-fetched - ptk/UpdateEvent - (update [_ state] - (let [pid (get-in state [:workspace :current]) - versions (into #{} (map :version) items) - items-map (index-by :version items) - min-version (apply min versions) - max-version (apply max versions)] - (update-in state [:workspace pid :history] - (fn [history] - (-> history - (assoc :min-version min-version) - (assoc :max-version max-version) - (update :byver merge items-map) - (update :items #(reduce conj % items))))))))) - -;; --- Fetch Page History - -(defn fetch-history - ([id] - (fetch-history id nil)) - ([id {:keys [since max]}] - (us/verify ::us/uuid id) - (ptk/reify ::fetch-history - ptk/WatchEvent - (watch [_ state s] - (let [params (merge {:page id - :max (or max 20)} - (when since - {:since since}))] - #_(->> (rp/req :fetch/page-history params) - (rx/map :payload) - (rx/map history-fetched))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Context Aware Events -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;; --- Select Section - -(deftype SelectSection [section] - ptk/UpdateEvent - (update [_ state] - (assoc-in state [:workspace :history :section] section))) - -(defn select-section - [section] - {:pre [(keyword? section)]} - (SelectSection. section)) - -;; --- Load More - -(def load-more - (ptk/reify ::load-more - ptk/WatchEvent - (watch [_ state stream] - (let [pid (get-in state [:workspace :current]) - since (get-in state [:workspace pid :history :min-version])] - (rx/of (fetch-history pid {:since since})))))) - -;; --- Select Page History - -(defn select - [version] - (us/verify int? version) - (ptk/reify ::select - ptk/UpdateEvent - (update [_ state] - #_(let [pid (get-in state [:workspace :current]) - item (get-in state [:workspace pid :history :byver version]) - page (-> (get-in state [:pages pid]) - (assoc :history true - :data (:data item)))] - (-> state - (dp/unpack-page page) - (assoc-in [:workspace pid :history :selected] version)))))) - -;; --- Apply Selected History - -(def apply-selected - (ptk/reify ::apply-selected - ptk/UpdateEvent - (update [_ state] - (let [pid (get-in state [:workspace :current])] - (-> state - (update-in [:pages pid] dissoc :history) - (assoc-in [:workspace pid :history :selected] nil)))) - - ptk/WatchEvent - (watch [_ state s] - #_(let [pid (get-in state [:workspace :current])] - (rx/of (dp/persist-page pid)))))) - -;; --- Deselect Page History - -(def deselect - (ptk/reify ::deselect - ptk/UpdateEvent - (update [_ state] - #_(let [pid (get-in state [:workspace :current]) - packed (get-in state [:packed-pages pid])] - (-> (dp/unpack-page state packed) - (assoc-in [:workspace pid :history :selected] nil)))))) - - ;; --- Refresh Page History - -(def refres-history - (ptk/reify ::refresh-history - ptk/WatchEvent - (watch [_ state stream] - (let [pid (get-in state [:workspace :current]) - history (get-in state [:workspace pid :history]) - maxitems (count (:items history))] - (rx/of (fetch-history pid {:max maxitems}) - (fetch-pinned-history pid)))))) - -;; --- History Item Updated - -(defn history-updated - [item] - (us/verify ::history-entry item) - (ptk/reify ::history-item-updated - ptk/UpdateEvent - (update [_ state] - (let [pid (get-in state [:workspace :current])] - (update-in state [:workspace pid :history] - (fn [history] - (-> history - (update :items #(into #{} (replace-by-id item) %)) - (update :pinned #(into #{} (replace-by-id item) %)) - (assoc-in [:byver (:version item)] item)))))))) - -(defn history-updated? - [v] - (= ::history-item-updated (ptk/type v))) - -;; --- Update History Item - -(defn update-history-item - [item] - (ptk/reify ::update-history-item - ptk/WatchEvent - (watch [_ state stream] - (rx/concat - #_(->> (rp/req :update/page-history item) - (rx/map :payload) - (rx/map history-updated)) - (->> (rx/filter history-updated? stream) - (rx/take 1) - (rx/map (constantly refres-history))))))) diff --git a/frontend/src/app/main/data/media.cljs b/frontend/src/app/main/data/media.cljs index 695807cc28..ba9ad47df4 100644 --- a/frontend/src/app/main/data/media.cljs +++ b/frontend/src/app/main/data/media.cljs @@ -6,22 +6,14 @@ (ns app.main.data.media (:require - [app.common.data :as d] - [app.common.media :as cm] - [app.common.spec :as us] - [app.common.uuid :as uuid] [app.common.exceptions :as ex] + [app.common.media :as cm] [app.main.data.messages :as dm] - [app.main.repo :as rp] [app.main.store :as st] [app.util.i18n :refer [tr]] - [app.util.router :as r] - [app.util.router :as rt] - [app.util.time :as ts] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] - [potok.core :as ptk])) + [cuerdas.core :as str])) ;; --- Predicates diff --git a/frontend/src/app/main/data/messages.cljs b/frontend/src/app/main/data/messages.cljs index 41b8f6db93..1a834fa3c6 100644 --- a/frontend/src/app/main/data/messages.cljs +++ b/frontend/src/app/main/data/messages.cljs @@ -7,10 +7,7 @@ (ns app.main.data.messages (:require [app.common.data :as d] - [app.common.exceptions :as ex] - [app.common.pages :as cp] [app.common.spec :as us] - [app.config :as cfg] [beicon.core :as rx] [cljs.spec.alpha :as s] [potok.core :as ptk])) @@ -54,7 +51,7 @@ (assoc state :message message))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (when (:timeout data) (let [stoper (rx/filter (ptk/type? ::show) stream)] (->> (rx/of hide) @@ -68,7 +65,7 @@ (d/update-when state :message assoc :status :hide)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stoper (rx/filter (ptk/type? ::show) stream)] (->> (rx/of #(dissoc % :message)) (rx/delay default-animation-timeout) @@ -78,7 +75,7 @@ [tag] (ptk/reify ::hide-tag ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [message (get state :message)] (when (= (:tag message) tag) (rx/of hide)))))) @@ -127,7 +124,7 @@ :tag tag}))) (defn assign-exception - [{:keys [type] :as error}] + [error] (ptk/reify ::assign-exception ptk/UpdateEvent (update [_ state] diff --git a/frontend/src/app/main/data/modal.cljs b/frontend/src/app/main/data/modal.cljs index b77f4ec159..daf3bb1b45 100644 --- a/frontend/src/app/main/data/modal.cljs +++ b/frontend/src/app/main/data/modal.cljs @@ -7,10 +7,10 @@ (ns app.main.data.modal (:refer-clojure :exclude [update]) (:require - [potok.core :as ptk] - [app.main.store :as st] [app.common.uuid :as uuid] - [cljs.core :as c])) + [app.main.store :as st] + [cljs.core :as c] + [potok.core :as ptk])) (defonce components (atom {})) @@ -29,7 +29,7 @@ :allow-click-outside false}))))) (defn update-props - ([type props] + ([_type props] (ptk/reify ::update-modal-props ptk/UpdateEvent (update [_ state] diff --git a/frontend/src/app/main/data/shortcuts.cljs b/frontend/src/app/main/data/shortcuts.cljs index e3eb7810d0..69c9596bce 100644 --- a/frontend/src/app/main/data/shortcuts.cljs +++ b/frontend/src/app/main/data/shortcuts.cljs @@ -8,7 +8,6 @@ (:refer-clojure :exclude [meta reset!]) (:require ["mousetrap" :as mousetrap] - [app.common.data :as d] [app.common.spec :as us] [app.config :as cfg] [app.util.logging :as log] @@ -164,8 +163,8 @@ (update :shortcuts (fnil conj '()) [key shortcuts]))) ptk/EffectEvent - (effect [_ state stream] - (let [[key shortcuts] (peek (:shortcuts state))] + (effect [_ state _] + (let [[_key shortcuts] (peek (:shortcuts state))] (reset! shortcuts))))) (defn pop-shortcuts @@ -179,7 +178,7 @@ (pop shortcuts) shortcuts))))) ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (let [[key* shortcuts] (peek (:shortcuts state))] (when (not= key key*) (reset! shortcuts)))))) diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 57c4e14678..32a81d39db 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -6,24 +6,20 @@ (ns app.main.data.users (:require - [app.config :as cf] [app.common.data :as d] [app.common.spec :as us] [app.common.uuid :as uuid] + [app.config :as cf] [app.main.data.events :as ev] [app.main.data.media :as di] [app.main.data.modal :as modal] - [app.main.data.messages :as dm] [app.main.repo :as rp] - [app.main.store :as st] - [app.util.avatars :as avatars] - [app.util.i18n :as i18n :refer [tr]] + [app.util.i18n :as i18n] [app.util.router :as rt] [app.util.storage :refer [storage]] [app.util.theme :as theme] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [potok.core :as ptk])) ;; --- COMMON SPECS @@ -75,7 +71,7 @@ [] (ptk/reify ::fetch-teams ptk/WatchEvent - (watch [_ state s] + (watch [_ _ _] (->> (rp/query! :teams) (rx/map teams-fetched))))) @@ -95,7 +91,7 @@ (assoc :profile profile))) ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (let [profile (:profile state)] (when (not= uuid/zero (:id profile)) (swap! storage assoc :profile profile) @@ -107,7 +103,7 @@ [] (ptk/reify ::fetch-profile ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query! :profile) (rx/map profile-fetched))))) @@ -120,7 +116,7 @@ [] (ptk/reify ::initialize-profile ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (rx/merge (rx/of (fetch-profile)) (->> stream @@ -141,7 +137,7 @@ (-deref [_] profile) ptk/WatchEvent - (watch [this state stream] + (watch [_ _ _] (let [team-id (get-current-team-id profile) profile (with-meta profile {::ev/source "login"})] @@ -166,7 +162,7 @@ (us/verify ::login-params data) (ptk/reify ::login ptk/WatchEvent - (watch [this state s] + (watch [_ _ _] (let [{:keys [on-error on-success] :or {on-error rx/throw on-success identity}} (meta data) @@ -186,7 +182,7 @@ [{:keys [profile] :as tdata}] (ptk/reify ::login-from-token ptk/WatchEvent - (watch [this state s] + (watch [_ _ _] (rx/of (logged-in (with-meta profile {::ev/source "login-with-token"})))))) @@ -201,11 +197,11 @@ (select-keys state [:route :router :session-id :history])) ptk/WatchEvent - (watch [_ state s] + (watch [_ _ _] (rx/of (rt/nav :auth-login))) ptk/EffectEvent - (effect [_ state s] + (effect [_ _ _] (reset! storage {}) (i18n/reset-locale)))) @@ -213,7 +209,7 @@ [] (ptk/reify ::logout ptk/WatchEvent - (watch [_ state s] + (watch [_ _ _] (->> (rp/mutation :logout) (rx/delay-at-least 300) (rx/catch (constantly (rx/of 1))) @@ -234,7 +230,7 @@ (s/assert ::register data) (ptk/reify ::register ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-error on-success] :or {on-error identity on-success identity}} (meta data)] @@ -249,7 +245,7 @@ (us/assert ::profile data) (ptk/reify ::update-profile ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [mdata (meta data) on-success (:on-success mdata identity) on-error (:on-error mdata #(rx/throw %))] @@ -273,7 +269,7 @@ (us/assert ::us/email email) (ptk/reify ::request-email-change ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-error on-success] :or {on-error identity on-success identity}} (meta data)] @@ -286,7 +282,7 @@ (def cancel-email-change (ptk/reify ::cancel-email-change ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation :cancel-email-change {}) (rx/map (constantly (fetch-profile))))))) @@ -302,7 +298,7 @@ (us/verify ::update-password data) (ptk/reify ::update-password ptk/WatchEvent - (watch [_ state s] + (watch [_ _ _] (let [{:keys [on-error on-success] :or {on-error identity on-success identity}} (meta data) @@ -321,7 +317,7 @@ ([{:keys [version]}] (ptk/reify ::mark-oboarding-as-viewed ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [version (or version (:main @cf/version)) props (-> (get-in state [:profile :props]) (assoc :onboarding-viewed true) @@ -336,7 +332,7 @@ (us/verify ::di/blob file) (ptk/reify ::update-photo ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [on-success di/notify-finished-loading on-error #(do (di/notify-finished-loading) (di/process-error %)) @@ -364,7 +360,7 @@ (assoc state :users)))] (ptk/reify ::fetch-team-users ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :team-users {:team-id team-id}) (rx/map #(partial fetched %))))))) @@ -374,7 +370,7 @@ [params] (ptk/reify ::request-account-deletion ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-error on-success] :or {on-error rx/throw on-success identity}} (meta params)] @@ -395,7 +391,7 @@ (us/verify ::request-profile-recovery data) (ptk/reify ::request-profile-recovery ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-error on-success] :or {on-error rx/throw on-success identity}} (meta data)] @@ -411,19 +407,17 @@ (s/keys :req-un [::password ::token])) (defn recover-profile - [{:keys [token password] :as data}] + [data] (us/verify ::recover-profile data) (ptk/reify ::recover-profile ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [{:keys [on-error on-success] :or {on-error rx/throw on-success identity}} (meta data)] (->> (rp/mutation :recover-profile data) (rx/tap on-success) - (rx/catch (fn [err] - (on-error) - (rx/empty)))))))) + (rx/catch on-error)))))) ;; --- EVENT: crete-demo-profile @@ -431,7 +425,7 @@ [] (ptk/reify ::create-demo-profile ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation :create-demo-profile {}) (rx/map login))))) diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index c4eb652924..c6dc46a37d 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -7,7 +7,6 @@ (ns app.main.data.viewer (:require [app.common.data :as d] - [app.common.exceptions :as ex] [app.common.pages :as cp] [app.common.spec :as us] [app.common.uuid :as uuid] @@ -15,8 +14,6 @@ [app.main.data.comments :as dcm] [app.main.data.fonts :as df] [app.main.repo :as rp] - [app.main.store :as st] - [app.util.avatars :as avatars] [app.util.router :as rt] [beicon.core :as rx] [cljs.spec.alpha :as s] @@ -27,7 +24,7 @@ (s/def ::id ::us/uuid) (s/def ::name ::us/string) -(s/def ::project (s/keys ::req-un [::id ::name])) +(s/def ::project (s/keys :req-un [::id ::name])) (s/def ::file (s/keys :req-un [::id ::name])) (s/def ::page ::cp/page) @@ -60,10 +57,10 @@ (s/def ::initialize-params (s/keys :req-un [::page-id ::file-id] - :opt-in [::token])) + :opt-un [::token])) (defn initialize - [{:keys [page-id file-id token] :as params}] + [{:keys [page-id file-id] :as params}] (us/assert ::initialize-params params) (ptk/reify ::initialize ptk/UpdateEvent @@ -78,7 +75,7 @@ lstate))))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (rx/of (fetch-bundle params) (fetch-comment-threads params))))) @@ -86,14 +83,14 @@ (s/def ::fetch-bundle-params (s/keys :req-un [::page-id ::file-id] - :opt-in [::token])) + :opt-un [::token])) (defn fetch-bundle [{:keys [page-id file-id token] :as params}] (us/assert ::fetch-bundle-params params) (ptk/reify ::fetch-file ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [params (cond-> {:page-id page-id :file-id file-id} (string? token) (assoc :token token))] @@ -145,7 +142,7 @@ (ptk/reify ::fetch-comment-threads ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :comment-threads {:file-id file-id}) (rx/map #(partial fetched %)) (rx/catch on-error)))))) @@ -156,7 +153,7 @@ (assoc-in state [:comment-threads id] thread))] (ptk/reify ::refresh-comment-thread ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :comment-thread {:file-id file-id :id id}) (rx/map #(partial fetched %))))))) @@ -167,7 +164,7 @@ (update state :comments assoc thread-id (d/index-by :id comments)))] (ptk/reify ::retrieve-comments ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/query :comments {:thread-id thread-id}) (rx/map #(partial fetched %))))))) @@ -175,7 +172,7 @@ [] (ptk/reify ::create-share-link ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [file-id (:current-file-id state) page-id (:current-page-id state)] (->> (rp/mutation! :create-file-share-token {:file-id file-id @@ -187,7 +184,7 @@ [] (ptk/reify ::delete-share-link ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [file-id (:current-file-id state) page-id (:current-page-id state) token (get-in state [:viewer-data :token]) @@ -246,7 +243,7 @@ (def select-prev-frame (ptk/reify ::select-prev-frame ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [route (:route state) screen (-> route :data :name keyword) qparams (:query-params route) @@ -260,7 +257,7 @@ (def select-next-frame (ptk/reify ::select-prev-frame ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [route (:route state) screen (-> route :data :name keyword) qparams (:query-params route) @@ -296,7 +293,7 @@ (assoc-in state [:viewer-local :interactions-show?] true)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stopper (rx/filter (ptk/type? ::flash-interactions) stream)] (->> (rx/of flash-done) (rx/delay 500) @@ -314,7 +311,7 @@ [index] (ptk/reify ::go-to-frame ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [route (:route state) screen (-> route :data :name keyword) qparams (:query-params route) @@ -326,7 +323,7 @@ (us/verify ::us/uuid frame-id) (ptk/reify ::go-to-frame ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [frames (get-in state [:viewer-data :frames]) index (d/index-of-pred frames #(= (:id %) frame-id))] (when index @@ -337,13 +334,11 @@ [section] (ptk/reify ::go-to-section ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [route (:route state) - screen (-> route :data :name keyword) pparams (:path-params route) qparams (:query-params route)] - (rx/of - (rt/nav :viewer pparams (assoc qparams :section section))))))) + (rx/of (rt/nav :viewer pparams (assoc qparams :section section))))))) (defn set-current-frame [frame-id] @@ -422,6 +417,6 @@ ([{:keys [team-id]}] (ptk/reify ::go-to-dashboard ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [team-id (or team-id (get-in state [:viewer-data :project :team-id]))] (rx/of (rt/nav :dashboard-projects {:team-id team-id}))))))) diff --git a/frontend/src/app/main/data/viewer/shortcuts.cljs b/frontend/src/app/main/data/viewer/shortcuts.cljs index 91ea3b3008..86f1ad8800 100644 --- a/frontend/src/app/main/data/viewer/shortcuts.cljs +++ b/frontend/src/app/main/data/viewer/shortcuts.cljs @@ -6,15 +6,9 @@ (ns app.main.data.viewer.shortcuts (:require - [app.config :as cfg] - [app.main.data.workspace.colors :as mdc] [app.main.data.shortcuts :as ds] - [app.main.data.shortcuts :refer [c-mod]] [app.main.data.viewer :as dv] - [app.main.store :as st] - [app.util.dom :as dom] - [beicon.core :as rx] - [potok.core :as ptk])) + [app.main.store :as st])) (def shortcuts {:increase-zoom {:tooltip "+" diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 618b656a12..aca9860a61 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -38,7 +38,6 @@ [app.main.worker :as uw] [app.util.http :as http] [app.util.i18n :as i18n] - [app.util.logging :as log] [app.util.router :as rt] [app.util.webapi :as wapi] [beicon.core :as rx] @@ -134,7 +133,7 @@ (or layout default-layout)))) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (if (and layout-name (contains? layout-names layout-name)) (rx/of (ensure-layout layout-name)) (rx/of (ensure-layout :layers)))))) @@ -153,7 +152,7 @@ :workspace-presence {})) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ stream] (rx/merge (rx/of (dwp/fetch-bundle project-id file-id)) @@ -162,7 +161,7 @@ (rx/filter (ptk/type? ::dwp/bundle-fetched)) (rx/take 1) (rx/map deref) - (rx/mapcat (fn [{:keys [project] :as bundle}] + (rx/mapcat (fn [bundle] (rx/merge (rx/of (dwn/initialize file-id) (dwp/initialize-file-persistence file-id) @@ -188,7 +187,7 @@ :workspace-libraries (d/index-by :id libraries))) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [file-id (:id file) ignore-until (:ignore-sync-until file) needs-update? (some #(and (> (:modified-at %) (:synced-at %)) @@ -199,7 +198,7 @@ (rx/of (dwl/notify-sync-file file-id))))))) (defn finalize-file - [project-id file-id] + [_project-id file-id] (ptk/reify ::finalize ptk/UpdateEvent (update [_ state] @@ -210,7 +209,7 @@ :workspace-persistence)) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (dwn/finalize file-id) ::dwp/finalize)))) @@ -262,7 +261,7 @@ {:id id :file-id file-id}) ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [pages (get-in state [:workspace-data :pages-index]) unames (dwc/retrieve-used-names pages) name (dwc/generate-unique-name unames "Page") @@ -280,7 +279,7 @@ [page-id] (ptk/reify ::duplicate-page ptk/WatchEvent - (watch [this state stream] + (watch [this state _] (let [id (uuid/next) pages (get-in state [:workspace-data :pages-index]) unames (dwc/retrieve-used-names pages) @@ -306,7 +305,7 @@ (us/verify string? name) (ptk/reify ::rename-page ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page (get-in state [:workspace-data :pages-index id]) rchg {:type :mod-page :id id @@ -327,7 +326,7 @@ [id] (ptk/reify ::delete-page ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page (get-in state [:workspace-data :pages-index id]) rchg {:type :del-page :id id} @@ -353,7 +352,7 @@ (assoc-in state [:workspace-file :name] name)) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [params {:id id :name name}] (->> (rp/mutation :rename-file params) (rx/ignore)))))) @@ -368,7 +367,7 @@ (defn initialize-viewport [{:keys [width height] :as size}] - (letfn [(update* [{:keys [vbox vport] :as local}] + (letfn [(update* [{:keys [vport] :as local}] (let [wprop (/ (:width vport) width) hprop (/ (:height vport) height)] (-> local @@ -433,7 +432,7 @@ ptk/UpdateEvent (update [_ state] (update state :workspace-local - (fn [{:keys [vbox vport left-sidebar? zoom] :as local}] + (fn [{:keys [vport left-sidebar? zoom] :as local}] (if (or (mth/almost-zero? width) (mth/almost-zero? height)) ;; If we have a resize to zero just keep the old value local @@ -452,7 +451,7 @@ (defn start-panning [] (ptk/reify ::start-panning ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [stopper (->> stream (rx/filter (ptk/type? ::finish-panning))) zoom (-> (get-in state [:workspace-local :zoom]) gpt/point)] (when-not (get-in state [:workspace-local :panning]) @@ -580,7 +579,7 @@ (mth/nan? (:height srect))) state (update state :workspace-local - (fn [{:keys [vbox vport] :as local}] + (fn [{:keys [vport] :as local}] (let [srect (gal/adjust-to-viewport vport srect {:padding 40}) zoom (/ (:width vport) (:width srect))] (-> local @@ -600,7 +599,7 @@ (map #(get objects %)) (gsh/selection-rect))] (update state :workspace-local - (fn [{:keys [vbox vport] :as local}] + (fn [{:keys [vport] :as local}] (let [srect (gal/adjust-to-viewport vport srect {:padding 40}) zoom (/ (:width vport) (:width srect))] (-> local @@ -615,7 +614,7 @@ (us/verify ::shape-attrs attrs) (ptk/reify ::update-shape ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (dch/update-shapes [id] #(merge % attrs)))))) (defn start-rename-shape @@ -631,7 +630,7 @@ (ptk/reify ::end-rename-shape ptk/UpdateEvent (update [_ state] - (update-in state [:workspace-local] dissoc :shape-for-rename)))) + (update state :workspace-local dissoc :shape-for-rename)))) ;; --- Update Selected Shapes attrs @@ -640,45 +639,17 @@ (us/verify ::shape-attrs attrs) (ptk/reify ::update-selected-shapes ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [selected (wsh/lookup-selected state)] (rx/from (map #(update-shape % attrs) selected)))))) -;; --- Shape Movement (using keyboard shorcuts) - -(declare initial-selection-align) - -(defn- get-displacement-with-grid - "Retrieve the correct displacement delta point for the - provided direction speed and distances thresholds." - [shape direction options] - (let [grid-x (:grid-x options 10) - grid-y (:grid-y options 10) - x-mod (mod (:x shape) grid-x) - y-mod (mod (:y shape) grid-y)] - (case direction - :up (gpt/point 0 (- (if (zero? y-mod) grid-y y-mod))) - :down (gpt/point 0 (- grid-y y-mod)) - :left (gpt/point (- (if (zero? x-mod) grid-x x-mod)) 0) - :right (gpt/point (- grid-x x-mod) 0)))) - -(defn- get-displacement - "Retrieve the correct displacement delta point for the - provided direction speed and distances thresholds." - [shape direction] - (case direction - :up (gpt/point 0 (- 1)) - :down (gpt/point 0 1) - :left (gpt/point (- 1) 0) - :right (gpt/point 1 0))) - ;; --- Delete Selected (def delete-selected "Deselect all and remove all selected shapes." (ptk/reify ::delete-selected ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [selected (wsh/lookup-selected state)] (rx/of (dwc/delete-shapes selected) (dws/deselect-all)))))) @@ -692,7 +663,7 @@ (us/verify ::loc loc) (ptk/reify ::vertical-order-selected ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -901,7 +872,7 @@ (ptk/reify ::relocate-shapes ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -1012,7 +983,7 @@ [parent-id to-index] (ptk/reify ::relocate-selected-shapes ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [selected (wsh/lookup-selected state)] (rx/of (relocate-shapes selected parent-id to-index)))))) @@ -1021,7 +992,7 @@ [] (ptk/reify ::start-editing-selected ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [selected (wsh/lookup-selected state)] (if-not (= 1 (count selected)) (rx/empty) @@ -1049,7 +1020,7 @@ [id index] (ptk/reify ::relocate-pages ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [cidx (-> (get-in state [:workspace-data :pages]) (d/index-of id)) rchg {:type :mov-page @@ -1072,7 +1043,7 @@ (us/verify ::gal/align-axis axis) (ptk/reify :align-objects ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -1103,7 +1074,7 @@ (us/verify ::gal/dist-axis axis) (ptk/reify :align-objects ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -1121,7 +1092,7 @@ [id lock] (ptk/reify ::set-shape-proportion-lock ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (letfn [(assign-proportions [shape] (if-not lock (assoc shape :proportion-lock false) @@ -1142,7 +1113,7 @@ (us/verify ::position position) (ptk/reify ::update-position ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) shape (get objects id) @@ -1164,7 +1135,7 @@ (s/assert ::shape-attrs flags) (ptk/reify ::update-shape-flags ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [update-fn (fn [obj] (cond-> obj @@ -1184,7 +1155,7 @@ [project-id] (ptk/reify ::navigate-to-project ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [page-ids (get-in state [:projects project-id :pages]) params {:project project-id :page (first page-ids)}] (rx/of (rt/nav :workspace/page params)))))) @@ -1193,7 +1164,7 @@ ([] (ptk/reify ::go-to-page ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [project-id (:current-project-id state) file-id (:current-file-id state) page-id (get-in state [:workspace-data :pages 0]) @@ -1205,7 +1176,7 @@ (us/verify ::us/uuid page-id) (ptk/reify ::go-to-page ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [project-id (:current-project-id state) file-id (:current-file-id state) pparams {:file-id file-id :project-id project-id} @@ -1217,10 +1188,10 @@ (us/verify ::layout-flag layout) (ptk/reify ::go-to-layout ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [project-id (get-in state [:workspace-project :id]) file-id (get-in state [:workspace-file :id]) - page-id (get-in state [:current-page-id]) + page-id (get state :current-page-id) pparams {:file-id file-id :project-id project-id} qparams {:page-id page-id :layout (name layout)}] (rx/of (rt/nav :workspace pparams qparams)))))) @@ -1228,7 +1199,7 @@ (def go-to-file (ptk/reify ::go-to-file ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [{:keys [id project-id data] :as file} (:workspace-file state) page-id (get-in data [:pages 0]) pparams {:project-id project-id :file-id id} @@ -1240,7 +1211,7 @@ ([{:keys [file-id page-id]}] (ptk/reify ::go-to-viewer ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [{:keys [current-file-id current-page-id]} state params {:file-id (or file-id current-file-id) :page-id (or page-id current-page-id)}] @@ -1252,7 +1223,7 @@ ([{:keys [team-id]}] (ptk/reify ::go-to-dashboard ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (when-let [team-id (or team-id (:current-team-id state))] (rx/of ::dwp/force-persist (rt/nav :dashboard-projects {:team-id team-id}))))))) @@ -1261,7 +1232,7 @@ [] (ptk/reify ::go-to-dashboard ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [team-id (:current-team-id state)] (rx/of ::dwp/force-persist (rt/nav :dashboard-fonts {:team-id team-id})))))) @@ -1291,7 +1262,7 @@ (us/verify ::cp/minimal-shape shape) (ptk/reify ::show-shape-context-menu ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [selected (wsh/lookup-selected state)] (rx/concat (when-not (selected (:id shape)) @@ -1383,7 +1354,7 @@ (ptk/reify ::copy-selected ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [objects (wsh/lookup-page-objects state) selected (->> (wsh/lookup-selected state) (cp/clean-loops objects)) @@ -1410,7 +1381,7 @@ (def paste (ptk/reify ::paste ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (try (let [clipboard-str (wapi/read-from-clipboard) @@ -1449,7 +1420,7 @@ [event in-viewport?] (ptk/reify ::paste-from-event ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (try (let [objects (wsh/lookup-page-objects state) paste-data (wapi/read-from-paste-event event) @@ -1487,8 +1458,8 @@ (defn selected-frame? [state] (let [selected (wsh/lookup-selected state) objects (wsh/lookup-page-objects state)] - (and (and (= 1 (count selected)) - (= :frame (get-in objects [(first selected) :type])))))) + (and (= 1 (count selected)) + (= :frame (get-in objects [(first selected) :type]))))) (defn- paste-shape [{:keys [selected objects images] :as data} in-viewport?] @@ -1569,7 +1540,6 @@ ;; Procceed with the standard shape paste procediment. (do-paste [it state mouse-pos media] (let [media-idx (d/index-by :prev-id media) - page-id (:current-page-id state) ;; Calculate position for the pasted elements [frame-id parent-id delta index] (calculate-paste-position state mouse-pos in-viewport?) @@ -1619,7 +1589,7 @@ (dwc/select-shapes selected))))] (ptk/reify ::paste-shape ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [file-id (:current-file-id state) mouse-pos (deref ms/mouse-position)] (if (= file-id (:file-id data)) @@ -1643,7 +1613,7 @@ (s/assert string? text) (ptk/reify ::paste-text ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [id (uuid/next) {:keys [x y]} @ms/mouse-position width (max 8 (min (* 7 (count text)) 700)) @@ -1672,7 +1642,7 @@ (s/assert string? text) (ptk/reify ::paste-svg ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [position (deref ms/mouse-position) file-id (:current-file-id state)] (->> (dwp/parse-svg ["svg" text]) @@ -1682,7 +1652,7 @@ [image] (ptk/reify ::paste-bin-impl ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [file-id (get-in state [:workspace-file :id]) params {:file-id file-id :blobs [image] @@ -1707,7 +1677,7 @@ [] (ptk/reify ::start-create-interaction ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [initial-pos @ms/mouse-position selected (wsh/lookup-selected state) stopper (rx/filter ms/mouse-up? stream)] @@ -1744,7 +1714,7 @@ (assoc-in [:workspace-local :draw-interaction-to-frame] nil))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [position @ms/mouse-position page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -1772,7 +1742,7 @@ [color] (ptk/reify ::change-canvas-color ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (get state :current-page-id) options (wsh/lookup-page-options state page-id) previus-color (:background options)] @@ -1787,7 +1757,6 @@ :value previus-color}] :origin it})))))) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Exports ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/frontend/src/app/main/data/workspace/changes.cljs b/frontend/src/app/main/data/workspace/changes.cljs index b3ffc2d76d..f18a871049 100644 --- a/frontend/src/app/main/data/workspace/changes.cljs +++ b/frontend/src/app/main/data/workspace/changes.cljs @@ -10,14 +10,13 @@ [app.common.pages :as cp] [app.common.pages.spec :as spec] [app.common.spec :as us] - [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.state-helpers :as wsh] - [app.main.worker :as uw] + [app.main.data.workspace.undo :as dwu] [app.main.store :as st] + [app.main.worker :as uw] [app.util.logging :as log] [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] [potok.core :as ptk])) ;; Change this to :info :debug or :trace to debug this module @@ -59,29 +58,29 @@ attrs) uops (cond-> uops - (not (empty? uops)) + (seq uops) (conj {:type :set-touched :touched (:touched old-obj)})) change {:type :mod-obj :page-id page-id :id id}] (cond-> changes - (not (empty? rops)) + (seq rops) (update :redo-changes conj (assoc change :operations rops)) - (not (empty? uops)) + (seq uops) (update :undo-changes conj (assoc change :operations uops))))) (defn update-shapes ([ids f] (update-shapes ids f nil)) ([ids f {:keys [reg-objects? save-undo? keys] - :or {reg-objects? false save-undo? true attrs nil}}] + :or {reg-objects? false save-undo? true}}] (us/assert ::coll-of-uuid ids) (us/assert fn? f) (ptk/reify ::update-shapes ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state) changes {:redo-changes [] @@ -107,7 +106,7 @@ [page-id changes] (ptk/reify ::update-indices ptk/EffectEvent - (effect [_ state stream] + (effect [_ _ _] (uw/ask! {:cmd :update-page-indices :page-id page-id :changes changes})))) @@ -147,7 +146,7 @@ state)))) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (when-not @error (let [;; adds page-id to page changes (that have the `id` field instead) add-page-id @@ -163,7 +162,7 @@ (group-by :page-id)) process-page-changes - (fn [[page-id changes]] + (fn [[page-id _changes]] (update-indices page-id redo-changes))] (rx/concat (rx/from (map process-page-changes changes-by-pages)) diff --git a/frontend/src/app/main/data/workspace/colors.cljs b/frontend/src/app/main/data/workspace/colors.cljs index 2e40b5b98b..1813fa7120 100644 --- a/frontend/src/app/main/data/workspace/colors.cljs +++ b/frontend/src/app/main/data/workspace/colors.cljs @@ -7,23 +7,13 @@ (ns app.main.data.workspace.colors (:require [app.common.data :as d] - [app.common.pages :as cp] - [app.common.spec :as us] - [app.common.uuid :as uuid] [app.main.data.modal :as md] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.texts :as dwt] [app.main.repo :as rp] - [app.main.store :as st] - [app.main.streams :as ms] - [app.util.color :as color] - [app.util.i18n :refer [tr]] - [app.util.router :as rt] - [app.util.time :as dt] [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] [potok.core :as ptk])) (def clear-color-for-rename @@ -38,17 +28,16 @@ [file-id color-id name] (ptk/reify ::rename-color ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (->> (rp/mutation! :rename-color {:id color-id :name name}) (rx/map (partial rename-color-result file-id)))))) (defn rename-color-result - [file-id color] + [_file-id color] (ptk/reify ::rename-color-result ptk/UpdateEvent (update [_ state] - (-> state - (update-in [:workspace-file :colors] #(d/replace-by-id % color)))))) + (update-in state [:workspace-file :colors] #(d/replace-by-id % color))))) (defn change-palette-size [size] @@ -125,7 +114,7 @@ [ids color] (ptk/reify ::change-fill ptk/WatchEvent - (watch [_ state s] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -157,32 +146,29 @@ [ids color] (ptk/reify ::change-stroke ptk/WatchEvent - (watch [_ state s] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) + (watch [_ _ _] + (let [attrs (cond-> {} + (contains? color :color) + (assoc :stroke-color (:color color)) - attrs (cond-> {} - (contains? color :color) - (assoc :stroke-color (:color color)) + (contains? color :id) + (assoc :stroke-color-ref-id (:id color)) - (contains? color :id) - (assoc :stroke-color-ref-id (:id color)) + (contains? color :file-id) + (assoc :stroke-color-ref-file (:file-id color)) - (contains? color :file-id) - (assoc :stroke-color-ref-file (:file-id color)) + (contains? color :gradient) + (assoc :stroke-color-gradient (:gradient color)) - (contains? color :gradient) - (assoc :stroke-color-gradient (:gradient color)) + (contains? color :opacity) + (assoc :stroke-opacity (:opacity color)))] - (contains? color :opacity) - (assoc :stroke-opacity (:opacity color)))] - - (rx/of (dch/update-shapes ids (fn [shape] - (cond-> (d/merge shape attrs) - (= (:stroke-style shape) :none) - (assoc :stroke-style :solid - :stroke-width 1 - :stroke-opacity 1))))))))) + (rx/of (dch/update-shapes ids (fn [shape] + (cond-> (d/merge shape attrs) + (= (:stroke-style shape) :none) + (assoc :stroke-style :solid + :stroke-width 1 + :stroke-opacity 1))))))))) (defn picker-for-selected-shape diff --git a/frontend/src/app/main/data/workspace/comments.cljs b/frontend/src/app/main/data/workspace/comments.cljs index 08f70ed2fa..d83b51455f 100644 --- a/frontend/src/app/main/data/workspace/comments.cljs +++ b/frontend/src/app/main/data/workspace/comments.cljs @@ -6,19 +6,14 @@ (ns app.main.data.workspace.comments (:require - [app.common.data :as d] - [app.common.exceptions :as ex] [app.common.math :as mth] [app.common.spec :as us] - [app.main.constants :as c] + [app.main.data.comments :as dcm] [app.main.data.workspace :as dw] [app.main.data.workspace.common :as dwc] - [app.main.data.comments :as dcm] - [app.main.store :as st] [app.main.streams :as ms] [app.util.router :as rt] [beicon.core :as rx] - [cljs.spec.alpha :as s] [potok.core :as ptk])) (declare handle-interrupt) @@ -29,7 +24,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::initialize-comments ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stoper (rx/filter #(= ::finalize %) stream)] (rx/merge (rx/of (dcm/retrieve-comment-threads file-id)) @@ -47,8 +42,8 @@ [] (ptk/reify ::handle-interrupt ptk/WatchEvent - (watch [_ state stream] - (let [local (:comments-local state)] + (watch [_ state _] + (let [local (:comments-local state)] (cond (:draft local) (rx/of (dcm/close-thread)) (:open local) (rx/of (dcm/close-thread)) @@ -62,7 +57,7 @@ [position] (ptk/reify ::handle-comment-layer-click ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [local (:comments-local state)] (if (some? (:open local)) (rx/of (dcm/close-thread)) @@ -74,14 +69,13 @@ (rx/of (dcm/create-draft params)))))))) (defn center-to-comment-thread - [{:keys [id position] :as thread}] + [{:keys [position] :as thread}] (us/assert ::dcm/comment-thread thread) (ptk/reify :center-to-comment-thread ptk/UpdateEvent (update [_ state] (update state :workspace-local - (fn [{:keys [vbox vport zoom] :as local}] - (prn "center-to-comment-thread" vbox) + (fn [{:keys [vbox zoom] :as local}] (let [pw (/ 50 zoom) ph (/ 200 zoom) nw (mth/round (- (/ (:width vbox) 2) pw)) @@ -93,11 +87,11 @@ (update local :vbox assoc :x nx :y ny))))))) (defn navigate - [{:keys [project-id file-id page-id] :as thread}] + [thread] (us/assert ::dcm/comment-thread thread) (ptk/reify ::navigate ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [pparams {:project-id (:project-id thread) :file-id (:file-id thread)} qparams {:page-id (:page-id thread)}] diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index 0e313686bc..75e9ce724e 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -40,15 +40,13 @@ [{:keys [file] :as bundle}] (ptk/reify ::setup-selection-index ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [msg {:cmd :initialize-indices :file-id (:id file) :data (:data file)}] (->> (uw/ask! msg) (rx/map (constantly ::index-initialized))))))) - - ;; --- Common Helpers & Events (defn get-frame-at-point @@ -59,7 +57,7 @@ (defn- extract-numeric-suffix [basename] - (if-let [[match p1 p2] (re-find #"(.*)-([0-9]+)$" basename)] + (if-let [[_ p1 p2] (re-find #"(.*)-([0-9]+)$" basename)] [p1 (+ 1 (d/parse-integer p2))] [basename 1])) @@ -112,7 +110,7 @@ (def undo (ptk/reify ::undo ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [edition (get-in state [:workspace-local :edition]) drawing (get state :workspace-drawing)] ;; Editors handle their own undo's @@ -131,7 +129,7 @@ (def redo (ptk/reify ::redo ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [edition (get-in state [:workspace-local :edition]) drawing (get state :workspace-drawing)] (when-not (or (some? edition) (not-empty drawing)) @@ -180,10 +178,10 @@ (assoc-in state [:workspace-local :selected] ids)) ptk/WatchEvent - (watch [it state stream] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id)] - (rx/of (expand-all-parents ids objects)))))) + (watch [_ state _] + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id)] + (rx/of (expand-all-parents ids objects)))))) (declare clear-edition-mode) @@ -202,12 +200,11 @@ state))) ptk/WatchEvent - (watch [it state stream] - (let [objects (wsh/lookup-page-objects state)] - (->> stream - (rx/filter interrupt?) - (rx/take 1) - (rx/map (constantly clear-edition-mode))))))) + (watch [_ _ stream] + (->> stream + (rx/filter interrupt?) + (rx/take 1) + (rx/map (constantly clear-edition-mode)))))) ;; If these event change modules review /src/app/main/data/workspace/path/undo.cljs (def clear-edition-mode @@ -282,7 +279,7 @@ (us/verify ::shape-attrs attrs) (ptk/reify ::add-shape ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -313,7 +310,7 @@ (defn move-shapes-into-frame [frame-id shapes] (ptk/reify ::move-shapes-into-frame ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) to-move-shapes (->> (cp/select-toplevel-shapes objects {:include-frames? false}) @@ -349,7 +346,7 @@ (us/assert ::set-of-uuid ids) (ptk/reify ::delete-shapes ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -504,7 +501,7 @@ [type frame-x frame-y data] (ptk/reify ::create-and-add-shape ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [{:keys [width height]} data [vbc-x vbc-y] (viewport-center state) @@ -524,7 +521,7 @@ [image {:keys [x y]}] (ptk/reify ::image-uploaded ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [{:keys [name width height id mtype]} image shape {:name name :width width diff --git a/frontend/src/app/main/data/workspace/drawing.cljs b/frontend/src/app/main/data/workspace/drawing.cljs index 503d6bee97..14ec47a2ac 100644 --- a/frontend/src/app/main/data/workspace/drawing.cljs +++ b/frontend/src/app/main/data/workspace/drawing.cljs @@ -7,17 +7,15 @@ (ns app.main.data.workspace.drawing "Drawing interactions." (:require - [beicon.core :as rx] - [potok.core :as ptk] - [app.common.spec :as us] [app.common.pages :as cp] [app.common.uuid :as uuid] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.selection :as dws] - [app.main.data.workspace.path :as path] + [app.main.data.workspace.drawing.box :as box] [app.main.data.workspace.drawing.common :as common] [app.main.data.workspace.drawing.curve :as curve] - [app.main.data.workspace.drawing.box :as box])) + [app.main.data.workspace.path :as path] + [beicon.core :as rx] + [potok.core :as ptk])) (declare start-drawing) (declare handle-drawing) @@ -38,7 +36,7 @@ (update :workspace-layout disj :scale-text))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stoper (rx/filter (ptk/type? ::clear-drawing) stream)] (rx/merge (when (= tool :path) @@ -88,16 +86,17 @@ (update-in state [:workspace-drawing :object] merge data))) ptk/WatchEvent - (watch [_ state stream] - (rx/of (case type - :path - (path/handle-new-shape) + (watch [_ _ _] + (rx/of + (case type + :path + (path/handle-new-shape) - :curve - (curve/handle-drawing-curve) + :curve + (curve/handle-drawing-curve) - ;; default - (box/handle-drawing-box)))))) + ;; default + (box/handle-drawing-box)))))) diff --git a/frontend/src/app/main/data/workspace/drawing/box.cljs b/frontend/src/app/main/data/workspace/drawing/box.cljs index d9e3879a7b..01632a744c 100644 --- a/frontend/src/app/main/data/workspace/drawing/box.cljs +++ b/frontend/src/app/main/data/workspace/drawing/box.cljs @@ -21,7 +21,7 @@ (defn truncate-zero [num default] (if (mth/almost-zero? num) default num)) -(defn resize-shape [{:keys [x y width height transform transform-inverse] :as shape} point lock?] +(defn resize-shape [{:keys [x y width height] :as shape} point lock?] (let [;; The new shape behaves like a resize on the bottom-right corner initial (gpt/point (+ x width) (+ y height)) shapev (gpt/point width height) @@ -53,9 +53,7 @@ (ptk/reify ::handle-drawing-box ptk/WatchEvent (watch [_ state stream] - (let [{:keys [flags]} (:workspace-local state) - - stoper? #(or (ms/mouse-up? %) (= % :interrupt)) + (let [stoper? #(or (ms/mouse-up? %) (= % :interrupt)) stoper (rx/filter stoper? stream) initial @ms/mouse-position diff --git a/frontend/src/app/main/data/workspace/drawing/common.cljs b/frontend/src/app/main/data/workspace/drawing/common.cljs index 92db099600..fb93c6f5cc 100644 --- a/frontend/src/app/main/data/workspace/drawing/common.cljs +++ b/frontend/src/app/main/data/workspace/drawing/common.cljs @@ -6,15 +6,13 @@ (ns app.main.data.workspace.drawing.common (:require - [beicon.core :as rx] - [potok.core :as ptk] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.selection :as dws] [app.main.data.workspace.undo :as dwu] - [app.main.streams :as ms] - [app.main.worker :as uw])) + [app.main.worker :as uw] + [beicon.core :as rx] + [potok.core :as ptk])) (def clear-drawing (ptk/reify ::clear-drawing @@ -25,7 +23,7 @@ (def handle-finish-drawing (ptk/reify ::handle-finish-drawing ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [shape (get-in state [:workspace-drawing :object])] (rx/concat (when (:initialized? shape) diff --git a/frontend/src/app/main/data/workspace/drawing/curve.cljs b/frontend/src/app/main/data/workspace/drawing/curve.cljs index 333404214f..463c1e9ead 100644 --- a/frontend/src/app/main/data/workspace/drawing/curve.cljs +++ b/frontend/src/app/main/data/workspace/drawing/curve.cljs @@ -6,7 +6,6 @@ (ns app.main.data.workspace.drawing.curve (:require - [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.common.geom.shapes.path :as gsp] [app.common.pages :as cp] @@ -19,7 +18,7 @@ (def simplify-tolerance 0.3) -(defn stoper-event? [{:keys [type shift] :as event}] +(defn stoper-event? [{:keys [type] :as event}] (ms/mouse-event? event) (= type :up)) (defn initialize-drawing [state] @@ -73,9 +72,8 @@ (defn handle-drawing-curve [] (ptk/reify ::handle-drawing-curve ptk/WatchEvent - (watch [_ state stream] - (let [{:keys [flags]} (:workspace-local state) - stoper (rx/filter stoper-event? stream) + (watch [_ _ stream] + (let [stoper (rx/filter stoper-event? stream) mouse (rx/sample 10 ms/mouse-position)] (rx/concat (rx/of initialize-drawing) diff --git a/frontend/src/app/main/data/workspace/grid.cljs b/frontend/src/app/main/data/workspace/grid.cljs index e405c23646..b04b99f6aa 100644 --- a/frontend/src/app/main/data/workspace/grid.cljs +++ b/frontend/src/app/main/data/workspace/grid.cljs @@ -6,11 +6,11 @@ (ns app.main.data.workspace.grid (:require - [beicon.core :as rx] - [potok.core :as ptk] [app.common.data :as d] [app.common.spec :as us] - [app.main.data.workspace.changes :as dch])) + [app.main.data.workspace.changes :as dch] + [beicon.core :as rx] + [potok.core :as ptk])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Grid @@ -40,7 +40,7 @@ (us/assert ::us/uuid frame-id) (ptk/reify ::add-frame-grid ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [page-id (:current-page-id state) data (get-in state [:workspace-data :pages-index page-id]) params (or (get-in data [:options :saved-grids :square]) @@ -56,21 +56,21 @@ [frame-id index] (ptk/reify ::set-frame-grid ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (dch/update-shapes [frame-id] (fn [o] (update o :grids (fnil #(d/remove-at-index % index) [])))))))) (defn set-frame-grid [frame-id index data] (ptk/reify ::set-frame-grid ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (dch/update-shapes [frame-id] #(assoc-in % [:grids index] data)))))) (defn set-default-grid [type params] (ptk/reify ::set-default-grid ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [pid (:current-page-id state) prev-value (get-in state [:workspace-data :pages-index pid :options :saved-grids type])] (rx/of (dch/commit-changes diff --git a/frontend/src/app/main/data/workspace/groups.cljs b/frontend/src/app/main/data/workspace/groups.cljs index 849fdde94a..fc88141b31 100644 --- a/frontend/src/app/main/data/workspace/groups.cljs +++ b/frontend/src/app/main/data/workspace/groups.cljs @@ -1,3 +1,9 @@ +;; 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.data.workspace.groups (:require [app.common.data :as d] @@ -5,7 +11,6 @@ [app.common.pages :as cp] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.selection :as dws] [app.main.data.workspace.state-helpers :as wsh] [beicon.core :as rx] [potok.core :as ptk])) @@ -22,7 +27,6 @@ [shapes prefix keep-name] (let [selrect (gsh/selection-rect shapes) frame-id (-> shapes first :frame-id) - parent-id (-> shapes first :parent-id) group-name (if (and keep-name (= (count shapes) 1) (= (:type (first shapes)) :group)) @@ -166,7 +170,7 @@ (def group-selected (ptk/reify ::group-selected ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -183,7 +187,7 @@ (def ungroup-selected (ptk/reify ::ungroup-selected ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -200,7 +204,7 @@ (def mask-group (ptk/reify ::mask-group ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) @@ -257,7 +261,7 @@ (def unmask-group (ptk/reify ::unmask-group ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state)] diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index f4f177274d..7996e492ad 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -46,7 +46,7 @@ (:component-id change) :objects (:id change)]) - :default nil)) + :else nil)) prefix (if (:component-id change) "[C] " "[P] ") @@ -90,7 +90,7 @@ (us/assert ::cp/color color) (ptk/reify ::add-color ptk/WatchEvent - (watch [it state s] + (watch [it _ _] (let [rchg {:type :add-color :color color} uchg {:type :del-color @@ -104,7 +104,7 @@ (us/assert ::cp/recent-color color) (ptk/reify ::add-recent-color ptk/WatchEvent - (watch [it state s] + (watch [it _ _] (let [rchg {:type :add-recent-color :color color}] (rx/of (dch/commit-changes {:redo-changes [rchg] @@ -123,7 +123,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::update-color ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [[path name] (cp/parse-path-name (:name color)) color (assoc color :path path :name name) prev (get-in state [:workspace-data :colors id]) @@ -141,7 +141,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-color ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [prev (get-in state [:workspace-data :colors id]) rchg {:type :del-color :id id} @@ -156,7 +156,7 @@ (us/assert ::cp/media-object media) (ptk/reify ::add-media ptk/WatchEvent - (watch [it state stream] + (watch [it _ _] (let [obj (select-keys media [:id :name :width :height :mtype]) rchg {:type :add-media :object obj} @@ -172,7 +172,7 @@ (us/assert ::us/string new-name) (ptk/reify ::rename-media ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [object (get-in state [:workspace-data :media id]) [path name] (cp/parse-path-name new-name) @@ -195,7 +195,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-media ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [prev (get-in state [:workspace-data :media id]) rchg {:type :del-media :id id} @@ -212,7 +212,7 @@ (us/assert ::cp/typography typography) (ptk/reify ::add-typography ptk/WatchEvent - (watch [it state s] + (watch [it _ _] (let [rchg {:type :add-typography :typography typography} uchg {:type :del-typography @@ -230,7 +230,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::update-typography ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [[path name] (cp/parse-path-name (:name typography)) typography (assoc typography :path path :name name) prev (get-in state [:workspace-data :typographies (:id typography)]) @@ -248,7 +248,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-typography ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [prev (get-in state [:workspace-data :typographies id]) rchg {:type :del-typography :id id} @@ -262,7 +262,7 @@ "Add a new component to current file library, from the currently selected shapes." (ptk/reify ::add-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [file-id (:current-file-id state) page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -285,7 +285,7 @@ (us/assert ::us/string new-name) (ptk/reify ::rename-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [[path name] (cp/parse-path-name new-name) component (get-in state [:workspace-data :components id]) objects (get component :objects) @@ -315,7 +315,7 @@ [{:keys [id] :as params}] (ptk/reify ::duplicate-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [component (cp/get-component id (:current-file-id state) (dwlh/get-local-file state) @@ -324,7 +324,7 @@ unames (set (map :name all-components)) new-name (dwc/generate-unique-name unames (:name component)) - [new-shape new-shapes updated-shapes] + [new-shape new-shapes _updated-shapes] (dwlh/duplicate-component component) rchanges [{:type :add-component @@ -346,7 +346,7 @@ (us/assert ::us/uuid id) (ptk/reify ::delete-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [component (get-in state [:workspace-data :components id]) rchanges [{:type :del-component @@ -371,7 +371,7 @@ (us/assert ::us/point position) (ptk/reify ::instantiate-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [local-library (dwlh/get-local-file state) libraries (get state :workspace-libraries) component (cp/get-component component-id file-id local-library libraries) @@ -449,7 +449,7 @@ (us/assert ::us/uuid id) (ptk/reify ::detach-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) shapes (cp/get-object-with-children id objects) @@ -511,13 +511,13 @@ (us/assert ::us/uuid file-id) (ptk/reify ::nav-to-component-file ptk/WatchEvent - (watch [it state stream] - (let [file (get-in state [:workspace-libraries file-id]) + (watch [_ state _] + (let [file (get-in state [:workspace-libraries file-id]) pparams {:project-id (:project-id file) :file-id (:id file)} qparams {:page-id (first (get-in file [:data :pages])) :layout :assets}] - (st/emit! (rt/nav-new-window :workspace pparams qparams)))))) + (rx/of (rt/nav-new-window :workspace pparams qparams)))))) (defn ext-library-changed [file-id modified-at revn changes] @@ -540,7 +540,7 @@ (us/assert ::us/uuid id) (ptk/reify ::reset-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "RESET-COMPONENT of shape" :id (str id)) (let [local-library (dwlh/get-local-file state) libraries (dwlh/get-libraries state) @@ -574,7 +574,7 @@ (us/assert ::us/uuid id) (ptk/reify ::update-component ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "UPDATE-COMPONENT of shape" :id (str id)) (let [page-id (get state :current-page-id) local-library (dwlh/get-local-file state) @@ -642,7 +642,7 @@ state)) ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "SYNC-FILE" :file (dwlh/pretty-file file-id state) :library (dwlh/pretty-file library-id state)) @@ -702,7 +702,7 @@ (us/assert ::us/uuid library-id) (ptk/reify ::sync-file-2nd-stage ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (log/info :msg "SYNC-FILE (2nd stage)" :file (dwlh/pretty-file file-id state) :library (dwlh/pretty-file library-id state)) @@ -727,7 +727,7 @@ (assoc-in state [:workspace-file :ignore-sync-until] (dt/now))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (rp/mutation :ignore-sync {:file-id (get-in state [:workspace-file :id]) :date (dt/now)})))) @@ -737,7 +737,7 @@ (us/assert ::us/uuid file-id) (ptk/reify ::notify-sync-file ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [libraries-need-sync (filter #(> (:modified-at %) (:synced-at %)) (vals (get state :workspace-libraries))) do-update #(do (apply st/emit! (map (fn [library] diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 738491e7d8..7a88d948b6 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -90,7 +90,7 @@ (assert (nil? (:shape-ref shape))) (let [;; Ensure that the component root is not an instance and ;; it's no longer tied to a frame. - update-new-shape (fn [new-shape original-shape] + update-new-shape (fn [new-shape _original-shape] (cond-> new-shape true (-> (assoc :frame-id nil) @@ -338,10 +338,10 @@ (defmulti generate-sync-shape "Generate changes to synchronize one shape with all assets of the given type that is using, in the given library." - (fn [type library-id state container shape] type)) + (fn [type _library-id _state _container _shape] type)) (defmethod generate-sync-shape :components - [_ library-id state container shape] + [_ _ state container shape] (generate-sync-shape-direct container (:id shape) (get-local-file state) @@ -666,7 +666,7 @@ [(d/concat rchanges child-rchanges) (d/concat uchanges child-uchanges)])) -(defn- generate-sync-shape-inverse +(defn generate-sync-shape-inverse "Generate changes to update the component a shape is linked to, from the values in the shape and all its children." [page-id shape-id local-library libraries] @@ -886,10 +886,10 @@ set-remote-synced? (assoc :remote-synced? true)))) - update-original-shape (fn [original-shape new-shape] + update-original-shape (fn [original-shape _new-shape] original-shape) - [new-shape new-shapes _] + [_ new-shapes _] (cp/clone-object component-shape (:id parent-shape) (get component :objects) @@ -939,7 +939,7 @@ (cp/get-parents (:id component-parent-shape) (:objects component)))) - update-new-shape (fn [new-shape original-shape] + update-new-shape (fn [new-shape _original-shape] (reposition-shape new-shape root-instance root-main)) @@ -950,7 +950,7 @@ :shape-ref (:id new-shape)) original-shape)) - [new-shape new-shapes updated-shapes] + [_new-shape new-shapes updated-shapes] (cp/clone-object shape (:id component-parent-shape) (get page :objects) @@ -1141,33 +1141,6 @@ :remote-synced? (:remote-synced? shape)}]})]] [rchanges uchanges])))) -(defn- set-touched-shapes-group - [shape container] - (if-not (:shape-ref shape) - empty-changes - (do - (log/info :msg (str "SET-TOUCHED-SHAPES-GROUP " - (if (cp/page? container) "[P] " "[C] ") - (:name shape))) - (let [rchanges [(make-change - container - {:type :mod-obj - :id (:id shape) - :operations - [{:type :set-touched - :touched (cp/set-touched-group - (:touched shape) - :shapes-group)}]})] - - uchanges [(make-change - container - {:type :mod-obj - :id (:id shape) - :operations - [{:type :set-touched - :touched (:touched shape)}]})]] - [rchanges uchanges])))) - (defn- update-attrs "The main function that implements the attribute sync algorithm. Copy attributes that have changed in the origin shape to the dest shape. diff --git a/frontend/src/app/main/data/workspace/notifications.cljs b/frontend/src/app/main/data/workspace/notifications.cljs index 49c7d13877..93dcf92291 100644 --- a/frontend/src/app/main/data/workspace/notifications.cljs +++ b/frontend/src/app/main/data/workspace/notifications.cljs @@ -16,11 +16,7 @@ [app.main.data.workspace.changes :as dch] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.persistence :as dwp] - [app.main.repo :as rp] - [app.main.store :as st] [app.main.streams :as ms] - [app.util.avatars :as avatars] - [app.util.i18n :as i18n :refer [tr]] [app.util.time :as dt] [app.util.websockets :as ws] [beicon.core :as rx] @@ -104,7 +100,7 @@ [file-id] (ptk/reify ::send-keepalive ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (when-let [ws (get-in state [:ws file-id])] (ws/send! ws {:type :keepalive}))))) @@ -112,9 +108,8 @@ [file-id point] (ptk/reify ::handle-pointer-update ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (let [ws (get-in state [:ws file-id]) - sid (:session-id state) pid (:current-page-id state) msg {:type :pointer-update :page-id pid @@ -128,7 +123,7 @@ [file-id] (ptk/reify ::finalize ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when-let [ws (get-in state [:ws file-id])] (ws/-close ws)) (rx/of ::finalize)))) @@ -187,7 +182,7 @@ (update state :workspace-presence update-presence)))))) (defn handle-pointer-update - [{:keys [page-id profile-id session-id x y] :as msg}] + [{:keys [page-id session-id x y] :as msg}] (ptk/reify ::handle-pointer-update ptk/UpdateEvent (update [_ state] @@ -213,7 +208,7 @@ (us/assert ::file-change-event msg) (ptk/reify ::handle-file-change ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (let [changes-by-pages (group-by :page-id changes) process-page-changes (fn [[page-id changes]] @@ -239,7 +234,7 @@ (us/assert ::library-change-event msg) (ptk/reify ::handle-library-change ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when (contains? (:workspace-libraries state) file-id) (rx/of (dwl/ext-library-changed file-id modified-at revn changes) (dwl/notify-sync-file file-id)))))) diff --git a/frontend/src/app/main/data/workspace/path/changes.cljs b/frontend/src/app/main/data/workspace/path/changes.cljs index cddf0a849f..c22fc25e0e 100644 --- a/frontend/src/app/main/data/workspace/path/changes.cljs +++ b/frontend/src/app/main/data/workspace/path/changes.cljs @@ -84,7 +84,7 @@ (assoc-in state (st/get-path state :content) content))) ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [objects (wsh/lookup-page-objects state) page-id (:current-page-id state) id (get-in state [:workspace-local :edition]) diff --git a/frontend/src/app/main/data/workspace/path/common.cljs b/frontend/src/app/main/data/workspace/path/common.cljs index d8e6e19cbf..f9313126db 100644 --- a/frontend/src/app/main/data/workspace/path/common.cljs +++ b/frontend/src/app/main/data/workspace/path/common.cljs @@ -16,7 +16,8 @@ [state] (dissoc state :last-point :prev-handler :drag-handler :preview)) -(defn finish-path [source] +(defn finish-path + [_source] (ptk/reify ::finish-path ptk/UpdateEvent (update [_ state] diff --git a/frontend/src/app/main/data/workspace/path/drawing.cljs b/frontend/src/app/main/data/workspace/path/drawing.cljs index 75c2f2202c..287dd61f00 100644 --- a/frontend/src/app/main/data/workspace/path/drawing.cljs +++ b/frontend/src/app/main/data/workspace/path/drawing.cljs @@ -17,7 +17,6 @@ [app.main.data.workspace.path.spec :as spec] [app.main.data.workspace.path.state :as st] [app.main.data.workspace.path.streams :as streams] - [app.main.data.workspace.path.tools :as tools] [app.main.data.workspace.path.undo :as undo] [app.main.data.workspace.state-helpers :as wsh] [app.main.streams :as ms] @@ -60,9 +59,8 @@ state))))) (defn drag-handler - ([{:keys [x y alt? shift?] :as position}] + ([position] (drag-handler nil nil :c1 position)) - ([position index prefix {:keys [x y alt? shift?]}] (ptk/reify ::drag-handler ptk/UpdateEvent @@ -110,7 +108,7 @@ (update-in (st/get-path state) helpers/update-selrect)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [id (st/get-path-id state) handler (get-in state [:workspace-local :edit-path id :prev-handler])] ;; Update the preview because can be outdated after the dragging @@ -124,9 +122,6 @@ ptk/WatchEvent (watch [_ state stream] (let [id (st/get-path-id state) - zoom (get-in state [:workspace-local :zoom]) - start-position @ms/mouse-position - stop-stream (->> stream (rx/filter #(or (helpers/end-path-event? %) (ms/mouse-up? %)))) @@ -166,9 +161,7 @@ (ptk/reify ::start-path-from-point ptk/WatchEvent (watch [_ state stream] - (let [start-point @ms/mouse-position - zoom (get-in state [:workspace-local :zoom]) - mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %) + (let [mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %) (ms/mouse-up? %)))) content (get-in state (st/get-path state :content)) points (upg/content->points content) @@ -195,7 +188,7 @@ (rx/merge-map #(rx/empty)))) (defn make-drag-stream - [stream snap-toggled zoom points down-event] + [stream snap-toggled _zoom points down-event] (let [mouse-up (->> stream (rx/filter #(or (helpers/end-path-event? %) (ms/mouse-up? %)))) @@ -211,7 +204,7 @@ (rx/of (finish-drag))))))) (defn handle-drawing-path - [id] + [_id] (ptk/reify ::handle-drawing-path ptk/UpdateEvent (update [_ state] @@ -278,11 +271,11 @@ state))) ptk/WatchEvent - (watch [_ state stream] - (->> (rx/of (setup-frame-path) - dwdc/handle-finish-drawing - (dwc/start-edition-mode shape-id) - (change-edit-mode :draw)))))) + (watch [_ _ _] + (rx/of (setup-frame-path) + dwdc/handle-finish-drawing + (dwc/start-edition-mode shape-id) + (change-edit-mode :draw))))) (defn handle-new-shape "Creates a new path shape" @@ -333,7 +326,7 @@ (defn check-changed-content [] (ptk/reify ::check-changed-content ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [id (st/get-path-id state) content (get-in state (st/get-path state :content)) old-content (get-in state [:workspace-local :edit-path id :old-content]) @@ -354,7 +347,7 @@ id (assoc-in [:workspace-local :edit-path id :edit-mode] mode)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [id (st/get-path-id state)] (cond (and id (= :move mode)) (rx/of (common/finish-path "change-edit-mode")) diff --git a/frontend/src/app/main/data/workspace/path/edition.cljs b/frontend/src/app/main/data/workspace/path/edition.cljs index 4a93e57dd3..2005ed10cd 100644 --- a/frontend/src/app/main/data/workspace/path/edition.cljs +++ b/frontend/src/app/main/data/workspace/path/edition.cljs @@ -8,11 +8,9 @@ (:require [app.common.data :as d] [app.common.geom.point :as gpt] - [app.common.math :as mth] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] + [app.main.data.workspace.common :as dwc] [app.main.data.workspace.path.changes :as changes] - [app.main.data.workspace.path.common :as common] [app.main.data.workspace.path.drawing :as drawing] [app.main.data.workspace.path.helpers :as helpers] [app.main.data.workspace.path.selection :as selection] @@ -47,7 +45,7 @@ (defn apply-content-modifiers [] (ptk/reify ::apply-content-modifiers ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [objects (wsh/lookup-page-objects state) id (st/get-path-id state) @@ -137,7 +135,7 @@ [position shift?] (ptk/reify ::start-move-path-point ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [id (get-in state [:workspace-local :edition]) selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{}) selected? (contains? selected-points position)] @@ -151,7 +149,7 @@ [start-position] (ptk/reify ::drag-selected-points ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [stopper (->> stream (rx/filter ms/mouse-up?)) id (get-in state [:workspace-local :edition]) snap-toggled (get-in state [:workspace-local :edit-path id :snap-toggled]) @@ -206,7 +204,7 @@ state))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [id (get-in state [:workspace-local :edition]) current-move (get-in state [:workspace-local :edit-path id :current-move])] (if (= same-event current-move) @@ -240,7 +238,7 @@ [index prefix] (ptk/reify ::start-move-handler ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [id (get-in state [:workspace-local :edition]) cx (d/prefix-keyword prefix :x) cy (d/prefix-keyword prefix :y) @@ -297,7 +295,7 @@ (assoc-in [:workspace-local :edit-path id :edit-mode] :draw)))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state stream] (let [mode (get-in state [:workspace-local :edit-path id :edit-mode])] (rx/concat (rx/of (undo/start-path-undo)) @@ -327,5 +325,5 @@ (update-in (st/get-path state :content) upt/split-segments #{from-p to-p} t)))) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/of (changes/save-path-content {:preserve-move-to true}))))) diff --git a/frontend/src/app/main/data/workspace/path/helpers.cljs b/frontend/src/app/main/data/workspace/path/helpers.cljs index cbf9d383ca..deff63dce1 100644 --- a/frontend/src/app/main/data/workspace/path/helpers.cljs +++ b/frontend/src/app/main/data/workspace/path/helpers.cljs @@ -6,25 +6,23 @@ (ns app.main.data.workspace.path.helpers (:require - [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.common.math :as mth] [app.main.data.workspace.path.common :as common] - [app.main.data.workspace.path.state :refer [get-path]] [app.main.streams :as ms] [app.util.path.commands :as upc] [app.util.path.subpaths :as ups] [potok.core :as ptk])) -(defn end-path-event? [{:keys [type shift] :as event}] +(defn end-path-event? [event] (or (= (ptk/type event) ::common/finish-path) (= (ptk/type event) :esc-pressed) (= :app.main.data.workspace.common/clear-edition-mode (ptk/type event)) (= :app.main.data.workspace/finalize-page (ptk/type event)) (= event :interrupt) ;; ESC - (and (ms/mouse-double-click? event)))) + (ms/mouse-double-click? event))) (defn content-center [content] @@ -35,7 +33,6 @@ (defn content->points+selrect "Given the content of a shape, calculate its points and selrect" [shape content] - (let [{:keys [flip-x flip-y]} shape transform (cond-> (:transform shape (gmt/matrix)) diff --git a/frontend/src/app/main/data/workspace/path/shortcuts.cljs b/frontend/src/app/main/data/workspace/path/shortcuts.cljs index b88ee5268a..55dbcd592d 100644 --- a/frontend/src/app/main/data/workspace/path/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/path/shortcuts.cljs @@ -22,7 +22,7 @@ (defn esc-pressed [] (ptk/reify :esc-pressed ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] ;; Not interrupt when we're editing a path (let [edition-id (or (get-in state [:workspace-drawing :object :id]) (get-in state [:workspace-local :edition])) diff --git a/frontend/src/app/main/data/workspace/path/spec.cljs b/frontend/src/app/main/data/workspace/path/spec.cljs index 96ad24fa0a..434a971170 100644 --- a/frontend/src/app/main/data/workspace/path/spec.cljs +++ b/frontend/src/app/main/data/workspace/path/spec.cljs @@ -40,8 +40,8 @@ (s/def ::content-entry (s/keys :req-un [::command] - :req-opt [::params - ::relative?])) + :opt-un [::params + ::relative?])) (s/def ::content (s/coll-of ::content-entry :kind vector?)) diff --git a/frontend/src/app/main/data/workspace/path/streams.cljs b/frontend/src/app/main/data/workspace/path/streams.cljs index f8059c483a..94c03259e4 100644 --- a/frontend/src/app/main/data/workspace/path/streams.cljs +++ b/frontend/src/app/main/data/workspace/path/streams.cljs @@ -6,17 +6,16 @@ (ns app.main.data.workspace.path.streams (:require - [app.main.data.workspace.path.helpers :as helpers] - [app.main.data.workspace.path.state :as state] [app.common.geom.point :as gpt] + [app.common.math :as mth] + [app.main.data.workspace.path.state :as state] + [app.main.snap :as snap] [app.main.store :as st] [app.main.streams :as ms] + [app.util.path.geom :as upg] [beicon.core :as rx] - [potok.core :as ptk] - [app.common.math :as mth] - [app.main.snap :as snap] [okulary.core :as l] - [app.util.path.geom :as upg])) + [potok.core :as ptk])) (defonce drag-threshold 5) @@ -50,7 +49,7 @@ (if (= value ::empty) not-drag-stream (rx/empty))))) - + (->> position-stream (rx/merge-map (fn [] to-stream))))))) @@ -107,7 +106,7 @@ (<= (- 180 rot-angle) 5))] (cond - snap-opposite-angle? + snap-opposite-angle? (let [rot-handler (gpt/rotate handler node (- 180 (* rot-sign rot-angle))) snap (gpt/to-vec handler rot-handler)] (merge position (gpt/add position snap))) @@ -122,7 +121,7 @@ (rx/map check-path-snap)))) (defn position-stream - [snap-toggled points] + [snap-toggled _points] (let [zoom (get-in @st/state [:workspace-local :zoom] 1) ;; ranges (snap/create-ranges points) d-pos (/ snap/snap-path-accuracy zoom) diff --git a/frontend/src/app/main/data/workspace/path/tools.cljs b/frontend/src/app/main/data/workspace/path/tools.cljs index 610897cd23..d13fbf7f70 100644 --- a/frontend/src/app/main/data/workspace/path/tools.cljs +++ b/frontend/src/app/main/data/workspace/path/tools.cljs @@ -6,11 +6,9 @@ (ns app.main.data.workspace.path.tools (:require - [app.common.geom.point :as gpt] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.common :as dwc] [app.main.data.workspace.path.changes :as changes] - [app.main.data.workspace.path.common :as common] [app.main.data.workspace.path.state :as st] [app.main.data.workspace.state-helpers :as wsh] [app.util.path.subpaths :as ups] @@ -25,7 +23,7 @@ ([points tool-fn] (ptk/reify ::process-path-tool ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [objects (wsh/lookup-page-objects state) id (st/get-path-id state) page-id (:current-page-id state) @@ -33,7 +31,7 @@ selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{}) points (or points selected-points)] - (when (and (not (empty? points)) (some? shape)) + (when (and (seq points) (some? shape)) (let [new-content (-> (tool-fn (:content shape) points) (ups/close-subpaths)) [rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)] diff --git a/frontend/src/app/main/data/workspace/path/undo.cljs b/frontend/src/app/main/data/workspace/path/undo.cljs index 74c8fcb348..8472d5c88a 100644 --- a/frontend/src/app/main/data/workspace/path/undo.cljs +++ b/frontend/src/app/main/data/workspace/path/undo.cljs @@ -9,8 +9,8 @@ [app.common.data :as d] [app.common.data.undo-stack :as u] [app.common.uuid :as uuid] - [app.main.data.workspace.path.state :as st] [app.main.data.workspace.path.changes :as changes] + [app.main.data.workspace.path.state :as st] [app.main.store :as store] [beicon.core :as rx] [okulary.core :as l] @@ -64,7 +64,7 @@ undo-stack))))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (rx/of (changes/save-path-content {:preserve-move-to true}))))) (defn redo-path [] @@ -82,7 +82,7 @@ undo-stack)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] (rx/of (changes/save-path-content))))) (defn merge-head @@ -92,10 +92,9 @@ (ptk/reify ::add-undo-entry ptk/UpdateEvent (update [_ state] - (let [id (st/get-path-id state) - entry (make-entry state) + (let [id (st/get-path-id state) stack (get-in state [:workspace-local :edit-path id :undo-stack]) - head (u/peek stack) + head (u/peek stack) stack (-> stack (u/undo) (u/fixup head))] (-> state (d/assoc-in-when @@ -145,7 +144,7 @@ assoc :undo-lock lock :undo-stack (u/make-stack))))) - + ptk/WatchEvent (watch [_ state stream] (let [undo-lock (get-in state [:workspace-local :edit-path (st/get-path-id state) :undo-lock])] diff --git a/frontend/src/app/main/data/workspace/persistence.cljs b/frontend/src/app/main/data/workspace/persistence.cljs index 2f668f7e15..76609c41a9 100644 --- a/frontend/src/app/main/data/workspace/persistence.cljs +++ b/frontend/src/app/main/data/workspace/persistence.cljs @@ -8,8 +8,6 @@ (:require [app.common.data :as d] [app.common.exceptions :as ex] - [app.common.geom.point :as gpt] - [app.common.media :as cm] [app.common.pages :as cp] [app.common.spec :as us] [app.common.uuid :as uuid] @@ -26,11 +24,9 @@ [app.main.refs :as refs] [app.main.repo :as rp] [app.main.store :as st] - [app.util.avatars :as avatars] [app.util.http :as http] [app.util.i18n :as i18n :refer [tr]] [app.util.object :as obj] - [app.util.router :as rt] [app.util.time :as dt] [app.util.uri :as uu] [beicon.core :as rx] @@ -52,7 +48,7 @@ [file-id] (ptk/reify ::initialize-persistence ptk/EffectEvent - (effect [_ state stream] + (effect [_ _ stream] (let [stoper (rx/filter #(= ::finalize %) stream) forcer (rx/filter #(= ::force-persist %) stream) notifier (->> stream @@ -120,12 +116,11 @@ (ptk/reify ::persist-changes ptk/UpdateEvent (update [_ state] - (let [conj (fnil conj []) - into* (fnil into [])] + (let [into* (fnil into [])] (update-in state [:workspace-persistence :queue] into* changes))) ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [sid (:session-id state) file (get state :workspace-file) queue (get-in state [:workspace-persistence :queue] []) @@ -176,7 +171,7 @@ (us/verify ::us/uuid file-id) (ptk/reify ::persist-synchronous-changes ptk/WatchEvent - (watch [it state stream] + (watch [_ state _] (let [sid (:session-id state) file (get-in state [:workspace-libraries file-id]) @@ -255,11 +250,11 @@ (declare fetch-libraries-content) (declare bundle-fetched) -(defn- fetch-bundle +(defn fetch-bundle [project-id file-id] (ptk/reify ::fetch-bundle ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (->> (rx/zip (rp/query :file {:id file-id}) (rp/query :team-users {:file-id file-id}) (rp/query :project {:id project-id}) @@ -285,7 +280,7 @@ (assoc-in state [:workspace-file :is-shared] is-shared)) ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [params {:id id :is-shared is-shared}] (->> (rp/mutation :set-file-shared params) (rx/ignore)))))) @@ -300,7 +295,7 @@ (us/assert ::us/uuid team-id) (ptk/reify ::fetch-shared-files ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (->> (rp/query :team-shared-files {:team-id team-id}) (rx/map shared-files-fetched))))) @@ -320,7 +315,7 @@ [file-id library-id] (ptk/reify ::link-file-to-library ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [fetched #(assoc-in %2 [:workspace-libraries (:id %1)] %1) params {:file-id file-id :library-id library-id}] @@ -332,7 +327,7 @@ [file-id library-id] (ptk/reify ::unlink-file-from-library ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [unlinked #(d/dissoc-in % [:workspace-libraries library-id]) params {:file-id file-id :library-id library-id}] @@ -348,7 +343,7 @@ (->> (rx/of (-> (tubax/xml->clj text) (assoc :name name)))) - (catch :default err + (catch :default _err (rx/throw {:type :svg-parser})))) (defn fetch-svg [name uri] @@ -458,7 +453,7 @@ (s/def ::process-media-objects (s/and (s/keys :req-un [::file-id ::local?] - :opt-in [::name ::data ::uris ::mtype]) + :opt-un [::name ::data ::uris ::mtype]) (fn [props] (or (contains? props :blobs) (contains? props :uris))))) @@ -468,7 +463,7 @@ (us/assert ::process-media-objects params) (ptk/reify ::process-media-objects ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (rx/concat (rx/of (dm/show {:content (tr "media.loading") :type :info @@ -515,7 +510,7 @@ (us/assert ::clone-media-objects-params params) (ptk/reify ::clone-media-objects ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] (let [{:keys [on-success on-error] :or {on-success identity on-error identity}} (meta params) @@ -548,7 +543,7 @@ [ids] (ptk/reify ::remove-thumbnails ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ _] ;; Removes the thumbnail while it's regenerated (rx/of (dch/update-shapes ids diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 52d36ee355..fe72eafe20 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -61,7 +61,7 @@ :height (mth/abs (- end-y start-y))}))] (ptk/reify ::handle-selection ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] (let [stop? (fn [event] (or (dwc/interrupt? event) (ms/mouse-up? event))) stoper (->> stream (rx/filter stop?))] (rx/concat @@ -100,7 +100,7 @@ (conj selected id)))))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id)] (rx/of (dwc/expand-all-parents [id] objects))))))) @@ -136,7 +136,7 @@ (assoc-in state [:workspace-local :selected] ids)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [objects (wsh/lookup-page-objects state)] (rx/of (dwc/expand-all-parents ids objects)))))) @@ -144,7 +144,7 @@ [] (ptk/reify ::select-all ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) new-selected (let [selected-objs @@ -204,7 +204,7 @@ [preserve?] (ptk/reify ::select-shapes-by-current-selrect ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state) selected (wsh/lookup-selected state) @@ -224,25 +224,23 @@ (rx/map select-shapes)))))))) (defn select-inside-group - ([group-id position] (select-inside-group group-id position false)) - ([group-id position deep-children] - (ptk/reify ::select-inside-group - ptk/WatchEvent - (watch [_ state stream] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) - group (get objects group-id) - children (map #(get objects %) (:shapes group)) + [group-id position] + (ptk/reify ::select-inside-group + ptk/WatchEvent + (watch [_ state _] + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) + group (get objects group-id) + children (map #(get objects %) (:shapes group)) - ;; We need to reverse the children because if two children - ;; overlap we want to select the one that's over (and it's - ;; in the later vector position - selected (->> children - reverse + ;; We need to reverse the children because if two children + ;; overlap we want to select the one that's over (and it's + ;; in the later vector position + selected (->> children + reverse (d/seek #(geom/has-point? % position)))] - (when selected - (rx/of (select-shape (:id selected))))))))) - + (when selected + (rx/of (select-shape (:id selected)))))))) ;; --- Duplicate Shapes (declare prepare-duplicate-change) @@ -321,7 +319,6 @@ name (dwc/generate-unique-name names (:name obj)) renamed-obj (assoc obj :id id :name name) moved-obj (geom/move renamed-obj delta) - frames (cp/select-frames objects) parent-id (or parent-id frame-id) children-changes @@ -378,7 +375,7 @@ (def duplicate-selected (ptk/reify ::duplicate-selected ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) selected (wsh/lookup-selected state) diff --git a/frontend/src/app/main/data/workspace/shortcuts.cljs b/frontend/src/app/main/data/workspace/shortcuts.cljs index 7d2fe9bf4f..9d8ce96180 100644 --- a/frontend/src/app/main/data/workspace/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/shortcuts.cljs @@ -10,14 +10,13 @@ [app.main.data.workspace :as dw] [app.main.data.workspace.colors :as mdc] [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.drawing :as dwd] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.texts :as dwtxt] [app.main.data.workspace.transforms :as dwt] + [app.main.data.workspace.undo :as dwu] [app.main.store :as st] - [app.util.dom :as dom] - [potok.core :as ptk])) + [app.util.dom :as dom])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Shortcuts diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index f2828eb3fa..048e4bb965 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -9,7 +9,6 @@ [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] - [app.common.geom.proportions :as gpr] [app.common.geom.shapes :as gsh] [app.common.pages :as cp] [app.common.uuid :as uuid] @@ -18,14 +17,12 @@ [app.main.data.workspace.state-helpers :as wsh] [app.main.repo :as rp] [app.util.color :as uc] - [app.util.object :as obj] [app.util.path.parser :as upp] [app.util.svg :as usvg] [app.util.uri :as uu] [beicon.core :as rx] [cuerdas.core :as str] - [potok.core :as ptk] - [promesa.core :as p])) + [potok.core :as ptk])) (defonce default-rect {:x 0 :y 0 :width 1 :height 1 :rx 0 :ry 0}) (defonce default-circle {:r 0 :cx 0 :cy 0}) @@ -163,7 +160,7 @@ (gsh/setup-selrect)))) (defn create-path-shape [name frame-id svg-data {:keys [attrs] :as data}] - (when (and (contains? attrs :d) (not (empty? (:d attrs)) )) + (when (and (contains? attrs :d) (seq (:d attrs))) (let [svg-transform (usvg/parse-transform (:transform attrs)) path-content (upp/parse-path (:d attrs)) content (cond-> path-content @@ -387,7 +384,7 @@ [svg-data file-id position] (ptk/reify ::svg-uploaded ptk/WatchEvent - (watch [it state stream] + (watch [_ _ _] ;; Once the SVG is uploaded, we need to extract all the bitmap ;; images and upload them separatelly, then proceed to create ;; all shapes. @@ -414,7 +411,7 @@ [svg-data {:keys [x y] :as position}] (ptk/reify ::create-svg-shapes ptk/WatchEvent - (watch [it state stream] + (watch [it state _] (try (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index f789a50ff7..d76abc46b1 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -16,17 +16,11 @@ [app.main.data.workspace.common :as dwc] [app.main.data.workspace.selection :as dws] [app.main.data.workspace.state-helpers :as wsh] - [app.main.data.workspace.transforms :as dwt] [app.main.data.workspace.undo :as dwu] - [app.main.fonts :as fonts] - [app.util.object :as obj] + [app.util.router :as rt] [app.util.text-editor :as ted] [app.util.timers :as ts] - [app.util.router :as rt] [beicon.core :as rx] - [cljs.spec.alpha :as s] - [cuerdas.core :as str] - [goog.object :as gobj] [potok.core :as ptk])) (defn update-editor @@ -42,7 +36,7 @@ [] (ptk/reify ::focus-editor ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (when-let [editor (:workspace-editor state)] (ts/schedule #(.focus ^js editor)))))) @@ -59,7 +53,7 @@ [{:keys [id] :as shape}] (ptk/reify ::finalize-editor-state ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [content (-> (get-in state [:workspace-editor-state id]) (ted/get-editor-current-content))] @@ -88,7 +82,7 @@ decorator)))) ptk/WatchEvent - (watch [_ state stream] + (watch [_ _ stream] ;; We need to finalize editor on two main events: (1) when user ;; explicitly navigates to other section or page; (2) when user ;; leaves the editor. @@ -149,7 +143,7 @@ [{:keys [id attrs]}] (ptk/reify ::update-root-attrs ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [objects (wsh/lookup-page-objects state) shape (get objects id) @@ -168,7 +162,7 @@ (d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-block-data attrs)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when-not (some? (get-in state [:workspace-editor-state id])) (let [objects (wsh/lookup-page-objects state) shape (get objects id) @@ -195,7 +189,7 @@ (d/update-in-when state [:workspace-editor-state id] ted/update-editor-current-inline-styles attrs)) ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (when-not (some? (get-in state [:workspace-editor-state id])) (let [objects (wsh/lookup-page-objects state) shape (get objects id) @@ -232,7 +226,7 @@ (defn resize-text-batch [changes] (ptk/reify ::resize-text-batch ptk/WatchEvent - (watch [_ state stream] + (watch [_ state _] (let [page-id (:current-page-id state) objects (get-in state [:workspace-data :pages-index page-id :objects])] (if-not (every? #(contains? objects(first %)) changes) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 8f3955b104..6438317716 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -11,7 +11,6 @@ [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] - [app.common.math :as mth] [app.common.pages :as cp] [app.common.spec :as us] [app.main.data.workspace.changes :as dch] @@ -19,13 +18,10 @@ [app.main.data.workspace.selection :as dws] [app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.undo :as dwu] - [app.main.refs :as refs] [app.main.snap :as snap] - [app.main.store :as st] [app.main.streams :as ms] [app.util.path.shapes-to-path :as ups] [beicon.core :as rx] - [beicon.core :as rx] [cljs.spec.alpha :as s] [potok.core :as ptk])) diff --git a/frontend/src/app/main/data/workspace/undo.cljs b/frontend/src/app/main/data/workspace/undo.cljs index a63225870b..85651e0d88 100644 --- a/frontend/src/app/main/data/workspace/undo.cljs +++ b/frontend/src/app/main/data/workspace/undo.cljs @@ -6,21 +6,10 @@ (ns app.main.data.workspace.undo (:require - [app.common.data :as d] - [app.common.geom.proportions :as gpr] - [app.common.geom.shapes :as gsh] [app.common.pages :as cp] [app.common.pages.spec :as spec] [app.common.spec :as us] - [app.common.uuid :as uuid] - [app.main.worker :as uw] - [app.main.streams :as ms] - [app.util.logging :as log] - [app.util.timers :as ts] - [beicon.core :as rx] [cljs.spec.alpha :as s] - [clojure.set :as set] - [cuerdas.core :as str] [potok.core :as ptk])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -42,7 +31,7 @@ (subvec undo (- cnt MAX-UNDO-SIZE)) undo))) -(defn- materialize-undo +(defn materialize-undo [changes index] (ptk/reify ::materialize-undo ptk/UpdateEvent @@ -51,15 +40,6 @@ (update :workspace-data cp/process-changes changes) (assoc-in [:workspace-undo :index] index))))) -(defn- reset-undo - [index] - (ptk/reify ::reset-undo - ptk/UpdateEvent - (update [_ state] - (-> state - (update :workspace-undo dissoc :undo-index) - (update-in [:workspace-undo :items] (fn [queue] (into [] (take (inc index) queue)))))))) - (defn- add-undo-entry [state entry] (if (and entry @@ -81,7 +61,7 @@ (update-in [:workspace-undo :transaction :undo-changes] #(into undo-changes %)) (update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes)))) -(defn- append-undo +(defn append-undo [entry] (us/assert ::undo-entry entry) (ptk/reify ::append-undo diff --git a/frontend/src/app/main/exports.cljs b/frontend/src/app/main/exports.cljs index cb5a327d54..f3ae1e8183 100644 --- a/frontend/src/app/main/exports.cljs +++ b/frontend/src/app/main/exports.cljs @@ -17,7 +17,6 @@ [app.main.ui.shapes.circle :as circle] [app.main.ui.shapes.embed :as embed] [app.main.ui.shapes.export :as use] - [app.main.ui.shapes.filters :as filters] [app.main.ui.shapes.frame :as frame] [app.main.ui.shapes.group :as group] [app.main.ui.shapes.image :as image] diff --git a/frontend/src/app/main/fonts.clj b/frontend/src/app/main/fonts.clj index d36810d457..c947cdabb7 100644 --- a/frontend/src/app/main/fonts.clj +++ b/frontend/src/app/main/fonts.clj @@ -7,9 +7,9 @@ (ns app.main.fonts "A fonts loading macros." (:require - [cuerdas.core :as str] + [clojure.data.json :as json] [clojure.java.io :as io] - [clojure.data.json :as json])) + [cuerdas.core :as str])) (defn- parse-gfont-variant [variant] diff --git a/frontend/src/app/main/fonts.cljs b/frontend/src/app/main/fonts.cljs index fcdd27ce30..dbd50cde36 100644 --- a/frontend/src/app/main/fonts.cljs +++ b/frontend/src/app/main/fonts.cljs @@ -15,7 +15,6 @@ [app.util.http :as http] [app.util.logging :as log] [app.util.object :as obj] - [app.util.timers :as ts] [beicon.core :as rx] [clojure.set :as set] [cuerdas.core :as str] @@ -104,7 +103,7 @@ [url on-loaded] (let [node (create-link-element url) head (.-head ^js js/document)] - (gev/listenOnce node "load" (fn [event] + (gev/listenOnce node "load" (fn [_] (when (fn? on-loaded) (on-loaded)))) (dom/append-child! head node))) @@ -140,7 +139,7 @@ (str base ":" variants "&display=block"))) (defmethod load-font :google - [{:keys [id family variants ::on-loaded] :as font}] + [{:keys [id ::on-loaded] :as font}] (when (exists? js/window) (log/debug :action "load-font" :font-id id :backend "google") (let [url (generate-gfonts-url font)] @@ -183,11 +182,13 @@ (str/join "\n"))) (defmethod load-font :custom - [{:keys [id family variants ::on-loaded] :as font}] + [{:keys [id ::on-loaded] :as font}] (when (exists? js/window) (js/console.log "[debug:fonts]: loading custom font" id) (let [css (generate-custom-font-css font)] - (add-font-css! css)))) + (add-font-css! css) + (when (fn? on-loaded) + (on-loaded))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; LOAD API diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index bb3f8a5cb0..22e9adebe2 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -10,11 +10,8 @@ (:require [app.common.data :as d] [app.common.pages :as cp] - [app.common.uuid :as uuid] - [app.main.constants :as c] [app.main.data.workspace.state-helpers :as wsh] [app.main.store :as st] - [beicon.core :as rx] [okulary.core :as l])) ;; ---- Global refs diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index 5ba1ef0d3b..26e62bacc6 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -9,7 +9,6 @@ ["react-dom/server" :as rds] [app.config :as cfg] [app.main.exports :as exports] - [app.main.exports :as svg] [app.main.fonts :as fonts] [app.util.http :as http] [beicon.core :as rx] @@ -31,16 +30,13 @@ [])) (defn populate-images-cache - ([data] - (populate-images-cache data nil)) - - ([data {:keys [resolve-media?] :or {resolve-media? false}}] - (let [images (->> (:objects data) - (vals) - (mapcat get-image-data))] - (->> (rx/from images) - (rx/map #(cfg/resolve-file-media %)) - (rx/flat-map http/fetch-data-uri))))) + [data] + (let [images (->> (:objects data) + (vals) + (mapcat get-image-data))] + (->> (rx/from images) + (rx/map #(cfg/resolve-file-media %)) + (rx/flat-map http/fetch-data-uri)))) (defn populate-fonts-cache [data] (let [texts (->> (:objects data) diff --git a/frontend/src/app/main/repo.cljs b/frontend/src/app/main/repo.cljs index cd79ddef75..e9df95ee65 100644 --- a/frontend/src/app/main/repo.cljs +++ b/frontend/src/app/main/repo.cljs @@ -10,9 +10,7 @@ [app.common.uri :as u] [app.config :as cfg] [app.util.http :as http] - [app.util.time :as dt] - [beicon.core :as rx] - [cuerdas.core :as str])) + [beicon.core :as rx])) (defn handle-response [{:keys [status body] :as response}] @@ -86,7 +84,7 @@ ([id params] (mutation id params))) (defmethod mutation :login-with-oauth - [id {:keys [provider] :as params}] + [_ {:keys [provider] :as params}] (let [uri (u/join base-uri "api/auth/oauth/" (d/name provider)) params (dissoc params :provider)] (->> (http/send! {:method :post :uri uri :query params}) @@ -94,7 +92,7 @@ (rx/mapcat handle-response)))) (defmethod mutation :send-feedback - [id params] + [_ params] (->> (http/send! {:method :post :uri (u/join base-uri "api/feedback") :body (http/transit-data params)}) @@ -102,7 +100,7 @@ (rx/mapcat handle-response))) (defmethod query :export - [id params] + [_ params] (->> (http/send! {:method :post :uri (u/join base-uri "export") :body (http/transit-data params) diff --git a/frontend/src/app/main/snap.cljs b/frontend/src/app/main/snap.cljs index b8e700b6bf..6021730ef5 100644 --- a/frontend/src/app/main/snap.cljs +++ b/frontend/src/app/main/snap.cljs @@ -19,24 +19,24 @@ [beicon.core :as rx] [clojure.set :as set])) -(defonce ^:private snap-accuracy 5) -(defonce ^:private snap-path-accuracy 10) -(defonce ^:private snap-distance-accuracy 10) +(def ^:const snap-accuracy 5) +(def ^:const snap-path-accuracy 10) +(def ^:const snap-distance-accuracy 10) (defn- remove-from-snap-points [remove-id?] (fn [query-result] (->> query-result (map (fn [[value data]] [value (remove (comp remove-id? second) data)])) - (filter (fn [[_ data]] (not (empty? data))))))) + (filter (fn [[_ data]] (seq data)))))) (defn- flatten-to-points [query-result] - (mapcat (fn [[v data]] (map (fn [[point _]] point) data)) query-result)) + (mapcat (fn [[_ data]] (map (fn [[point _]] point) data)) query-result)) (defn- calculate-distance [query-result point coord] (->> query-result - (map (fn [[value data]] [(mth/abs (- value (coord point))) [(coord point) value]])))) + (map (fn [[value _]] [(mth/abs (- value (coord point))) [(coord point) value]])))) (defn- get-min-distance-snap [points coord] (fn [query-result] @@ -45,7 +45,7 @@ (apply min-key first) second))) -(defn- snap-frame-id [shapes] +(defn snap-frame-id [shapes] (let [frames (into #{} (map :frame-id shapes))] (cond ;; Only shapes from one frame. The common is the only one @@ -286,8 +286,9 @@ (fn [matches other] (let [matches (into {} matches) - other (into {} other) - keys (set/union (keys matches) (keys other))] + other (into {} other) + keys (set/union (set (keys matches)) + (set (keys other)))] (into {} (map (fn [key] [key @@ -308,7 +309,7 @@ min-match-coord (fn [matches] - (if (and (seq matches) (not (empty? matches))) + (if (seq matches) (->> matches (reduce get-min)) default))] diff --git a/frontend/src/app/main/store.cljs b/frontend/src/app/main/store.cljs index f4f15b9416..4fd743ecd3 100644 --- a/frontend/src/app/main/store.cljs +++ b/frontend/src/app/main/store.cljs @@ -75,12 +75,12 @@ (logjs "state" (get-in @state [:workspace-data :pages-index page-id :objects])))) (defn ^:export dump-object [name] - (let [page-id (get @state :current-page-id)] - (let [objects (get-in @state [:workspace-data :pages-index page-id :objects]) - target (or (d/seek (fn [[id shape]] (= name (:name shape))) objects) - (get objects (uuid name)))] - (->> target - (logjs "state"))))) + (let [page-id (get @state :current-page-id) + objects (get-in @state [:workspace-data :pages-index page-id :objects]) + target (or (d/seek (fn [[_ shape]] (= name (:name shape))) objects) + (get objects (uuid name)))] + (->> target + (logjs "state")))) (defn ^:export dump-tree ([] (dump-tree false false)) @@ -89,7 +89,7 @@ (let [page-id (get @state :current-page-id) objects (get-in @state [:workspace-data :pages-index page-id :objects]) components (get-in @state [:workspace-data :components]) - libraries (get-in @state [:workspace-libraries]) + libraries (get @state :workspace-libraries) root (d/seek #(nil? (:parent-id %)) (vals objects))] (letfn [(show-shape [shape-id level objects] diff --git a/frontend/src/app/main/streams.cljs b/frontend/src/app/main/streams.cljs index e71667fd6a..15a05e01ae 100644 --- a/frontend/src/app/main/streams.cljs +++ b/frontend/src/app/main/streams.cljs @@ -7,12 +7,10 @@ (ns app.main.streams "User interaction events and streams." (:require - [beicon.core :as rx] [app.main.store :as st] - [app.main.refs :as refs] - [app.common.geom.point :as gpt] [app.util.globals :as globals] - [app.util.keyboard :as kbd])) + [app.util.keyboard :as kbd] + [beicon.core :as rx])) ;; --- User Events diff --git a/frontend/src/app/main/ui.cljs b/frontend/src/app/main/ui.cljs index 3ea44d9ea9..8859dacd35 100644 --- a/frontend/src/app/main/ui.cljs +++ b/frontend/src/app/main/ui.cljs @@ -6,15 +6,12 @@ (ns app.main.ui (:require - [app.config :as cf] - [app.common.data :as d] [app.common.exceptions :as ex] [app.common.spec :as us] - [app.common.uuid :as uuid] - [app.config :as cfg] - [app.main.data.users :as du] - [app.main.data.messages :as dm] + [app.config :as cf] [app.main.data.events :as ev] + [app.main.data.messages :as dm] + [app.main.data.users :as du] [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.auth :refer [auth]] @@ -32,8 +29,6 @@ [app.main.ui.static :as static] [app.main.ui.viewer :refer [viewer-page]] [app.main.ui.workspace :as workspace] - [app.util.i18n :as i18n :refer [tr t]] - [app.util.router :as rt] [app.util.timers :as ts] [cljs.pprint :refer [pprint]] [cljs.spec.alpha :as s] @@ -60,11 +55,11 @@ (def routes [["/auth" ["/login" :auth-login] - (when cfg/registration-enabled + (when cf/registration-enabled ["/register" :auth-register]) - (when cfg/registration-enabled + (when cf/registration-enabled ["/register/validate" :auth-register-validate]) - (when cfg/registration-enabled + (when cf/registration-enabled ["/register/success" :auth-register-success]) ["/recovery/request" :auth-recovery-request] ["/recovery" :auth-recovery] @@ -102,9 +97,8 @@ (mf/defc on-main-error [{:keys [error] :as props}] - (let [data (ex-data error)] - (mf/use-effect #(ptk/handle-error error)) - [:span "Internal application errror"])) + (mf/use-effect #(ptk/handle-error error)) + [:span "Internal application errror"]) (mf/defc main-page {::mf/wrap [#(mf/catch % {:fallback on-main-error})]} @@ -211,14 +205,14 @@ (derive :service-unavailable ::exceptional-state) (defmethod ptk/handle-error ::exceptional-state - [{:keys [status] :as error}] + [error] (ts/schedule (st/emitf (dm/assign-exception error)))) ;; We receive a explicit authentication error; this explicitly clears ;; all profile data and redirect the user to the login page. (defmethod ptk/handle-error :authentication - [error] + [_] (ts/schedule (st/emitf (du/logout)))) ;; Error that happens on an active bussines model validation does not @@ -245,7 +239,7 @@ ;; Error on parsing an SVG (defmethod ptk/handle-error :svg-parser - [error] + [_] (ts/schedule (st/emitf (dm/show {:content "SVG is invalid or malformed" @@ -261,7 +255,7 @@ context (str/fmt "ns: '%s'\nname: '%s'\nfile: '%s:%s'" (:ns context) (:name context) - (str cfg/public-uri "js/cljs-runtime/" (:file context)) + (str cf/public-uri "js/cljs-runtime/" (:file context)) (:line context))] (ts/schedule (st/emitf diff --git a/frontend/src/app/main/ui/auth.cljs b/frontend/src/app/main/ui/auth.cljs index 96996970e5..5cf1a715bd 100644 --- a/frontend/src/app/main/ui/auth.cljs +++ b/frontend/src/app/main/ui/auth.cljs @@ -6,38 +6,27 @@ (ns app.main.ui.auth (: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.recovery :refer [recovery-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.icons :as i] [app.util.dom :as dom] - [app.util.forms :as fm] - [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] + [app.util.i18n :as i18n :refer [tr]] [rumext.alpha :as mf])) (mf/defc auth [{:keys [route] :as props}] (let [section (get-in route [:data :name]) - locale (mf/deref i18n/locale) params (:query-params route)] (mf/use-effect - #(dom/set-html-title (t locale "title.default"))) + #(dom/set-html-title (tr "title.default"))) [:div.auth [:section.auth-sidebar - [:a.logo {:href "#/"} i/logo] - [:span.tagline (t locale "auth.sidebar-tagline")]] + [:a.logo {:href "https://penpot.app"} i/logo] + [:span.tagline (tr "auth.sidebar-tagline")]] [:section.auth-content (case section @@ -54,10 +43,10 @@ [:& login-page {:params params}] :auth-recovery-request - [:& recovery-request-page {:locale locale}] + [:& recovery-request-page] :auth-recovery - [:& recovery-page {:locale locale :params params}]) + [:& recovery-page {:params params}]) [:div.terms-login [:a {:href "https://penpot.app/terms.html" :target "_blank"} "Terms of service"] diff --git a/frontend/src/app/main/ui/auth/login.cljs b/frontend/src/app/main/ui/auth/login.cljs index c095f3a034..3f8e89e662 100644 --- a/frontend/src/app/main/ui/auth/login.cljs +++ b/frontend/src/app/main/ui/auth/login.cljs @@ -16,8 +16,7 @@ [app.main.ui.icons :as i] [app.main.ui.messages :as msgs] [app.util.dom :as dom] - [app.util.i18n :refer [tr t]] - [app.util.object :as obj] + [app.util.i18n :refer [tr]] [app.util.router :as rt] [beicon.core :as rx] [cljs.spec.alpha :as s] @@ -74,7 +73,7 @@ on-submit (mf/use-callback (mf/deps form) - (fn [event] + (fn [_] (reset! error nil) (let [params (with-meta (:clean-data @form) {:on-error on-error})] diff --git a/frontend/src/app/main/ui/auth/recovery.cljs b/frontend/src/app/main/ui/auth/recovery.cljs index 7040059867..e18471d2b3 100644 --- a/frontend/src/app/main/ui/auth/recovery.cljs +++ b/frontend/src/app/main/ui/auth/recovery.cljs @@ -11,12 +11,9 @@ [app.main.data.users :as du] [app.main.store :as st] [app.main.ui.components.forms :as fm] - [app.main.ui.icons :as i] - [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t tr]] + [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [rumext.alpha :as mf])) (s/def ::password-1 ::us/not-empty-string) @@ -40,7 +37,7 @@ (assoc :password-1 {:message "errors.password-too-short"})))) (defn- on-error - [form error] + [_form _error] (st/emit! (dm/error (tr "auth.notifications.invalid-token-error")))) (defn- on-success @@ -49,7 +46,7 @@ (rt/nav :auth-login))) (defn- on-submit - [form event] + [form _event] (let [mdata {:on-error on-error :on-success on-success} params {:token (get-in @form [:clean-data :token]) @@ -57,7 +54,7 @@ (st/emit! (du/recover-profile (with-meta params mdata))))) (mf/defc recovery-form - [{:keys [locale params] :as props}] + [{:keys [params] :as props}] (let [form (fm/use-form :spec ::recovery-form :validators [password-equality] :initial params)] @@ -66,28 +63,28 @@ [:div.fields-row [:& fm/input {:type "password" :name :password-1 - :label (t locale "auth.new-password")}]] + :label (tr "auth.new-password")}]] [:div.fields-row [:& fm/input {:type "password" :name :password-2 - :label (t locale "auth.confirm-password")}]] + :label (tr "auth.confirm-password")}]] [:& fm/submit-button - {:label (t locale "auth.recovery-submit")}]])) + {:label (tr "auth.recovery-submit")}]])) ;; --- Recovery Request Page (mf/defc recovery-page - [{:keys [locale params] :as props}] + [{:keys [params] :as props}] [:section.generic-form [:div.form-container [:h1 "Forgot your password?"] [:div.subtitle "Please enter your new password"] - [:& recovery-form {:locale locale :params params}] + [:& recovery-form {:params params}] [:div.links [:div.link-entry [:a {:on-click #(st/emit! (rt/nav :auth-login))} - (t locale "profile.recovery.go-to-login")]]]]]) + (tr "profile.recovery.go-to-login")]]]]]) diff --git a/frontend/src/app/main/ui/auth/recovery_request.cljs b/frontend/src/app/main/ui/auth/recovery_request.cljs index 5c7cb5c2d1..e5a16089f2 100644 --- a/frontend/src/app/main/ui/auth/recovery_request.cljs +++ b/frontend/src/app/main/ui/auth/recovery_request.cljs @@ -12,12 +12,10 @@ [app.main.store :as st] [app.main.ui.components.forms :as fm] [app.main.ui.icons :as i] - [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [tr t]] + [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [rumext.alpha :as mf])) (s/def ::email ::us/email) @@ -30,7 +28,7 @@ on-success (mf/use-callback - (fn [data] + (fn [_ _] (reset! submitted false) (st/emit! (dm/info (tr "auth.notifications.recovery-token-sent")) (rt/nav :auth-login)))) diff --git a/frontend/src/app/main/ui/auth/register.cljs b/frontend/src/app/main/ui/auth/register.cljs index 4e968b4fe3..f6022e2899 100644 --- a/frontend/src/app/main/ui/auth/register.cljs +++ b/frontend/src/app/main/ui/auth/register.cljs @@ -8,21 +8,18 @@ (:require [app.common.spec :as us] [app.config :as cf] - [app.main.data.users :as du] [app.main.data.messages :as dm] - [app.main.store :as st] + [app.main.data.users :as du] [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.icons :as i] [app.main.ui.messages :as msgs] - [app.main.ui.auth.login :as login] - [app.util.dom :as dom] - [app.util.i18n :refer [tr t]] + [app.util.i18n :refer [tr]] [app.util.router :as rt] - [app.util.timers :as tm] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [rumext.alpha :as mf])) (mf/defc demo-warning @@ -71,7 +68,7 @@ (st/emit! (dm/error (tr "errors.generic"))))) (defn- handle-prepare-register-success - [form {:keys [token] :as result}] + [_form {:keys [token] :as result}] (st/emit! (rt/nav :auth-register-validate {} {:token token}))) (mf/defc register-form @@ -84,7 +81,7 @@ on-submit (mf/use-callback - (fn [form event] + (fn [form _event] (reset! submitted? true) (let [params (:clean-data @form)] (->> (rp/mutation :prepare-register-profile params) @@ -166,7 +163,7 @@ (st/emit! (dm/error (tr "errors.generic")))))) (defn- handle-register-success - [form data] + [_form data] (cond (some? (:invitation-token data)) (let [token (:invitation-token data)] @@ -200,7 +197,7 @@ on-submit (mf/use-callback - (fn [form event] + (fn [form _event] (reset! submitted? true) (let [params (:clean-data @form)] (->> (rp/mutation :register-profile params) diff --git a/frontend/src/app/main/ui/auth/verify_token.cljs b/frontend/src/app/main/ui/auth/verify_token.cljs index 3e0bf5323d..119a4cd404 100644 --- a/frontend/src/app/main/ui/auth/verify_token.cljs +++ b/frontend/src/app/main/ui/auth/verify_token.cljs @@ -6,23 +6,16 @@ (ns app.main.ui.auth.verify-token (: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.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.util.dom :as dom] - [app.util.forms :as fm] [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] [app.util.timers :as ts] [beicon.core :as rx] - [cljs.spec.alpha :as s] [rumext.alpha :as mf])) (defmulti handle-token (fn [token] (:iss token))) @@ -34,7 +27,7 @@ (st/emit! (du/login-from-token data)))) (defmethod handle-token :change-email - [data] + [_data] (let [msg (tr "dashboard.notifications.email-changed-successfully")] (ts/schedule 100 #(st/emit! (dm/success msg))) (st/emit! (rt/nav :settings-profile) @@ -57,7 +50,7 @@ (st/emit! (rt/nav :auth-register {} {:invitation-token token}))))) (defmethod handle-token :default - [tdata] + [_tdata] (st/emit! (rt/nav :auth-login) (dm/warn (tr "errors.unexpected-token")))) diff --git a/frontend/src/app/main/ui/comments.cljs b/frontend/src/app/main/ui/comments.cljs index a4a98f35e6..3ae6832382 100644 --- a/frontend/src/app/main/ui/comments.cljs +++ b/frontend/src/app/main/ui/comments.cljs @@ -11,16 +11,13 @@ [app.main.data.modal :as modal] [app.main.refs :as refs] [app.main.store :as st] - [app.main.streams :as ms] [app.main.ui.components.dropdown :refer [dropdown]] - [app.main.ui.context :as ctx] [app.main.ui.icons :as i] [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.object :as obj] [app.util.time :as dt] - [cuerdas.core :as str] [okulary.core :as l] [rumext.alpha :as mf])) @@ -105,7 +102,7 @@ :on-focus on-focus :on-change on-change}] (when (or @show-buttons? - (not (empty? @content))) + (seq @content)) [:div.buttons [:input.btn-primary {:type "button" :value "Post" :on-click on-submit}] [:input.btn-secondary {:type "button" :value "Cancel" :on-click on-cancel}]])])) @@ -323,7 +320,7 @@ (mf/defc thread-bubble {::mf/wrap [mf/memo]} - [{:keys [thread zoom open? on-click] :as params}] + [{:keys [thread zoom on-click] :as params}] (let [pos (:position thread) pos-x (* (:x pos) zoom) pos-y (* (:y pos) zoom) diff --git a/frontend/src/app/main/ui/components/color_bullet.cljs b/frontend/src/app/main/ui/components/color_bullet.cljs index 54872e605d..89f22128bb 100644 --- a/frontend/src/app/main/ui/components/color_bullet.cljs +++ b/frontend/src/app/main/ui/components/color_bullet.cljs @@ -6,9 +6,9 @@ (ns app.main.ui.components.color-bullet (:require - [rumext.alpha :as mf] + [app.util.color :as uc] [app.util.i18n :as i18n :refer [tr]] - [app.util.color :as uc])) + [rumext.alpha :as mf])) (mf/defc color-bullet [{:keys [color on-click]}] (if (uc/multiple? color) @@ -31,7 +31,7 @@ (mf/defc color-name [{:keys [color size on-click on-double-click]}] (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)))] (when (or (not size) (= size :big)) [:span.color-text {:on-click #(when on-click (on-click %)) diff --git a/frontend/src/app/main/ui/components/color_input.cljs b/frontend/src/app/main/ui/components/color_input.cljs index 8b851e5465..254a6c25f2 100644 --- a/frontend/src/app/main/ui/components/color_input.cljs +++ b/frontend/src/app/main/ui/components/color_input.cljs @@ -6,16 +6,11 @@ (ns app.main.ui.components.color-input (: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.dom :as dom] + [app.util.i18n :as i18n :refer [tr]] [app.util.keyboard :as kbd] [app.util.object :as obj] - [app.util.simple-math :as sm] - [app.util.i18n :as i18n :refer [tr]] [rumext.alpha :as mf])) (mf/defc color-input @@ -80,7 +75,7 @@ handle-blur (mf/use-callback (mf/deps parse-value apply-value update-input) - (fn [event] + (fn [_] (let [new-value (parse-value)] (if new-value (apply-value new-value) diff --git a/frontend/src/app/main/ui/components/context_menu.cljs b/frontend/src/app/main/ui/components/context_menu.cljs index 16b1ccf4c1..e8198377dc 100644 --- a/frontend/src/app/main/ui/components/context_menu.cljs +++ b/frontend/src/app/main/ui/components/context_menu.cljs @@ -6,13 +6,12 @@ (ns app.main.ui.components.context-menu (:require - [rumext.alpha :as mf] - [goog.object :as gobj] [app.main.ui.components.dropdown :refer [dropdown']] [app.main.ui.icons :as i] - [app.common.uuid :as uuid] [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/wrap-props false} @@ -52,7 +51,7 @@ (- node-height) 0)] - (if (not= target-offset (:offset @local)) + (when (not= target-offset (:offset @local)) (swap! local assoc :offset target-offset)))))) enter-submenu diff --git a/frontend/src/app/main/ui/components/copy_button.cljs b/frontend/src/app/main/ui/components/copy_button.cljs index 8436484410..6911ba5ae4 100644 --- a/frontend/src/app/main/ui/components/copy_button.cljs +++ b/frontend/src/app/main/ui/components/copy_button.cljs @@ -6,11 +6,11 @@ (ns app.main.ui.components.copy-button (:require - [beicon.core :as rx] - [rumext.alpha :as mf] - [app.util.webapi :as wapi] + [app.main.ui.icons :as i] [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]}] (let [just-copied (mf/use-state false)] @@ -24,9 +24,8 @@ [:button.copy-button {:on-click #(when-not @just-copied - (do - (reset! just-copied true) - (wapi/write-to-clipboard data)))} + (reset! just-copied true) + (wapi/write-to-clipboard data))} (if @just-copied i/tick i/copy)])) diff --git a/frontend/src/app/main/ui/components/dropdown.cljs b/frontend/src/app/main/ui/components/dropdown.cljs index 54e33925fc..114617fa5b 100644 --- a/frontend/src/app/main/ui/components/dropdown.cljs +++ b/frontend/src/app/main/ui/components/dropdown.cljs @@ -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 (:require - [rumext.alpha :as mf] - [app.common.uuid :as uuid] [app.util.dom :as dom] [app.util.keyboard :as kbd] [goog.events :as events] - [goog.object :as gobj]) + [goog.object :as gobj] + [rumext.alpha :as mf]) (:import goog.events.EventType)) (mf/defc dropdown' diff --git a/frontend/src/app/main/ui/components/editable_label.cljs b/frontend/src/app/main/ui/components/editable_label.cljs index 60e5feea4d..02907d5abd 100644 --- a/frontend/src/app/main/ui/components/editable_label.cljs +++ b/frontend/src/app/main/ui/components/editable_label.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.components.editable-label (:require [app.main.ui.icons :as i] - [app.util.data :refer [classnames]] [app.util.dom :as dom] [app.util.keyboard :as kbd] [app.util.timers :as timers] @@ -32,7 +31,7 @@ cancel-editing (fn [] (stop-editing) (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] (cond (kbd/esc? e) diff --git a/frontend/src/app/main/ui/components/editable_select.cljs b/frontend/src/app/main/ui/components/editable_select.cljs index 27fe4d897e..40c13e7702 100644 --- a/frontend/src/app/main/ui/components/editable_select.cljs +++ b/frontend/src/app/main/ui/components/editable_select.cljs @@ -6,13 +6,13 @@ (ns app.main.ui.components.editable-select (:require - [rumext.alpha :as mf] - [app.common.uuid :as uuid] [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.timers :as timers] - [app.main.ui.icons :as i] - [app.main.ui.components.dropdown :refer [dropdown]])) + [rumext.alpha :as mf])) (mf/defc editable-select [{:keys [value type options class on-change placeholder]}] (let [state (mf/use-state {:id (uuid/next) @@ -24,7 +24,7 @@ open-dropdown #(swap! state assoc :is-open? true) close-dropdown #(swap! state assoc :is-open? false) select-item (fn [value] - (fn [event] + (fn [_] (swap! state assoc :current-value value) (when on-change (on-change value)))) diff --git a/frontend/src/app/main/ui/components/file_uploader.cljs b/frontend/src/app/main/ui/components/file_uploader.cljs index 1151976143..8aa5c55b53 100644 --- a/frontend/src/app/main/ui/components/file_uploader.cljs +++ b/frontend/src/app/main/ui/components/file_uploader.cljs @@ -6,10 +6,9 @@ (ns app.main.ui.components.file-uploader (:require - [rumext.alpha :as mf] - [app.main.data.workspace :as dw] [app.main.store :as st] - [app.util.dom :as dom])) + [app.util.dom :as dom] + [rumext.alpha :as mf])) (mf/defc file-uploader {::mf/forward-ref true} diff --git a/frontend/src/app/main/ui/components/fullscreen.cljs b/frontend/src/app/main/ui/components/fullscreen.cljs index baf9ceca2f..21ee1f29b7 100644 --- a/frontend/src/app/main/ui/components/fullscreen.cljs +++ b/frontend/src/app/main/ui/components/fullscreen.cljs @@ -8,7 +8,6 @@ (:require [app.util.dom :as dom] [app.util.webapi :as wapi] - [beicon.core :as rx] [rumext.alpha :as mf])) (def fullscreen-context @@ -21,7 +20,7 @@ change (mf/use-callback - (fn [event] + (fn [_] (let [val (dom/fullscreen?)] (reset! state val)))) diff --git a/frontend/src/app/main/ui/components/numeric_input.cljs b/frontend/src/app/main/ui/components/numeric_input.cljs index b460d7b6c4..b1cf44c10e 100644 --- a/frontend/src/app/main/ui/components/numeric_input.cljs +++ b/frontend/src/app/main/ui/components/numeric_input.cljs @@ -132,7 +132,7 @@ handle-blur (mf/use-callback (mf/deps parse-value apply-value update-input) - (fn [event] + (fn [_] (let [new-value (parse-value)] (if new-value (apply-value new-value) diff --git a/frontend/src/app/main/ui/components/select.cljs b/frontend/src/app/main/ui/components/select.cljs index c88138c8f1..d651313177 100644 --- a/frontend/src/app/main/ui/components/select.cljs +++ b/frontend/src/app/main/ui/components/select.cljs @@ -6,10 +6,10 @@ (ns app.main.ui.components.select (:require - [rumext.alpha :as mf] [app.common.uuid :as uuid] + [app.main.ui.components.dropdown :refer [dropdown]] [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]}] (let [state (mf/use-state {:id (uuid/next) @@ -17,9 +17,10 @@ :current-value default-value}) open-dropdown #(swap! state assoc :is-open? true) close-dropdown #(swap! state assoc :is-open? false) - select-item (fn [value] (fn [event] - (swap! state assoc :current-value value) - (when on-change (on-change value)))) + select-item (fn [value] + (fn [_] + (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])) value->label (into {} (->> options (map as-key-value))) ] diff --git a/frontend/src/app/main/ui/components/tab_container.cljs b/frontend/src/app/main/ui/components/tab_container.cljs index 25a375fc43..126acff2dc 100644 --- a/frontend/src/app/main/ui/components/tab_container.cljs +++ b/frontend/src/app/main/ui/components/tab_container.cljs @@ -8,7 +8,7 @@ (:require [rumext.alpha :as mf])) (mf/defc tab-element - [{:keys [children id title]}] + [{:keys [children]}] [:div.tab-element [:div.tab-element-content children]]) diff --git a/frontend/src/app/main/ui/confirm.cljs b/frontend/src/app/main/ui/confirm.cljs index a622236018..030aafd203 100644 --- a/frontend/src/app/main/ui/confirm.cljs +++ b/frontend/src/app/main/ui/confirm.cljs @@ -57,10 +57,10 @@ (let [on-keydown (fn [event] (when (k/enter? event) - (do (dom/prevent-default event) - (dom/stop-propagation event) - (st/emit! (modal/hide)) - (on-accept props)))) + (dom/prevent-default event) + (dom/stop-propagation event) + (st/emit! (modal/hide)) + (on-accept props))) key (events/listen js/document EventType.KEYDOWN on-keydown)] #(events/unlistenByKey key)))) diff --git a/frontend/src/app/main/ui/cursors.clj b/frontend/src/app/main/ui/cursors.clj index 5d0bedbe1b..0b63e5f579 100644 --- a/frontend/src/app/main/ui/cursors.clj +++ b/frontend/src/app/main/ui/cursors.clj @@ -6,9 +6,9 @@ (ns app.main.ui.cursors (:require + [app.common.uri :as u] [clojure.java.io :as io] - [cuerdas.core :as str] - [app.common.uri :as u])) + [cuerdas.core :as str])) (def cursor-folder "images/cursors") diff --git a/frontend/src/app/main/ui/cursors.cljs b/frontend/src/app/main/ui/cursors.cljs index 5748bb54fe..c52be68919 100644 --- a/frontend/src/app/main/ui/cursors.cljs +++ b/frontend/src/app/main/ui/cursors.cljs @@ -6,9 +6,10 @@ (ns app.main.ui.cursors (:require-macros [app.main.ui.cursors :refer [cursor-ref cursor-fn]]) - (:require [rumext.alpha :as mf] - [cuerdas.core :as str] - [app.util.timers :as ts])) + (:require + [app.util.timers :as ts] + [cuerdas.core :as str] + [rumext.alpha :as mf])) ;; Static cursors (def comments (cursor-ref :comments 0 2 20)) @@ -40,7 +41,7 @@ (mf/defc debug-preview {::mf/wrap-props false} - [props] + [] (let [rotation (mf/use-state 0)] (mf/use-effect (fn [] (ts/interval 100 #(reset! rotation inc)))) diff --git a/frontend/src/app/main/ui/dashboard.cljs b/frontend/src/app/main/ui/dashboard.cljs index dc14df9cd6..ef87216974 100644 --- a/frontend/src/app/main/ui/dashboard.cljs +++ b/frontend/src/app/main/ui/dashboard.cljs @@ -6,9 +6,7 @@ (ns app.main.ui.dashboard (:require - [app.common.exceptions :as ex] [app.common.spec :as us] - [app.common.uuid :as uuid] [app.config :as cf] [app.main.data.dashboard :as dd] [app.main.data.modal :as modal] @@ -16,19 +14,13 @@ [app.main.store :as st] [app.main.ui.context :as ctx] [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.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.sidebar :refer [sidebar]] [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] - [beicon.core :as rx] - [cuerdas.core :as str] - [okulary.core :as l] [rumext.alpha :as mf])) (defn ^boolean uuid-str? @@ -37,9 +29,8 @@ (boolean (re-seq us/uuid-rx s)))) (defn- parse-params - [route profile] - (let [route-name (get-in route [:data :name]) - search-term (get-in route [:params :query :search-term]) + [route] + (let [search-term (get-in route [:params :query :search-term]) team-id (get-in route [:params :path :team-id]) project-id (get-in route [:params :path :project-id])] (cond-> @@ -87,7 +78,7 @@ [{:keys [route] :as props}] (let [profile (mf/deref refs/profile) section (get-in route [:data :name]) - params (parse-params route profile) + params (parse-params route) project-id (:project-id params) team-id (:team-id params) diff --git a/frontend/src/app/main/ui/dashboard/comments.cljs b/frontend/src/app/main/ui/dashboard/comments.cljs index 48703fdf25..ce2f8b4f53 100644 --- a/frontend/src/app/main/ui/dashboard/comments.cljs +++ b/frontend/src/app/main/ui/dashboard/comments.cljs @@ -6,29 +6,15 @@ (ns app.main.ui.dashboard.comments (: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.workspace.comments :as dwcm] [app.main.refs :as refs] - [app.main.repo :as rp] [app.main.store :as st] - [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.comments :as cmt] + [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.icons :as i] [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t 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] + [app.util.i18n :as i18n :refer [tr]] [rumext.alpha :as mf])) (mf/defc comments-section diff --git a/frontend/src/app/main/ui/dashboard/files.cljs b/frontend/src/app/main/ui/dashboard/files.cljs index dc7b44e8b4..2ec4874139 100644 --- a/frontend/src/app/main/ui/dashboard/files.cljs +++ b/frontend/src/app/main/ui/dashboard/files.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.dashboard.files (:require [app.main.data.dashboard :as dd] - [app.main.data.modal :as modal] [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.dashboard.grid :refer [grid]] @@ -16,18 +15,12 @@ [app.main.ui.icons :as i] [app.util.dom :as dom] [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])) (mf/defc header - [{:keys [team project] :as props}] + [{:keys [project] :as props}] (let [local (mf/use-state {:menu-open false :edition false}) - project-id (:id project) - team-id (:id team) - on-menu-click (mf/use-callback (fn [event] @@ -83,7 +76,7 @@ (if (:is-pinned project) i/pin-fill i/pin)] - + [:div.icon.tooltip.tooltip-bottom {:on-click on-menu-click :alt (tr "dashboard.options")} i/actions]]])) diff --git a/frontend/src/app/main/ui/dashboard/fonts.cljs b/frontend/src/app/main/ui/dashboard/fonts.cljs index 9363698bf4..72d65eb27f 100644 --- a/frontend/src/app/main/ui/dashboard/fonts.cljs +++ b/frontend/src/app/main/ui/dashboard/fonts.cljs @@ -6,27 +6,22 @@ (ns app.main.ui.dashboard.fonts (:require - [app.common.data :as d] [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.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.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.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] - [app.util.logging :as log] [app.util.keyboard :as kbd] - [app.util.router :as rt] - [app.util.webapi :as wa] - [cuerdas.core :as str] + [app.util.logging :as log] + ;; [app.util.router :as rt] [beicon.core :as rx] - [okulary.core :as l] + [cuerdas.core :as str] [rumext.alpha :as mf])) (log/set-level! :trace) @@ -47,29 +42,29 @@ (mf/defc header {::mf/wrap [mf/memo]} [{:keys [section team] :as props}] - (let [go-fonts - (mf/use-callback - (mf/deps team) - (st/emitf (rt/nav :dashboard-fonts {:team-id (:id team)}))) + ;; (let [go-fonts + ;; (mf/use-callback + ;; (mf/deps team) + ;; (st/emitf (rt/nav :dashboard-fonts {:team-id (:id team)}))) - go-providers - (mf/use-callback - (mf/deps team) - (st/emitf (rt/nav :dashboard-font-providers {:team-id (:id team)})))] + ;; go-providers + ;; (mf/use-callback + ;; (mf/deps 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 - [:div.dashboard-title - [:h1 (tr "labels.fonts")]] - [:nav - #_[:ul - [:li {:class (when (= section :fonts) "active")} - [:a {:on-click go-fonts} (tr "labels.custom-fonts")]] - [:li {:class (when (= section :providers) "active")} - [:a {:on-click go-providers} (tr "labels.font-providers")]]]] + [:header.dashboard-header + [:div.dashboard-title + [:h1 (tr "labels.fonts")]] + [:nav + #_[:ul + [:li {:class (when (= section :fonts) "active")} + [:a {:on-click go-fonts} (tr "labels.custom-fonts")]] + [:li {:class (when (= section :providers) "active")} + [:a {:on-click go-providers} (tr "labels.font-providers")]]]] - [:div]])) + [:div]]) (mf/defc font-variant-display-name [{:keys [variant]}] @@ -88,9 +83,6 @@ on-click (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 (mf/use-callback (mf/deps team installed-fonts) @@ -190,7 +182,7 @@ (reset! state (dom/get-target-val event))) on-save - (fn [event] + (fn [_] (let [font-family @state] (when-not (str/blank? font-family) (st/emit! (df/update-font @@ -204,7 +196,7 @@ (on-save event))) on-cancel - (fn [event] + (fn [_] (reset! edit? false) (reset! state (:font-family font))) @@ -221,8 +213,7 @@ :title (tr "modals.delete-font.title") :message (tr "modals.delete-font.message") :accept-label (tr "labels.delete") - :on-accept (fn [props] - (delete-font-fn))}))) + :on-accept (fn [_props] (delete-font-fn))}))) on-delete-variant (fn [id] @@ -231,7 +222,7 @@ :title (tr "modals.delete-font-variant.title") :message (tr "modals.delete-font-variant.message") :accept-label (tr "labels.delete") - :on-accept (fn [props] + :on-accept (fn [_props] (delete-variant-fn id))})))] [:div.font-item.table-row @@ -276,7 +267,7 @@ (mf/defc installed-fonts - [{:keys [team fonts] :as props}] + [{:keys [fonts] :as props}] (let [sterm (mf/use-state "") matches? diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index 3afa25470d..c15b2e6641 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -7,11 +7,8 @@ (ns app.main.ui.dashboard.grid (:require [app.common.math :as mth] - [app.common.uuid :as uuid] - [app.config :as cfg] [app.main.data.dashboard :as dd] [app.main.data.messages :as dm] - [app.main.data.modal :as modal] [app.main.fonts :as fonts] [app.main.refs :as refs] [app.main.store :as st] @@ -23,12 +20,10 @@ [app.util.dom.dnd :as dnd] [app.util.i18n :as i18n :refer [tr]] [app.util.keyboard :as kbd] - [app.util.router :as rt] [app.util.time :as dt] [app.util.timers :as ts] [app.util.webapi :as wapi] [beicon.core :as rx] - [cuerdas.core :as str] [rumext.alpha :as mf])) ;; --- Grid Item Thumbnail @@ -59,7 +54,7 @@ (str (tr "ds.updated-at" time)))) (defn create-counter-element - [element file-count] + [_element file-count] (let [counter-el (dom/create-element "div")] (dom/set-property! counter-el "class" "drag-counter") (dom/set-text! counter-el (str file-count)) @@ -215,7 +210,7 @@ [:div.text (tr "dashboard.loading-files")]]) (mf/defc grid - [{:keys [id opts files] :as props}] + [{:keys [files] :as props}] [:section.dashboard-grid (cond (nil? files) @@ -233,7 +228,7 @@ [:& empty-placeholder])]) (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) width (mf/use-state nil) @@ -288,7 +283,7 @@ (tr "dashboard.show-all-files")]])])) (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) selected-files (mf/deref refs/dashboard-selected-files) @@ -326,7 +321,7 @@ on-drop (mf/use-callback (mf/deps files selected-files) - (fn [e] + (fn [_] (reset! dragging? false) (when (not= selected-project project-id) (let [data {:ids (into #{} (keys selected-files)) diff --git a/frontend/src/app/main/ui/dashboard/import.cljs b/frontend/src/app/main/ui/dashboard/import.cljs index c540a744aa..e3f63b38d1 100644 --- a/frontend/src/app/main/ui/dashboard/import.cljs +++ b/frontend/src/app/main/ui/dashboard/import.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.dashboard.import (:require [app.main.ui.components.file-uploader :refer [file-uploader]] - [app.main.ui.icons :as i] [app.main.worker :as uw] [app.util.dom :as dom] [app.util.logging :as log] diff --git a/frontend/src/app/main/ui/dashboard/libraries.cljs b/frontend/src/app/main/ui/dashboard/libraries.cljs index e61d4bcd4d..7130c97216 100644 --- a/frontend/src/app/main/ui/dashboard/libraries.cljs +++ b/frontend/src/app/main/ui/dashboard/libraries.cljs @@ -7,14 +7,11 @@ (ns app.main.ui.dashboard.libraries (:require [app.main.data.dashboard :as dd] + [app.main.refs :as refs] [app.main.store :as st] [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.i18n :as i18n :refer [tr]] - [app.util.router :as rt] - [okulary.core :as l] [rumext.alpha :as mf])) (mf/defc libraries-page diff --git a/frontend/src/app/main/ui/dashboard/project_menu.cljs b/frontend/src/app/main/ui/dashboard/project_menu.cljs index 68c166a326..48e0ab05e4 100644 --- a/frontend/src/app/main/ui/dashboard/project_menu.cljs +++ b/frontend/src/app/main/ui/dashboard/project_menu.cljs @@ -10,7 +10,6 @@ [app.main.data.messages :as dm] [app.main.data.modal :as modal] [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.context :as ctx] @@ -19,7 +18,6 @@ [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] - [beicon.core :as rx] [rumext.alpha :as mf])) (mf/defc project-menu @@ -62,7 +60,7 @@ (dd/move-project (with-meta data mdata))))) delete-fn - (fn [event] + (fn [_] (st/emit! (dm/success (tr "dashboard.success-delete-project")) (dd/delete-project project) (dd/go-to-projects (:team-id project)))) diff --git a/frontend/src/app/main/ui/dashboard/projects.cljs b/frontend/src/app/main/ui/dashboard/projects.cljs index 262fcaac62..66e12999a6 100644 --- a/frontend/src/app/main/ui/dashboard/projects.cljs +++ b/frontend/src/app/main/ui/dashboard/projects.cljs @@ -6,8 +6,6 @@ (ns app.main.ui.dashboard.projects (:require - [app.common.exceptions :as ex] - [app.main.constants :as c] [app.main.data.dashboard :as dd] [app.main.refs :as refs] [app.main.store :as st] @@ -16,8 +14,7 @@ [app.main.ui.dashboard.project-menu :refer [project-menu]] [app.main.ui.icons :as i] [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t tr]] - [app.util.keyboard :as kbd] + [app.util.i18n :as i18n :refer [tr]] [app.util.router :as rt] [app.util.time :as dt] [okulary.core :as l] @@ -38,7 +35,6 @@ [{:keys [project first? files] :as props}] (let [locale (mf/deref i18n/locale) - project-id (:id project) team-id (:team-id project) file-count (or (:count project) 0) diff --git a/frontend/src/app/main/ui/dashboard/search.cljs b/frontend/src/app/main/ui/dashboard/search.cljs index d3c6ed9ed6..56bc7439f0 100644 --- a/frontend/src/app/main/ui/dashboard/search.cljs +++ b/frontend/src/app/main/ui/dashboard/search.cljs @@ -13,7 +13,6 @@ [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] - [okulary.core :as l] [rumext.alpha :as mf])) (mf/defc search-page diff --git a/frontend/src/app/main/ui/dashboard/sidebar.cljs b/frontend/src/app/main/ui/dashboard/sidebar.cljs index b35edc7e0d..07416cb045 100644 --- a/frontend/src/app/main/ui/dashboard/sidebar.cljs +++ b/frontend/src/app/main/ui/dashboard/sidebar.cljs @@ -9,13 +9,11 @@ [app.common.data :as d] [app.common.spec :as us] [app.config :as cfg] - [app.main.data.comments :as dcm] [app.main.data.dashboard :as dd] [app.main.data.messages :as dm] [app.main.data.modal :as modal] [app.main.data.users :as du] [app.main.refs :as refs] - [app.main.repo :as rp] [app.main.store :as st] [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.forms :as fm] @@ -24,23 +22,17 @@ [app.main.ui.dashboard.project-menu :refer [project-menu]] [app.main.ui.dashboard.team-form] [app.main.ui.icons :as i] - [app.util.avatars :as avatars] [app.util.dom :as dom] [app.util.dom.dnd :as dnd] [app.util.i18n :as i18n :refer [tr]] - [app.util.keyboard :as kbd] [app.util.object :as obj] [app.util.router :as rt] - [app.util.time :as dt] - [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [goog.functions :as f] - [okulary.core :as l] [rumext.alpha :as mf])) (mf/defc sidebar-project - [{:keys [item team-id selected?] :as props}] + [{:keys [item selected?] :as props}] (let [dstate (mf/deref refs/dashboard-local) selected-files (:selected-files dstate) selected-project (:selected-project dstate) @@ -111,7 +103,7 @@ on-drop (mf/use-callback (mf/deps item selected-files) - (fn [e] + (fn [_] (swap! local assoc :dragging? false) (when (not= selected-project (:id item)) (let [data {:ids selected-files @@ -157,7 +149,7 @@ on-search-blur (mf/use-callback - (fn [event] + (fn [_] (reset! focused? false))) on-search-change @@ -170,7 +162,7 @@ on-clear-click (mf/use-callback (mf/deps team-id) - (fn [event] + (fn [_] (let [search-input (dom/get-element "search-input")] (dom/clean-value! search-input) (dom/focus! search-input) @@ -189,7 +181,7 @@ :on-change on-search-change :ref #(when % (set! (.-value %) search-term))}] - (if (or @focused? (not (empty? search-term))) + (if (or @focused? (seq search-term)) [:div.clear-search {:on-click on-clear-click} i/close] @@ -199,9 +191,8 @@ i/search])])) (mf/defc teams-selector-dropdown - [{:keys [team profile] :as props}] - (let [show-dropdown? (mf/use-state false) - teams (mf/deref refs/teams) + [{:keys [profile] :as props}] + (let [teams (mf/deref refs/teams) on-create-clicked (mf/use-callback @@ -246,7 +237,7 @@ on-cancel (st/emitf (modal/hide)) on-accept - (fn [event] + (fn [_] (let [member-id (get-in @form [:clean-data :member-id])] (accept member-id)))] @@ -291,9 +282,6 @@ members-map (mf/deref refs/dashboard-team-members) members (vals members-map) - on-create-clicked - (st/emitf (modal/show :team-form {})) - on-rename-clicked (st/emitf (modal/show :team-form {:team team})) @@ -358,9 +346,7 @@ (mf/defc sidebar-team-switch [{:keys [team profile] :as props}] - (let [show-dropdown? (mf/use-state false) - - show-team-opts-ddwn? (mf/use-state false) + (let [show-team-opts-ddwn? (mf/use-state false) show-teams-ddwn? (mf/use-state false)] [:div.sidebar-team-switch diff --git a/frontend/src/app/main/ui/dashboard/team.cljs b/frontend/src/app/main/ui/dashboard/team.cljs index 4eb028314c..4c87aa4d12 100644 --- a/frontend/src/app/main/ui/dashboard/team.cljs +++ b/frontend/src/app/main/ui/dashboard/team.cljs @@ -7,10 +7,8 @@ (ns app.main.ui.dashboard.team (:require [app.common.data :as d] - [app.common.exceptions :as ex] [app.common.spec :as us] [app.config :as cfg] - [app.main.constants :as c] [app.main.data.dashboard :as dd] [app.main.data.messages :as dm] [app.main.data.modal :as modal] @@ -23,15 +21,12 @@ [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] - [app.util.router :as rt] - [app.util.time :as dt] [cljs.spec.alpha :as s] - [okulary.core :as l] [rumext.alpha :as mf])) (mf/defc header {::mf/wrap [mf/memo]} - [{:keys [section team] :as props}] + [{:keys [section] :as props}] (let [go-members (st/emitf (dd/go-to-team-members)) go-settings (st/emitf (dd/go-to-team-settings)) invite-member (st/emitf (modal/show {:type ::invite-member})) @@ -43,7 +38,7 @@ [:h1 (cond members-section? (tr "labels.members") settings-section? (tr "labels.settings") - nil)]] + :else nil)]] [:nav [:ul [:li {:class (when members-section? "active")} @@ -96,7 +91,7 @@ (dm/error (tr "errors.member-is-muted")) (and (= :validation type) - (= :email-has-permanent-bounces)) + (= :email-has-permanent-bounces code)) (dm/error (tr "errors.email-has-permanent-bounces" email)) :else @@ -136,7 +131,7 @@ set-owner-fn (partial set-role :owner) set-admin (partial set-role :admin) set-editor (partial set-role :editor) - set-viewer (partial set-role :viewer) + ;; set-viewer (partial set-role :viewer) set-owner (st/emitf (modal/show @@ -242,7 +237,7 @@ :members-map members-map}]]])) (mf/defc team-settings-page - [{:keys [team profile] :as props}] + [{:keys [team] :as props}] (let [finput (mf/use-ref) members-map (mf/deref refs/dashboard-team-members) diff --git a/frontend/src/app/main/ui/dashboard/team_form.cljs b/frontend/src/app/main/ui/dashboard/team_form.cljs index 758477b702..1a936b26fb 100644 --- a/frontend/src/app/main/ui/dashboard/team_form.cljs +++ b/frontend/src/app/main/ui/dashboard/team_form.cljs @@ -6,7 +6,6 @@ (ns app.main.ui.dashboard.team-form (:require - [app.common.data :as d] [app.common.spec :as us] [app.main.data.dashboard :as dd] [app.main.data.messages :as dm] @@ -14,13 +13,10 @@ [app.main.store :as st] [app.main.ui.components.forms :as fm] [app.main.ui.icons :as i] - [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] - [app.util.object :as obj] [app.util.router :as rt] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [rumext.alpha :as mf])) (s/def ::name ::us/not-empty-string) @@ -28,20 +24,20 @@ (s/keys :req-un [::name])) (defn- on-create-success - [form response] + [_form response] (let [msg "Team created successfuly"] (st/emit! (dm/success msg) (modal/hide) (rt/nav :dashboard-projects {:team-id (:id response)})))) (defn- on-update-success - [form response] + [_form _response] (let [msg "Team created successfuly"] (st/emit! (dm/success msg) (modal/hide)))) (defn- on-error - [form response] + [form _response] (let [id (get-in @form [:clean-data :id])] (if id (rx/of (dm/error "Error on updating team.")) diff --git a/frontend/src/app/main/ui/handoff.cljs b/frontend/src/app/main/ui/handoff.cljs index ee82788f08..bee408f97b 100644 --- a/frontend/src/app/main/ui/handoff.cljs +++ b/frontend/src/app/main/ui/handoff.cljs @@ -6,7 +6,6 @@ (ns app.main.ui.handoff (:require - [app.common.exceptions :as ex] [app.main.data.viewer :as dv] [app.main.data.viewer.shortcuts :as sc] [app.main.refs :as refs] @@ -15,15 +14,12 @@ [app.main.ui.handoff.render :refer [render-frame-svg]] [app.main.ui.handoff.right-sidebar :refer [right-sidebar]] [app.main.ui.hooks :as hooks] - [app.main.ui.icons :as i] [app.main.ui.viewer.header :refer [header]] [app.main.ui.viewer.thumbnails :refer [thumbnails-panel]] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [t tr]] [app.util.keyboard :as kbd] - [beicon.core :as rx] [goog.events :as events] - [okulary.core :as l] [rumext.alpha :as mf]) (:import goog.events.EventType)) diff --git a/frontend/src/app/main/ui/handoff/attributes.cljs b/frontend/src/app/main/ui/handoff/attributes.cljs index 51a59746fa..cdce9e76d1 100644 --- a/frontend/src/app/main/ui/handoff/attributes.cljs +++ b/frontend/src/app/main/ui/handoff/attributes.cljs @@ -6,18 +6,18 @@ (ns app.main.ui.handoff.attributes (:require - [rumext.alpha :as mf] - [app.util.i18n :as i18n] [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.fill :refer [fill-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.svg :refer [svg-panel]])) + [app.main.ui.handoff.exports :refer [exports]] + [app.util.i18n :as i18n] + [rumext.alpha :as mf])) (def type->options {:multiple [:fill :stroke :image :text :shadow :blur] diff --git a/frontend/src/app/main/ui/handoff/attributes/blur.cljs b/frontend/src/app/main/ui/handoff/attributes/blur.cljs index 9d3ca9d969..67f3b9194b 100644 --- a/frontend/src/app/main/ui/handoff/attributes/blur.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/blur.cljs @@ -6,12 +6,11 @@ (ns app.main.ui.handoff.attributes.blur (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [app.util.i18n :refer [t]] - [app.main.ui.icons :as i] + [app.main.ui.components.copy-button :refer [copy-button]] [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] (:blur shape)) diff --git a/frontend/src/app/main/ui/handoff/attributes/common.cljs b/frontend/src/app/main/ui/handoff/attributes/common.cljs index 03c3410740..2171979a50 100644 --- a/frontend/src/app/main/ui/handoff/attributes/common.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/common.cljs @@ -6,19 +6,16 @@ (ns app.main.ui.handoff.attributes.common (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [okulary.core :as l] [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.i18n :refer [t] :as i18n] - [app.util.color :as uc] - [app.util.code-gen :as cg] - [app.util.webapi :as wapi] - [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]])) + [cuerdas.core :as str] + [okulary.core :as l] + [rumext.alpha :as mf])) (def file-colors-ref diff --git a/frontend/src/app/main/ui/handoff/attributes/fill.cljs b/frontend/src/app/main/ui/handoff/attributes/fill.cljs index fdb15cf5c9..a2b6301dc0 100644 --- a/frontend/src/app/main/ui/handoff/attributes/fill.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/fill.cljs @@ -6,13 +6,12 @@ (ns app.main.ui.handoff.attributes.fill (: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.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]) @@ -36,7 +35,7 @@ {:to-prop "background" :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) color (shape->color shape)] @@ -46,16 +45,15 @@ :copy-data (copy-data shape)}])) (mf/defc fill-panel - [{:keys [shapes locale]}] + [{:keys [shapes]}] (let [shapes (->> shapes (filter has-color?))] (when (seq shapes) [:div.attributes-block [: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) [:& copy-button {:data (copy-data (first shapes))}])] (for [shape shapes] [:& fill-block {:key (str "fill-block-" (:id shape)) - :shape shape - :locale locale}])]))) + :shape shape}])]))) diff --git a/frontend/src/app/main/ui/handoff/attributes/image.cljs b/frontend/src/app/main/ui/handoff/attributes/image.cljs index 238b7dea89..e798188682 100644 --- a/frontend/src/app/main/ui/handoff/attributes/image.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/image.cljs @@ -6,19 +6,17 @@ (ns app.main.ui.handoff.attributes.image (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] [app.config :as cfg] - [app.util.i18n :refer [t]] - [app.util.dom :as dom] - [app.main.ui.icons :as i] + [app.main.ui.components.copy-button :refer [copy-button]] [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] - (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?))] (for [shape shapes] [:div.attributes-block {:key (str "image-" (:id shape))} @@ -27,12 +25,12 @@ [:img {:src (cfg/resolve-file-media (-> shape :metadata))}]]] [: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"] [:& copy-button {:data (cg/generate-css-props shape :width)}]] [: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"] [:& copy-button {:data (cg/generate-css-props shape :height)}]] @@ -44,4 +42,4 @@ (str name "." extension) name) :href (cfg/resolve-file-media (-> shape :metadata))} - (t locale "handoff.attributes.image.download")])]))) + (tr "handoff.attributes.image.download")])]))) diff --git a/frontend/src/app/main/ui/handoff/attributes/layout.cljs b/frontend/src/app/main/ui/handoff/attributes/layout.cljs index 2a55eff534..4704bbb0a9 100644 --- a/frontend/src/app/main/ui/handoff/attributes/layout.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/layout.cljs @@ -6,13 +6,12 @@ (ns app.main.ui.handoff.attributes.layout (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [app.util.i18n :refer [t]] [app.common.math :as mth] - [app.main.ui.icons :as i] + [app.main.ui.components.copy-button :refer [copy-button]] [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])) (def properties [:width :height :x :y :radius :rx :r1]) diff --git a/frontend/src/app/main/ui/handoff/attributes/shadow.cljs b/frontend/src/app/main/ui/handoff/attributes/shadow.cljs index 9d757d7880..892f466794 100644 --- a/frontend/src/app/main/ui/handoff/attributes/shadow.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/shadow.cljs @@ -6,15 +6,13 @@ (ns app.main.ui.handoff.attributes.shadow (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] [app.common.data :as d] - [app.util.i18n :refer [t]] - [app.util.code-gen :as cg] - [app.main.ui.icons :as i] - [app.util.code-gen :as cg] [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.i18n :refer [tr]] + [cuerdas.core :as str] + [rumext.alpha :as mf])) (defn has-shadow? [shape] (:shadow shape)) @@ -33,26 +31,25 @@ {:to-prop "box-shadow" :format #(cg/shadow->css shadow)})) -(mf/defc shadow-block [{:keys [shape locale shadow]}] - (let [color-format (mf/use-state :hex) - copy-data (shadow-copy-data shadow)] +(mf/defc shadow-block [{:keys [shadow]}] + (let [color-format (mf/use-state :hex)] [:div.attributes-shadow-block [:div.attributes-shadow-row - [:div.attributes-label (->> shadow :style d/name (str "handoff.attributes.shadow.style.") (t locale))] + [:div.attributes-label (->> shadow :style d/name (str "handoff.attributes.shadow.style.") (tr))] [:div.attributes-shadow - [:div.attributes-label (t locale "handoff.attributes.shadow.shorthand.offset-x")] + [:div.attributes-label (tr "handoff.attributes.shadow.shorthand.offset-x")] [:div.attributes-value (str (:offset-x shadow))]] [:div.attributes-shadow - [:div.attributes-label (t locale "handoff.attributes.shadow.shorthand.offset-y")] + [:div.attributes-label (tr "handoff.attributes.shadow.shorthand.offset-y")] [:div.attributes-value (str (:offset-y shadow))]] [:div.attributes-shadow - [:div.attributes-label (t locale "handoff.attributes.shadow.shorthand.blur")] + [:div.attributes-label (tr "handoff.attributes.shadow.shorthand.blur")] [:div.attributes-value (str (:blur shadow))]] [:div.attributes-shadow - [:div.attributes-label (t locale "handoff.attributes.shadow.shorthand.spread")] + [:div.attributes-label (tr "handoff.attributes.shadow.shorthand.spread")] [:div.attributes-value (str (:spread shadow))]] [:& copy-button {:data (shadow-copy-data shadow)}]] @@ -61,12 +58,12 @@ :format @color-format :on-change-format #(reset! color-format %)}]])) -(mf/defc shadow-panel [{:keys [shapes locale]}] +(mf/defc shadow-panel [{:keys [shapes]}] (let [shapes (->> shapes (filter has-shadow?))] (when (seq shapes) [:div.attributes-block [:div.attributes-block-title - [:div.attributes-block-title-text (t locale "handoff.attributes.shadow")] + [:div.attributes-block-title-text (tr "handoff.attributes.shadow")] (when (= (count shapes) 1) [:& copy-button {:data (shape-copy-data (first shapes))}])] @@ -74,5 +71,4 @@ (for [shape shapes] (for [shadow (:shadow shape)] [:& shadow-block {:shape shape - :locale locale :shadow shadow}]))]]))) diff --git a/frontend/src/app/main/ui/handoff/attributes/stroke.cljs b/frontend/src/app/main/ui/handoff/attributes/stroke.cljs index 075daae30d..ddd5a3263c 100644 --- a/frontend/src/app/main/ui/handoff/attributes/stroke.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/stroke.cljs @@ -6,16 +6,15 @@ (ns app.main.ui.handoff.attributes.stroke (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] [app.common.data :as d] [app.common.math :as mth] - [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.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 [t]] + [cuerdas.core :as str] + [rumext.alpha :as mf])) (defn shape->color [shape] {:color (:stroke-color shape) diff --git a/frontend/src/app/main/ui/handoff/attributes/svg.cljs b/frontend/src/app/main/ui/handoff/attributes/svg.cljs index 033ad073fe..a2308c5986 100644 --- a/frontend/src/app/main/ui/handoff/attributes/svg.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/svg.cljs @@ -6,14 +6,14 @@ (ns app.main.ui.handoff.attributes.svg (:require - [rumext.alpha :as mf] - [app.common.data :as d] - [cuerdas.core :as str] - [app.util.i18n :refer [tr]] #_[app.common.math :as mth] #_[app.main.ui.icons :as i] #_[app.util.code-gen :as cg] - [app.main.ui.components.copy-button :refer [copy-button]])) + [app.common.data :as d] + [app.main.ui.components.copy-button :refer [copy-button]] + [app.util.i18n :refer [tr]] + [cuerdas.core :as str] + [rumext.alpha :as mf])) (defn map->css [attr] @@ -47,7 +47,7 @@ [{:keys [shapes]}] (let [shape (first shapes)] - (when (and (:svg-attrs shape) (not (empty? (:svg-attrs shape)))) + (when (seq (:svg-attrs shape)) [:div.attributes-block [:div.attributes-block-title [:div.attributes-block-title-text (tr "workspace.sidebar.options.svg-attrs.title")]] diff --git a/frontend/src/app/main/ui/handoff/attributes/text.cljs b/frontend/src/app/main/ui/handoff/attributes/text.cljs index f49276d6f4..694c3525b8 100644 --- a/frontend/src/app/main/ui/handoff/attributes/text.cljs +++ b/frontend/src/app/main/ui/handoff/attributes/text.cljs @@ -11,11 +11,9 @@ [app.main.store :as st] [app.main.ui.components.copy-button :refer [copy-button]] [app.main.ui.handoff.attributes.common :refer [color-row]] - [app.main.ui.icons :as i] - [app.util.i18n :refer [tr]] [app.util.code-gen :as cg] [app.util.color :as uc] - [app.util.webapi :as wapi] + [app.util.i18n :refer [tr]] [cuerdas.core :as str] [okulary.core :as l] [rumext.alpha :as mf])) @@ -68,7 +66,7 @@ ([style & properties] (cg/generate-css-props style properties params))) -(mf/defc typography-block [{:keys [shape text style full-style]}] +(mf/defc typography-block [{:keys [text style full-style]}] (let [typography-library-ref (mf/use-memo (mf/deps (:typography-ref-file style)) (make-typographies-library-ref (:typography-ref-file style))) @@ -77,7 +75,6 @@ file-typographies (mf/deref file-typographies-ref) color-format (mf/use-state :hex) - color (shape->color style) typography (get (or typography-library file-typographies) (:typography-ref-id style))] @@ -163,14 +160,11 @@ m1)) (mf/defc text-block [{:keys [shape]}] - (let [font (cg/search-text-attrs (:content shape) - (keys txt/default-text-attrs)) - style-text-blocks (->> (keys txt/default-text-attrs) + (let [style-text-blocks (->> (keys txt/default-text-attrs) (cg/parse-style-text-blocks (:content shape)) - (remove (fn [[style text]] (str/empty? (str/trim text)))) - (mapv (fn [[style text]] (vector (merge txt/default-text-attrs style) text)))) + (remove (fn [[_ text]] (str/empty? (str/trim text)))) + (mapv (fn [[style text]] (vector (merge txt/default-text-attrs style) text))))] - font (merge txt/default-text-attrs font)] (for [[idx [full-style text]] (map-indexed vector style-text-blocks)] (let [previus-style (first (nth style-text-blocks (dec idx) nil)) style (remove-equal-values full-style previus-style) diff --git a/frontend/src/app/main/ui/handoff/code.cljs b/frontend/src/app/main/ui/handoff/code.cljs index 2bf92cc3d4..b6eab07445 100644 --- a/frontend/src/app/main/ui/handoff/code.cljs +++ b/frontend/src/app/main/ui/handoff/code.cljs @@ -7,17 +7,16 @@ (ns app.main.ui.handoff.code (:require ["js-beautify" :as beautify] - [cuerdas.core :as str] - [rumext.alpha :as mf] - [app.util.i18n :as i18n] - [app.util.dom :as dom] - [app.util.code-gen :as cg] - [app.main.ui.icons :as i] [app.common.geom.shapes :as gsh] + [app.main.ui.components.code-block :refer [code-block]] [app.main.ui.components.copy-button :refer [copy-button]] - [app.main.ui.components.code-block :refer [code-block]])) + [app.main.ui.icons :as i] + [app.util.code-gen :as cg] + [app.util.dom :as dom] + [cuerdas.core :as str] + [rumext.alpha :as mf])) -(defn generate-markup-code [type shapes] +(defn generate-markup-code [_type shapes] (let [frame (dom/query js/document "#svg-frame") markup-shape (fn [shape] @@ -42,8 +41,6 @@ [{:keys [shapes frame on-expand]}] (let [style-type (mf/use-state "css") markup-type (mf/use-state "svg") - - locale (mf/deref i18n/locale) shapes (->> shapes (map #(gsh/translate-to-frame % frame))) diff --git a/frontend/src/app/main/ui/handoff/exports.cljs b/frontend/src/app/main/ui/handoff/exports.cljs index a8a36b2bf2..670a8f312f 100644 --- a/frontend/src/app/main/ui/handoff/exports.cljs +++ b/frontend/src/app/main/ui/handoff/exports.cljs @@ -6,21 +6,19 @@ (ns app.main.ui.handoff.exports (:require - [rumext.alpha :as mf] - [beicon.core :as rx] - [app.util.i18n :refer [t] :as i18n] - [app.common.geom.shapes :as gsh] - [app.main.ui.icons :as i] [app.common.data :as d] - [app.util.dom :as dom] - [app.main.store :as st] [app.main.data.messages :as dm] - [app.main.ui.workspace.sidebar.options.menus.exports :as we])) + [app.main.store :as st] + [app.main.ui.icons :as i] + [app.main.ui.workspace.sidebar.options.menus.exports :as we] + [app.util.dom :as dom] + [app.util.i18n :refer [tr]] + [beicon.core :as rx] + [rumext.alpha :as mf])) (mf/defc exports [{:keys [shape page-id file-id] :as props}] - (let [locale (mf/deref i18n/locale) - exports (mf/use-state (:exports shape [])) + (let [exports (mf/use-state (:exports shape [])) loading? (mf/use-state false) on-download @@ -35,7 +33,7 @@ (js/console.log status body) (if (= status 200) (dom/trigger-download (:name shape) body) - (st/emit! (dm/error (t locale "errors.unexpected-error"))))) + (st/emit! (dm/error (tr "errors.unexpected-error"))))) (constantly nil) (fn [] (swap! loading? not)))))) @@ -90,7 +88,7 @@ [:div.element-set.exports-options [:div.element-set-title - [:span (t locale "workspace.options.export")] + [:span (tr "workspace.options.export")] [:div.add-page {:on-click add-export} i/close]] (when (seq @exports) @@ -124,6 +122,6 @@ :class (dom/classnames :btn-disabled @loading?) :disabled @loading?} (if @loading? - (t locale "workspace.options.exporting-object") - (t locale "workspace.options.export-object"))]])])) + (tr "workspace.options.exporting-object") + (tr "workspace.options.export-object"))]])])) diff --git a/frontend/src/app/main/ui/handoff/left_sidebar.cljs b/frontend/src/app/main/ui/handoff/left_sidebar.cljs index e378a4d5b1..12d4ea0318 100644 --- a/frontend/src/app/main/ui/handoff/left_sidebar.cljs +++ b/frontend/src/app/main/ui/handoff/left_sidebar.cljs @@ -7,11 +7,10 @@ (ns app.main.ui.handoff.left-sidebar (:require [app.common.data :as d] - [app.common.uuid :as uuid] [app.main.data.viewer :as dv] [app.main.store :as st] [app.main.ui.icons :as i] - [app.main.ui.workspace.sidebar.layers :refer [element-icon layer-name frame-wrapper]] + [app.main.ui.workspace.sidebar.layers :refer [element-icon layer-name]] [app.util.dom :as dom] [app.util.keyboard :as kbd] [okulary.core :as l] @@ -29,7 +28,7 @@ (l/derived st/state))) (mf/defc layer-item - [{:keys [index item selected objects disable-collapse?] :as props}] + [{:keys [item selected objects disable-collapse?] :as props}] (let [id (:id item) selected? (contains? selected id) item-ref (mf/use-ref nil) diff --git a/frontend/src/app/main/ui/handoff/render.cljs b/frontend/src/app/main/ui/handoff/render.cljs index 6d28af9066..d4d8a89e4e 100644 --- a/frontend/src/app/main/ui/handoff/render.cljs +++ b/frontend/src/app/main/ui/handoff/render.cljs @@ -7,50 +7,46 @@ (ns app.main.ui.handoff.render "The main container for a frame in handoff mode" (:require - [rumext.alpha :as mf] - [app.util.object :as obj] - [app.util.dom :as dom] [app.common.data :as d] - [app.common.pages :as cp] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as geom] - [app.main.refs :as refs] - [app.main.store :as st] + [app.common.pages :as cp] [app.main.data.viewer :as dv] - [app.main.ui.shapes.filters :as filters] + [app.main.store :as st] + [app.main.ui.handoff.selection-feedback :refer [selection-feedback]] [app.main.ui.shapes.circle :as circle] [app.main.ui.shapes.frame :as frame] [app.main.ui.shapes.group :as group] - [app.main.ui.shapes.svg-raw :as svg-raw] [app.main.ui.shapes.image :as image] [app.main.ui.shapes.path :as path] [app.main.ui.shapes.rect :as rect] + [app.main.ui.shapes.shape :refer [shape-container]] + [app.main.ui.shapes.svg-raw :as svg-raw] [app.main.ui.shapes.text :as text] - [app.main.ui.handoff.selection-feedback :refer [selection-feedback]] - [app.main.ui.shapes.shape :refer [shape-container]])) + [app.util.dom :as dom] + [app.util.object :as obj] + [rumext.alpha :as mf])) (declare shape-container-factory) (defn handle-hover-shape [{:keys [type id]} hover?] #(when-not (#{:group :frame} type) - (do - (dom/prevent-default %) - (dom/stop-propagation %) - (st/emit! (dv/hover-shape id hover?))))) + (dom/prevent-default %) + (dom/stop-propagation %) + (st/emit! (dv/hover-shape id hover?)))) (defn select-shape [{:keys [type id]}] (fn [event] (when-not (#{:group :frame} type) - (do - (dom/stop-propagation event) - (dom/prevent-default event) - (cond - (.-shiftKey event) - (st/emit! (dv/toggle-selection id)) + (dom/stop-propagation event) + (dom/prevent-default event) + (cond + (.-shiftKey event) + (st/emit! (dv/toggle-selection id)) - :else - (st/emit! (dv/select-shape id))))))) + :else + (st/emit! (dv/select-shape id)))))) (defn shape-wrapper-factory [component] @@ -114,8 +110,8 @@ (defn svg-raw-container-factory [objects] (let [shape-container (shape-container-factory objects) - svg-raw-shape (svg-raw/svg-raw-shape shape-container) - svg-raw-wrapper (shape-wrapper-factory svg-raw-shape)] + svg-raw-shape (svg-raw/svg-raw-shape shape-container) + svg-raw-wrapper (shape-wrapper-factory svg-raw-shape)] (mf/fnc group-container {::mf/wrap-props false} [props] @@ -127,7 +123,7 @@ [:> svg-raw-wrapper props])))) (defn shape-container-factory - [objects show-interactions?] + [objects] (let [path-wrapper (shape-wrapper-factory path/path-shape) text-wrapper (shape-wrapper-factory text/text-shape) rect-wrapper (shape-wrapper-factory rect/rect-shape) diff --git a/frontend/src/app/main/ui/handoff/right_sidebar.cljs b/frontend/src/app/main/ui/handoff/right_sidebar.cljs index 5773417523..390aeaf421 100644 --- a/frontend/src/app/main/ui/handoff/right_sidebar.cljs +++ b/frontend/src/app/main/ui/handoff/right_sidebar.cljs @@ -6,16 +6,16 @@ (ns app.main.ui.handoff.right-sidebar (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [app.util.i18n :refer [t] :as i18n] [app.common.data :as d] [app.main.store :as st] - [app.main.ui.icons :as i] [app.main.ui.components.tab-container :refer [tab-container tab-element]] - [app.main.ui.workspace.sidebar.layers :refer [element-icon]] [app.main.ui.handoff.attributes :refer [attributes]] - [app.main.ui.handoff.code :refer [code]])) + [app.main.ui.handoff.code :refer [code]] + [app.main.ui.icons :as i] + [app.main.ui.workspace.sidebar.layers :refer [element-icon]] + [app.util.i18n :refer [t] :as i18n] + [okulary.core :as l] + [rumext.alpha :as mf])) (defn make-selected-shapes-iref [] diff --git a/frontend/src/app/main/ui/handoff/selection_feedback.cljs b/frontend/src/app/main/ui/handoff/selection_feedback.cljs index ccfd218243..70df269238 100644 --- a/frontend/src/app/main/ui/handoff/selection_feedback.cljs +++ b/frontend/src/app/main/ui/handoff/selection_feedback.cljs @@ -6,15 +6,11 @@ (ns app.main.ui.handoff.selection-feedback (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [okulary.core :as l] - [app.common.data :as d] - [app.common.math :as mth] [app.common.geom.shapes :as gsh] - [app.common.geom.point :as gpt] [app.main.store :as st] - [app.main.ui.measurements :refer [selection-guides size-display measurement]])) + [app.main.ui.measurements :refer [selection-guides size-display measurement]] + [okulary.core :as l] + [rumext.alpha :as mf])) ;; ------------------------------------------------ ;; CONSTANTS @@ -67,7 +63,7 @@ ;; COMPONENTS ;; ------------------------------------------------ -(mf/defc selection-rect [{:keys [frame selrect zoom]}] +(mf/defc selection-rect [{:keys [selrect zoom]}] (let [{:keys [x y width height]} selrect selection-rect-width (/ selection-rect-width zoom)] [:g.selection-rect diff --git a/frontend/src/app/main/ui/hooks.cljs b/frontend/src/app/main/ui/hooks.cljs index 830906bc17..257b3b2393 100644 --- a/frontend/src/app/main/ui/hooks.cljs +++ b/frontend/src/app/main/ui/hooks.cljs @@ -7,20 +7,14 @@ (ns app.main.ui.hooks "A collection of general purpose react hooks." (:require - [app.common.spec :as us] [app.main.data.shortcuts :as dsc] [app.main.store :as st] [app.util.dom :as dom] [app.util.dom.dnd :as dnd] [app.util.logging :as log] - [app.util.object :as obj] [app.util.timers :as ts] - [app.util.webapi :as wapi] [beicon.core :as rx] - [cljs.spec.alpha :as s] - [goog.events :as events] - [rumext.alpha :as mf]) - (:import goog.events.EventType)) + [rumext.alpha :as mf])) (log/set-level! :warn) @@ -98,10 +92,7 @@ cleanup (fn [] - ;; (js/console.log "cleanup" (:name data)) - (when-let [subscr (:subscr @state)] - ;; (js/console.log "unsubscribing" (:name data)) - (rx/unsub! (:subscr @state))) + (some-> (:subscr @state) rx/unsub!) (swap! state (fn [state] (-> state (cancel-timer) @@ -118,9 +109,8 @@ (fn [event] (if disabled (dom/prevent-default event) - (let [target (dom/get-target event)] + (do (dom/stop-propagation event) - ;; (dnd/trace event data "drag-start") (dnd/set-data! event data-type data) (dnd/set-drag-image! event (invisible-image)) (dnd/set-allowed-effect! event "move") @@ -237,7 +227,7 @@ [] (try (not js/window) - (catch :default e + (catch :default _e ;; When exception accessing window we're in ssr true))) diff --git a/frontend/src/app/main/ui/icons.cljs b/frontend/src/app/main/ui/icons.cljs index e577e082be..b4b4cd7126 100644 --- a/frontend/src/app/main/ui/icons.cljs +++ b/frontend/src/app/main/ui/icons.cljs @@ -5,7 +5,7 @@ ;; Copyright (c) UXBOX Labs SL (ns app.main.ui.icons - (:refer-clojure :exclude [import]) + (:refer-clojure :exclude [import mask]) (:require-macros [app.main.ui.icons :refer [icon-xref]]) (:require [rumext.alpha :as mf])) @@ -163,7 +163,7 @@ (mf/defc debug-icons-preview {::mf/wrap-props false} - [props] + [] [:section.debug-icons-preview (for [[key val] (sort-by first (ns-publics 'app.main.ui.icons))] (when (not= key 'debug-icons-preview) diff --git a/frontend/src/app/main/ui/loader.cljs b/frontend/src/app/main/ui/loader.cljs index 503d59be1e..bd5500b18c 100644 --- a/frontend/src/app/main/ui/loader.cljs +++ b/frontend/src/app/main/ui/loader.cljs @@ -6,9 +6,9 @@ (ns app.main.ui.loader (:require - [rumext.alpha :as mf] + [app.main.store :as st] [app.main.ui.icons :as i] - [app.main.store :as st])) + [rumext.alpha :as mf])) ;; --- Component diff --git a/frontend/src/app/main/ui/measurements.cljs b/frontend/src/app/main/ui/measurements.cljs index 3cdb0faff7..4fc319c1f1 100644 --- a/frontend/src/app/main/ui/measurements.cljs +++ b/frontend/src/app/main/ui/measurements.cljs @@ -11,9 +11,7 @@ [app.common.geom.shapes :as gsh] [app.common.math :as mth] [app.common.uuid :as uuid] - [app.main.store :as st] [cuerdas.core :as str] - [okulary.core :as l] [rumext.alpha :as mf])) ;; ------------------------------------------------ @@ -82,10 +80,10 @@ (and (neg? ss) (> ss se))) (conj [ from-s (+ from-s ss) ]) - (or (and (neg? se) (<= ss se))) + (and (neg? se) (<= ss se)) (conj [ from-s (+ from-s se) ]) - (or (and (pos? es) (<= es ee))) + (and (pos? es) (<= es ee)) (conj [ from-e (+ from-e es) ]) (or (and (pos? ee) (neg? es)) @@ -97,7 +95,7 @@ ;; COMPONENTS ;; ------------------------------------------------ -(mf/defc size-display [{:keys [type selrect zoom]}] +(mf/defc size-display [{:keys [selrect zoom]}] (let [{:keys [x y width height]} selrect size-label (str/fmt "%s x %s" (mth/round width) (mth/round height)) @@ -127,7 +125,6 @@ (mf/defc distance-display-pill [{:keys [x y zoom distance bounds]}] (let [distance-pill-width (/ distance-pill-width zoom) distance-pill-height (/ distance-pill-height zoom) - distance-line-stroke (/ distance-line-stroke zoom) font-size (/ font-size zoom) text-padding (/ 3 zoom) distance-border-radius (/ distance-border-radius zoom) @@ -169,7 +166,7 @@ :font-size font-size}} distance]])) -(mf/defc selection-rect [{:keys [frame selrect zoom]}] +(mf/defc selection-rect [{:keys [selrect zoom]}] (let [{:keys [x y width height]} selrect selection-rect-width (/ selection-rect-width zoom)] [:g.selection-rect @@ -181,7 +178,7 @@ :stroke hover-color :stroke-width selection-rect-width}}]])) -(mf/defc distance-display [{:keys [type from to zoom frame bounds]}] +(mf/defc distance-display [{:keys [from to zoom bounds]}] (let [fixed-x (if (gsh/fully-contained? from to) (+ (:x to) (/ (:width to) 2)) (+ (:x from) (/ (:width from) 2))) diff --git a/frontend/src/app/main/ui/messages.cljs b/frontend/src/app/main/ui/messages.cljs index 70aecb9b2b..aff6c6f81e 100644 --- a/frontend/src/app/main/ui/messages.cljs +++ b/frontend/src/app/main/ui/messages.cljs @@ -6,7 +6,6 @@ (ns app.main.ui.messages (:require - [app.common.spec :as us] [app.common.uuid :as uuid] [app.main.data.messages :as dm] [app.main.refs :as refs] diff --git a/frontend/src/app/main/ui/modal.cljs b/frontend/src/app/main/ui/modal.cljs index 0e462130e1..b07e3dd57f 100644 --- a/frontend/src/app/main/ui/modal.cljs +++ b/frontend/src/app/main/ui/modal.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.modal (:require [app.main.data.modal :as dm] - [app.main.refs :as refs] [app.main.store :as st] [app.util.dom :as dom] [app.util.keyboard :as k] @@ -19,8 +18,8 @@ (defn- on-esc-clicked [event allow-click-outside] (when (and (k/esc? event) (not allow-click-outside)) - (do (dom/stop-propagation event) - (st/emit! (dm/hide))))) + (dom/stop-propagation event) + (st/emit! (dm/hide)))) (defn- on-pop-state [event] @@ -29,16 +28,6 @@ (st/emit! (dm/hide)) (.forward js/history)) -(defn- on-parent-clicked - [event parent-ref] - (let [parent (mf/ref-val parent-ref) - current (dom/get-target event)] - (when (and (dom/equals? (.-firstElementChild ^js parent) current) - (= (.-className ^js current) "modal-overlay")) - (dom/stop-propagation event) - (dom/prevent-default event) - (st/emit! (dm/hide))))) - (defn- on-click-outside [event wrapper-ref type allow-click-outside] (let [wrapper (mf/ref-val wrapper-ref) diff --git a/frontend/src/app/main/ui/onboarding.cljs b/frontend/src/app/main/ui/onboarding.cljs index 3079151450..9d520a7f15 100644 --- a/frontend/src/app/main/ui/onboarding.cljs +++ b/frontend/src/app/main/ui/onboarding.cljs @@ -6,18 +6,18 @@ (ns app.main.ui.onboarding (:require - [app.config :as cf] [app.common.spec :as us] + [app.config :as cf] [app.main.data.dashboard :as dd] [app.main.data.messages :as dm] [app.main.data.modal :as modal] [app.main.data.users :as du] [app.main.store :as st] - [app.main.ui.components.forms :as fm :refer [input submit-button form]] + [app.main.ui.components.forms :as fm] [app.util.dom :as dom] + [app.util.object :as obj] [app.util.router :as rt] [app.util.timers :as tm] - [app.util.object :as obj] [cljs.spec.alpha :as s] [rumext.alpha :as mf])) @@ -186,24 +186,24 @@ (mf/defc onboarding-team-modal {::mf/register modal/components ::mf/register-as :onboarding-team} - [props] + [] (let [close (mf/use-fn (st/emitf (modal/hide))) form (fm/use-form :spec ::team-form :initial {}) on-success (mf/use-callback - (fn [form response] + (fn [_form response] (st/emit! (modal/hide) (rt/nav :dashboard-projects {:team-id (:id response)})))) on-error (mf/use-callback - (fn [form response] + (fn [_form _response] (st/emit! (dm/error "Error on creating team.")))) on-submit (mf/use-callback - (fn [form event] + (fn [form _event] (let [mdata {:on-success (partial on-success form) :on-error (partial on-error form)} params {:name (get-in @form [:clean-data :name])}] diff --git a/frontend/src/app/main/ui/render.cljs b/frontend/src/app/main/ui/render.cljs index 628a8ddb1b..cb09796fc2 100644 --- a/frontend/src/app/main/ui/render.cljs +++ b/frontend/src/app/main/ui/render.cljs @@ -9,7 +9,6 @@ [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] - [app.common.math :as mth] [app.common.pages :as cp] [app.common.uuid :as uuid] [app.main.data.fonts :as df] @@ -20,7 +19,6 @@ [app.main.ui.shapes.filters :as filters] [app.main.ui.shapes.shape :refer [shape-container]] [beicon.core :as rx] - [cljs.spec.alpha :as s] [cuerdas.core :as str] [rumext.alpha :as mf])) @@ -44,8 +42,6 @@ objects (reduce updt-fn objects mod-ids) object (get objects object-id) - {:keys [width height]} (gsh/points->selrect (:points object)) - ;; We need to get the shadows/blurs paddings to create the viewbox properly {:keys [x y width height]} (filters/get-filters-bounds object) @@ -115,7 +111,7 @@ (repo/query! :font-variants {:file-id file-id}) (repo/query! :file {:id file-id})) (rx/subs - (fn [[fonts {:keys [data]} :as kaka]] + (fn [[fonts {:keys [data]}]] (when (seq fonts) (st/emit! (df/fonts-fetched fonts))) (let [objs (get-in data [:pages-index page-id :objects]) diff --git a/frontend/src/app/main/ui/settings.cljs b/frontend/src/app/main/ui/settings.cljs index 7ca893dfef..7c9cd788ff 100644 --- a/frontend/src/app/main/ui/settings.cljs +++ b/frontend/src/app/main/ui/settings.cljs @@ -7,14 +7,13 @@ (ns app.main.ui.settings (:require [app.main.refs :as refs] - [app.main.store :as st] - [app.main.ui.settings.options :refer [options-page]] + [app.main.ui.settings.change-email] + [app.main.ui.settings.delete-account] [app.main.ui.settings.feedback :refer [feedback-page]] + [app.main.ui.settings.options :refer [options-page]] [app.main.ui.settings.password :refer [password-page]] [app.main.ui.settings.profile :refer [profile-page]] [app.main.ui.settings.sidebar :refer [sidebar]] - [app.main.ui.settings.change-email] - [app.main.ui.settings.delete-account] [app.util.i18n :as i18n :refer [tr]] [rumext.alpha :as mf])) diff --git a/frontend/src/app/main/ui/settings/change_email.cljs b/frontend/src/app/main/ui/settings/change_email.cljs index 46726c87fb..5ea32034f3 100644 --- a/frontend/src/app/main/ui/settings/change_email.cljs +++ b/frontend/src/app/main/ui/settings/change_email.cljs @@ -15,10 +15,9 @@ [app.main.ui.components.forms :as fm] [app.main.ui.icons :as i] [app.main.ui.messages :as msgs] - [app.util.i18n :as i18n :refer [tr t]] + [app.util.i18n :as i18n :refer [tr]] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [rumext.alpha :as mf])) (s/def ::email-1 ::us/email) @@ -63,7 +62,7 @@ (modal/hide))))) (defn- on-submit - [form event] + [form _event] (let [params {:email (get-in @form [:clean-data :email-1])} mdata {:on-error (partial on-error form) :on-success (partial on-success form)}] @@ -73,8 +72,7 @@ {::mf/register modal/components ::mf/register-as :change-email} [] - (let [locale (mf/deref i18n/locale) - profile (mf/deref refs/profile) + (let [profile (mf/deref refs/profile) form (fm/use-form :spec ::email-change-form :validators [email-equality] :initial profile) @@ -88,30 +86,30 @@ [:div.modal-header [:div.modal-header-title - [:h2 (t locale "modals.change-email.title")]] + [:h2 (tr "modals.change-email.title")]] [:div.modal-close-button {:on-click on-close} i/close]] [:div.modal-content [:& msgs/inline-banner {:type :info - :content (t locale "modals.change-email.info" (:email profile))}] + :content (tr "modals.change-email.info" (:email profile))}] [:div.fields-row [:& fm/input {:type "text" :name :email-1 - :label (t locale "modals.change-email.new-email") + :label (tr "modals.change-email.new-email") :trim true}]] [:div.fields-row [:& fm/input {:type "text" :name :email-2 - :label (t locale "modals.change-email.confirm-email") + :label (tr "modals.change-email.confirm-email") :trim true}]]] [:div.modal-footer [:div.action-buttons [:& fm/submit-button - {:label (t locale "modals.change-email.submit")}]]]]]])) + {:label (tr "modals.change-email.submit")}]]]]]])) diff --git a/frontend/src/app/main/ui/settings/delete_account.cljs b/frontend/src/app/main/ui/settings/delete_account.cljs index f26881ddb5..f4e7262192 100644 --- a/frontend/src/app/main/ui/settings/delete_account.cljs +++ b/frontend/src/app/main/ui/settings/delete_account.cljs @@ -13,9 +13,7 @@ [app.main.ui.icons :as i] [app.main.ui.messages :as msgs] [app.util.i18n :as i18n :refer [tr]] - [app.util.router :as rt] [beicon.core :as rx] - [cljs.spec.alpha :as s] [rumext.alpha :as mf])) (defn on-error @@ -28,7 +26,7 @@ (mf/defc delete-account-modal {::mf/register modal/components ::mf/register-as :delete-account} - [props] + [] (let [on-close (mf/use-callback (st/emitf (modal/hide))) diff --git a/frontend/src/app/main/ui/settings/options.cljs b/frontend/src/app/main/ui/settings/options.cljs index 0b7bfb597f..e3b3aed6b4 100644 --- a/frontend/src/app/main/ui/settings/options.cljs +++ b/frontend/src/app/main/ui/settings/options.cljs @@ -13,7 +13,6 @@ [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.components.forms :as fm] - [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [t tr]] [cljs.spec.alpha :as s] @@ -26,11 +25,11 @@ (s/keys :opt-un [::lang ::theme])) (defn- on-success - [form] + [_] (st/emit! (dm/success (tr "notifications.profile-saved")))) (defn- on-submit - [form event] + [form _event] (let [data (:clean-data @form) data (cond-> data (empty? (:lang data)) diff --git a/frontend/src/app/main/ui/settings/password.cljs b/frontend/src/app/main/ui/settings/password.cljs index 6b63fc4d83..f0b6a32230 100644 --- a/frontend/src/app/main/ui/settings/password.cljs +++ b/frontend/src/app/main/ui/settings/password.cljs @@ -11,7 +11,6 @@ [app.main.data.users :as udu] [app.main.store :as st] [app.main.ui.components.forms :as fm] - [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [t tr]] [cljs.spec.alpha :as s] @@ -29,7 +28,7 @@ (st/emit! (dm/error msg))))) (defn- on-success - [form] + [_] (let [msg (tr "dashboard.notifications.password-saved")] (st/emit! (dm/success msg)))) diff --git a/frontend/src/app/main/ui/settings/profile.cljs b/frontend/src/app/main/ui/settings/profile.cljs index 03a6ddda28..eded1e265e 100644 --- a/frontend/src/app/main/ui/settings/profile.cljs +++ b/frontend/src/app/main/ui/settings/profile.cljs @@ -6,8 +6,8 @@ (ns app.main.ui.settings.profile (:require - [app.config :as cfg] [app.common.spec :as us] + [app.config :as cfg] [app.main.data.messages :as dm] [app.main.data.modal :as modal] [app.main.data.users :as du] @@ -16,13 +16,10 @@ [app.main.ui.components.file-uploader :refer [file-uploader]] [app.main.ui.components.forms :as fm] [app.main.ui.icons :as i] - [app.main.ui.messages :as msgs] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr t]] [cljs.spec.alpha :as s] - [cuerdas.core :as str] - [rumext.alpha :as mf] - [app.config :as cfg])) + [rumext.alpha :as mf])) (s/def ::fullname ::us/not-empty-string) (s/def ::email ::us/email) @@ -31,11 +28,11 @@ (s/keys :req-un [::fullname ::email])) (defn- on-success - [form] + [_] (st/emit! (dm/success (tr "notifications.profile-saved")))) (defn- on-submit - [form event] + [form _event] (let [data (:clean-data @form) mdata {:on-success (partial on-success form)}] (st/emit! (du/update-profile (with-meta data mdata))))) diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index a70dd66b94..dcb26a3695 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -6,12 +6,11 @@ (ns app.main.ui.shapes.attrs (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [app.common.data :as d] - [app.util.object :as obj] [app.main.ui.context :as muc] - [app.util.svg :as usvg])) + [app.util.object :as obj] + [app.util.svg :as usvg] + [cuerdas.core :as str] + [rumext.alpha :as mf])) (defn- stroke-type->dasharray [style] diff --git a/frontend/src/app/main/ui/shapes/circle.cljs b/frontend/src/app/main/ui/shapes/circle.cljs index da19c2003e..74a4084fbd 100644 --- a/frontend/src/app/main/ui/shapes/circle.cljs +++ b/frontend/src/app/main/ui/shapes/circle.cljs @@ -6,17 +6,17 @@ (ns app.main.ui.shapes.circle (:require - [rumext.alpha :as mf] + [app.common.geom.shapes :as geom] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]] - [app.common.geom.shapes :as geom] - [app.util.object :as obj])) + [app.util.object :as obj] + [rumext.alpha :as mf])) (mf/defc circle-shape {::mf/wrap-props false} [props] (let [shape (unchecked-get props "shape") - {:keys [id x y width height]} shape + {:keys [x y width height]} shape transform (geom/transform-matrix shape) cx (+ x (/ width 2)) diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index 0fa42483c7..741494946c 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -7,8 +7,6 @@ (ns app.main.ui.shapes.custom-stroke (:require [app.common.data :as d] - [app.common.geom.shapes :as geom] - [app.common.uuid :as uuid] [app.main.ui.context :as muc] [app.util.object :as obj] [cuerdas.core :as str] @@ -26,7 +24,7 @@ (-> props (obj/merge #js {:style style})))) (mf/defc inner-stroke-clip-path - [{:keys [shape render-id]}] + [{:keys [render-id]}] (let [clip-id (str "inner-stroke-" render-id) shape-id (str "stroke-shape-" render-id)] [:> "clipPath" #js {:id clip-id} @@ -70,8 +68,6 @@ child (obj/get props "children") base-props (obj/get child "props") elem-name (obj/get child "type") - shape (obj/get props "shape") - stroke-width (:stroke-width shape 0) stroke-mask-id (str "outer-stroke-" render-id) shape-id (str "stroke-shape-" render-id) @@ -148,8 +144,8 @@ stroke-width (:stroke-width shape 0) stroke-style (:stroke-style shape :none) stroke-position (:stroke-alignment shape :center) - has-stroke? (and (and (> stroke-width 0) - (not= stroke-style :none))) + has-stroke? (and (> stroke-width 0) + (not= stroke-style :none)) inner? (= :inner stroke-position) outer? (= :outer stroke-position)] diff --git a/frontend/src/app/main/ui/shapes/export.cljs b/frontend/src/app/main/ui/shapes/export.cljs index a74740040c..c7d60b3c2d 100644 --- a/frontend/src/app/main/ui/shapes/export.cljs +++ b/frontend/src/app/main/ui/shapes/export.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.shapes.export (:require [app.common.data :as d] - [app.common.geom.matrix :as gmt] [app.common.geom.shapes :as gsh] [app.util.json :as json] [app.util.object :as obj] @@ -47,8 +46,7 @@ (cond-> props (some? val) (obj/set! ns-attr (trfn val))))))] - (let [frame? (= :frame (:type shape)) - group? (= :group (:type shape)) + (let [group? (= :group (:type shape)) rect? (= :rect (:type shape)) text? (= :text (:type shape)) mask? (and group? (:masked-group? shape)) @@ -175,6 +173,6 @@ (when (and (= (:type shape) :frame) - (not (empty? (:grids shape)))) + (seq (:grids shape))) [:& export-grid-data {:grids (:grids shape)}])])) diff --git a/frontend/src/app/main/ui/shapes/filters.cljs b/frontend/src/app/main/ui/shapes/filters.cljs index 838d7e421b..c2664d695c 100644 --- a/frontend/src/app/main/ui/shapes/filters.cljs +++ b/frontend/src/app/main/ui/shapes/filters.cljs @@ -84,7 +84,7 @@ :result filter-id}]])) (mf/defc background-blur-filter - [{:keys [filter-id filter-in params]}] + [{:keys [filter-id params]}] [:* [:feGaussianBlur {:in "BackgroundImage" :stdDeviation (/ (:value params) 2)}] diff --git a/frontend/src/app/main/ui/shapes/frame.cljs b/frontend/src/app/main/ui/shapes/frame.cljs index bf48f0f378..aa1930e779 100644 --- a/frontend/src/app/main/ui/shapes/frame.cljs +++ b/frontend/src/app/main/ui/shapes/frame.cljs @@ -6,7 +6,6 @@ (ns app.main.ui.shapes.frame (:require - [app.common.data :as d] [app.main.ui.shapes.attrs :as attrs] [app.util.object :as obj] [rumext.alpha :as mf])) @@ -20,7 +19,7 @@ [props] (let [childs (unchecked-get props "childs") shape (unchecked-get props "shape") - {:keys [id width height]} shape + {:keys [width height]} shape props (-> (merge frame-default-props shape) (attrs/extract-style-attrs) @@ -32,7 +31,7 @@ :className "frame-background"}))] [:* [:> :rect props] - (for [[i item] (d/enumerate childs)] + (for [item childs] [:& shape-wrapper {:frame shape :shape item :key (:id item)}])]))) diff --git a/frontend/src/app/main/ui/shapes/gradients.cljs b/frontend/src/app/main/ui/shapes/gradients.cljs index 4cee1d330d..51a34a84fe 100644 --- a/frontend/src/app/main/ui/shapes/gradients.cljs +++ b/frontend/src/app/main/ui/shapes/gradients.cljs @@ -6,18 +6,15 @@ (ns app.main.ui.shapes.gradients (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [app.util.object :as obj] - [app.common.uuid :as uuid] - [app.main.ui.context :as muc] - [app.common.geom.point :as gpt] [app.common.geom.matrix :as gmt] - [app.common.geom.shapes :as gsh])) + [app.common.geom.point :as gpt] + [app.common.geom.shapes :as gsh] + [app.main.ui.context :as muc] + [app.util.object :as obj] + [rumext.alpha :as mf])) (mf/defc linear-gradient [{:keys [id gradient shape]}] - (let [{:keys [x y width height]} (:selrect shape) - transform (when (= :path (:type shape)) (gsh/transform-matrix shape nil (gpt/point 0.5 0.5)))] + (let [transform (when (= :path (:type shape)) (gsh/transform-matrix shape nil (gpt/point 0.5 0.5)))] [:> :linearGradient #js {:id id :x1 (:start-x gradient) :y1 (:start-y gradient) @@ -43,49 +40,46 @@ (mf/defc radial-gradient [{:keys [id gradient shape]}] (let [{:keys [x y width height]} (:selrect shape) - center (gsh/center-shape shape) transform (if (= :path (:type shape)) (gsh/transform-matrix shape) - (gmt/matrix))] - (let [[x y] (if (= (:type shape) :frame) [0 0] [x y]) - translate-vec (gpt/point (+ x (* width (:start-x gradient))) - (+ y (* height (:start-y gradient)))) + (gmt/matrix)) + [x y] (if (= (:type shape) :frame) [0 0] [x y]) + translate-vec (gpt/point (+ x (* width (:start-x gradient))) + (+ y (* height (:start-y gradient)))) - gradient-vec (gpt/to-vec (gpt/point (* width (:start-x gradient)) - (* height (:start-y gradient))) - (gpt/point (* width (:end-x gradient)) - (* height (:end-y gradient)))) + gradient-vec (gpt/to-vec (gpt/point (* width (:start-x gradient)) + (* height (:start-y gradient))) + (gpt/point (* width (:end-x gradient)) + (* height (:end-y gradient)))) - angle (gpt/angle gradient-vec - (gpt/point 1 0)) + angle (gpt/angle gradient-vec + (gpt/point 1 0)) - shape-height-vec (gpt/point 0 (/ height 2)) + scale-factor-y (/ (gpt/length gradient-vec) (/ height 2)) + scale-factor-x (* scale-factor-y (:width gradient)) - scale-factor-y (/ (gpt/length gradient-vec) (/ height 2)) - scale-factor-x (* scale-factor-y (:width gradient)) + scale-vec (gpt/point (* scale-factor-y (/ height 2)) + (* scale-factor-x (/ width 2))) - scale-vec (gpt/point (* scale-factor-y (/ height 2)) - (* scale-factor-x (/ width 2))) + transform (gmt/multiply transform + (gmt/translate-matrix translate-vec) + (gmt/rotate-matrix angle) + (gmt/scale-matrix scale-vec)) - transform (gmt/multiply transform - (gmt/translate-matrix translate-vec) - (gmt/rotate-matrix angle) - (gmt/scale-matrix scale-vec)) + base-props #js {:id id + :cx 0 + :cy 0 + :r 1 + :gradientUnits "userSpaceOnUse" + :gradientTransform transform} - base-props #js {:id id - :cx 0 - :cy 0 - :r 1 - :gradientUnits "userSpaceOnUse" - :gradientTransform transform} - - props (-> base-props (add-metadata gradient))] - [:> :radialGradient props - (for [{:keys [offset color opacity]} (:stops gradient)] - [:stop {:key (str id "-stop-" offset) - :offset (or offset 0) - :stop-color color - :stop-opacity opacity}])]))) + props (-> base-props (add-metadata gradient))] + [:> :radialGradient props + (for [{:keys [offset color opacity]} (:stops gradient)] + [:stop {:key (str id "-stop-" offset) + :offset (or offset 0) + :stop-color color + :stop-opacity opacity}])])) (mf/defc gradient {::mf/wrap-props false} diff --git a/frontend/src/app/main/ui/shapes/group.cljs b/frontend/src/app/main/ui/shapes/group.cljs index 9dc4ea0e9f..84d8d54a64 100644 --- a/frontend/src/app/main/ui/shapes/group.cljs +++ b/frontend/src/app/main/ui/shapes/group.cljs @@ -6,10 +6,9 @@ (ns app.main.ui.shapes.group (:require + [app.main.ui.shapes.mask :refer [mask-str clip-str mask-factory]] [app.util.object :as obj] - [rumext.alpha :as mf] - [app.main.ui.shapes.attrs :as attrs] - [app.main.ui.shapes.mask :refer [mask-str clip-str mask-factory]])) + [rumext.alpha :as mf])) (defn group-shape [shape-wrapper] @@ -20,9 +19,8 @@ (let [frame (unchecked-get props "frame") shape (unchecked-get props "shape") childs (unchecked-get props "childs") - pointer-events (unchecked-get props "pointer-events") - {:keys [id x y width height masked-group?]} shape + masked-group? (:masked-group? shape) [mask childs] (if masked-group? [(first childs) (rest childs)] diff --git a/frontend/src/app/main/ui/shapes/image.cljs b/frontend/src/app/main/ui/shapes/image.cljs index 16f9a84d78..5fa4eec47a 100644 --- a/frontend/src/app/main/ui/shapes/image.cljs +++ b/frontend/src/app/main/ui/shapes/image.cljs @@ -7,39 +7,38 @@ (ns app.main.ui.shapes.image (:require [app.common.geom.shapes :as geom] + [app.config :as cfg] [app.main.ui.shapes.attrs :as attrs] - [app.main.ui.shapes.embed :as se] + [app.main.ui.shapes.embed :as embed] [app.util.dom :as dom] [app.util.object :as obj] - [rumext.alpha :as mf] - [app.config :as cfg] - [app.main.ui.shapes.embed :as embed])) + [rumext.alpha :as mf])) (mf/defc image-shape {::mf/wrap-props false} [props] (let [shape (unchecked-get props "shape") - {:keys [id x y width height rotation metadata]} shape - uri (cfg/resolve-file-media metadata) - embed (embed/use-data-uris [uri])] + {:keys [x y width height metadata]} shape + uri (cfg/resolve-file-media metadata) + embed (embed/use-data-uris [uri]) - (let [transform (geom/transform-matrix shape) - props (-> (attrs/extract-style-attrs shape) - (obj/merge! - #js {:x x - :y y - :transform transform - :width width - :height height - :preserveAspectRatio "none" - :data-loading (str (not (contains? embed uri)))})) + transform (geom/transform-matrix shape) + props (-> (attrs/extract-style-attrs shape) + (obj/merge! + #js {:x x + :y y + :transform transform + :width width + :height height + :preserveAspectRatio "none" + :data-loading (str (not (contains? embed uri)))})) - on-drag-start (fn [event] - ;; Prevent browser dragging of the image - (dom/prevent-default event))] + on-drag-start (fn [event] + ;; Prevent browser dragging of the image + (dom/prevent-default event))] - [:> "image" (obj/merge! - props - #js {:xlinkHref (get embed uri uri) - :onDragStart on-drag-start})]))) + [:> "image" (obj/merge! + props + #js {:xlinkHref (get embed uri uri) + :onDragStart on-drag-start})])) diff --git a/frontend/src/app/main/ui/shapes/mask.cljs b/frontend/src/app/main/ui/shapes/mask.cljs index c48f9c9c43..093ec72016 100644 --- a/frontend/src/app/main/ui/shapes/mask.cljs +++ b/frontend/src/app/main/ui/shapes/mask.cljs @@ -6,9 +6,9 @@ (ns app.main.ui.shapes.mask (:require - [rumext.alpha :as mf] + [app.common.geom.shapes :as gsh] [cuerdas.core :as str] - [app.common.geom.shapes :as gsh])) + [rumext.alpha :as mf])) (defn mask-str [mask] (str/fmt "url(#%s)" (str (:id mask) "-mask"))) diff --git a/frontend/src/app/main/ui/shapes/path.cljs b/frontend/src/app/main/ui/shapes/path.cljs index 9726803051..8c2decdc6f 100644 --- a/frontend/src/app/main/ui/shapes/path.cljs +++ b/frontend/src/app/main/ui/shapes/path.cljs @@ -6,26 +6,23 @@ (ns app.main.ui.shapes.path (:require - [cuerdas.core :as str] - [rumext.alpha :as mf] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]] [app.util.object :as obj] - [app.util.path.format :as upf])) + [app.util.path.format :as upf] + [rumext.alpha :as mf])) ;; --- Path Shape (mf/defc path-shape {::mf/wrap-props false} [props] - (let [shape (unchecked-get props "shape") - background? (unchecked-get props "background?") - {:keys [id x y width height]} (:selrect shape) + (let [shape (unchecked-get props "shape") content (:content shape) - pdata (mf/use-memo (mf/deps content) #(upf/format-path content)) - props (-> (attrs/extract-style-attrs shape) - (obj/merge! - #js {:d pdata}))] + pdata (mf/use-memo (mf/deps content) #(upf/format-path content)) + props (-> (attrs/extract-style-attrs shape) + (obj/merge! + #js {:d pdata}))] [:& shape-custom-stroke {:shape shape} [:> :path props]])) diff --git a/frontend/src/app/main/ui/shapes/rect.cljs b/frontend/src/app/main/ui/shapes/rect.cljs index bb0ccd60a8..a995f51ccb 100644 --- a/frontend/src/app/main/ui/shapes/rect.cljs +++ b/frontend/src/app/main/ui/shapes/rect.cljs @@ -9,7 +9,6 @@ [app.common.geom.shapes :as gsh] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]] - [app.main.ui.shapes.gradients :refer [gradient]] [app.util.object :as obj] [rumext.alpha :as mf])) @@ -17,7 +16,7 @@ {::mf/wrap-props false} [props] (let [shape (unchecked-get props "shape") - {:keys [id x y width height]} shape + {:keys [x y width height]} shape transform (gsh/transform-matrix shape) props (-> (attrs/extract-style-attrs shape) diff --git a/frontend/src/app/main/ui/shapes/svg_defs.cljs b/frontend/src/app/main/ui/shapes/svg_defs.cljs index 4002be4568..ac04f57f70 100644 --- a/frontend/src/app/main/ui/shapes/svg_defs.cljs +++ b/frontend/src/app/main/ui/shapes/svg_defs.cljs @@ -100,7 +100,8 @@ (cond->> id (contains? svg-defs id) (str render-id "-")))] - (when (and svg-defs (not (empty? svg-defs))) + ;; TODO: no key? + (when (seq svg-defs) (for [svg-def (vals svg-defs)] [:& svg-node {:node svg-def :prefix-id prefix-id diff --git a/frontend/src/app/main/ui/shapes/svg_raw.cljs b/frontend/src/app/main/ui/shapes/svg_raw.cljs index 01c9841041..407f5096d0 100644 --- a/frontend/src/app/main/ui/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/shapes/svg_raw.cljs @@ -6,15 +6,10 @@ (ns app.main.ui.shapes.svg-raw (:require - [app.common.data :as cd] - [app.common.geom.matrix :as gmt] - [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.main.ui.shapes.attrs :as usa] - [app.util.data :as ud] [app.util.object :as obj] [app.util.svg :as usvg] - [cuerdas.core :as str] [rumext.alpha :as mf])) ;; Graphic tags @@ -53,7 +48,7 @@ children (unchecked-get props "children") {:keys [x y width height]} shape - {:keys [tag attrs] :as content} (:content shape) + {:keys [attrs] :as content} (:content shape) ids-mapping (mf/use-memo #(usvg/generate-id-mapping content)) @@ -85,9 +80,7 @@ element-id (get-in content [:attrs :id]) attrs (cond-> (set-styles attrs shape) (and element-id (contains? ids-mapping element-id)) - (obj/set! "id" (get ids-mapping element-id))) - - {:keys [x y width height]} (:selrect shape)] + (obj/set! "id" (get ids-mapping element-id)))] [:> (name tag) attrs children])) (defn svg-raw-shape [shape-wrapper] diff --git a/frontend/src/app/main/ui/shapes/text.cljs b/frontend/src/app/main/ui/shapes/text.cljs index 48a5162400..b6e037dd01 100644 --- a/frontend/src/app/main/ui/shapes/text.cljs +++ b/frontend/src/app/main/ui/shapes/text.cljs @@ -8,12 +8,9 @@ (:require [app.common.data :as d] [app.common.geom.shapes :as geom] - [app.main.ui.context :as muc] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.text.styles :as sts] - [app.util.color :as uc] [app.util.object :as obj] - [cuerdas.core :as str] [rumext.alpha :as mf])) (mf/defc render-text @@ -40,8 +37,7 @@ (mf/defc render-paragraph-set {::mf/wrap-props false} [props] - (let [node (obj/get props "node") - children (obj/get props "children") + (let [children (obj/get props "children") shape (obj/get props "shape") style (sts/generate-paragraph-set-styles shape)] [:div.paragraph-set {:style style} children])) diff --git a/frontend/src/app/main/ui/shapes/text/fontfaces.cljs b/frontend/src/app/main/ui/shapes/text/fontfaces.cljs index e00a6919c6..e75f0407b2 100644 --- a/frontend/src/app/main/ui/shapes/text/fontfaces.cljs +++ b/frontend/src/app/main/ui/shapes/text/fontfaces.cljs @@ -46,7 +46,7 @@ #(rx/dispose! sub)))) (mf/ref-val fonts-css-ref))) - + (mf/defc fontfaces-style {::mf/wrap-props false ::mf/wrap [#(mf/memo' % (mf/check-props ["shapes"]))]} @@ -74,6 +74,6 @@ ;; Creates a style tag by replacing the urls with the data uri style (replace-embeds fonts-css fonts-urls fonts-embed)] - - (when (and (some? style) (not (empty? style))) + + (when (seq style) [:style style]))) diff --git a/frontend/src/app/main/ui/shapes/text/styles.cljs b/frontend/src/app/main/ui/shapes/text/styles.cljs index 8c15ccb43c..9d247e13fd 100644 --- a/frontend/src/app/main/ui/shapes/text/styles.cljs +++ b/frontend/src/app/main/ui/shapes/text/styles.cljs @@ -15,7 +15,7 @@ (defn generate-root-styles [shape node] - (let [valign (or (:vertical-align node "top")) + (let [valign (:vertical-align node "top") base #js {:height (or (:height shape) "100%") :width (or (:width shape) "100%")}] (cond-> base @@ -104,18 +104,18 @@ (when (and (string? font-id) (pos? (alength font-id))) (fonts/ensure-loaded! font-id) - (let [font (get fontsdb font-id)] - (let [font-family (str/quote - (or (:family font) - (:font-family data))) - font-variant (d/seek #(= font-variant-id (:id %)) - (:variants font)) - font-style (or (:style font-variant) - (:font-style data)) - font-weight (or (:weight font-variant) - (:font-weight data))] - (obj/set! base "fontFamily" font-family) - (obj/set! base "fontStyle" font-style) - (obj/set! base "fontWeight" font-weight)))) + (let [font (get fontsdb font-id) + font-family (str/quote + (or (:family font) + (:font-family data))) + font-variant (d/seek #(= font-variant-id (:id %)) + (:variants font)) + font-style (or (:style font-variant) + (:font-style data)) + font-weight (or (:weight font-variant) + (:font-weight data))] + (obj/set! base "fontFamily" font-family) + (obj/set! base "fontStyle" font-style) + (obj/set! base "fontWeight" font-weight))) base)) diff --git a/frontend/src/app/main/ui/static.cljs b/frontend/src/app/main/ui/static.cljs index 0cd9c0b5a8..aec0d11bc1 100644 --- a/frontend/src/app/main/ui/static.cljs +++ b/frontend/src/app/main/ui/static.cljs @@ -10,12 +10,9 @@ [app.main.data.users :as du] [app.main.refs :as refs] [app.main.store :as st] - [app.main.ui.context :as ctx] [app.main.ui.icons :as i] [app.util.i18n :refer [tr]] [app.util.router :as rt] - [cljs.spec.alpha :as s] - [cuerdas.core :as str] [rumext.alpha :as mf])) (defn- go-to-dashboard @@ -24,7 +21,7 @@ (st/emit! (rt/nav :dashboard-projects {:team-id team-id})))) (mf/defc not-found - [{:keys [error] :as props}] + [] (let [profile (mf/deref refs/profile)] [:section.exception-layout [:div.exception-header @@ -42,7 +39,7 @@ (tr "labels.sign-out")]]]]])) (mf/defc bad-gateway - [{:keys [error] :as props}] + [] (let [profile (mf/deref refs/profile)] [:section.exception-layout [:div.exception-header @@ -59,7 +56,7 @@ (tr "labels.retry")]]]]])) (mf/defc service-unavailable - [{:keys [error] :as props}] + [] (let [profile (mf/deref refs/profile)] [:section.exception-layout [:div.exception-header @@ -76,7 +73,7 @@ (tr "labels.retry")]]]]])) (mf/defc internal-error - [props] + [] (let [profile (mf/deref refs/profile)] [:section.exception-layout [:div.exception-header diff --git a/frontend/src/app/main/ui/viewer.cljs b/frontend/src/app/main/ui/viewer.cljs index a5f330b7d8..7f6e493a10 100644 --- a/frontend/src/app/main/ui/viewer.cljs +++ b/frontend/src/app/main/ui/viewer.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.viewer (:require [app.common.data :as d] - [app.common.exceptions :as ex] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as geom] @@ -19,9 +18,8 @@ [app.main.store :as st] [app.main.ui.comments :as cmt] [app.main.ui.hooks :as hooks] - [app.main.ui.icons :as i] [app.main.ui.viewer.header :refer [header]] - [app.main.ui.viewer.shapes :as shapes :refer [frame-svg]] + [app.main.ui.viewer.shapes :as shapes] [app.main.ui.viewer.thumbnails :refer [thumbnails-panel]] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [t tr]] @@ -44,7 +42,7 @@ (l/derived :comments-local st/state)) (mf/defc comments-layer - [{:keys [width height zoom frame data] :as props}] + [{:keys [zoom frame data] :as props}] (let [profile (mf/deref refs/profile) modifier1 (-> (gpt/point (:x frame) (:y frame)) @@ -62,7 +60,7 @@ mframe (geom/transform-shape frame) threads (->> (vals threads-map) (dcm/apply-filters cstate profile) - (filter (fn [{:keys [seqn position]}] + (filter (fn [{:keys [position]}] (frame-contains? mframe position)))) on-bubble-click @@ -127,7 +125,7 @@ (mf/defc viewport {::mf/wrap [mf/memo]} - [{:keys [state data index section] :or {zoom 1} :as props}] + [{:keys [state data index section] :as props}] (let [zoom (:zoom state) objects (:objects data) diff --git a/frontend/src/app/main/ui/viewer/shapes.cljs b/frontend/src/app/main/ui/viewer/shapes.cljs index 54dde52d74..39d90d175c 100644 --- a/frontend/src/app/main/ui/viewer/shapes.cljs +++ b/frontend/src/app/main/ui/viewer/shapes.cljs @@ -13,10 +13,8 @@ [app.common.geom.shapes :as geom] [app.common.pages :as cp] [app.main.data.viewer :as dv] - [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.shapes.circle :as circle] - [app.main.ui.shapes.filters :as filters] [app.main.ui.shapes.frame :as frame] [app.main.ui.shapes.group :as group] [app.main.ui.shapes.image :as image] @@ -62,13 +60,10 @@ (mf/fnc generic-wrapper {::mf/wrap-props false} [props] - (let [shape (unchecked-get props "shape") + (let [shape (unchecked-get props "shape") objects (unchecked-get props "objects") - {:keys [x y width height]} (:selrect shape) - frame? (= :frame (:type shape)) - - childs (unchecked-get props "childs") - frame (unchecked-get props "frame") + childs (unchecked-get props "childs") + frame (unchecked-get props "frame") interactions (->> (:interactions shape) (filter #(contains? objects (:destination %)))) diff --git a/frontend/src/app/main/ui/viewer/thumbnails.cljs b/frontend/src/app/main/ui/viewer/thumbnails.cljs index 66bf403b0b..9c1d09e7ca 100644 --- a/frontend/src/app/main/ui/viewer/thumbnails.cljs +++ b/frontend/src/app/main/ui/viewer/thumbnails.cljs @@ -6,25 +6,16 @@ (ns app.main.ui.viewer.thumbnails (:require - [goog.events :as events] - [goog.object :as gobj] - [rumext.alpha :as mf] - [app.main.ui.icons :as i] [app.common.data :as d] - [app.main.store :as st] [app.main.data.viewer :as dv] - [app.main.ui.components.dropdown :refer [dropdown']] - [app.main.ui.shapes.frame :as frame] [app.main.exports :as exports] + [app.main.store :as st] + [app.main.ui.components.dropdown :refer [dropdown']] + [app.main.ui.icons :as i] [app.util.data :refer [classnames]] - [app.util.dom :as dom] - [app.common.geom.matrix :as gmt] - [app.common.geom.point :as gpt] - [app.util.i18n :as i18n :refer [t tr]] - [app.common.math :as mth] - [app.util.router :as rt] - [app.main.data.viewer :as vd]) - (:import goog.events.EventType)) + [app.util.i18n :as i18n :refer [tr]] + [goog.object :as gobj] + [rumext.alpha :as mf])) (mf/defc thumbnails-content [{:keys [children expanded? total] :as props}] @@ -35,14 +26,14 @@ offset (mf/use-state 0) on-left-arrow-click - (fn [event] + (fn [_] (swap! offset (fn [v] (if (pos? v) (dec v) v)))) on-right-arrow-click - (fn [event] + (fn [_] (let [visible (/ @width @element-width) max-val (- total visible)] (swap! offset (fn [v] @@ -90,26 +81,25 @@ [:span.name {:title (:name frame)} (:name frame)]]]) (mf/defc thumbnails-panel - [{:keys [data index screen] :as props}] + [{:keys [data index] :as props}] (let [expanded? (mf/use-state false) container (mf/use-ref) - page-id (get-in data [:page :id]) - file-id (get-in data [:file :id]) on-close #(st/emit! dv/toggle-thumbnails-panel) selected (mf/use-var false) on-mouse-leave - (fn [event] + (fn [_] (when @selected (on-close))) on-item-click - (fn [event index] + (fn [_ index] (compare-and-set! selected false true) (st/emit! (dv/go-to-frame-by-index index)) (when @expanded? (on-close)))] + [:& dropdown' {:on-close on-close :container container :show true} diff --git a/frontend/src/app/main/ui/workspace.cljs b/frontend/src/app/main/ui/workspace.cljs index 34877fdaa2..2086412dfb 100644 --- a/frontend/src/app/main/ui/workspace.cljs +++ b/frontend/src/app/main/ui/workspace.cljs @@ -97,7 +97,7 @@ (when page-id (st/emit! (dw/finalize-page page-id)))))) - (when-let [page (mf/deref trimmed-page-ref)] + (when (mf/deref trimmed-page-ref) [:& workspace-content {:key page-id :file file :layout layout}])) diff --git a/frontend/src/app/main/ui/workspace/colorpalette.cljs b/frontend/src/app/main/ui/workspace/colorpalette.cljs index f4495ccb3c..e4bbf6d37a 100644 --- a/frontend/src/app/main/ui/workspace/colorpalette.cljs +++ b/frontend/src/app/main/ui/workspace/colorpalette.cljs @@ -7,14 +7,12 @@ (ns app.main.ui.workspace.colorpalette (:require [app.common.math :as mth] - [app.main.data.workspace :as udw] [app.main.data.workspace.colors :as mdc] [app.main.data.workspace.state-helpers :as wsh] [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.components.color-bullet :as cb] [app.main.ui.components.dropdown :refer [dropdown]] - [app.main.ui.context :as ctx] [app.main.ui.icons :as i] [app.util.color :as uc] [app.util.i18n :refer [tr]] @@ -39,14 +37,9 @@ (-> (l/in [:workspace-local :selected-palette-size]) (l/derived st/state))) -(defn- make-selected-palette-item-ref - [lib-id] - (-> (l/in [:library-items :palettes lib-id]) - (l/derived st/state))) - ;; --- Components (mf/defc palette-item - [{:keys [color size local?]}] + [{:keys [color size]}] (let [select-color (fn [event] (let [ids (wsh/lookup-selected @st/state)] @@ -70,13 +63,12 @@ max-offset (- (count current-colors) visible) - close-fn #(st/emit! (udw/toggle-layout-flags :colorpalette)) container (mf/use-ref nil) on-left-arrow-click (mf/use-callback (mf/deps max-offset visible) - (fn [event] + (fn [_] (swap! state update :offset (fn [offset] (if (pos? offset) @@ -86,7 +78,7 @@ on-right-arrow-click (mf/use-callback (mf/deps max-offset visible) - (fn [event] + (fn [_] (swap! state update :offset (fn [offset] (if (< offset max-offset) @@ -104,7 +96,7 @@ on-resize (mf/use-callback - (fn [event] + (fn [_] (let [dom (mf/ref-val container) width (obj/get dom "clientWidth")] (swap! state assoc :width width))))] @@ -132,7 +124,7 @@ (when (= selected (:id cur-library)) i/tick) [:div.library-name (str (:name cur-library) " " (str/format "(%s)" (count colors)))] [:div.color-sample - (for [[idx {:keys [id color]}] (map-indexed vector (take 7 colors))] + (for [[idx {:keys [color]}] (map-indexed vector (take 7 colors))] [:& cb/color-bullet {:key (str "color-" idx) :color color}])]])) @@ -193,8 +185,7 @@ (mf/defc colorpalette [] - (let [team-id (mf/use-ctx ctx/current-team-id) - recent-colors (mf/deref refs/workspace-recent-colors) + (let [recent-colors (mf/deref refs/workspace-recent-colors) file-colors (mf/deref refs/workspace-file-colors) shared-libs (mf/deref refs/workspace-libraries) selected (or (mf/deref selected-palette-ref) :recent) diff --git a/frontend/src/app/main/ui/workspace/colorpicker.cljs b/frontend/src/app/main/ui/workspace/colorpicker.cljs index 993c1cdc83..96f338b59d 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker.cljs @@ -6,28 +6,24 @@ (ns app.main.ui.workspace.colorpicker (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [cuerdas.core :as str] - [app.common.geom.point :as gpt] - [app.common.math :as math] - [app.common.uuid :refer [uuid]] - [app.util.dom :as dom] - [app.util.color :as uc] - [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] - [app.main.data.workspace.colors :as dc] [app.main.data.modal :as modal] + [app.main.data.workspace.colors :as dc] + [app.main.data.workspace.libraries :as dwl] + [app.main.refs :as refs] + [app.main.store :as st] [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]] + [app.main.ui.workspace.colorpicker.color-inputs :refer [color-inputs]] [app.main.ui.workspace.colorpicker.gradients :refer [gradients]] [app.main.ui.workspace.colorpicker.harmony :refer [harmony-selector]] [app.main.ui.workspace.colorpicker.hsva :refer [hsva-selector]] + [app.main.ui.workspace.colorpicker.libraries :refer [libraries]] [app.main.ui.workspace.colorpicker.ramp :refer [ramp-selector]] - [app.main.ui.workspace.colorpicker.color-inputs :refer [color-inputs]] - [app.main.ui.workspace.colorpicker.libraries :refer [libraries]])) + [app.util.color :as uc] + [app.util.dom :as dom] + [app.util.i18n :as i18n :refer [t]] + [cuerdas.core :as str] + [okulary.core :as l] + [rumext.alpha :as mf])) ;; --- Refs @@ -127,7 +123,6 @@ picking-color? (mf/deref picking-color?) picked-color (mf/deref picked-color) picked-color-select (mf/deref picked-color-select) - picked-shift? (mf/deref picked-shift?) editing-spot-state (mf/deref editing-spot-state-ref) current-gradient (mf/deref current-gradient-ref) @@ -156,11 +151,11 @@ handle-change-stop (fn [offset] (when-let [offset-color (get-in @state [:stops offset])] - (do (swap! state assoc - :current-color offset-color - :editing-stop offset) + (swap! state assoc + :current-color offset-color + :editing-stop offset) - (st/emit! (dc/select-gradient-stop offset))))) + (st/emit! (dc/select-gradient-stop offset)))) on-select-library-color (fn [color] @@ -172,7 +167,7 @@ (on-change color))))) on-add-library-color - (fn [color] + (fn [_] (st/emit! (dwl/add-color (state->data @state)))) on-activate-gradient @@ -197,7 +192,7 @@ (mf/use-effect (mf/deps current-color) (fn [] (let [node (mf/ref-val ref-picker) - {:keys [r g b h s v]} current-color + {:keys [r g b h v]} current-color rgb [r g b] hue-rgb (uc/hsv->rgb [h 1.0 255]) hsl-from (uc/hsv->hsl [h 0.0 v]) @@ -248,9 +243,8 @@ :end-x :end-y :width])] (when (not= (:gradient-data @state) gradient-data) - (do - (reset! dirty? true) - (swap! state assoc :gradient-data gradient-data))))))) + (reset! dirty? true) + (swap! state assoc :gradient-data gradient-data)))))) ;; Check if we've opened a color with gradient (mf/use-effect @@ -265,7 +259,7 @@ (mf/use-effect (mf/deps @state) (fn [] - (if @dirty? + (when @dirty? (let [color (state->data @state)] (reset! dirty? false) (reset! last-color color) @@ -357,7 +351,7 @@ (mf/defc colorpicker-modal {::mf/register modal/components ::mf/register-as :colorpicker} - [{:keys [x y default data page position + [{:keys [x y data position disable-gradient disable-opacity on-change on-close on-accept] :as props}] @@ -367,7 +361,7 @@ position (or position :left) style (calculate-position vport position x y) - handle-change (fn [new-data shift-clicked?] + handle-change (fn [new-data _shift-clicked?] (reset! dirty? (not= data new-data)) (reset! last-change new-data) (when on-change diff --git a/frontend/src/app/main/ui/workspace/colorpicker/color_inputs.cljs b/frontend/src/app/main/ui/workspace/colorpicker/color_inputs.cljs index 08a0ddd2db..ed86777bdf 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/color_inputs.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/color_inputs.cljs @@ -6,22 +6,10 @@ (ns app.main.ui.workspace.colorpicker.color-inputs (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [cuerdas.core :as str] - [app.common.geom.point :as gpt] [app.common.math :as math] - [app.common.uuid :refer [uuid]] - [app.util.dom :as dom] [app.util.color :as uc] - [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] - [app.main.data.workspace.colors :as dc] - [app.main.data.modal :as modal] - [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]])) + [app.util.dom :as dom] + [rumext.alpha :as mf])) (mf/defc color-inputs [{:keys [type color disable-opacity on-change]}] (let [{red :r green :g blue :b diff --git a/frontend/src/app/main/ui/workspace/colorpicker/gradients.cljs b/frontend/src/app/main/ui/workspace/colorpicker/gradients.cljs index 447bfbbe79..56c3ef0509 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/gradients.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/gradients.cljs @@ -6,22 +6,8 @@ (ns app.main.ui.workspace.colorpicker.gradients (:require - [rumext.alpha :as mf] - [okulary.core :as l] [cuerdas.core :as str] - [app.common.geom.point :as gpt] - [app.common.math :as math] - [app.common.uuid :refer [uuid]] - [app.util.dom :as dom] - [app.util.color :as uc] - [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] - [app.main.data.workspace.colors :as dc] - [app.main.data.modal :as modal] - [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]])) + [rumext.alpha :as mf])) (defn gradient->string [stops] (let [format-stop diff --git a/frontend/src/app/main/ui/workspace/colorpicker/harmony.cljs b/frontend/src/app/main/ui/workspace/colorpicker/harmony.cljs index d9b9f57a23..d4a2e17726 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/harmony.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/harmony.cljs @@ -6,24 +6,14 @@ (ns app.main.ui.workspace.colorpicker.harmony (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [cuerdas.core :as str] [app.common.geom.point :as gpt] [app.common.math :as math] - [app.common.uuid :refer [uuid]] - [app.util.dom :as dom] + [app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]] [app.util.color :as uc] + [app.util.dom :as dom] [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] - [app.main.data.workspace.colors :as dc] - [app.main.data.modal :as modal] - [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]] - [app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]])) - + [cuerdas.core :as str] + [rumext.alpha :as mf])) (defn create-color-wheel [canvas-node] @@ -100,7 +90,7 @@ (on-change {:hex hex :r r :g g :b b :v new-value}))) - on-complement-click (fn [ev] + on-complement-click (fn [_] (let [new-hue (mod (+ hue 180) 360) hex (uc/hsv->hex [new-hue saturation value]) [r g b] (uc/hex->rgb hex)] diff --git a/frontend/src/app/main/ui/workspace/colorpicker/hsva.cljs b/frontend/src/app/main/ui/workspace/colorpicker/hsva.cljs index 0e5e9b8bb6..e9523cf09c 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/hsva.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/hsva.cljs @@ -6,23 +6,9 @@ (ns app.main.ui.workspace.colorpicker.hsva (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [cuerdas.core :as str] - [app.common.geom.point :as gpt] - [app.common.math :as math] - [app.common.uuid :refer [uuid]] - [app.util.dom :as dom] + [app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]] [app.util.color :as uc] - [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] - [app.main.data.workspace.colors :as dc] - [app.main.data.modal :as modal] - [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]] - [app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]])) + [rumext.alpha :as mf])) (mf/defc hsva-selector [{:keys [color disable-opacity on-change]}] (let [{hue :h saturation :s value :v alpha :alpha} color diff --git a/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs b/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs index c866a08e1c..a305e8fed4 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs @@ -6,42 +6,29 @@ (ns app.main.ui.workspace.colorpicker.libraries (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [cuerdas.core :as str] - [app.common.geom.point :as gpt] - [app.common.math :as math] [app.common.uuid :refer [uuid]] - [app.util.dom :as dom] - [app.util.color :as uc] - [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.colors :as dc] - [app.main.data.modal :as modal] - [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]] + [app.main.refs :as refs] + [app.main.store :as st] [app.main.ui.components.color-bullet :refer [color-bullet]] - [app.main.ui.workspace.colorpicker.gradients :refer [gradients]] - [app.main.ui.workspace.colorpicker.harmony :refer [harmony-selector]] - [app.main.ui.workspace.colorpicker.hsva :refer [hsva-selector]] - [app.main.ui.workspace.colorpicker.ramp :refer [ramp-selector]] - [app.main.ui.workspace.colorpicker.color-inputs :refer [color-inputs]])) + [app.main.ui.icons :as i] + [app.util.dom :as dom] + [app.util.i18n :as i18n :refer [tr]] + [okulary.core :as l] + [rumext.alpha :as mf])) (def selected-palette-ref (-> (l/in [:workspace-local :selected-palette-colorpicker]) (l/derived st/state))) -(mf/defc libraries [{:keys [current-color on-select-color on-add-library-color - disable-gradient disable-opacity]}] +(mf/defc libraries + [{:keys [on-select-color on-add-library-color disable-gradient disable-opacity]}] (let [selected-library (or (mf/deref selected-palette-ref) :recent) current-library-colors (mf/use-state []) shared-libs (mf/deref refs/workspace-libraries) file-colors (mf/deref refs/workspace-file-colors) recent-colors (mf/deref refs/workspace-recent-colors) - locale (mf/deref i18n/locale) parse-selected (fn [selected-str] @@ -85,8 +72,8 @@ (when-let [val (parse-selected (dom/get-target-val e))] (st/emit! (dc/change-palette-selected-colorpicker val)))) :value (name selected-library)} - [:option {:value "recent"} (t locale "workspace.libraries.colors.recent-colors")] - [:option {:value "file"} (t locale "workspace.libraries.colors.file-library")] + [:option {:value "recent"} (tr "workspace.libraries.colors.recent-colors")] + [:option {:value "file"} (tr "workspace.libraries.colors.file-library")] (for [[_ {:keys [name id]}] shared-libs] [:option {:key id diff --git a/frontend/src/app/main/ui/workspace/colorpicker/ramp.cljs b/frontend/src/app/main/ui/workspace/colorpicker/ramp.cljs index 23bb4f4133..ea79bbd3cf 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/ramp.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/ramp.cljs @@ -6,26 +6,14 @@ (ns app.main.ui.workspace.colorpicker.ramp (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [cuerdas.core :as str] - [app.common.geom.point :as gpt] [app.common.math :as math] - [app.common.uuid :refer [uuid]] - [app.util.dom :as dom] - [app.util.color :as uc] - [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] - [app.main.data.workspace.colors :as dc] - [app.main.data.modal :as modal] - [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]] [app.main.ui.components.color-bullet :refer [color-bullet]] - [app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]])) + [app.main.ui.workspace.colorpicker.slider-selector :refer [slider-selector]] + [app.util.color :as uc] + [app.util.dom :as dom] + [rumext.alpha :as mf])) -(mf/defc value-saturation-selector [{:keys [hue saturation value on-change]}] +(mf/defc value-saturation-selector [{:keys [saturation value on-change]}] (let [dragging? (mf/use-state false) calculate-pos (fn [ev] diff --git a/frontend/src/app/main/ui/workspace/colorpicker/slider_selector.cljs b/frontend/src/app/main/ui/workspace/colorpicker/slider_selector.cljs index 0c3a8e1da1..e0e630e437 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/slider_selector.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/slider_selector.cljs @@ -6,22 +6,10 @@ (ns app.main.ui.workspace.colorpicker.slider-selector (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [cuerdas.core :as str] - [app.common.geom.point :as gpt] [app.common.math :as math] - [app.common.uuid :refer [uuid]] [app.util.dom :as dom] - [app.util.color :as uc] [app.util.object :as obj] - [app.main.store :as st] - [app.main.refs :as refs] - [app.main.data.workspace.libraries :as dwl] - [app.main.data.workspace.colors :as dc] - [app.main.data.modal :as modal] - [app.main.ui.icons :as i] - [app.util.i18n :as i18n :refer [t]])) + [rumext.alpha :as mf])) (mf/defc slider-selector [{:keys [value class min-value max-value vertical? reverse? on-change]}] diff --git a/frontend/src/app/main/ui/workspace/comments.cljs b/frontend/src/app/main/ui/workspace/comments.cljs index da126962e0..7084739318 100644 --- a/frontend/src/app/main/ui/workspace/comments.cljs +++ b/frontend/src/app/main/ui/workspace/comments.cljs @@ -16,7 +16,7 @@ [app.main.ui.context :as ctx] [app.main.ui.icons :as i] [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t tr]] + [app.util.i18n :as i18n :refer [tr]] [app.util.timers :as tm] [rumext.alpha :as mf])) @@ -25,10 +25,8 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (mf/defc sidebar-options - [{:keys [local] :as props}] + [] (let [{cmode :mode cshow :show} (mf/deref refs/comments-local) - locale (mf/deref i18n/locale) - update-mode (mf/use-callback (fn [mode] @@ -43,19 +41,19 @@ [:li {:class (dom/classnames :selected (or (= :all cmode) (nil? cmode))) :on-click #(update-mode :all)} [:span.icon i/tick] - [:span.label (t locale "labels.show-all-comments")]] + [:span.label (tr "labels.show-all-comments")]] [:li {:class (dom/classnames :selected (= :yours cmode)) :on-click #(update-mode :yours)} [:span.icon i/tick] - [:span.label (t locale "labels.show-your-comments")]] + [:span.label (tr "labels.show-your-comments")]] [:hr] [:li {:class (dom/classnames :selected (= :pending cshow)) :on-click #(update-show (if (= :pending cshow) :all :pending))} [:span.icon i/tick] - [:span.label (t locale "labels.hide-resolved-comments")]]])) + [:span.label (tr "labels.hide-resolved-comments")]]])) (mf/defc comments-sidebar [] @@ -109,7 +107,7 @@ :on-thread-click on-thread-click :users users :key (:page-id tgroup)}]])] - + [:div.thread-groups-placeholder i/chat (tr "labels.no-comments-available")])])) diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 5720cd50b9..e493bb5fc5 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -9,23 +9,17 @@ (:require [app.main.data.modal :as modal] [app.main.data.workspace :as dw] - [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.shortcuts :as sc] + [app.main.data.workspace.undo :as dwu] [app.main.refs :as refs] [app.main.store :as st] - [app.main.streams :as ms] [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.context :as ctx] - [app.main.ui.hooks :refer [use-rxsub]] - [app.main.ui.icons :as i] [app.util.dom :as dom] - [app.util.i18n :refer [t] :as i18n] + [app.util.i18n :refer [tr] :as i18n] [app.util.timers :as timers] - [beicon.core :as rx] [okulary.core :as l] - [potok.core :as ptk] [rumext.alpha :as mf])) (def menu-ref @@ -43,13 +37,12 @@ [:span.shortcut (or shortcut "")]]) (mf/defc menu-separator - [props] + [] [:li.separator]) (mf/defc shape-context-menu [{:keys [mdata] :as props}] - (let [locale (mf/deref i18n/locale) - {:keys [id] :as shape} (:shape mdata) + (let [{:keys [id] :as shape} (:shape mdata) selected (:selected mdata) single? (= (count selected) 1) @@ -97,91 +90,91 @@ do-update-remote-component (st/emitf (modal/show {:type :confirm :message "" - :title (t locale "modals.update-remote-component.message") - :hint (t locale "modals.update-remote-component.hint") - :cancel-label (t locale "modals.update-remote-component.cancel") - :accept-label (t locale "modals.update-remote-component.accept") + :title (tr "modals.update-remote-component.message") + :hint (tr "modals.update-remote-component.hint") + :cancel-label (tr "modals.update-remote-component.cancel") + :accept-label (tr "modals.update-remote-component.accept") :accept-style :primary :on-accept confirm-update-remote-component})) do-show-component (st/emitf (dw/go-to-layout :assets)) do-navigate-component-file (st/emitf (dwl/nav-to-component-file (:component-file shape)))] [:* - [:& menu-entry {:title (t locale "workspace.shape.menu.copy") + [:& menu-entry {:title (tr "workspace.shape.menu.copy") :shortcut (sc/get-tooltip :copy) :on-click do-copy}] - [:& menu-entry {:title (t locale "workspace.shape.menu.cut") + [:& menu-entry {:title (tr "workspace.shape.menu.cut") :shortcut (sc/get-tooltip :cut) :on-click do-cut}] - [:& menu-entry {:title (t locale "workspace.shape.menu.paste") + [:& menu-entry {:title (tr "workspace.shape.menu.paste") :shortcut (sc/get-tooltip :paste) :on-click do-paste}] - [:& menu-entry {:title (t locale "workspace.shape.menu.duplicate") + [:& menu-entry {:title (tr "workspace.shape.menu.duplicate") :shortcut (sc/get-tooltip :duplicate) :on-click do-duplicate}] [:& menu-separator] - [:& menu-entry {:title (t locale "workspace.shape.menu.forward") + [:& menu-entry {:title (tr "workspace.shape.menu.forward") :shortcut (sc/get-tooltip :bring-forward) :on-click do-bring-forward}] - [:& menu-entry {:title (t locale "workspace.shape.menu.front") + [:& menu-entry {:title (tr "workspace.shape.menu.front") :shortcut (sc/get-tooltip :bring-front) :on-click do-bring-to-front}] - [:& menu-entry {:title (t locale "workspace.shape.menu.backward") + [:& menu-entry {:title (tr "workspace.shape.menu.backward") :shortcut (sc/get-tooltip :bring-backward) :on-click do-send-backward}] - [:& menu-entry {:title (t locale "workspace.shape.menu.back") + [:& menu-entry {:title (tr "workspace.shape.menu.back") :shortcut (sc/get-tooltip :bring-back) :on-click do-send-to-back}] [:& menu-separator] (when multiple? [:* - [:& menu-entry {:title (t locale "workspace.shape.menu.group") + [:& menu-entry {:title (tr "workspace.shape.menu.group") :shortcut (sc/get-tooltip :group) :on-click do-create-group}] - [:& menu-entry {:title (t locale "workspace.shape.menu.mask") + [:& menu-entry {:title (tr "workspace.shape.menu.mask") :shortcut (sc/get-tooltip :mask) :on-click do-mask-group}] [:& menu-separator]]) (when (or single? multiple?) [:* - [:& menu-entry {:title (t locale "workspace.shape.menu.flip-vertical") + [:& menu-entry {:title (tr "workspace.shape.menu.flip-vertical") :shortcut (sc/get-tooltip :flip-vertical) :on-click do-flip-vertical}] - [:& menu-entry {:title (t locale "workspace.shape.menu.flip-horizontal") + [:& menu-entry {:title (tr "workspace.shape.menu.flip-horizontal") :shortcut (sc/get-tooltip :flip-horizontal) :on-click do-flip-horizontal}] [:& menu-separator]]) (when (and single? (= (:type shape) :group)) [:* - [:& menu-entry {:title (t locale "workspace.shape.menu.ungroup") + [:& menu-entry {:title (tr "workspace.shape.menu.ungroup") :shortcut (sc/get-tooltip :ungroup) :on-click do-remove-group}] (if (:masked-group? shape) - [:& menu-entry {:title (t locale "workspace.shape.menu.unmask") + [:& menu-entry {:title (tr "workspace.shape.menu.unmask") :shortcut (sc/get-tooltip :unmask) :on-click do-unmask-group}] - [:& menu-entry {:title (t locale "workspace.shape.menu.mask") + [:& menu-entry {:title (tr "workspace.shape.menu.mask") :shortcut (sc/get-tooltip :group) :on-click do-mask-group}])]) (when (and single? editable-shape?) - [:& menu-entry {:title (t locale "workspace.shape.menu.edit") + [:& menu-entry {:title (tr "workspace.shape.menu.edit") :shortcut (sc/get-tooltip :start-editing) :on-click do-start-editing}]) (if (:hidden shape) - [:& menu-entry {:title (t locale "workspace.shape.menu.show") + [:& menu-entry {:title (tr "workspace.shape.menu.show") :on-click do-show-shape}] - [:& menu-entry {:title (t locale "workspace.shape.menu.hide") + [:& menu-entry {:title (tr "workspace.shape.menu.hide") :on-click do-hide-shape}]) (if (:blocked shape) - [:& menu-entry {:title (t locale "workspace.shape.menu.unlock") + [:& menu-entry {:title (tr "workspace.shape.menu.unlock") :on-click do-unlock-shape}] - [:& menu-entry {:title (t locale "workspace.shape.menu.lock") + [:& menu-entry {:title (tr "workspace.shape.menu.lock") :on-click do-lock-shape}]) (when (and (or (nil? (:shape-ref shape)) @@ -189,7 +182,7 @@ (not= (:type shape) :frame)) [:* [:& menu-separator] - [:& menu-entry {:title (t locale "workspace.shape.menu.create-component") + [:& menu-entry {:title (tr "workspace.shape.menu.create-component") :shortcut (sc/get-tooltip :create-component) :on-click do-add-component}]]) @@ -201,41 +194,39 @@ (if (= (:component-file shape) current-file-id) [:* [:& menu-separator] - [:& menu-entry {:title (t locale "workspace.shape.menu.detach-instance") + [:& menu-entry {:title (tr "workspace.shape.menu.detach-instance") :on-click do-detach-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.reset-overrides") + [:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides") :on-click do-reset-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.update-main") + [:& menu-entry {:title (tr "workspace.shape.menu.update-main") :on-click do-update-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.show-main") + [:& menu-entry {:title (tr "workspace.shape.menu.show-main") :on-click do-show-component}]] [:* [:& menu-separator] - [:& menu-entry {:title (t locale "workspace.shape.menu.detach-instance") + [:& menu-entry {:title (tr "workspace.shape.menu.detach-instance") :on-click do-detach-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.reset-overrides") + [:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides") :on-click do-reset-component}] - [:& menu-entry {:title (t locale "workspace.shape.menu.go-main") + [:& menu-entry {:title (tr "workspace.shape.menu.go-main") :on-click do-navigate-component-file}] - [:& menu-entry {:title (t locale "workspace.shape.menu.update-main") + [:& menu-entry {:title (tr "workspace.shape.menu.update-main") :on-click do-update-remote-component}]])) [:& menu-separator] - [:& menu-entry {:title (t locale "workspace.shape.menu.delete") + [:& menu-entry {:title (tr "workspace.shape.menu.delete") :shortcut (sc/get-tooltip :delete) :on-click do-delete}]])) (mf/defc viewport-context-menu - [{:keys [mdata] :as props}] - (let [locale (mf/deref i18n/locale) - do-paste (st/emitf dw/paste)] - [:* - [:& menu-entry {:title (t locale "workspace.shape.menu.paste") - :shortcut (sc/get-tooltip :paste) - :on-click do-paste}]])) + [] + (let [do-paste (st/emitf dw/paste)] + [:& menu-entry {:title (tr "workspace.shape.menu.paste") + :shortcut (sc/get-tooltip :paste) + :on-click do-paste}])) (mf/defc context-menu - [props] + [] (let [mdata (mf/deref menu-ref) top (- (get-in mdata [:position :y]) 20) left (get-in mdata [:position :x]) diff --git a/frontend/src/app/main/ui/workspace/coordinates.cljs b/frontend/src/app/main/ui/workspace/coordinates.cljs index bb8ad3e7f1..a261e9ae92 100644 --- a/frontend/src/app/main/ui/workspace/coordinates.cljs +++ b/frontend/src/app/main/ui/workspace/coordinates.cljs @@ -6,8 +6,8 @@ (ns app.main.ui.workspace.coordinates (:require - [app.main.ui.hooks :as hooks] [app.main.streams :as ms] + [app.main.ui.hooks :as hooks] [rumext.alpha :as mf])) (mf/defc coordinates diff --git a/frontend/src/app/main/ui/workspace/effects.cljs b/frontend/src/app/main/ui/workspace/effects.cljs index b42e1f92ba..12515dc0da 100644 --- a/frontend/src/app/main/ui/workspace/effects.cljs +++ b/frontend/src/app/main/ui/workspace/effects.cljs @@ -68,7 +68,7 @@ (dom/stop-propagation event) (let [toggle-selected? (and selected? shift?) - deselect? (and (not selected?) (not (empty? selected)) (not shift?))] + deselect? (and (not selected?) (seq selected) (not shift?))] (apply st/emit! (cond-> [] diff --git a/frontend/src/app/main/ui/workspace/header.cljs b/frontend/src/app/main/ui/workspace/header.cljs index 9b5d230d82..6eccf64825 100644 --- a/frontend/src/app/main/ui/workspace/header.cljs +++ b/frontend/src/app/main/ui/workspace/header.cljs @@ -11,7 +11,6 @@ [app.main.data.modal :as modal] [app.main.data.workspace :as dw] [app.main.data.workspace.shortcuts :as sc] - [app.main.data.workspace.shortcuts :as sc] [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.components.dropdown :refer [dropdown]] @@ -89,8 +88,6 @@ (let [show-menu? (mf/use-state false) editing? (mf/use-state false) - locale (mf/deref i18n/locale) - edit-input-ref (mf/use-ref nil) add-shared-fn @@ -125,7 +122,7 @@ :on-accept del-shared-fn}))) - handle-blur (fn [event] + handle-blur (fn [_] (let [value (-> edit-input-ref mf/ref-val dom/get-value)] (st/emit! (dw/rename-file (:id file) value))) (reset! editing? false)) @@ -243,9 +240,7 @@ [{:keys [file layout project page-id] :as props}] (let [team-id (:team-id project) zoom (mf/deref refs/selected-zoom) - router (mf/deref refs/router) params {:page-id page-id :file-id (:id file)} - view-url (rt/resolve router :viewer params {:index 0}) go-back (mf/use-callback diff --git a/frontend/src/app/main/ui/workspace/libraries.cljs b/frontend/src/app/main/ui/workspace/libraries.cljs index f78a3aef11..c0766515d6 100644 --- a/frontend/src/app/main/ui/workspace/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/libraries.cljs @@ -7,18 +7,18 @@ (ns app.main.ui.workspace.libraries (:require [app.common.data :as d] - [rumext.alpha :as mf] - [cuerdas.core :as str] - [okulary.core :as l] - [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t tr]] - [app.util.data :refer [classnames matches-search]] - [app.main.store :as st] - [app.main.refs :as refs] + [app.main.data.modal :as modal] [app.main.data.workspace :as dw] [app.main.data.workspace.libraries :as dwl] + [app.main.refs :as refs] + [app.main.store :as st] [app.main.ui.icons :as i] - [app.main.data.modal :as modal])) + [app.util.data :refer [classnames matches-search]] + [app.util.dom :as dom] + [app.util.i18n :as i18n :refer [t tr]] + [cuerdas.core :as str] + [okulary.core :as l] + [rumext.alpha :as mf])) (def workspace-file (l/derived :workspace-file st/state)) @@ -68,7 +68,7 @@ on-search-clear (mf/use-callback - (fn [event] + (fn [_] (reset! search-term ""))) link-library @@ -152,8 +152,7 @@ project (mf/deref refs/workspace-project) file (mf/deref workspace-file) libraries (->> (mf/deref refs/workspace-libraries) - (d/removem (fn [[key val]] - (:is-indirect val)))) + (d/removem (fn [[_ val]] (:is-indirect val)))) shared-files (mf/deref refs/workspace-shared-files) change-tab #(reset! selected-tab %) diff --git a/frontend/src/app/main/ui/workspace/presence.cljs b/frontend/src/app/main/ui/workspace/presence.cljs index 8947bfb009..22138de9d6 100644 --- a/frontend/src/app/main/ui/workspace/presence.cljs +++ b/frontend/src/app/main/ui/workspace/presence.cljs @@ -8,14 +8,12 @@ (:require [app.config :as cfg] [app.main.refs :as refs] - [app.main.store :as st] - [app.util.router :as rt] [rumext.alpha :as mf])) ;; --- SESSION WIDGET (mf/defc session-widget - [{:keys [session self? profile] :as props}] + [{:keys [session profile] :as props}] [:li.tooltip.tooltip-bottom {:alt (:fullname profile)} [:img {:style {:border-color (:color session)} @@ -24,15 +22,13 @@ (mf/defc active-sessions {::mf/wrap [mf/memo]} [] - (let [profile (mf/deref refs/profile) - users (mf/deref refs/users) + (let [users (mf/deref refs/users) presence (mf/deref refs/workspace-presence)] [:ul.active-users (for [session (vals presence)] [:& session-widget {:session session :profile (get users (:profile-id session)) - :self? (= (:profile-id session) (:id profile)) :key (:id session)}])])) diff --git a/frontend/src/app/main/ui/workspace/rules.cljs b/frontend/src/app/main/ui/workspace/rules.cljs index d599a6bacf..d455cf9705 100644 --- a/frontend/src/app/main/ui/workspace/rules.cljs +++ b/frontend/src/app/main/ui/workspace/rules.cljs @@ -6,10 +6,9 @@ (ns app.main.ui.workspace.rules (:require - [rumext.alpha :as mf] [app.common.math :as mth] [app.util.object :as obj] - [app.util.timers :as timers])) + [rumext.alpha :as mf])) (defn- calculate-step-size [zoom] @@ -30,7 +29,7 @@ :else 1)) (defn draw-rule! - [dctx {:keys [zoom size start count type] :or {count 200}}] + [dctx {:keys [zoom size start type]}] (when start (let [txfm (- (* (- 0 start) zoom) 20) step (calculate-step-size zoom) diff --git a/frontend/src/app/main/ui/workspace/shapes/bounding_box.cljs b/frontend/src/app/main/ui/workspace/shapes/bounding_box.cljs index 83e58e5c70..c7d599a2bb 100644 --- a/frontend/src/app/main/ui/workspace/shapes/bounding_box.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/bounding_box.cljs @@ -6,15 +6,11 @@ (ns app.main.ui.workspace.shapes.bounding-box (:require - [cuerdas.core :as str] - [rumext.alpha :as mf] - [app.util.debug :as debug] + ["randomcolor" :as rdcolor] [app.common.geom.shapes :as gsh] - [app.common.geom.matrix :as gmt] - [app.common.geom.point :as gpt] - [app.util.debug :refer [debug?]] [app.main.refs :as refs] - ["randomcolor" :as rdcolor])) + [cuerdas.core :as str] + [rumext.alpha :as mf])) (defn fixed [num] @@ -58,15 +54,11 @@ (mf/defc bounding-box {::mf/wrap-props false} [props] - (let [shape (-> (unchecked-get props "shape")) - frame (unchecked-get props "frame") + (let [shape (unchecked-get props "shape") bounding-box (gsh/points->selrect (-> shape :points)) shape-center (gsh/center-shape shape) - line-color (rdcolor #js {:seed (str (:id shape))}) - zoom (mf/deref refs/selected-zoom) - childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape))) - childs (->> (mf/deref childs-ref) - (map gsh/transform-shape))] + line-color (rdcolor #js {:seed (str (:id shape))}) + zoom (mf/deref refs/selected-zoom)] [:g.bounding-box [:text {:x (:x bounding-box) @@ -81,7 +73,7 @@ [:& cross-point {:point shape-center :zoom zoom :color line-color}]] - + [:g.points (for [point (:points shape)] [:& cross-point {:point point diff --git a/frontend/src/app/main/ui/workspace/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/shapes/frame.cljs index 9387ad1ca8..12cbfca7cf 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.workspace.shapes.frame (:require [app.common.geom.shapes :as gsh] - [app.main.refs :as refs] [app.main.ui.shapes.frame :as frame] [app.main.ui.shapes.shape :refer [shape-container]] [app.main.ui.shapes.text.fontfaces :as ff] @@ -77,14 +76,10 @@ objects (unchecked-get props "objects") thumbnail? (unchecked-get props "thumbnail?") - edition (mf/deref refs/selected-edition) - shape (gsh/transform-shape shape) children (mapv #(get objects %) (:shapes shape)) - ds-modifier (get-in shape [:modifiers :displacement]) - - rendered? (mf/use-state false) + rendered? (mf/use-state false) show-thumbnail? (and thumbnail? (some? (:thumbnail shape))) diff --git a/frontend/src/app/main/ui/workspace/shapes/group.cljs b/frontend/src/app/main/ui/workspace/shapes/group.cljs index 8e7f22fb48..745523a1bf 100644 --- a/frontend/src/app/main/ui/workspace/shapes/group.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/group.cljs @@ -6,15 +6,12 @@ (ns app.main.ui.workspace.shapes.group (:require - [app.common.geom.shapes :as gsh] [app.main.data.workspace :as dw] [app.main.refs :as refs] [app.main.store :as st] [app.main.streams :as ms] - [app.main.ui.hooks :as hooks] [app.main.ui.shapes.group :as group] [app.main.ui.shapes.shape :refer [shape-container]] - [app.util.debug :refer [debug?]] [app.util.dom :as dom] [rumext.alpha :as mf])) @@ -33,10 +30,8 @@ {::mf/wrap [#(mf/memo' % (mf/check-props ["shape" "frame"]))] ::mf/wrap-props false} [props] - (let [shape (unchecked-get props "shape") - frame (unchecked-get props "frame") - - {:keys [id x y width height]} shape + (let [shape (unchecked-get props "shape") + frame (unchecked-get props "frame") childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape) {:with-modifiers? true})) childs (mf/deref childs-ref)] diff --git a/frontend/src/app/main/ui/workspace/shapes/path.cljs b/frontend/src/app/main/ui/workspace/shapes/path.cljs index c9183c3fe9..bae6a5d990 100644 --- a/frontend/src/app/main/ui/workspace/shapes/path.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/path.cljs @@ -6,13 +6,10 @@ (ns app.main.ui.workspace.shapes.path (:require - [app.main.data.workspace :as dw] [app.main.refs :as refs] - [app.main.store :as st] [app.main.ui.shapes.path :as path] [app.main.ui.shapes.shape :refer [shape-container]] [app.main.ui.workspace.shapes.path.common :as pc] - [app.util.dom :as dom] [app.util.path.commands :as upc] [rumext.alpha :as mf])) diff --git a/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs b/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs index 5d050a58cd..e266380261 100644 --- a/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/path/editor.cljs @@ -17,10 +17,10 @@ [app.main.ui.hooks :as hooks] [app.main.ui.workspace.shapes.path.common :as pc] [app.util.dom :as dom] - [app.util.path.geom :as upg] + [app.util.keyboard :as kbd] [app.util.path.commands :as upc] [app.util.path.format :as upf] - [app.util.keyboard :as kbd] + [app.util.path.geom :as upg] [clojure.set :refer [map-invert]] [goog.events :as events] [rumext.alpha :as mf]) @@ -31,12 +31,12 @@ on-enter (mf/use-callback - (fn [event] + (fn [_] (st/emit! (drp/path-pointer-enter position)))) - + on-leave (mf/use-callback - (fn [event] + (fn [_] (st/emit! (drp/path-pointer-leave position)))) on-mouse-down @@ -96,11 +96,11 @@ (when (and point handler) (let [{:keys [x y]} handler on-enter - (fn [event] + (fn [_] (st/emit! (drp/path-handler-enter index prefix))) on-leave - (fn [event] + (fn [_] (st/emit! (drp/path-handler-leave index prefix))) on-mouse-down @@ -135,7 +135,7 @@ :y (- y (/ 3 zoom)) :width (/ 6 zoom) :height (/ 6 zoom) - + :style {:stroke-width (/ 1 zoom) :stroke (cond (or selected? hover?) pc/black-color :else pc/primary-color) @@ -225,7 +225,6 @@ points (into #{} content-points) - last-command (last content) last-p (->> content last upc/command->point) handlers (upc/content->handlers content) @@ -247,7 +246,7 @@ moving-nodes)) handle-double-click-outside - (fn [event] + (fn [_] (when (= edit-mode :move) (st/emit! :interrupt)))] @@ -298,7 +297,7 @@ last-p? (= last-point (get point->base position)) pos-handlers (->> pos-handlers (filter show-handler?)) - curve? (not (empty? pos-handlers))] + curve? (boolean (seq pos-handlers))] [:g.path-node [:g.point-handlers {:pointer-events (when (= edit-mode :draw) "none")} diff --git a/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs b/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs index d2a34d3162..dda2e33b3f 100644 --- a/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/svg_raw.cljs @@ -7,11 +7,9 @@ (ns app.main.ui.workspace.shapes.svg-raw (:require [app.main.refs :as refs] - [app.main.ui.shapes.svg-raw :as svg-raw] [app.main.ui.shapes.shape :refer [shape-container]] - [rumext.alpha :as mf] - [app.common.geom.shapes :as gsh] - [app.main.ui.context :as muc])) + [app.main.ui.shapes.svg-raw :as svg-raw] + [rumext.alpha :as mf])) (defn svg-raw-wrapper-factory [shape-wrapper] @@ -20,20 +18,12 @@ {::mf/wrap [#(mf/memo' % (mf/check-props ["shape" "frame"]))] ::mf/wrap-props false} [props] - (let [shape (unchecked-get props "shape") - frame (unchecked-get props "frame") - - {:keys [id x y width height]} shape + (let [shape (unchecked-get props "shape") + frame (unchecked-get props "frame") childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape))) - childs (mf/deref childs-ref) + childs (mf/deref childs-ref)] - {:keys [id x y width height]} shape - transform (gsh/transform-matrix shape) - - tag (get-in shape [:content :tag]) - - def-ctx? (mf/use-ctx muc/def-ctx)] (if (or (= (get-in shape [:content :tag]) :svg) (and (contains? shape :svg-attrs) (map? (:content shape)))) diff --git a/frontend/src/app/main/ui/workspace/shapes/text.cljs b/frontend/src/app/main/ui/workspace/shapes/text.cljs index 9e4a3efbec..6f3b652ce7 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text.cljs @@ -6,25 +6,20 @@ (ns app.main.ui.workspace.shapes.text (:require - [app.common.geom.shapes :as gsh] [app.common.math :as mth] - [app.main.data.workspace :as dw] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.texts :as dwt] [app.main.refs :as refs] [app.main.store :as st] - [app.main.ui.context :as muc] [app.main.ui.shapes.shape :refer [shape-container]] [app.main.ui.shapes.text :as text] - [app.main.ui.workspace.shapes.common :as common] [app.util.dom :as dom] [app.util.logging :as log] [app.util.object :as obj] + [app.util.text-editor :as ted] [app.util.timers :as timers] [app.util.webapi :as wapi] - [app.util.text-editor :as ted] - [okulary.core :as l] [beicon.core :as rx] + [okulary.core :as l] [rumext.alpha :as mf])) ;; Change this to :info :debug or :trace to debug this module @@ -50,7 +45,7 @@ (mf/defc text-resize-content {::mf/wrap-props false} [props] - (let [{:keys [id name x y grow-type] :as shape} (obj/get props "shape") + (let [{:keys [id name grow-type] :as shape} (obj/get props "shape") ;; NOTE: this breaks the hooks rule of "no hooks inside ;; conditional code"; but we ensure that this component will @@ -77,8 +72,8 @@ #(let [width (obj/get-in entries [0 "contentRect" "width"]) height (obj/get-in entries [0 "contentRect" "height"])] (when (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height))) - (do (log/debug :msg "Resize detected" :shape-id id :width width :height height) - (st/emit! (dwt/resize-text id (mth/ceil width) (mth/ceil height)))))))))) + (log/debug :msg "Resize detected" :shape-id id :width width :height height) + (st/emit! (dwt/resize-text id (mth/ceil width) (mth/ceil height))))))))) text-ref-cb (mf/use-callback @@ -109,7 +104,7 @@ (mf/defc text-wrapper {::mf/wrap-props false} [props] - (let [{:keys [id x y width height] :as shape} (unchecked-get props "shape") + (let [{:keys [id] :as shape} (unchecked-get props "shape") edition-ref (mf/use-memo (mf/deps id) #(l/derived (fn [o] (= id (:edition o))) refs/workspace-local)) edition? (mf/deref edition-ref)] @@ -124,4 +119,4 @@ ;; the component if the edition flag changes. [:& text-resize-content {:shape shape :edition? edition? - :key (str (:id shape) edition?)}]]])) + :key (str id edition?)}]]])) diff --git a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs index 8486228935..2859344226 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/editor.cljs @@ -7,12 +7,9 @@ (ns app.main.ui.workspace.shapes.text.editor (:require ["draft-js" :as draft] - [app.common.data :as d] [app.common.geom.shapes :as gsh] [app.common.text :as txt] [app.main.data.workspace :as dw] - [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.selection :as dws] [app.main.data.workspace.texts :as dwt] [app.main.refs :as refs] [app.main.store :as st] @@ -22,9 +19,7 @@ [app.util.keyboard :as kbd] [app.util.object :as obj] [app.util.text-editor :as ted] - [cuerdas.core :as str] [goog.events :as events] - [okulary.core :as l] [rumext.alpha :as mf]) (:import goog.events.EventType)) @@ -34,12 +29,11 @@ (mf/defc block-component {::mf/wrap-props false} [props] - (let [children (obj/get props "children") - bprops (obj/get props "blockProps") - data (obj/get bprops "data") - style (sts/generate-paragraph-styles (obj/get bprops "shape") + (let [bprops (obj/get props "blockProps") + data (obj/get bprops "data") + style (sts/generate-paragraph-styles (obj/get bprops "shape") (obj/get bprops "data")) - dir (:text-direction data "auto")] + dir (:text-direction data "auto")] [:div {:style style :dir dir} @@ -72,10 +66,9 @@ {::mf/wrap [mf/memo] ::mf/wrap-props false ::mf/forward-ref true} - [props ref] - (let [{:keys [id x y width height grow-type content] :as shape} (obj/get props "shape") + [props _] + (let [{:keys [id content] :as shape} (obj/get props "shape") - zoom (mf/deref refs/selected-zoom) state-map (mf/deref refs/workspace-editor-state) state (get state-map id empty-editor-state) self-ref (mf/use-ref) @@ -86,9 +79,8 @@ (fn [event] (dom/stop-propagation event) (when (kbd/esc? event) - (do - (st/emit! :interrupt) - (st/emit! dw/clear-edition-mode)))) + (st/emit! :interrupt) + (st/emit! dw/clear-edition-mode))) on-mount (fn [] @@ -111,7 +103,7 @@ on-focus (mf/use-callback (mf/deps shape state) - (fn [event] + (fn [_] (reset! blured false))) on-change @@ -131,7 +123,7 @@ handle-return (mf/use-callback - (fn [event state] + (fn [_ state] (st/emit! (dwt/update-editor-state shape (ted/editor-split-block state))) "handled")) ] @@ -165,7 +157,7 @@ {::mf/wrap [mf/memo] ::mf/wrap-props false ::mf/forward-ref true} - [props ref] + [props _] (let [{:keys [id x y width height grow-type] :as shape} (obj/get props "shape") clip-id (str "clip-" id)] [:g.text-editor {:clip-path (str "url(#" clip-id ")")} diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index 2935531008..96e035cd4c 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -7,22 +7,18 @@ (ns app.main.ui.workspace.sidebar.assets (:require [app.common.data :as d] - [app.common.spec :as us] - [app.common.geom.point :as gpt] - [app.common.geom.shapes :as geom] [app.common.media :as cm] [app.common.pages :as cp] + [app.common.spec :as us] [app.common.text :as txt] - [app.common.uuid :as uuid] [app.config :as cfg] - [app.main.data.workspace.colors :as dc] [app.main.data.modal :as modal] [app.main.data.workspace :as dw] - [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.undo :as dwu] + [app.main.data.workspace.colors :as dc] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.texts :as dwt] + [app.main.data.workspace.undo :as dwu] [app.main.exports :as exports] [app.main.refs :as refs] [app.main.store :as st] @@ -31,17 +27,15 @@ [app.main.ui.components.editable-label :refer [editable-label]] [app.main.ui.components.file-uploader :refer [file-uploader]] [app.main.ui.components.forms :as fm] - [app.main.ui.components.tab-container :refer [tab-container tab-element]] [app.main.ui.context :as ctx] [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.menus.typography :refer [typography-entry]] [app.util.data :refer [matches-search]] [app.util.dom :as dom] [app.util.dom.dnd :as dnd] - [app.util.i18n :as i18n :refer [tr t]] + [app.util.i18n :as i18n :refer [tr]] [app.util.keyboard :as kbd] [app.util.router :as rt] - [app.util.timers :as timers] [cljs.spec.alpha :as s] [cuerdas.core :as str] [okulary.core :as l] @@ -133,7 +127,7 @@ on-accept (mf/use-callback (mf/deps form) - (fn [event] + (fn [_] (let [asset-name (get-in @form [:clean-data :asset-name])] (if create? (accept asset-name) @@ -219,7 +213,7 @@ content)])) (mf/defc asset-section-block - [{:keys [children role]}] + [{:keys [children]}] [:* children]) (mf/defc asset-group-title @@ -352,11 +346,11 @@ selected-components (:components selected-assets) multi-components? (> (count selected-components) 1) - multi-assets? (or (not (empty? (:graphics selected-assets))) - (not (empty? (:colors selected-assets))) - (not (empty? (:typographies selected-assets)))) + multi-assets? (or (seq (:graphics selected-assets)) + (seq (:colors selected-assets)) + (seq (:typographies selected-assets))) - groups (group-assets components) + groups (group-assets components) on-duplicate (mf/use-callback @@ -603,9 +597,9 @@ selected-objects (:graphics selected-assets) multi-objects? (> (count selected-objects) 1) - multi-assets? (or (not (empty? (:components selected-assets))) - (not (empty? (:colors selected-assets))) - (not (empty? (:typographies selected-assets)))) + multi-assets? (or (seq (:components selected-assets)) + (seq (:colors selected-assets)) + (seq (:typographies selected-assets))) groups (group-assets objects) @@ -776,10 +770,8 @@ (mf/defc color-item [{:keys [color local? file-id selected-colors multi-colors? multi-assets? - on-asset-click on-assets-delete on-clear-selection on-group - colors locale] :as props}] + on-asset-click on-assets-delete on-clear-selection on-group] :as props}] (let [rename? (= (:color-for-rename @refs/workspace-local) (:id color)) - id (:id color) input-ref (mf/use-ref) state (mf/use-state {:editing rename?}) @@ -790,8 +782,9 @@ (:color color) (:color color) :else (:value color)) + ;; TODO: looks like the first argument is not necessary apply-color - (fn [color-id event] + (fn [_ event] (let [ids (wsh/lookup-selected @st/state)] (if (kbd/shift? event) (st/emit! (dc/change-stroke ids color)) @@ -892,17 +885,17 @@ {:on-close on-close-menu :state @menu-state :options [(when-not (or multi-colors? multi-assets?) - [(t locale "workspace.assets.rename") rename-color-clicked]) + [(tr "workspace.assets.rename") rename-color-clicked]) (when-not (or multi-colors? multi-assets?) - [(t locale "workspace.assets.edit") edit-color-clicked]) - [(t locale "workspace.assets.delete") delete-color] + [(tr "workspace.assets.edit") edit-color-clicked]) + [(tr "workspace.assets.delete") delete-color] (when-not multi-assets? [(tr "workspace.assets.group") (on-group (:id color))])]}])])) (mf/defc colors-group [{:keys [file-id prefix groups open-groups local? selected-colors multi-colors? multi-assets? on-asset-click on-assets-delete - on-clear-selection on-group on-rename-group on-ungroup colors locale]}] + on-clear-selection on-group on-rename-group on-ungroup colors]}] (let [group-open? (get open-groups prefix true)] [:* @@ -932,8 +925,7 @@ :on-assets-delete on-assets-delete :on-clear-selection on-clear-selection :on-group on-group - :colors colors - :locale locale}]))]) + :colors colors}]))]) (for [[path-item content] groups] (when-not (empty? path-item) [:& colors-group {:file-id file-id @@ -950,24 +942,23 @@ :on-group on-group :on-rename-group on-rename-group :on-ungroup on-ungroup - :colors colors - :locale locale}]))])])) + :colors colors}]))])])) (mf/defc colors-box - [{:keys [file-id local? colors locale open? open-groups selected-assets + [{:keys [file-id local? colors open? open-groups selected-assets on-asset-click on-assets-delete on-clear-selection] :as props}] (let [selected-colors (:colors selected-assets) multi-colors? (> (count selected-colors) 1) - multi-assets? (or (not (empty? (:components selected-assets))) - (not (empty? (:graphics selected-assets))) - (not (empty? (:typographies selected-assets)))) + multi-assets? (or (seq (:components selected-assets)) + (seq (:graphics selected-assets)) + (seq (:typographies selected-assets))) - groups (group-assets colors) + groups (group-assets colors) add-color (mf/use-callback (mf/deps file-id) - (fn [value opacity] + (fn [value _opacity] (st/emit! (dwl/add-color value)))) add-color-clicked @@ -1072,8 +1063,7 @@ :on-group on-group :on-rename-group on-rename-group :on-ungroup on-ungroup - :colors colors - :locale locale}]]])) + :colors colors}]]])) ;; ---- Typography box ---- @@ -1127,7 +1117,7 @@ :on-context-menu on-context-menu}]))])])) (mf/defc typographies-box - [{:keys [file file-id local? typographies locale open? open-groups selected-assets + [{:keys [file file-id local? typographies open? open-groups selected-assets on-asset-click on-assets-delete on-clear-selection] :as props}] (let [state (mf/use-state {:detail-open? false :id nil}) @@ -1140,14 +1130,14 @@ selected-typographies (:typographies selected-assets) multi-typographies? (> (count selected-typographies) 1) - multi-assets? (or (not (empty? (:components selected-assets))) - (not (empty? (:graphics selected-assets))) - (not (empty? (:colors selected-assets)))) + multi-assets? (or (seq (:components selected-assets)) + (seq (:graphics selected-assets)) + (seq (:colors selected-assets))) add-typography (mf/use-callback (mf/deps file-id) - (fn [value opacity] + (fn [_] (st/emit! (dwl/add-typography txt/default-typography)))) handle-change @@ -1157,7 +1147,7 @@ (st/emit! (dwl/update-typography (merge typography changes) file-id)))) apply-typography - (fn [typography event] + (fn [typography _event] (let [ids (wsh/lookup-selected @st/state) attrs (merge {:typography-ref-file file-id @@ -1243,11 +1233,6 @@ (fn [] (swap! menu-state close-auto-pos-menu))) - closed-typography-edit - (mf/use-callback - (mf/deps file-id) - (fn [event] )) - handle-rename-typography-clicked (fn [] (st/emit! #(assoc-in % [:workspace-local :rename-typography] (:id @state)))) @@ -1307,10 +1292,10 @@ {:on-close on-close-menu :state @menu-state :options [(when-not (or multi-typographies? multi-assets?) - [(t locale "workspace.assets.rename") handle-rename-typography-clicked]) + [(tr "workspace.assets.rename") handle-rename-typography-clicked]) (when-not (or multi-typographies? multi-assets?) - [(t locale "workspace.assets.edit") handle-edit-typography-clicked]) - [(t locale "workspace.assets.delete") handle-delete-typography] + [(tr "workspace.assets.edit") handle-edit-typography-clicked]) + [(tr "workspace.assets.delete") handle-delete-typography] (when-not multi-assets? [(tr "workspace.assets.group") on-group])]}])]])) @@ -1322,7 +1307,7 @@ (l/derived (fn [state] (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:colors])) + (vals (get wfile :colors)) (vals (get-in state [:workspace-libraries id :data :colors]))))) st/state =)) @@ -1331,7 +1316,7 @@ (l/derived (fn [state] (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:media])) + (vals (get wfile :media)) (vals (get-in state [:workspace-libraries id :data :media]))))) st/state =)) @@ -1340,7 +1325,7 @@ (l/derived (fn [state] (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:components])) + (vals (get wfile :components)) (vals (get-in state [:workspace-libraries id :data :components]))))) st/state =)) @@ -1349,7 +1334,7 @@ (l/derived (fn [state] (let [wfile (:workspace-data state)] (if (= (:id wfile) id) - (vals (get-in wfile [:typographies])) + (vals (get wfile :typographies)) (vals (get-in state [:workspace-libraries id :data :typographies]))))) st/state =)) @@ -1374,7 +1359,7 @@ comp-fn)))) (mf/defc file-library - [{:keys [file local? default-open? filters locale] :as props}] + [{:keys [file local? default-open? filters] :as props}] (let [open-file (mf/deref (open-file-ref (:id file))) open? (-> open-file :library @@ -1425,23 +1410,23 @@ toggle-sort (mf/use-callback - (fn [event] - (swap! reverse-sort? not))) + (fn [_] + (swap! reverse-sort? not))) toggle-listing (mf/use-callback - (fn [event] - (swap! listing-thumbs? not))) + (fn [_] + (swap! listing-thumbs? not))) toggle-selected-asset (mf/use-callback - (mf/deps @selected-assets) - (fn [asset-type asset-id] - (swap! selected-assets update asset-type - (fn [selected] - (if (contains? selected asset-id) - (disj selected asset-id) - (conj selected asset-id)))))) + (mf/deps @selected-assets) + (fn [asset-type asset-id] + (swap! selected-assets update asset-type + (fn [selected] + (if (contains? selected asset-id) + (disj selected asset-id) + (conj selected asset-id)))))) extend-selected-assets (mf/use-callback @@ -1453,7 +1438,7 @@ (get groups "" []) (reduce concat [] - (->> (filter #(not (empty? (first %))) groups) + (->> (filter #(seq (first %)) groups) (map second) (map flatten-groups)))))] (swap! selected-assets update asset-type @@ -1504,17 +1489,16 @@ (mf/use-callback (mf/deps @selected-assets) (fn [] - (do - (st/emit! (dwu/start-undo-transaction)) - (apply st/emit! (map #(dwl/delete-component {:id %}) - (:components @selected-assets))) - (apply st/emit! (map #(dwl/delete-media {:id %}) - (:graphics @selected-assets))) - (apply st/emit! (map #(dwl/delete-color {:id %}) - (:colors @selected-assets))) - (apply st/emit! (map #(dwl/delete-typography %) - (:typographies @selected-assets))) - (st/emit! (dwu/commit-undo-transaction)))))] + (st/emit! (dwu/start-undo-transaction)) + (apply st/emit! (map #(dwl/delete-component {:id %}) + (:components @selected-assets))) + (apply st/emit! (map #(dwl/delete-media {:id %}) + (:graphics @selected-assets))) + (apply st/emit! (map #(dwl/delete-color {:id %}) + (:colors @selected-assets))) + (apply st/emit! (map #(dwl/delete-typography %) + (:typographies @selected-assets))) + (st/emit! (dwu/commit-undo-transaction))))] [:div.tool-window {:on-context-menu #(dom/prevent-default %) :on-click unselect-all} @@ -1526,9 +1510,9 @@ (if local? [:* - [:span (t locale "workspace.assets.file-library")] + [:span (tr "workspace.assets.file-library")] (when shared? - [:span.tool-badge (t locale "workspace.assets.shared")])] + [:span.tool-badge (tr "workspace.assets.shared")])] [:* [:span (:name file)] [:span.tool-link.tooltip.tooltip-left {:alt "Open library file"} @@ -1594,7 +1578,6 @@ (when show-colors? [:& colors-box {:file-id (:id file) :local? local? - :locale locale :colors colors :open? (open-box? :colors) :open-groups (open-groups :colors) @@ -1607,7 +1590,6 @@ [:& typographies-box {:file file :file-id (:id file) :local? local? - :locale locale :typographies typographies :open? (open-box? :typographies) :open-groups (open-groups :typographies) @@ -1618,7 +1600,7 @@ (when (and (not show-components?) (not show-graphics?) (not show-colors?)) [:div.asset-section - [:div.asset-title (t locale "workspace.assets.not-found")]])]))])) + [:div.asset-title (tr "workspace.assets.not-found")]])]))])) (mf/defc assets-toolbox @@ -1627,7 +1609,6 @@ (vals) (remove :is-indirect)) file (mf/deref refs/workspace-file) - locale (mf/deref i18n/locale) team-id (mf/use-ctx ctx/current-team-id) filters (mf/use-state {:term "" :box :all}) @@ -1641,7 +1622,7 @@ on-search-clear-click (mf/use-callback (mf/deps team-id) - (fn [event] + (fn [_] (swap! filters assoc :term ""))) on-box-filter-change @@ -1657,10 +1638,10 @@ [:div.tool-window [:div.tool-window-content [:div.assets-bar-title - (t locale "workspace.assets.assets") + (tr "workspace.assets.assets") [:div.libraries-button {:on-click #(modal/show! :libraries-dialog {})} i/text-align-justify - (t locale "workspace.assets.libraries")]] + (tr "workspace.assets.libraries")]] [:div.search-block [:input.search-input @@ -1677,16 +1658,15 @@ [:select.input-select {:value (:box @filters) :on-change on-box-filter-change} - [:option {:value ":all"} (t locale "workspace.assets.box-filter-all")] - [:option {:value ":components"} (t locale "workspace.assets.components")] - [:option {:value ":graphics"} (t locale "workspace.assets.graphics")] - [:option {:value ":colors"} (t locale "workspace.assets.colors")] - [:option {:value ":typographies"} (t locale "workspace.assets.typography")]]]] + [:option {:value ":all"} (tr "workspace.assets.box-filter-all")] + [:option {:value ":components"} (tr "workspace.assets.components")] + [:option {:value ":graphics"} (tr "workspace.assets.graphics")] + [:option {:value ":colors"} (tr "workspace.assets.colors")] + [:option {:value ":typographies"} (tr "workspace.assets.typography")]]]] [:div.libraries-wrapper [:& file-library {:file file - :locale locale :local? true :default-open? true :filters @filters}] @@ -1697,7 +1677,6 @@ {:key (:id file) :file file :local? false - :locale locale :default-open? false :filters @filters}])]])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/history.cljs b/frontend/src/app/main/ui/workspace/sidebar/history.cljs index f188172a23..86f294d5b2 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/history.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/history.cljs @@ -6,21 +6,15 @@ (ns app.main.ui.workspace.sidebar.history (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] [app.common.data :as d] - [app.main.ui.icons :as i] - [app.main.data.history :as udh] - [app.main.data.workspace :as dw] [app.main.refs :as refs] [app.main.store :as st] - [app.util.data :refer [read-string]] + [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :refer [t] :as i18n] - [app.util.router :as r] - [app.util.time :as dt] + [cuerdas.core :as str] [okulary.core :as l] - [app.main.store :as st])) + [rumext.alpha :as mf])) (def workspace-undo (l/derived :workspace-undo st/state)) @@ -137,7 +131,7 @@ i/layers)) (defn is-shape? [type] - #{:shape :rect :circle :text :path :frame :group}) + (contains? #{:shape :rect :circle :text :path :frame :group} type)) (defn parse-entry [{:keys [redo-changes]}] (->> redo-changes @@ -211,7 +205,7 @@ :modify (->> candidates (filter #(= :modify (:operation %))) (group-by :id) - (d/mapm (fn [k v] (->> v + (d/mapm (fn [_ v] (->> v (mapcat :detail) (map (comp safe-name :attr)) (remove nil?) @@ -280,7 +274,7 @@ (mf/defc history-toolbox [] (let [locale (mf/deref i18n/locale) objects (mf/deref refs/workspace-page-objects) - {:keys [items index transaction]} (mf/deref workspace-undo) + {:keys [items index]} (mf/deref workspace-undo) entries (parse-entries items objects)] [:div.history-toolbox [:div.history-toolbox-title (t locale "workspace.undo.title")] diff --git a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs index 310ece2765..0f147b1f26 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs @@ -16,12 +16,9 @@ [app.main.ui.hooks :as hooks] [app.main.ui.icons :as i] [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t]] [app.util.keyboard :as kbd] [app.util.object :as obj] - [app.util.perf :as perf] [app.util.timers :as ts] - [beicon.core :as rx] [okulary.core :as l] [rumext.alpha :as mf])) @@ -175,7 +172,7 @@ (st/emit! (dw/select-shape id)))) on-drop - (fn [side {:keys [id] :as data}] + (fn [side _data] (if (= side :center) (st/emit! (dw/relocate-selected-shapes (:id item) 0)) (let [to-index (if (= side :top) (inc index) index) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options.cljs b/frontend/src/app/main/ui/workspace/sidebar/options.cljs index 8f072fcd9e..89248b58b0 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options.cljs @@ -6,13 +6,11 @@ (ns app.main.ui.workspace.sidebar.options (:require - [app.common.spec :as us] [app.main.data.workspace :as udw] [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.components.tab-container :refer [tab-container tab-element]] [app.main.ui.context :as ctx] - [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.align :refer [align-options]] [app.main.ui.workspace.sidebar.options.menus.exports :refer [exports-menu]] [app.main.ui.workspace.sidebar.options.menus.interactions :refer [interactions-menu]] @@ -26,9 +24,8 @@ [app.main.ui.workspace.sidebar.options.shapes.rect :as rect] [app.main.ui.workspace.sidebar.options.shapes.svg-raw :as svg-raw] [app.main.ui.workspace.sidebar.options.shapes.text :as text] - [app.util.i18n :as i18n :refer [tr t]] + [app.util.i18n :as i18n :refer [tr]] [app.util.object :as obj] - [beicon.core :as rx] [rumext.alpha :as mf])) ;; --- Options @@ -52,32 +49,30 @@ :page-id page-id :file-id file-id}]]) - (mf/defc options-content {::mf/wrap [mf/memo]} [{:keys [selected section shapes shapes-with-children page-id file-id]}] - (let [locale (mf/deref i18n/locale)] - [:div.tool-window - [:div.tool-window-content - [:& tab-container {:on-change-tab #(st/emit! (udw/set-options-mode %)) - :selected section} - [:& tab-element {:id :design - :title (t locale "workspace.options.design")} - [:div.element-options - [:& align-options] - (case (count selected) - 0 [:& page/options] - 1 [:& shape-options {:shape (first shapes) - :page-id page-id - :file-id file-id - :shapes-with-children shapes-with-children}] - [:& multiple/options {:shapes-with-children shapes-with-children - :shapes shapes}])]] + [:div.tool-window + [:div.tool-window-content + [:& tab-container {:on-change-tab #(st/emit! (udw/set-options-mode %)) + :selected section} + [:& tab-element {:id :design + :title (tr "workspace.options.design")} + [:div.element-options + [:& align-options] + (case (count selected) + 0 [:& page/options] + 1 [:& shape-options {:shape (first shapes) + :page-id page-id + :file-id file-id + :shapes-with-children shapes-with-children}] + [:& multiple/options {:shapes-with-children shapes-with-children + :shapes shapes}])]] - [:& tab-element {:id :prototype - :title (t locale "workspace.options.prototype")} - [:div.element-options - [:& interactions-menu {:shape (first shapes)}]]]]]])) + [:& tab-element {:id :prototype + :title (tr "workspace.options.prototype")} + [:div.element-options + [:& interactions-menu {:shape (first shapes)}]]]]]]) ;; TODO: this need optimizations, selected-objects and diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/common.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/common.cljs index 6468e1b4d1..733fd420b8 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/common.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/common.cljs @@ -6,14 +6,10 @@ (ns app.main.ui.workspace.sidebar.options.common (:require - [rumext.alpha :as mf] - [app.util.dom :as dom])) + [rumext.alpha :as mf])) -(mf/defc advanced-options [{:keys [visible? on-close children]}] - (let [ref (mf/use-ref nil) - handle-click (fn [event] (when on-close - (do (dom/stop-propagation event) - (on-close))))] +(mf/defc advanced-options [{:keys [visible? children]}] + (let [ref (mf/use-ref nil)] (mf/use-effect (mf/deps visible?) (fn [] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/blur.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/blur.cljs index cb2e9fd808..fac3572764 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/blur.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/blur.cljs @@ -6,16 +6,13 @@ (ns app.main.ui.workspace.sidebar.options.menus.blur (:require - [rumext.alpha :as mf] - [app.common.data :as d] [app.common.uuid :as uuid] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] [app.main.store :as st] [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.rows.input-row :refer [input-row]] - [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t]])) + [app.util.i18n :as i18n :refer [tr]] + [rumext.alpha :as mf])) (def blur-attrs [:blur]) @@ -27,8 +24,7 @@ :hidden false})) (mf/defc blur-menu [{:keys [ids type values]}] - (let [locale (i18n/use-locale) - blur (:blur values) + (let [blur (:blur values) has-value? (not (nil? blur)) multiple? (= blur :multiple) @@ -59,9 +55,9 @@ [:div.element-set-title [:span (case type - :multiple (t locale "workspace.options.blur-options.title.multiple") - :group (t locale "workspace.options.blur-options.title.group") - (t locale "workspace.options.blur-options.title"))] + :multiple (tr "workspace.options.blur-options.title.multiple") + :group (tr "workspace.options.blur-options.title.group") + (tr "workspace.options.blur-options.title"))] [:div.element-set-title-actions (when (and has-value? (not multiple?)) @@ -78,5 +74,5 @@ :class "pixels" :min 0 :value (:value blur) - :placeholder (t locale "settings.multiple") + :placeholder (tr "settings.multiple") :on-change handle-change}]])])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index bc7c393847..024c391d10 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -6,20 +6,19 @@ (ns app.main.ui.workspace.sidebar.options.menus.component (:require - [rumext.alpha :as mf] [app.common.pages :as cp] [app.main.data.modal :as modal] + [app.main.data.workspace :as dw] + [app.main.data.workspace.libraries :as dwl] + [app.main.data.workspace.undo :as dwu] [app.main.refs :as refs] [app.main.store :as st] + [app.main.ui.components.context-menu :refer [context-menu]] [app.main.ui.context :as ctx] [app.main.ui.icons :as i] - [app.main.ui.components.context-menu :refer [context-menu]] - [app.main.data.workspace :as dw] - [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.undo :as dwu] - [app.main.data.workspace.libraries :as dwl] + [app.util.dom :as dom] [app.util.i18n :as i18n :refer [t]] - [app.util.dom :as dom])) + [rumext.alpha :as mf])) (def component-attrs [:component-id :component-file :shape-ref]) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/exports.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/exports.cljs index dd62aef455..ff24325fcf 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/exports.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/exports.cljs @@ -6,21 +6,18 @@ (ns app.main.ui.workspace.sidebar.options.menus.exports (:require - [cuerdas.core :as str] - [beicon.core :as rx] - [rumext.alpha :as mf] [app.common.data :as d] - [app.main.repo :as rp] - [app.main.ui.icons :as i] [app.main.data.messages :as dm] [app.main.data.workspace :as udw] + [app.main.repo :as rp] [app.main.store :as st] - [app.util.object :as obj] + [app.main.ui.icons :as i] [app.util.dom :as dom] - [app.util.http :as http] - [app.util.i18n :as i18n :refer [tr t]])) + [app.util.i18n :as i18n :refer [tr]] + [beicon.core :as rx] + [rumext.alpha :as mf])) -(defn- request-export +(defn request-export [shape exports] (rp/query! :export {:page-id (:page-id shape) @@ -31,8 +28,7 @@ (mf/defc exports-menu [{:keys [shape page-id file-id] :as props}] - (let [locale (mf/deref i18n/locale) - exports (:exports shape []) + (let [exports (:exports shape []) loading? (mf/use-state false) filename (cond-> (:name shape) @@ -50,7 +46,7 @@ (rx/subs (fn [body] (dom/trigger-download filename body)) - (fn [error] + (fn [_error] (swap! loading? not) (st/emit! (dm/error (tr "errors.unexpected-error")))) (fn [] @@ -108,7 +104,7 @@ [:div.element-set.exports-options [:div.element-set-title - [:span (t locale "workspace.options.export")] + [:span (tr "workspace.options.export")] [:div.add-page {:on-click add-export} i/close]] (when (seq exports) [:div.element-set-content @@ -141,6 +137,6 @@ :btn-disabled @loading?) :disabled @loading?} (if @loading? - (t locale "workspace.options.exporting-object") - (t locale "workspace.options.export-object"))]])])) + (tr "workspace.options.exporting-object") + (tr "workspace.options.export-object"))]])])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs index 47112a3f2b..c13fc2b9a7 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs @@ -8,16 +8,12 @@ (:require [app.common.pages :as cp] [app.main.data.workspace.colors :as dc] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.undo :as dwu] - [app.main.data.workspace.texts :as dwt] - [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.rows.color-row :refer [color-row]] [app.util.color :as uc] - [app.util.i18n :as i18n :refer [tr t]] - [app.util.object :as obj] + [app.util.i18n :as i18n :refer [tr]] [rumext.alpha :as mf])) (def fill-attrs @@ -30,14 +26,13 @@ (mf/defc fill-menu {::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values"]))]} [{:keys [ids type values] :as props}] - (let [locale (mf/deref i18n/locale) - show? (or (not (nil? (:fill-color values))) - (not (nil? (:fill-color-gradient values)))) + (let [show? (or (not (nil? (:fill-color values))) + (not (nil? (:fill-color-gradient values)))) label (case type - :multiple (t locale "workspace.options.selection-fill") - :group (t locale "workspace.options.group-fill") - (t locale "workspace.options.fill")) + :multiple (tr "workspace.options.selection-fill") + :group (tr "workspace.options.group-fill") + (tr "workspace.options.fill")) color {:color (:fill-color values) :opacity (:fill-opacity values) @@ -48,21 +43,21 @@ on-add (mf/use-callback (mf/deps ids) - (fn [event] + (fn [_] (st/emit! (dc/change-fill ids {:color cp/default-color :opacity 1})))) on-delete (mf/use-callback (mf/deps ids) - (fn [event] + (fn [_] (st/emit! (dc/change-fill ids (into {} uc/empty-color))))) on-change (mf/use-callback (mf/deps ids) (fn [color] - (let [remove-multiple (fn [[key value]] (not= value :multiple)) + (let [remove-multiple (fn [[_ value]] (not= value :multiple)) color (into {} (filter remove-multiple) color)] (st/emit! (dc/change-fill ids color))))) @@ -70,7 +65,7 @@ (mf/use-callback (mf/deps ids) (fn [] - (let [remove-multiple (fn [[key value]] (not= value :multiple)) + (let [remove-multiple (fn [[_ value]] (not= value :multiple)) color (-> (into {} (filter remove-multiple) color) (assoc :id nil :file-id nil))] (st/emit! (dc/change-fill ids color))))) @@ -78,13 +73,13 @@ on-open-picker (mf/use-callback (mf/deps ids) - (fn [value opacity id file-id] + (fn [_value _opacity _id _file-id] (st/emit! (dwu/start-undo-transaction)))) on-close-picker (mf/use-callback (mf/deps ids) - (fn [value opacity id file-id] + (fn [_value _opacity _id _file-id] (st/emit! (dwu/commit-undo-transaction))))] (if show? diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/frame_grid.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/frame_grid.cljs index 1c30246c86..99f43711ea 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/frame_grid.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/frame_grid.cljs @@ -6,38 +6,34 @@ (ns app.main.ui.workspace.sidebar.options.menus.frame-grid (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [app.util.dom :as dom] - [app.util.data :as d] [app.common.math :as mth] - [app.common.data :refer [parse-integer]] - [app.main.store :as st] - [app.main.refs :as refs] [app.main.data.workspace.grid :as dw] - [app.util.geom.grid :as gg] + [app.main.refs :as refs] + [app.main.store :as st] + [app.main.ui.components.editable-select :refer [editable-select]] + [app.main.ui.components.numeric-input :refer [numeric-input]] + [app.main.ui.components.select :refer [select]] [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.common :refer [advanced-options]] [app.main.ui.workspace.sidebar.options.rows.color-row :refer [color-row]] [app.main.ui.workspace.sidebar.options.rows.input-row :refer [input-row]] - [app.main.ui.components.numeric-input :refer [numeric-input]] - [app.main.ui.components.select :refer [select]] - [app.main.ui.components.editable-select :refer [editable-select]] - [app.main.ui.components.dropdown :refer [dropdown]] - [app.util.i18n :as i18n :refer [tr t]])) + [app.util.data :as d] + [app.util.geom.grid :as gg] + [app.util.i18n :as i18n :refer [tr]] + [okulary.core :as l] + [rumext.alpha :as mf])) (def workspace-saved-grids (l/derived :saved-grids refs/workspace-page-options)) -(defn- get-size-options [locale] - [{:value :auto :label (t locale "workspace.options.grid.auto")} +(defn- get-size-options [] + [{:value :auto :label (tr "workspace.options.grid.auto")} :separator 18 12 10 8 6 4 3 2]) (mf/defc grid-options [{:keys [grid frame default-grid-params on-change on-remove on-save-grid]}] - (let [locale (i18n/use-locale) - size-options (get-size-options locale) + (let [size-options (get-size-options) state (mf/use-state {:show-advanced-options false}) {:keys [type display params]} grid @@ -45,12 +41,12 @@ #(swap! state update :show-advanced-options not) handle-toggle-visibility - (fn [event] + (fn [_] (when on-change (on-change (update grid :display #(if (nil? %) false (not %)))))) handle-remove-grid - (fn [event] + (fn [_] (when on-remove (on-remove))) handle-change-type @@ -82,7 +78,7 @@ handle-change-item-length (fn [item-length] - (let [{:keys [margin gutter size]} (:params grid) + (let [size (get-in grid [:params :size]) size (if (and (nil? item-length) (or (nil? size) (= :auto size))) 12 size)] (when on-change (on-change (-> grid @@ -128,9 +124,9 @@ [:& select {:class "flex-grow" :default-value type - :options [{:value :square :label (t locale "workspace.options.grid.square")} - {:value :column :label (t locale "workspace.options.grid.column")} - {:value :row :label (t locale "workspace.options.grid.row")}] + :options [{:value :square :label (tr "workspace.options.grid.square")} + {:value :column :label (tr "workspace.options.grid.column")} + {:value :row :label (tr "workspace.options.grid.row")}] :on-change handle-change-type}] (if (= type :square) @@ -154,14 +150,14 @@ :on-close toggle-advanced-options} [:button.custom-button {:on-click toggle-advanced-options} i/actions] (when (= :square type) - [:& input-row {:label (t locale "workspace.options.grid.params.size") + [:& input-row {:label (tr "workspace.options.grid.params.size") :class "pixels" :min 1 :value (:size params) :on-change (handle-change :params :size)}]) (when (= :row type) - [:& input-row {:label (t locale "workspace.options.grid.params.rows") + [:& input-row {:label (tr "workspace.options.grid.params.rows") :type :editable-select :options size-options :value (:size params) @@ -170,7 +166,7 @@ :on-change handle-change-size}]) (when (= :column type) - [:& input-row {:label (t locale "workspace.options.grid.params.columns") + [:& input-row {:label (tr "workspace.options.grid.params.columns") :type :editable-select :options size-options :value (:size params) @@ -179,23 +175,23 @@ :on-change handle-change-size}]) (when (#{:row :column} type) - [:& input-row {:label (t locale "workspace.options.grid.params.type") + [:& input-row {:label (tr "workspace.options.grid.params.type") :type :select - :options [{:value :stretch :label (t locale "workspace.options.grid.params.type.stretch")} + :options [{:value :stretch :label (tr "workspace.options.grid.params.type.stretch")} {:value :left :label (if (= type :row) - (t locale "workspace.options.grid.params.type.top") - (t locale "workspace.options.grid.params.type.left"))} - {:value :center :label (t locale "workspace.options.grid.params.type.center")} + (tr "workspace.options.grid.params.type.top") + (tr "workspace.options.grid.params.type.left"))} + {:value :center :label (tr "workspace.options.grid.params.type.center")} {:value :right :label (if (= type :row) - (t locale "workspace.options.grid.params.type.bottom") - (t locale "workspace.options.grid.params.type.right"))}] + (tr "workspace.options.grid.params.type.bottom") + (tr "workspace.options.grid.params.type.right"))}] :value (:type params) :on-change (handle-change :params :type)}]) (when (#{:row :column} type) [:& input-row {:label (if (= :row type) - (t locale "workspace.options.grid.params.height") - (t locale "workspace.options.grid.params.width")) + (tr "workspace.options.grid.params.height") + (tr "workspace.options.grid.params.width")) :class "pixels" :placeholder "Auto" :value (or (:item-length params) "") @@ -203,13 +199,13 @@ (when (#{:row :column} type) [:* - [:& input-row {:label (t locale "workspace.options.grid.params.gutter") + [:& input-row {:label (tr "workspace.options.grid.params.gutter") :class "pixels" :value (:gutter params) :min 0 :placeholder "0" :on-change (handle-change :params :gutter)}] - [:& input-row {:label (t locale "workspace.options.grid.params.margin") + [:& input-row {:label (tr "workspace.options.grid.params.margin") :class "pixels" :min 0 :placeholder "0" @@ -222,13 +218,12 @@ :on-detach handle-detach-color}] [:div.row-flex [:button.btn-options {:disabled is-default - :on-click handle-use-default} (t locale "workspace.options.grid.params.use-default")] + :on-click handle-use-default} (tr "workspace.options.grid.params.use-default")] [:button.btn-options {:disabled is-default - :on-click handle-set-as-default} (t locale "workspace.options.grid.params.set-default")]]]])) + :on-click handle-set-as-default} (tr "workspace.options.grid.params.set-default")]]]])) (mf/defc frame-grid [{:keys [shape]}] - (let [locale (i18n/use-locale) - id (:id shape) + (let [id (:id shape) default-grid-params (merge dw/default-grid-params (mf/deref workspace-saved-grids)) handle-create-grid #(st/emit! (dw/add-frame-grid id)) handle-remove-grid (fn [index] #(st/emit! (dw/remove-frame-grid id index))) @@ -236,10 +231,10 @@ handle-save-grid (fn [grid] (st/emit! (dw/set-default-grid (:type grid) (:params grid))))] [:div.element-set [:div.element-set-title - [:span (t locale "workspace.options.grid.title")] + [:span (tr "workspace.options.grid.title")] [:div.add-page {:on-click handle-create-grid} i/close]] - (when (not (empty? (:grids shape))) + (when (seq (:grids shape)) [:div.element-set-content (for [[index grid] (map-indexed vector (:grids shape))] [:& grid-options {:key (str (:id shape) "-" index) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs index 10dad31477..500b5e0388 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs @@ -6,7 +6,6 @@ (ns app.main.ui.workspace.sidebar.options.menus.interactions (:require - [rumext.alpha :as mf] [app.common.data :as d] [app.common.pages :as cp] [app.main.data.workspace :as dw] @@ -14,13 +13,12 @@ [app.main.store :as st] [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.icons :as i] - [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t]])) + [app.util.i18n :as i18n :refer [tr]] + [rumext.alpha :as mf])) (mf/defc interactions-menu [{:keys [shape] :as props}] - (let [locale (mf/deref i18n/locale) - objects (deref refs/workspace-page-objects) + (let [objects (deref refs/workspace-page-objects) interaction (first (:interactions shape)) ; TODO: in the ; future we may ; have several @@ -48,26 +46,26 @@ (if (not shape) [:* [:div.interactions-help-icon i/interaction] - [:div.interactions-help (t locale "workspace.options.select-a-shape")] + [:div.interactions-help (tr "workspace.options.select-a-shape")] [:div.interactions-help-icon i/play] - [:div.interactions-help (t locale "workspace.options.use-play-button")]] + [:div.interactions-help (tr "workspace.options.use-play-button")]] [:div.element-set {:on-blur on-set-blur} [:div.element-set-title - [:span (t locale "workspace.options.navigate-to")]] + [:span (tr "workspace.options.navigate-to")]] [:div.element-set-content [:div.row-flex [:div.custom-select.flex-grow {:on-click #(reset! show-frames-dropdown? true)} (if destination [:span (:name destination)] - [:span (t locale "workspace.options.select-artboard")]) + [:span (tr "workspace.options.select-artboard")]) [:span.dropdown-button i/arrow-down] [:& dropdown {:show @show-frames-dropdown? :on-close #(reset! show-frames-dropdown? false)} [:ul.custom-select-dropdown [:li.dropdown-separator {:on-click #(on-select-destination nil)} - (t locale "workspace.options.none")] + (tr "workspace.options.none")] (for [frame frames] (when (and (not= (:id frame) (:id shape)) ; A frame cannot navigate to itself diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layer.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layer.cljs index c7be781cf5..68f2e86650 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layer.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layer.cljs @@ -8,7 +8,6 @@ (:require [app.common.data :as d] [app.common.math :as mth] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] [app.main.store :as st] [app.main.ui.components.numeric-input :refer [numeric-input]] @@ -54,25 +53,25 @@ handle-set-hidden (mf/use-callback (mf/deps change!) - (fn [event] + (fn [_] (change! :hidden true))) handle-set-visible (mf/use-callback (mf/deps change!) - (fn [event] + (fn [_] (change! :hidden false))) handle-set-blocked (mf/use-callback (mf/deps change!) - (fn [event] + (fn [_] (change! :blocked true))) handle-set-unblocked (mf/use-callback (mf/deps change!) - (fn [event] + (fn [_] (change! :blocked false)))] [:div.element-set @@ -92,7 +91,7 @@ [:option {:value "multiple"} "--"]) [:option {:value "normal"} (tr "workspace.options.layer-options.blend-mode.normal")] - + [:option {:value "darken"} (tr "workspace.options.layer-options.blend-mode.darken")] [:option {:value "multiply"} (tr "workspace.options.layer-options.blend-mode.multiply")] [:option {:value "color-burn"} (tr "workspace.options.layer-options.blend-mode.color-burn")] @@ -127,13 +126,13 @@ (cond (or (= :multiple (:hidden values)) (not (:hidden values))) [:div.element-set-actions-button {:on-click handle-set-hidden} i/eye] - + :else [:div.element-set-actions-button {:on-click handle-set-visible} i/eye-closed]) (cond (or (= :multiple (:blocked values)) (not (:blocked values))) [:div.element-set-actions-button {:on-click handle-set-blocked} i/unlock] - + :else [:div.element-set-actions-button {:on-click handle-set-unblocked} i/lock])]]]])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs index f7e8fa6323..7ac385827a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs @@ -6,24 +6,21 @@ (ns app.main.ui.workspace.sidebar.options.menus.measures (:require - [cuerdas.core :as str] - [rumext.alpha :as mf] - [app.main.ui.icons :as i] - [app.main.store :as st] - [app.main.refs :as refs] [app.common.data :as d] - [app.util.dom :as dom] - [app.util.data :refer [classnames]] [app.common.geom.shapes :as gsh] - [app.common.geom.point :as gpt] + [app.common.math :as math] [app.common.pages.spec :as spec] [app.common.uuid :as uuid] [app.main.data.workspace :as udw] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] + [app.main.refs :as refs] + [app.main.store :as st] [app.main.ui.components.numeric-input :refer [numeric-input]] - [app.common.math :as math] - [app.util.i18n :refer [tr] :as i18n])) + [app.main.ui.icons :as i] + [app.util.dom :as dom] + [app.util.i18n :as i18n :refer [tr]] + [cuerdas.core :as str] + [rumext.alpha :as mf])) (def measure-attrs [:proportion-lock :width :height @@ -88,7 +85,7 @@ on-proportion-lock-change (mf/use-callback (mf/deps ids) - (fn [event] + (fn [_] (let [new-lock (if (= proportion-lock :multiple) true (not proportion-lock))] (run! #(st/emit! (udw/set-shape-proportion-lock % new-lock)) ids)))) @@ -114,7 +111,7 @@ on-switch-to-radius-1 (mf/use-callback (mf/deps ids) - (fn [value] + (fn [_value] (let [radius-update (fn [shape] (cond-> shape @@ -126,7 +123,7 @@ on-switch-to-radius-4 (mf/use-callback (mf/deps ids) - (fn [value] + (fn [_value] (let [radius-update (fn [shape] (cond-> shape @@ -180,164 +177,162 @@ on-constraint-button-clicked (mf/use-callback - (mf/deps [ids values]) - (fn [button] - (fn [event] - (let [constraints-h (get values :constraints-h :scale) - constraints-v (get values :constraints-v :scale) + (mf/deps [ids values]) + (fn [button] + (fn [_] + (let [constraints-h (get values :constraints-h :scale) + constraints-v (get values :constraints-v :scale) - [constraint new-value] - (case button - :top (case constraints-v - :top [:constraints-v :scale] - :topbottom [:constraints-v :bottom] - :bottom [:constraints-v :topbottom] - [:constraints-v :top]) - :bottom (case constraints-v - :bottom [:constraints-v :scale] - :topbottom [:constraints-v :top] - :top [:constraints-v :topbottom] - [:constraints-v :bottom]) - :left (case constraints-h - :left [:constraints-h :scale] - :leftright [:constraints-h :right] - :right [:constraints-h :leftright] - [:constraints-h :left]) - :right (case constraints-h - :right [:constraints-h :scale] - :leftright [:constraints-h :left] - :left [:constraints-h :leftright] - [:constraints-h :right]) - :centerv (case constraints-v + [constraint new-value] + (case button + :top (case constraints-v + :top [:constraints-v :scale] + :topbottom [:constraints-v :bottom] + :bottom [:constraints-v :topbottom] + [:constraints-v :top]) + :bottom (case constraints-v + :bottom [:constraints-v :scale] + :topbottom [:constraints-v :top] + :top [:constraints-v :topbottom] + [:constraints-v :bottom]) + :left (case constraints-h + :left [:constraints-h :scale] + :leftright [:constraints-h :right] + :right [:constraints-h :leftright] + [:constraints-h :left]) + :right (case constraints-h + :right [:constraints-h :scale] + :leftright [:constraints-h :left] + :left [:constraints-h :leftright] + [:constraints-h :right]) + :centerv (case constraints-v :center [:constraints-v :scale] [:constraints-v :center]) - :centerh (case constraints-h + :centerh (case constraints-h :center [:constraints-h :scale] [:constraints-h :center]))] - (st/emit! (dch/update-shapes - ids - #(assoc % constraint new-value))))))) + (st/emit! (dch/update-shapes + ids + #(assoc % constraint new-value))))))) on-constraint-select-changed (mf/use-callback - (mf/deps [ids values]) - (fn [constraint] + (mf/deps [ids values]) + (fn [constraint] (fn [event] (let [value (-> (dom/get-target-val event) (keyword))] (when-not (str/empty? value) (st/emit! (dch/update-shapes - ids - #(assoc % constraint value)))))))) + ids + #(assoc % constraint value)))))))) on-fixed-scroll-clicked (mf/use-callback - (mf/deps [ids values]) - (fn [event] - (st/emit! (dch/update-shapes - ids - #(update % :fixed-scroll not)))))] + (mf/deps [ids values]) + (fn [_] + (st/emit! (dch/update-shapes ids #(update % :fixed-scroll not)))))] [:* - [:div.element-set - [:div.element-set-content + [:div.element-set + [:div.element-set-content - ;; WIDTH & HEIGHT - (when (options :size) - [:div.row-flex - [:span.element-set-subtitle (tr "workspace.options.size")] - [:div.input-element.width - [:> numeric-input {:min 1 - :no-validate true - :placeholder "--" - :on-click select-all - :on-change on-width-change - :value (attr->string :width values)}]] + ;; WIDTH & HEIGHT + (when (options :size) + [:div.row-flex + [:span.element-set-subtitle (tr "workspace.options.size")] + [:div.input-element.width + [:> numeric-input {:min 1 + :no-validate true + :placeholder "--" + :on-click select-all + :on-change on-width-change + :value (attr->string :width values)}]] - [:div.input-element.height - [:> numeric-input {:min 1 - :no-validate true - :placeholder "--" - :on-click select-all - :on-change on-height-change - :value (attr->string :height values)}]] + [:div.input-element.height + [:> numeric-input {:min 1 + :no-validate true + :placeholder "--" + :on-click select-all + :on-change on-height-change + :value (attr->string :height values)}]] - [:div.lock-size {:class (classnames + [:div.lock-size {:class (dom/classnames :selected (true? proportion-lock) :disabled (= proportion-lock :multiple)) - :on-click on-proportion-lock-change} - (if proportion-lock - i/lock - i/unlock)]]) + :on-click on-proportion-lock-change} + (if proportion-lock + i/lock + i/unlock)]]) - ;; POSITION - (when (options :position) - [:div.row-flex - [:span.element-set-subtitle (tr "workspace.options.position")] - [:div.input-element.Xaxis - [:> numeric-input {:no-validate true - :placeholder "--" - :on-click select-all - :on-change on-pos-x-change - :value (attr->string :x values)}]] - [:div.input-element.Yaxis - [:> numeric-input {:no-validate true - :placeholder "--" - :on-click select-all - :on-change on-pos-y-change - :value (attr->string :y values)}]]]) + ;; POSITION + (when (options :position) + [:div.row-flex + [:span.element-set-subtitle (tr "workspace.options.position")] + [:div.input-element.Xaxis + [:> numeric-input {:no-validate true + :placeholder "--" + :on-click select-all + :on-change on-pos-x-change + :value (attr->string :x values)}]] + [:div.input-element.Yaxis + [:> numeric-input {:no-validate true + :placeholder "--" + :on-click select-all + :on-change on-pos-y-change + :value (attr->string :y values)}]]]) - ;; ROTATION - (when (options :rotation) - [:div.row-flex - [:span.element-set-subtitle (tr "workspace.options.rotation")] - [:div.input-element.degrees - [:> numeric-input - {:no-validate true - :min 0 - :max 359 - :data-wrap true - :placeholder "--" - :on-click select-all - :on-change on-rotation-change - :value (attr->string :rotation values)}]] - #_[:input.slidebar - {:type "range" - :min "0" - :max "359" - :step "10" - :no-validate true - :on-change on-rotation-change - :value (attr->string :rotation values)}]]) + ;; ROTATION + (when (options :rotation) + [:div.row-flex + [:span.element-set-subtitle (tr "workspace.options.rotation")] + [:div.input-element.degrees + [:> numeric-input + {:no-validate true + :min 0 + :max 359 + :data-wrap true + :placeholder "--" + :on-click select-all + :on-change on-rotation-change + :value (attr->string :rotation values)}]] + #_[:input.slidebar + {:type "range" + :min "0" + :max "359" + :step "10" + :no-validate true + :on-change on-rotation-change + :value (attr->string :rotation values)}]]) - ;; RADIUS - (let [radius-1? (some? (:rx values)) - radius-4? (some? (:r1 values))] - (when (and (options :radius) (or radius-1? radius-4?)) - [:div.row-flex - [:div.radius-options + ;; RADIUS + (let [radius-1? (some? (:rx values)) + radius-4? (some? (:r1 values))] + (when (and (options :radius) (or radius-1? radius-4?)) + [:div.row-flex + [:div.radius-options [:div.radius-icon.tooltip.tooltip-bottom - {:class (classnames - :selected - (and radius-1? (not radius-4?))) + {:class (dom/classnames + :selected + (and radius-1? (not radius-4?))) :alt (tr "workspace.options.radius.all-corners") :on-click on-switch-to-radius-1} i/radius-1] [:div.radius-icon.tooltip.tooltip-bottom - {:class (classnames - :selected - (and radius-4? (not radius-1?))) + {:class (dom/classnames + :selected + (and radius-4? (not radius-1?))) :alt (tr "workspace.options.radius.single-corners") :on-click on-switch-to-radius-4} i/radius-4]] - (if radius-1? - [:div.input-element.mini - [:> numeric-input - {:placeholder "--" - :min 0 - :on-click select-all - :on-change on-radius-1-change - :value (attr->string :rx values)}]] + (if radius-1? + [:div.input-element.mini + [:> numeric-input + {:placeholder "--" + :min 0 + :on-click select-all + :on-change on-radius-1-change + :value (attr->string :rx values)}]] - [:* + [:* [:div.input-element.mini [:> numeric-input {:placeholder "--" @@ -367,66 +362,66 @@ :on-change on-radius-r4-change :value (attr->string :r4 values)}]]])]))]] - ;; CONSTRAINTS - (when in-frame? - [:div.element-set - [:div.element-set-title - [:span (tr "workspace.options.constraints")]] + ;; CONSTRAINTS + (when in-frame? + [:div.element-set + [:div.element-set-title + [:span (tr "workspace.options.constraints")]] - [:div.element-set-content - [:div.row-flex.align-top + [:div.element-set-content + [:div.row-flex.align-top - [:div.constraints-widget - [:div.constraints-box] - [:div.constraint-button.top - {:class (classnames :active (or (= constraints-v :top) - (= constraints-v :topbottom))) - :on-click (on-constraint-button-clicked :top)}] - [:div.constraint-button.bottom - {:class (classnames :active (or (= constraints-v :bottom) - (= constraints-v :topbottom))) - :on-click (on-constraint-button-clicked :bottom)}] - [:div.constraint-button.left - {:class (classnames :active (or (= constraints-h :left) - (= constraints-h :leftright))) - :on-click (on-constraint-button-clicked :left)}] - [:div.constraint-button.right - {:class (classnames :active (or (= constraints-h :right) - (= constraints-h :leftright))) - :on-click (on-constraint-button-clicked :right)}] - [:div.constraint-button.centerv - {:class (classnames :active (= constraints-v :center)) - :on-click (on-constraint-button-clicked :centerv)}] - [:div.constraint-button.centerh - {:class (classnames :active (= constraints-h :center)) - :on-click (on-constraint-button-clicked :centerh)}]] + [:div.constraints-widget + [:div.constraints-box] + [:div.constraint-button.top + {:class (dom/classnames :active (or (= constraints-v :top) + (= constraints-v :topbottom))) + :on-click (on-constraint-button-clicked :top)}] + [:div.constraint-button.bottom + {:class (dom/classnames :active (or (= constraints-v :bottom) + (= constraints-v :topbottom))) + :on-click (on-constraint-button-clicked :bottom)}] + [:div.constraint-button.left + {:class (dom/classnames :active (or (= constraints-h :left) + (= constraints-h :leftright))) + :on-click (on-constraint-button-clicked :left)}] + [:div.constraint-button.right + {:class (dom/classnames :active (or (= constraints-h :right) + (= constraints-h :leftright))) + :on-click (on-constraint-button-clicked :right)}] + [:div.constraint-button.centerv + {:class (dom/classnames :active (= constraints-v :center)) + :on-click (on-constraint-button-clicked :centerv)}] + [:div.constraint-button.centerh + {:class (dom/classnames :active (= constraints-h :center)) + :on-click (on-constraint-button-clicked :centerh)}]] - [:div.constraints-form - [:div.row-flex - [:span.left-right i/full-screen] - [:select.input-select {:on-change (on-constraint-select-changed :constraints-h) - :value (d/name constraints-h "scale")} - (when (= constraints-h :multiple) - [:option {:value ""} (tr "settings.multiple")]) - [:option {:value "left"} (tr "workspace.options.constraints.left")] - [:option {:value "right"} (tr "workspace.options.constraints.right")] - [:option {:value "leftright"} (tr "workspace.options.constraints.leftright")] - [:option {:value "center"} (tr "workspace.options.constraints.center")] - [:option {:value "scale"} (tr "workspace.options.constraints.scale")]]] - [:div.row-flex - [:span.top-bottom i/full-screen] - [:select.input-select {:on-change (on-constraint-select-changed :constraints-v) - :value (d/name constraints-v "scale")} - (when (= constraints-v :multiple) - [:option {:value ""} (tr "settings.multiple")]) - [:option {:value "top"} (tr "workspace.options.constraints.top")] - [:option {:value "bottom"} (tr "workspace.options.constraints.bottom")] - [:option {:value "topbottom"} (tr "workspace.options.constraints.topbottom")] - [:option {:value "center"} (tr "workspace.options.constraints.center")] - [:option {:value "scale"} (tr "workspace.options.constraints.scale")]]] - (when first-level? - [:div.row-flex - [:div.fix-when {:class (classnames :active (:fixed-scroll values)) - :on-click on-fixed-scroll-clicked} - i/pin - [:span (tr "workspace.options.constraints.fix-when-scrolling")]]])]]]])])) + [:div.constraints-form + [:div.row-flex + [:span.left-right i/full-screen] + [:select.input-select {:on-change (on-constraint-select-changed :constraints-h) + :value (d/name constraints-h "scale")} + (when (= constraints-h :multiple) + [:option {:value ""} (tr "settings.multiple")]) + [:option {:value "left"} (tr "workspace.options.constraints.left")] + [:option {:value "right"} (tr "workspace.options.constraints.right")] + [:option {:value "leftright"} (tr "workspace.options.constraints.leftright")] + [:option {:value "center"} (tr "workspace.options.constraints.center")] + [:option {:value "scale"} (tr "workspace.options.constraints.scale")]]] + [:div.row-flex + [:span.top-bottom i/full-screen] + [:select.input-select {:on-change (on-constraint-select-changed :constraints-v) + :value (d/name constraints-v "scale")} + (when (= constraints-v :multiple) + [:option {:value ""} (tr "settings.multiple")]) + [:option {:value "top"} (tr "workspace.options.constraints.top")] + [:option {:value "bottom"} (tr "workspace.options.constraints.bottom")] + [:option {:value "topbottom"} (tr "workspace.options.constraints.topbottom")] + [:option {:value "center"} (tr "workspace.options.constraints.center")] + [:option {:value "scale"} (tr "workspace.options.constraints.scale")]]] + (when first-level? + [:div.row-flex + [:div.fix-when {:class (dom/classnames :active (:fixed-scroll values)) + :on-click on-fixed-scroll-clicked} + i/pin + [:span (tr "workspace.options.constraints.fix-when-scrolling")]]])]]]])])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs index 9b6e487353..5cd11f6f3a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs @@ -6,19 +6,18 @@ (ns app.main.ui.workspace.sidebar.options.menus.shadow (:require - [rumext.alpha :as mf] [app.common.data :as d] [app.common.uuid :as uuid] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.undo :as dwu] [app.main.store :as st] - [app.main.ui.icons :as i] [app.main.ui.components.numeric-input :refer [numeric-input]] + [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.common :refer [advanced-options]] [app.main.ui.workspace.sidebar.options.rows.color-row :refer [color-row]] [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t]])) + [app.util.i18n :as i18n :refer [tr]] + [rumext.alpha :as mf])) (def shadow-attrs [:shadow]) @@ -38,8 +37,7 @@ (mf/defc shadow-entry [{:keys [ids index value]}] - (let [locale (i18n/use-locale) - open-shadow (mf/use-state false) + (let [open-shadow (mf/use-state false) basic-offset-x-ref (mf/use-ref nil) basic-offset-y-ref (mf/use-ref nil) @@ -52,7 +50,7 @@ remove-shadow-by-index (fn [values index] (->> (d/enumerate values) - (filterv (fn [[idx s]] (not= idx index))) + (filterv (fn [[idx _]] (not= idx index))) (mapv second))) on-remove-shadow @@ -61,7 +59,7 @@ (st/emit! (dch/update-shapes ids #(update % :shadow remove-shadow-by-index index) )))) select-text - (fn [ref] (fn [event] (dom/select-text! (mf/ref-val ref)))) + (fn [ref] (fn [_] (dom/select-text! (mf/ref-val ref)))) update-attr (fn update-attr @@ -86,12 +84,12 @@ detach-color (fn [index] - (fn [color opacity] - (if-not (string? (:color value)) + (fn [_color _opacity] + (when-not (string? (:color value)) (st/emit! (dch/update-shapes - ids - #(assoc-in % [:shadow index :color] - (dissoc (:color value) :id :file-id))))))) + ids + #(assoc-in % [:shadow index :color] + (dissoc (:color value) :id :file-id))))))) toggle-visibility (fn [index] @@ -122,8 +120,8 @@ :on-change (fn [event] (let [value (-> event dom/get-target dom/get-value d/read-string)] (st/emit! (dch/update-shapes ids #(assoc-in % [:shadow index :style] value)))))} - [:option {:value ":drop-shadow"} (t locale "workspace.options.shadow-options.drop-shadow")] - [:option {:value ":inner-shadow"} (t locale "workspace.options.shadow-options.inner-shadow")]] + [:option {:value ":drop-shadow"} (tr "workspace.options.shadow-options.drop-shadow")] + [:option {:value ":inner-shadow"} (tr "workspace.options.shadow-options.inner-shadow")]] [:div.element-set-actions [:div.element-set-actions-button {:on-click (toggle-visibility index)} @@ -142,8 +140,8 @@ :on-change (fn [event] (let [value (-> event dom/get-target dom/get-value d/read-string)] (st/emit! (dch/update-shapes ids #(assoc-in % [:shadow index :style] value)))))} - [:option {:value ":drop-shadow"} (t locale "workspace.options.shadow-options.drop-shadow")] - [:option {:value ":inner-shadow"} (t locale "workspace.options.shadow-options.inner-shadow")]]] + [:option {:value ":drop-shadow"} (tr "workspace.options.shadow-options.drop-shadow")] + [:option {:value ":inner-shadow"} (tr "workspace.options.shadow-options.inner-shadow")]]] [:div.row-grid-2 [:div.input-element @@ -153,7 +151,7 @@ :on-click (select-text adv-offset-x-ref) :on-change (update-attr index :offset-x valid-number? basic-offset-x-ref) :value (:offset-x value)}] - [:span.after (t locale "workspace.options.shadow-options.offsetx")]] + [:span.after (tr "workspace.options.shadow-options.offsetx")]] [:div.input-element [:> numeric-input {:ref adv-offset-y-ref @@ -162,7 +160,7 @@ :on-click (select-text adv-offset-y-ref) :on-change (update-attr index :offset-y valid-number? basic-offset-y-ref) :value (:offset-y value)}] - [:span.after (t locale "workspace.options.shadow-options.offsety")]]] + [:span.after (tr "workspace.options.shadow-options.offsety")]]] [:div.row-grid-2 [:div.input-element @@ -173,7 +171,7 @@ :on-change (update-attr index :blur valid-number? basic-blur-ref) :min 0 :value (:blur value)}] - [:span.after (t locale "workspace.options.shadow-options.blur")]] + [:span.after (tr "workspace.options.shadow-options.blur")]] [:div.input-element [:> numeric-input {:ref adv-spread-ref @@ -183,7 +181,7 @@ :on-change (update-attr index :spread valid-number?) :min 0 :value (:spread value)}] - [:span.after (t locale "workspace.options.shadow-options.spread")]]] + [:span.after (tr "workspace.options.shadow-options.spread")]]] [:div.color-row-wrap [:& color-row {:color (if (string? (:color value)) @@ -197,10 +195,8 @@ :on-close #(st/emit! (dwu/commit-undo-transaction))}]]]])) (mf/defc shadow-menu [{:keys [ids type values] :as props}] - (let [locale (i18n/use-locale) - on-remove-all-shadows - (fn [event] - (st/emit! (dch/update-shapes ids #(dissoc % :shadow) ))) + (let [on-remove-all-shadows + (fn [_] (st/emit! (dch/update-shapes ids #(dissoc % :shadow)))) on-add-shadow (fn [] @@ -209,9 +205,9 @@ [:div.element-set-title [:span (case type - :multiple (t locale "workspace.options.shadow-options.title.multiple") - :group (t locale "workspace.options.shadow-options.title.group") - (t locale "workspace.options.shadow-options.title"))] + :multiple (tr "workspace.options.shadow-options.title.multiple") + :group (tr "workspace.options.shadow-options.title.group") + (tr "workspace.options.shadow-options.title"))] (when-not (= :multiple (:shadow values)) [:div.add-page {:on-click on-add-shadow} i/close])] @@ -220,14 +216,14 @@ (= :multiple (:shadow values)) [:div.element-set-content [:div.element-set-options-group - [:div.element-set-label (t locale "settings.multiple")] + [:div.element-set-label (tr "settings.multiple")] [:div.element-set-actions [:div.element-set-actions-button {:on-click on-remove-all-shadows} i/minus]]]] - (not (empty? (:shadow values))) + (seq (:shadow values)) [:div.element-set-content - (for [[index {:keys [id] :as value}] (d/enumerate (:shadow values []))] + (for [[index value] (d/enumerate (:shadow values []))] [:& shadow-entry {:key (str "shadow-" index) :ids ids :value value diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/stroke.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/stroke.cljs index 14ae0a784c..beee39a191 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/stroke.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/stroke.cljs @@ -6,21 +6,18 @@ (ns app.main.ui.workspace.sidebar.options.menus.stroke (:require - [cuerdas.core :as str] - [rumext.alpha :as mf] [app.common.data :as d] [app.common.math :as math] - [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.colors :as dc] + [app.main.data.workspace.undo :as dwu] [app.main.store :as st] [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.rows.color-row :refer [color-row]] - [app.util.data :refer [classnames]] [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [tr t]] - [app.util.object :as obj])) + [app.util.i18n :as i18n :refer [tr]] + [cuerdas.core :as str] + [rumext.alpha :as mf])) (def stroke-attrs [:stroke-style @@ -47,11 +44,10 @@ (mf/defc stroke-menu {::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values" "type"]))]} [{:keys [ids type values] :as props}] - (let [locale (i18n/use-locale) - label (case type - :multiple (t locale "workspace.options.selection-stroke") - :group (t locale "workspace.options.group-stroke") - (t locale "workspace.options.stroke")) + (let [label (case type + :multiple (tr "workspace.options.selection-stroke") + :group (tr "workspace.options.group-stroke") + (tr "workspace.options.stroke")) show-options (not= (:stroke-style values :none) :none) @@ -65,7 +61,7 @@ (mf/use-callback (mf/deps ids) (fn [color] - (let [remove-multiple (fn [[key value]] (not= value :multiple)) + (let [remove-multiple (fn [[_ value]] (not= value :multiple)) color (into {} (filter remove-multiple) color)] (st/emit! (dc/change-stroke ids color))))) @@ -99,7 +95,7 @@ (st/emit! (dch/update-shapes ids #(assoc % :stroke-width value)))))) on-add-stroke - (fn [event] + (fn [_] (st/emit! (dch/update-shapes ids #(assoc % :stroke-style :solid :stroke-color "#000000" @@ -107,19 +103,19 @@ :stroke-width 1)))) on-del-stroke - (fn [event] + (fn [_] (st/emit! (dch/update-shapes ids #(assoc % :stroke-style :none)))) on-open-picker (mf/use-callback (mf/deps ids) - (fn [value opacity id file-id] + (fn [_value _opacity _id _file-id] (st/emit! (dwu/start-undo-transaction)))) on-close-picker (mf/use-callback (mf/deps ids) - (fn [value opacity id file-id] + (fn [_value _opacity _id _file-id] (st/emit! (dwu/commit-undo-transaction))))] (if show-options @@ -139,29 +135,29 @@ ;; Stroke Width, Alignment & Style [:div.row-flex [:div.input-element - {:class (classnames :pixels (not= (:stroke-width values) :multiple))} + {:class (dom/classnames :pixels (not= (:stroke-width values) :multiple))} [:input.input-text {:type "number" :min "0" :value (-> (:stroke-width values) width->string) - :placeholder (t locale "settings.multiple") + :placeholder (tr "settings.multiple") :on-change on-stroke-width-change}]] [:select#style.input-select {:value (enum->string (:stroke-alignment values)) :on-change on-stroke-alignment-change} (when (= (:stroke-alignment values) :multiple) [:option {:value ""} "--"]) - [:option {:value ":center"} (t locale "workspace.options.stroke.center")] - [:option {:value ":inner"} (t locale "workspace.options.stroke.inner")] - [:option {:value ":outer"} (t locale "workspace.options.stroke.outer")]] + [:option {:value ":center"} (tr "workspace.options.stroke.center")] + [:option {:value ":inner"} (tr "workspace.options.stroke.inner")] + [:option {:value ":outer"} (tr "workspace.options.stroke.outer")]] [:select#style.input-select {:value (enum->string (:stroke-style values)) :on-change on-stroke-style-change} (when (= (:stroke-style values) :multiple) [:option {:value ""} "--"]) - [:option {:value ":solid"} (t locale "workspace.options.stroke.solid")] - [:option {:value ":dotted"} (t locale "workspace.options.stroke.dotted")] - [:option {:value ":dashed"} (t locale "workspace.options.stroke.dashed")] - [:option {:value ":mixed"} (t locale "workspace.options.stroke.mixed")]]]]] + [:option {:value ":solid"} (tr "workspace.options.stroke.solid")] + [:option {:value ":dotted"} (tr "workspace.options.stroke.dotted")] + [:option {:value ":dashed"} (tr "workspace.options.stroke.dashed")] + [:option {:value ":mixed"} (tr "workspace.options.stroke.mixed")]]]]] ;; NO STROKE [:div.element-set diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/svg_attrs.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/svg_attrs.cljs index bd6dc955ae..3d953a699b 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/svg_attrs.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/svg_attrs.cljs @@ -6,16 +6,14 @@ (ns app.main.ui.workspace.sidebar.options.menus.svg-attrs (:require - [cuerdas.core :as str] [app.common.data :as d] - [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] [app.main.store :as st] + [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.rows.input-row :refer [input-row]] [app.util.dom :as dom] [app.util.i18n :refer [tr]] - [rumext.alpha :as mf] - [app.main.ui.icons :as i])) + [rumext.alpha :as mf])) (mf/defc attribute-value [{:keys [attr value on-change on-delete] :as props}] (let [handle-change @@ -55,7 +53,7 @@ :on-change on-change :on-delete on-delete}])])])) -(mf/defc svg-attrs-menu [{:keys [ids type values]}] +(mf/defc svg-attrs-menu [{:keys [ids values]}] (let [handle-change (mf/use-callback (mf/deps ids) @@ -86,7 +84,7 @@ [:div.element-set-title [:span (tr "workspace.sidebar.options.svg-attrs.title")]] - (for [[index [attr-key attr-value]] (d/enumerate (:svg-attrs values))] + (for [[attr-key attr-value] (:svg-attrs values)] [:& attribute-value {:key attr-key :attr [attr-key] :value attr-value diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs index 3cda61c33a..d9f9ec455b 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs @@ -7,9 +7,8 @@ (ns app.main.ui.workspace.sidebar.options.menus.text (:require [app.common.data :as d] - [app.common.uuid :as uuid] [app.common.text :as txt] - [app.main.data.workspace.common :as dwc] + [app.common.uuid :as uuid] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.texts :as dwt] @@ -81,10 +80,10 @@ (def attrs (d/concat #{} shape-attrs root-attrs paragraph-attrs text-attrs)) (mf/defc text-align-options - [{:keys [ids values on-change] :as props}] + [{:keys [values on-change] :as props}] (let [{:keys [text-align]} values handle-change - (fn [event new-align] + (fn [_ new-align] (on-change {:text-align new-align}))] ;; --- Align @@ -111,9 +110,9 @@ i/text-align-justify]])) (mf/defc text-direction-options - [{:keys [ids values on-change] :as props}] + [{:keys [values on-change] :as props}] (let [direction (:text-direction values) - handle-change (fn [event val] + handle-change (fn [_ val] (on-change {:text-direction val}))] ;; --- Align [:div.align-icons @@ -129,11 +128,11 @@ i/text-direction-rtl]])) (mf/defc vertical-align - [{:keys [shapes ids values on-change] :as props}] + [{:keys [values on-change] :as props}] (let [{:keys [vertical-align]} values vertical-align (or vertical-align "top") handle-change - (fn [event new-align] + (fn [_ new-align] (on-change {:vertical-align new-align}))] [:div.align-icons @@ -154,11 +153,10 @@ i/align-bottom]])) (mf/defc grow-options - [{:keys [ids values on-change] :as props}] - (let [to-single-value (fn [coll] (if (> (count coll) 1) nil (first coll))) - grow-type (->> values :grow-type) + [{:keys [ids values] :as props}] + (let [grow-type (:grow-type values) handle-change-grow - (fn [event grow-type] + (fn [_ grow-type] (st/emit! (dch/update-shapes ids #(assoc % :grow-type grow-type))))] [:div.align-icons @@ -179,13 +177,10 @@ i/auto-height]])) (mf/defc text-decoration-options - [{:keys [ids values on-change] :as props}] - (let [{:keys [text-decoration]} values - - text-decoration (or text-decoration "none") - + [{:keys [values on-change] :as props}] + (let [text-decoration (or (:text-decoration values) "none") handle-change - (fn [event type] + (fn [_ type] (on-change {:text-decoration type}))] [:div.align-icons [:span.tooltip.tooltip-bottom @@ -262,18 +257,18 @@ (get typographies (:typography-ref-id values))))) on-convert-to-typography - (fn [event] + (fn [_] (let [setted-values (-> (d/without-nils values) (select-keys (d/concat text-font-attrs text-spacing-attrs text-transform-attrs))) typography (merge txt/default-typography setted-values) - typography (generate-typography-name typography)] - (let [id (uuid/next)] - (st/emit! (dwl/add-typography (assoc typography :id id) false)) - (run! #(emit-update! % {:typography-ref-id id - :typography-ref-file file-id}) ids)))) + typography (generate-typography-name typography) + id (uuid/next)] + (st/emit! (dwl/add-typography (assoc typography :id id) false)) + (run! #(emit-update! % {:typography-ref-id id + :typography-ref-file file-id}) ids))) handle-detach-typography (mf/use-callback diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/typography.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/typography.cljs index 36e8acdf0b..ca5e77631a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/typography.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/typography.cljs @@ -7,30 +7,24 @@ (ns app.main.ui.workspace.sidebar.options.menus.typography (:require ["react-virtualized" :as rvt] - [app.common.exceptions :as ex] [app.common.data :as d] + [app.common.exceptions :as ex] [app.common.pages :as cp] [app.common.text :as txt] - [app.main.data.workspace.texts :as dwt] [app.main.data.shortcuts :as dsc] - [app.main.data.fonts :as df] - [app.main.data.workspace :as dw] [app.main.fonts :as fonts] - [app.main.refs :as refs] [app.main.store :as st] - [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.editable-select :refer [editable-select]] [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.common :refer [advanced-options]] [app.util.dom :as dom] - [app.util.object :as obj] - [app.util.timers :as tm] - [app.util.keyboard :as kbd] [app.util.i18n :as i18n :refer [tr]] + [app.util.keyboard :as kbd] + [app.util.object :as obj] [app.util.router :as rt] - [app.util.timers :as ts] - [goog.events :as events] + [app.util.timers :as tm] [cuerdas.core :as str] + [goog.events :as events] [rumext.alpha :as mf])) (defn- attr->string [value] @@ -88,11 +82,11 @@ (comp (filter #(contains? backends (:backend %)))))] (into [] xform fonts))) -(defn- toggle-backend - [backends id] - (if (contains? backends id) - (disj backends id) - (conj backends id))) +;; (defn- toggle-backend +;; [backends id] +;; (if (contains? backends id) +;; (disj backends id) +;; (conj backends id))) (mf/defc font-selector [{:keys [on-select on-close current-font] :as props}] @@ -101,7 +95,6 @@ flist (mf/use-ref) input (mf/use-ref) - ddown (mf/use-ref) fonts (mf/use-memo (mf/deps @state) #(filter-fonts @state @fonts/fonts)) @@ -237,7 +230,7 @@ :current? (= (:id font) (:id selected))}]))) (mf/defc font-options - [{:keys [editor ids values on-change] :as props}] + [{:keys [values on-change] :as props}] (let [{:keys [font-id font-size font-variant-id]} values font-id (or font-id (:font-id txt/default-text-attrs)) @@ -261,15 +254,6 @@ :font-weight weight :font-style style})))) - on-font-family-change - (mf/use-callback - (mf/deps fonts change-font) - (fn [event] - (let [new-font-id (dom/get-target-val event)] - (when-not (str/empty? new-font-id) - (let [font (get fonts new-font-id)] - (fonts/ensure-loaded! new-font-id (partial change-font new-font-id))))))) - on-font-size-change (mf/use-callback (mf/deps on-change) @@ -345,7 +329,7 @@ (mf/defc spacing-options - [{:keys [editor ids values on-change] :as props}] + [{:keys [values on-change] :as props}] (let [{:keys [line-height letter-spacing]} values @@ -385,13 +369,10 @@ :on-change #(handle-change % :letter-spacing)}]]])) (mf/defc text-transform-options - [{:keys [editor ids values on-change] :as props}] - (let [{:keys [text-transform]} values - - text-transform (or text-transform "none") - + [{:keys [values on-change] :as props}] + (let [text-transform (or (:text-transform values) "none") handle-change - (fn [event type] + (fn [_ type] (on-change {:text-transform type}))] [:div.align-icons [:span.tooltip.tooltip-bottom @@ -461,7 +442,7 @@ (mf/deps focus-name?) (fn [] (when focus-name? - (ts/schedule + (tm/schedule #(when-let [node (mf/ref-val name-input-ref)] (dom/focus! node) (dom/select-text! node)))))) @@ -539,7 +520,7 @@ :ref name-input-ref :default-value (cp/merge-path-item (:path typography) (:name typography)) :on-blur on-name-blur}] - + [:div.element-set-actions-button {:on-click #(reset! open? false)} i/actions]]] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs index b42996c5de..c44d93ad28 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/input_row.cljs @@ -6,12 +6,10 @@ (ns app.main.ui.workspace.sidebar.options.rows.input-row (:require - [rumext.alpha :as mf] - [app.common.data :as d] + [app.main.ui.components.editable-select :refer [editable-select]] [app.main.ui.components.numeric-input :refer [numeric-input]] [app.main.ui.components.select :refer [select]] - [app.main.ui.components.editable-select :refer [editable-select]] - [app.util.dom :as dom])) + [rumext.alpha :as mf])) (mf/defc input-row [{:keys [label options value class min max on-change type placeholder]}] [:div.row-flex.input-row diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs index 8c8888aaa1..df658997dd 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs @@ -6,14 +6,14 @@ (ns app.main.ui.workspace.sidebar.options.shapes.circle (:require - [rumext.alpha :as mf] - [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] - [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] - [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] - [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] + [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] + [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]] + [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] + [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] + [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] [app.main.ui.workspace.sidebar.options.menus.svg-attrs :refer [svg-attrs-menu]] - [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]])) + [rumext.alpha :as mf])) (mf/defc options [{:keys [shape] :as props}] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs index 3990546eef..6f7280e688 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs @@ -6,23 +6,22 @@ (ns app.main.ui.workspace.sidebar.options.shapes.frame (:require - [rumext.alpha :as mf] [app.common.data :as d] - [app.util.dom :as dom] - [app.common.geom.point :as gpt] - [app.util.i18n :refer [tr]] [app.common.math :as math] - [app.main.store :as st] [app.main.data.workspace :as udw] - [app.main.ui.icons :as i] + [app.main.store :as st] [app.main.ui.components.dropdown :refer [dropdown]] [app.main.ui.components.numeric-input :refer [numeric-input]] - [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] - [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] - [app.main.ui.workspace.sidebar.options.menus.frame-grid :refer [frame-grid]] - [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] + [app.main.ui.icons :as i] [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] - [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]])) + [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] + [app.main.ui.workspace.sidebar.options.menus.frame-grid :refer [frame-grid]] + [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]] + [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] + [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] + [app.util.dom :as dom] + [app.util.i18n :refer [tr]] + [rumext.alpha :as mf])) (declare +size-presets+) @@ -50,7 +49,7 @@ (st/emit! (udw/update-dimensions [(:id shape)] attr value))) on-proportion-lock-change - (fn [event] + (fn [_] (st/emit! (udw/set-shape-proportion-lock (:id shape) (not (:proportion-lock shape))))) on-position-change @@ -82,8 +81,8 @@ :on-click #(on-preset-selected (:width size-preset) (:height size-preset))} (:name size-preset) [:span (:width size-preset) " x " (:height size-preset)]]))]]] - [:span.orientation-icon {on-click #(on-orientation-clicked :vert)} i/size-vert] - [:span.orientation-icon {on-click #(on-orientation-clicked :horiz)} i/size-horiz]] + [:span.orientation-icon {:on-click #(on-orientation-clicked :vert)} i/size-vert] + [:span.orientation-icon {:on-click #(on-orientation-clicked :horiz)} i/size-horiz]] ;; WIDTH & HEIGHT [:div.row-flex diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs index 49d87ddebd..eae1f87461 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs @@ -6,18 +6,18 @@ (ns app.main.ui.workspace.sidebar.options.shapes.group (:require - [rumext.alpha :as mf] [app.common.data :as d] - [app.main.ui.workspace.sidebar.options.shapes.multiple :refer [get-attrs]] - [app.main.ui.workspace.sidebar.options.menus.measures :refer [measures-menu]] + [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] [app.main.ui.workspace.sidebar.options.menus.component :refer [component-attrs component-menu]] [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-menu]] - [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] + [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-menu]] + [app.main.ui.workspace.sidebar.options.menus.measures :refer [measures-menu]] [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-menu]] - [app.main.ui.workspace.sidebar.options.menus.text :as ot] [app.main.ui.workspace.sidebar.options.menus.svg-attrs :refer [svg-attrs-menu]] - [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]])) + [app.main.ui.workspace.sidebar.options.menus.text :as ot] + [app.main.ui.workspace.sidebar.options.shapes.multiple :refer [get-attrs]] + [rumext.alpha :as mf])) (mf/defc options {::mf/wrap [mf/memo] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs index 4db2bb0290..a506b56b80 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs @@ -6,11 +6,11 @@ (ns app.main.ui.workspace.sidebar.options.shapes.image (:require - [rumext.alpha :as mf] + [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] + [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]] [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] - [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] - [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]])) + [rumext.alpha :as mf])) (mf/defc options [{:keys [shape] :as props}] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs index 86a0490531..42d822850f 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs @@ -147,7 +147,7 @@ :else (attrs/get-attrs-multi [v1 v2] attrs))) extract-attrs - (fn [[ids values] {:keys [id type shapes content] :as shape}] + (fn [[ids values] {:keys [id type content] :as shape}] (let [props (get-in type->props [type attr-type])] (case props :ignore [ids values] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs index 00d09a17ec..1139f19b92 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs @@ -6,15 +6,14 @@ (ns app.main.ui.workspace.sidebar.options.shapes.path (:require - [rumext.alpha :as mf] - [app.common.data :as d] - [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] - [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] - [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] - [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] + [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] + [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]] + [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] + [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] + [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] [app.main.ui.workspace.sidebar.options.menus.svg-attrs :refer [svg-attrs-menu]] - [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]])) + [rumext.alpha :as mf])) (mf/defc options [{:keys [shape] :as props}] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs index bf8a4ac47e..17d1c991a4 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs @@ -6,14 +6,14 @@ (ns app.main.ui.workspace.sidebar.options.shapes.rect (:require - [rumext.alpha :as mf] - [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] - [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] - [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] - [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] + [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] + [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]] + [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] + [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] + [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] [app.main.ui.workspace.sidebar.options.menus.svg-attrs :refer [svg-attrs-menu]] - [app.main.ui.workspace.sidebar.options.menus.layer :refer [layer-attrs layer-menu]])) + [rumext.alpha :as mf])) (mf/defc options {::mf/wrap [mf/memo]} diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs index 01494340fc..6d6ae07356 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs @@ -6,22 +6,23 @@ (ns app.main.ui.workspace.sidebar.options.shapes.svg-raw (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [app.util.data :as d] - [app.util.color :as uc] - [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] - [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] - [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] - [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] [app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]] - [app.main.ui.workspace.sidebar.options.menus.svg-attrs :refer [svg-attrs-menu]])) + [app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs fill-menu]] + [app.main.ui.workspace.sidebar.options.menus.measures :refer [measure-attrs measures-menu]] + [app.main.ui.workspace.sidebar.options.menus.shadow :refer [shadow-menu]] + [app.main.ui.workspace.sidebar.options.menus.stroke :refer [stroke-attrs stroke-menu]] + [app.main.ui.workspace.sidebar.options.menus.svg-attrs :refer [svg-attrs-menu]] + [app.util.color :as uc] + [app.util.data :as d] + [cuerdas.core :as str] + [rumext.alpha :as mf])) ;; This is a list of svg tags that can be grouped in shape-container ;; this allows them to have gradients, shadows and masks (def svg-elements #{:svg :g :circle :ellipse :image :line :path :polygon :polyline :rect :symbol :text :textPath}) -(defn hex->number [hex] 1) +(defn hex->number [_] 1) + (defn shorthex->longhex [hex] (let [[_ r g b] hex] (str "#" r r g g b b))) @@ -45,10 +46,10 @@ (defn get-fill-values [shape] - (let [fill-values (or (select-keys shape fill-attrs)) - color (-> (or (get-in shape [:content :attrs :fill]) - (get-in shape [:content :attrs :style :fill])) - (parse-color)) + (let [fill-values (select-keys shape fill-attrs) + color (-> (or (get-in shape [:content :attrs :fill]) + (get-in shape [:content :attrs :style :fill])) + (parse-color)) fill-values (if (and (empty? fill-values) color) {:fill-color (:color color) @@ -57,10 +58,10 @@ fill-values)) (defn get-stroke-values [shape] - (let [stroke-values (or (select-keys shape stroke-attrs)) - color (-> (or (get-in shape [:content :attrs :stroke]) - (get-in shape [:content :attrs :style :stroke])) - (parse-color)) + (let [stroke-values (select-keys shape stroke-attrs) + color (-> (or (get-in shape [:content :attrs :stroke]) + (get-in shape [:content :attrs :style :stroke])) + (parse-color)) stroke-color (:color color "#000000") stroke-opacity (:opacity color 1) @@ -90,7 +91,7 @@ (let [ids [(:id shape)] type (:type shape) - {:keys [tag attrs] :as content} (:content shape) + {:keys [tag] :as content} (:content shape) measure-values (select-keys shape measure-attrs) fill-values (get-fill-values shape) stroke-values (get-stroke-values shape)] diff --git a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs index ae5ac0ed8c..65cf1c0fef 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/sitemap.cljs @@ -18,8 +18,6 @@ [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] [app.util.keyboard :as kbd] - [app.util.router :as rt] - [cuerdas.core :as str] [okulary.core :as l] [rumext.alpha :as mf])) @@ -86,12 +84,12 @@ on-drop (mf/use-callback (mf/deps id) - (fn [side {:keys [id name] :as data}] + (fn [side {:keys [id] :as data}] (let [index (if (= :bot side) (inc index) index)] (st/emit! (dw/relocate-page id index))))) on-duplicate - (fn [event] + (fn [_] (st/emit! (dw/duplicate-page id))) [dprops dref] @@ -169,7 +167,7 @@ st/state =)) (mf/defc page-item-wrapper - [{:keys [file-id page-id index deletable? selected?] :as props}] + [{:keys [page-id index deletable? selected?] :as props}] (let [page-ref (mf/use-memo (mf/deps page-id) #(make-page-ref page-id)) page (mf/deref page-ref)] [:& page-item {:page page @@ -197,7 +195,7 @@ ;; --- Sitemap Toolbox (mf/defc sitemap - [{:keys [layout] :as props}] + [] (let [file (mf/deref refs/workspace-file) create (mf/use-callback (mf/deps file) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 6a79f9c1e1..a56430b5f0 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -7,11 +7,9 @@ (ns app.main.ui.workspace.viewport (:require [app.common.data :as d] - [app.common.geom.shapes :as gsh] [app.common.pages :as cp] [app.main.refs :as refs] [app.main.ui.context :as ctx] - [app.main.ui.context :as muc] [app.main.ui.measurements :as msr] [app.main.ui.shapes.embed :as embed] [app.main.ui.shapes.export :as use] @@ -79,7 +77,6 @@ ;; REFS viewport-ref (mf/use-ref nil) - zoom-view-ref (mf/use-ref nil) render-ref (mf/use-ref nil) ;; VARS @@ -139,7 +136,9 @@ show-presence? page-id show-prototypes? (= options-mode :prototype) show-selection-handlers? (seq selected) - show-snap-distance? (and (contains? layout :dynamic-alignment) (= transform :move) (not (empty? selected))) + show-snap-distance? (and (contains? layout :dynamic-alignment) + (= transform :move) + (seq selected)) show-snap-points? (and (or (contains? layout :dynamic-alignment) (contains? layout :snap-grid)) (or drawing-obj transform)) diff --git a/frontend/src/app/main/ui/workspace/viewport/actions.cljs b/frontend/src/app/main/ui/workspace/viewport/actions.cljs index a32ae106e3..9fdcdbbf55 100644 --- a/frontend/src/app/main/ui/workspace/viewport/actions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/actions.cljs @@ -12,10 +12,10 @@ [app.main.data.workspace :as dw] [app.main.data.workspace.drawing :as dd] [app.main.data.workspace.libraries :as dwl] + [app.main.data.workspace.path :as dwdp] [app.main.store :as st] [app.main.streams :as ms] [app.main.ui.workspace.viewport.utils :as utils] - [app.main.data.workspace.path :as dwdp] [app.util.dom :as dom] [app.util.dom.dnd :as dnd] [app.util.keyboard :as kbd] @@ -290,8 +290,7 @@ (st/emit! (ms/->KeyboardEvent :up key shift? ctrl? alt? meta?)))))) (defn on-mouse-move [viewport-ref zoom] - (let [last-position (mf/use-var nil) - viewport (mf/ref-val viewport-ref)] + (let [last-position (mf/use-var nil)] (mf/use-callback (mf/deps zoom) (fn [event] @@ -477,7 +476,7 @@ (defn on-resize [viewport-ref] (mf/use-callback - (fn [event] + (fn [_] (let [node (mf/ref-val viewport-ref) prnt (dom/get-parent node) size (dom/get-client-size prnt)] diff --git a/frontend/src/app/main/ui/workspace/viewport/drawarea.cljs b/frontend/src/app/main/ui/workspace/viewport/drawarea.cljs index 20d6e49600..740c6956c3 100644 --- a/frontend/src/app/main/ui/workspace/viewport/drawarea.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/drawarea.cljs @@ -7,17 +7,12 @@ (ns app.main.ui.workspace.viewport.drawarea "Drawing components." (:require - [rumext.alpha :as mf] - [app.main.data.workspace :as dw] - [app.main.data.workspace.drawing :as dd] - [app.main.store :as st] - [app.main.ui.workspace.shapes :as shapes] - [app.main.ui.shapes.path :refer [path-shape]] - [app.main.ui.workspace.shapes.path.editor :refer [path-editor]] [app.common.geom.shapes :as gsh] - [app.common.data :as d] - [app.util.dom :as dom] - [app.util.i18n :as i18n :refer [t]])) + [app.common.math :as mth] + [app.main.ui.shapes.path :refer [path-shape]] + [app.main.ui.workspace.shapes :as shapes] + [app.main.ui.workspace.shapes.path.editor :refer [path-editor]] + [rumext.alpha :as mf])) (declare generic-draw-area) (declare path-draw-area) @@ -38,8 +33,8 @@ [{:keys [shape zoom]}] (let [{:keys [x y width height]} (:selrect (gsh/transform-shape shape))] (when (and x y - (not (d/nan? x)) - (not (d/nan? y))) + (not (mth/nan? x)) + (not (mth/nan? y))) [:rect.main {:x x :y y :width width diff --git a/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs b/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs index d9b147bbc3..5cd49cc681 100644 --- a/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs @@ -6,18 +6,17 @@ (ns app.main.ui.workspace.viewport.frame-grid (:require - [rumext.alpha :as mf] - [okulary.core :as l] - [app.main.refs :as refs] - [app.common.math :as mth] - [app.common.pages :as cp] [app.common.geom.shapes :as gsh] + [app.common.math :as mth] + [app.common.uuid :as uuid] + [app.main.refs :as refs] [app.util.geom.grid :as gg] - [app.common.uuid :as uuid])) + [okulary.core :as l] + [rumext.alpha :as mf])) (mf/defc square-grid [{:keys [frame zoom grid] :as props}] (let [grid-id (mf/use-memo #(uuid/next)) - {:keys [color size] :as params} (-> grid :params) + {:keys [size] :as params} (-> grid :params) {color-value :color color-opacity :opacity} (-> grid :params :color) ;; Support for old color format color-value (or color-value (:value (get-in grid [:params :color :value])))] @@ -43,7 +42,7 @@ :height (:height frame) :fill (str "url(#" grid-id ")")}]])) -(mf/defc layout-grid [{:keys [key frame zoom grid]}] +(mf/defc layout-grid [{:keys [key frame grid]}] (let [{color-value :color color-opacity :opacity} (-> grid :params :color) ;; Support for old color format color-value (or color-value (:value (get-in grid [:params :color :value]))) diff --git a/frontend/src/app/main/ui/workspace/viewport/gradients.cljs b/frontend/src/app/main/ui/workspace/viewport/gradients.cljs index e65bc12d05..48a8668754 100644 --- a/frontend/src/app/main/ui/workspace/viewport/gradients.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/gradients.cljs @@ -7,21 +7,19 @@ (ns app.main.ui.workspace.viewport.gradients "Gradients handlers and renders" (:require - [rumext.alpha :as mf] - [cuerdas.core :as str] - [beicon.core :as rx] - [okulary.core :as l] - [app.common.math :as mth] - [app.common.geom.shapes :as gsh] - [app.common.geom.point :as gpt] [app.common.geom.matrix :as gmt] - [app.util.dom :as dom] - [app.main.store :as st] + [app.common.geom.point :as gpt] + [app.common.geom.shapes :as gsh] + [app.common.math :as mth] + [app.main.data.workspace.colors :as dc] [app.main.refs :as refs] + [app.main.store :as st] [app.main.streams :as ms] - [app.main.data.modal :as modal] - [app.main.data.workspace.common :as dwc] - [app.main.data.workspace.colors :as dc])) + [app.util.dom :as dom] + [beicon.core :as rx] + [cuerdas.core :as str] + [okulary.core :as l] + [rumext.alpha :as mf])) (def gradient-line-stroke-width 2) (def gradient-line-stroke-color "white") @@ -94,7 +92,7 @@ on-click on-mouse-down on-mouse-up]}] [:g {:filter (str/fmt "url(#%s)" filter-id) :transform (gmt/rotate-matrix angle point)} - + [:image {:href checkboard :x (- (:x point) (/ gradient-square-width 2 zoom)) :y (- (:y point) (/ gradient-square-width 2 zoom)) @@ -127,7 +125,7 @@ (mf/defc gradient-handler-transformed [{:keys [from-p to-p width-p from-color to-color zoom editing - on-change-start on-change-finish on-change-width on-change-stop-color]}] + on-change-start on-change-finish on-change-width]}] (let [moving-point (mf/use-var nil) angle (+ 90 (gpt/angle from-p to-p)) @@ -138,7 +136,7 @@ (st/emit! (dc/select-gradient-stop (case position :from-p 0 :to-p 1))))) - + on-mouse-down (fn [position event] (dom/stop-propagation event) (dom/prevent-default event) @@ -148,7 +146,7 @@ :from-p 0 :to-p 1))))) - on-mouse-up (fn [position event] + on-mouse-up (fn [_position event] (dom/stop-propagation event) (dom/prevent-default event) (reset! moving-point nil))] diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index bbda478b0c..1d9c98b1a6 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -37,8 +37,6 @@ (mf/deps on-key-down on-key-up on-mouse-move on-mouse-wheel on-resize on-paste) (fn [] (let [node (mf/ref-val viewport-ref) - prnt (dom/get-parent node) - keys [(events/listen js/document EventType.KEYDOWN on-key-down) (events/listen js/document EventType.KEYUP on-key-up) (events/listen node EventType.MOUSEMOVE on-mouse-move) @@ -90,7 +88,8 @@ (hooks/use-stream ms/keyboard-alt #(reset! alt? %)) (hooks/use-stream ms/keyboard-ctrl #(reset! ctrl? %))) -(defn setup-hover-shapes [page-id move-stream selected objects transform selected ctrl? hover hover-ids zoom] +;; TODO: revisit the arguments, looks like `selected` is not necessary here +(defn setup-hover-shapes [page-id move-stream _selected objects transform selected ctrl? hover hover-ids zoom] (let [query-point (mf/use-callback (mf/deps page-id) @@ -111,12 +110,7 @@ ;; When transforming shapes we stop querying the worker (rx/filter #(not (some? (mf/ref-val transform-ref)))) (rx/switch-map query-point)) - - roots (mf/use-memo - (mf/deps selected objects) - (fn [] - (let [roots-ids (cp/clean-loops objects selected)] - (->> roots-ids (mapv #(get objects %))))))] + ] (mf/use-effect (mf/deps transform) diff --git a/frontend/src/app/main/ui/workspace/viewport/interactions.cljs b/frontend/src/app/main/ui/workspace/viewport/interactions.cljs index 4e126fe878..ca0d1b0e2e 100644 --- a/frontend/src/app/main/ui/workspace/viewport/interactions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/interactions.cljs @@ -7,15 +7,11 @@ (ns app.main.ui.workspace.viewport.interactions "Visually show shape interactions in workspace" (:require - [app.common.geom.point :as gpt] - [app.common.geom.shapes :as geom] [app.main.data.workspace :as dw] [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.workspace.viewport.outline :refer [outline]] - [app.util.data :as dt] [app.util.dom :as dom] - [app.util.keyboard :as kbd] [cuerdas.core :as str] [rumext.alpha :as mf] )) @@ -24,14 +20,11 @@ [shape] (first (filter #(= (:event-type %) :click) (:interactions shape)))) - (defn- on-mouse-down - [event {:keys [id type] :as shape} selected] - (do - (dom/stop-propagation event) - (st/emit! (dw/select-shape id)) - (st/emit! (dw/start-create-interaction)))) - + [event {:keys [id] :as shape}] + (dom/stop-propagation event) + (st/emit! (dw/select-shape id)) + (st/emit! (dw/start-create-interaction))) (defn connect-to-shape "Calculate the best position to draw an interaction line @@ -118,7 +111,7 @@ (mf/defc interaction-path - [{:keys [orig-shape dest-shape dest-point selected selected? zoom] :as props}] + [{:keys [orig-shape dest-shape dest-point selected? zoom] :as props}] (let [[orig-pos orig-x orig-y dest-pos dest-x dest-y] (if dest-shape (connect-to-shape orig-shape dest-shape) @@ -138,9 +131,9 @@ :pointer-events "visible" :stroke-width (/ 2 zoom) :d pdata - :on-mouse-down #(on-mouse-down % orig-shape selected)}] + :on-mouse-down #(on-mouse-down % orig-shape)}] - [:g {:on-mouse-down #(on-mouse-down % orig-shape selected)} + [:g {:on-mouse-down #(on-mouse-down % orig-shape)} [:path {:stroke "#31EFB8" :fill "none" :pointer-events "visible" @@ -161,11 +154,11 @@ (mf/defc interaction-handle - [{:keys [shape selected zoom] :as props}] + [{:keys [shape zoom] :as props}] (let [shape-rect (:selrect shape) handle-x (+ (:x shape-rect) (:width shape-rect)) handle-y (+ (:y shape-rect) (/ (:height shape-rect) 2))] - [:g {:on-mouse-down #(on-mouse-down % shape selected)} + [:g {:on-mouse-down #(on-mouse-down % shape)} [:& interaction-marker {:x handle-x :y handle-y :arrow-dir :right diff --git a/frontend/src/app/main/ui/workspace/viewport/outline.cljs b/frontend/src/app/main/ui/workspace/viewport/outline.cljs index a024a7d3a9..44d644f6b0 100644 --- a/frontend/src/app/main/ui/workspace/viewport/outline.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/outline.cljs @@ -9,8 +9,8 @@ [app.common.geom.shapes :as gsh] [app.common.pages :as cp] [app.main.refs :as refs] - [app.util.path.format :as upf] [app.util.object :as obj] + [app.util.path.format :as upf] [clojure.set :as set] [rumext.alpha :as mf] [rumext.util :refer [map->obj]])) @@ -29,7 +29,7 @@ (mf/deps shape) #(when path? (upf/format-path (:content shape)))) - {:keys [id x y width height selrect]} shape + {:keys [x y width height selrect]} shape outline-type (case (:type shape) :circle "ellipse" diff --git a/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs b/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs index d504faf56b..f6d85e32cf 100644 --- a/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs @@ -7,9 +7,7 @@ (ns app.main.ui.workspace.viewport.path-actions (:require [app.main.data.workspace.path :as drp] - [app.main.data.workspace.path.helpers :as wph] [app.main.data.workspace.path.shortcuts :as sc] - [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.icons :as i] [app.main.ui.workspace.shapes.path.common :as pc] @@ -20,8 +18,8 @@ (defn check-enabled [content selected-points] (let [segments (upt/get-segments content selected-points) num-points (count selected-points) - points-selected? (not (empty? selected-points)) - segments-selected? (not (empty? segments))] + points-selected? (seq selected-points) + segments-selected? (seq segments)] {:make-corner points-selected? :make-curve points-selected? :add-node segments-selected? @@ -31,8 +29,7 @@ :separate-nodes segments-selected?})) (mf/defc path-actions [{:keys [shape]}] - (let [id (mf/deref refs/selected-edition) - {:keys [edit-mode selected-points snap-toggled] :as all} (mf/deref pc/current-edit-path-ref) + (let [{:keys [edit-mode selected-points snap-toggled] :as all} (mf/deref pc/current-edit-path-ref) content (:content shape) enabled-buttons @@ -42,66 +39,66 @@ on-select-draw-mode (mf/use-callback - (fn [event] + (fn [_] (st/emit! (drp/change-edit-mode :draw)))) - + on-select-edit-mode (mf/use-callback - (fn [event] + (fn [_] (st/emit! (drp/change-edit-mode :move)))) - + on-add-node (mf/use-callback (mf/deps (:add-node enabled-buttons)) - (fn [event] + (fn [_] (when (:add-node enabled-buttons) (st/emit! (drp/add-node))))) - + on-remove-node (mf/use-callback (mf/deps (:remove-node enabled-buttons)) - (fn [event] + (fn [_] (when (:remove-node enabled-buttons) (st/emit! (drp/remove-node))))) - + on-merge-nodes (mf/use-callback (mf/deps (:merge-nodes enabled-buttons)) - (fn [event] + (fn [_] (when (:merge-nodes enabled-buttons) (st/emit! (drp/merge-nodes))))) - + on-join-nodes (mf/use-callback (mf/deps (:join-nodes enabled-buttons)) - (fn [event] + (fn [_] (when (:join-nodes enabled-buttons) (st/emit! (drp/join-nodes))))) - + on-separate-nodes (mf/use-callback (mf/deps (:separate-nodes enabled-buttons)) - (fn [event] + (fn [_] (when (:separate-nodes enabled-buttons) (st/emit! (drp/separate-nodes))))) on-make-corner (mf/use-callback (mf/deps (:make-corner enabled-buttons)) - (fn [event] + (fn [_] (when (:make-corner enabled-buttons) (st/emit! (drp/make-corner))))) - + on-make-curve (mf/use-callback (mf/deps (:make-curve enabled-buttons)) - (fn [event] + (fn [_] (when (:make-curve enabled-buttons) (st/emit! (drp/make-curve))))) on-toggle-snap (mf/use-callback - (fn [event] + (fn [_] (st/emit! (drp/toggle-snap)))) ] @@ -121,7 +118,7 @@ :alt (tr "workspace.path.actions.draw-nodes" (sc/get-tooltip :draw-nodes)) :on-click on-select-edit-mode} i/pointer-inner]] - + [:div.viewport-actions-group ;; Add Node [:div.viewport-actions-entry.tooltip.tooltip-bottom diff --git a/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs b/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs index 9601b2b982..1373a151e0 100644 --- a/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs @@ -7,21 +7,18 @@ (ns app.main.ui.workspace.viewport.pixel-overlay (:require [app.common.uuid :as uuid] - [app.main.data.workspace.colors :as dwc] [app.main.data.modal :as modal] + [app.main.data.workspace.colors :as dwc] [app.main.refs :as refs] [app.main.store :as st] - [app.main.ui.context :as muc] [app.main.ui.cursors :as cur] [app.main.ui.workspace.shapes :refer [shape-wrapper frame-wrapper]] [app.util.dom :as dom] [app.util.keyboard :as kbd] [app.util.object :as obj] - [app.util.timers :as timers] [beicon.core :as rx] [cuerdas.core :as str] [goog.events :as events] - [okulary.core :as l] [promesa.core :as p] [rumext.alpha :as mf]) (:import goog.events.EventType)) @@ -54,11 +51,8 @@ {::mf/wrap-props false} [props] (let [vport (unchecked-get props "vport") - vbox (unchecked-get props "vbox") viewport-ref (unchecked-get props "viewport-ref") viewport-node (mf/ref-val viewport-ref) - options (unchecked-get props "options") - svg-ref (mf/use-ref nil) canvas-ref (mf/use-ref nil) img-ref (mf/use-ref nil) @@ -67,11 +61,11 @@ handle-keydown (mf/use-callback (fn [event] - (when (and (kbd/esc? event)) - (do (dom/stop-propagation event) - (dom/prevent-default event) - (st/emit! (dwc/stop-picker)) - (modal/disallow-click-outside!))))) + (when (kbd/esc? event) + (dom/stop-propagation event) + (dom/prevent-default event) + (st/emit! (dwc/stop-picker)) + (modal/disallow-click-outside!)))) handle-mouse-move-picker (mf/use-callback diff --git a/frontend/src/app/main/ui/workspace/viewport/selection.cljs b/frontend/src/app/main/ui/workspace/viewport/selection.cljs index 3b18129437..ad547c9e51 100644 --- a/frontend/src/app/main/ui/workspace/viewport/selection.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/selection.cljs @@ -10,23 +10,15 @@ [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as geom] - [app.common.math :as mth] - [app.common.uuid :as uuid] [app.main.data.workspace :as dw] - [app.main.data.workspace.common :as dwc] [app.main.refs :as refs] [app.main.store :as st] - [app.main.streams :as ms] [app.main.ui.cursors :as cur] - [app.main.ui.hooks :as hooks] [app.main.ui.workspace.shapes.path.editor :refer [path-editor]] - [app.util.data :as d] [app.util.debug :refer [debug?]] [app.util.dom :as dom] [app.util.object :as obj] - [beicon.core :as rx] [cuerdas.core :as str] - [potok.core :as ptk] [rumext.alpha :as mf] [rumext.util :refer [map->obj]])) @@ -178,17 +170,12 @@ :cursor cursor} :on-mouse-down #(on-resize {:x cx' :y cy'} %)}]) - (let [rot-square (case position - :top-left 0 - :top-right 90 - :bottom-right 180 - :bottom-left 270)] - [:circle {:on-mouse-down #(on-resize {:x cx' :y cy'} %) - :r (/ resize-point-circle-radius zoom) - :cx cx' - :cy cy' - :style {:fill (if (debug? :resize-handler) "red" "none") - :cursor cursor}}]) + [:circle {:on-mouse-down #(on-resize {:x cx' :y cy'} %) + :r (/ resize-point-circle-radius zoom) + :cx cx' + :cy cy' + :style {:fill (if (debug? :resize-handler) "red" "none") + :cursor cursor}}] )])) (mf/defc resize-side-handler @@ -232,7 +219,7 @@ (mf/defc controls {::mf/wrap-props false} [props] - (let [{:keys [overflow-text type] :as shape} (obj/get props "shape") + (let [{:keys [overflow-text] :as shape} (obj/get props "shape") zoom (obj/get props "zoom") color (obj/get props "color") on-move-selected (obj/get props "on-move-selected") @@ -275,7 +262,7 @@ ;; TODO: add specs for clarity (mf/defc text-edition-selection-handlers - [{:keys [shape zoom color] :as props}] + [{:keys [shape color] :as props}] (let [{:keys [x y width height]} shape] [:g.controls [:rect.main {:x x :y y @@ -299,12 +286,6 @@ shape-center (geom/center-shape shape) - hover-id (-> (mf/deref refs/current-hover) first) - hover-id (when-not (d/seek #(= hover-id (:id %)) shapes) hover-id) - hover-shape (mf/deref (refs/object-by-id hover-id)) - - vbox (mf/deref refs/vbox) - on-resize (fn [current-position initial-position event] (dom/stop-propagation event) (st/emit! (dw/start-resize current-position initial-position selected shape))) @@ -329,14 +310,6 @@ (let [shape-id (:id shape) shape (geom/transform-shape shape {:round-coords? false}) - frame (mf/deref (refs/object-by-id (:frame-id shape))) - frame (when-not (= (:id frame) uuid/zero) frame) - vbox (mf/deref refs/vbox) - - hover-id (-> (mf/deref refs/current-hover) first) - hover-id (when-not (= shape-id hover-id) hover-id) - hover-shape (mf/deref (refs/object-by-id hover-id)) - shape' (if (debug? :simple-selection) (geom/setup {:type :rect} (geom/selection-rect [shape])) shape) on-resize (fn [current-position initial-position event] (dom/stop-propagation event) @@ -357,7 +330,7 @@ {::mf/wrap [mf/memo]} [{:keys [shapes selected edition zoom disable-handlers on-move-selected] :as props}] (let [num (count shapes) - {:keys [id type] :as shape} (first shapes) + {:keys [type] :as shape} (first shapes) color (if (or (> num 1) (nil? (:shape-ref shape))) selection-rect-color-normal diff --git a/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs b/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs index ae6c809ad3..a5c85499f9 100644 --- a/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs @@ -7,15 +7,11 @@ (ns app.main.ui.workspace.viewport.snap-distances (:require [app.common.data :as d] - [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.common.math :as mth] [app.common.pages :as cp] - [app.common.uuid :as uuid] [app.main.refs :as refs] - [app.main.snap :as snap] [app.main.worker :as uw] - [app.util.geom.snap-points :as sp] [beicon.core :as rx] [clojure.set :as set] [cuerdas.core :as str] @@ -275,21 +271,20 @@ update-shape (fn [shape] (-> shape (update :modifiers merge (:modifiers local)) - gsh/transform-shape))] - (let [selrect (->> selected-shapes (map update-shape) gsh/selection-rect) - key (->> selected (map str) (str/join "-"))] - [:g.distance - [:& shape-distance - {:selrect selrect - :page-id page-id - :frame frame - :zoom zoom - :coord :x - :selected selected}] - [:& shape-distance - {:selrect selrect - :page-id page-id - :frame frame - :zoom zoom - :coord :y - :selected selected}]]))) + gsh/transform-shape)) + selrect (->> selected-shapes (map update-shape) gsh/selection-rect)] + [:g.distance + [:& shape-distance + {:selrect selrect + :page-id page-id + :frame frame + :zoom zoom + :coord :x + :selected selected}] + [:& shape-distance + {:selrect selrect + :page-id page-id + :frame frame + :zoom zoom + :coord :y + :selected selected}]])) diff --git a/frontend/src/app/main/ui/workspace/viewport/snap_points.cljs b/frontend/src/app/main/ui/workspace/viewport/snap_points.cljs index f9cc2707c7..5fad2a5c1d 100644 --- a/frontend/src/app/main/ui/workspace/viewport/snap_points.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/snap_points.cljs @@ -6,12 +6,10 @@ (ns app.main.ui.workspace.viewport.snap-points (:require - [app.common.pages :as cp] - [app.common.math :as mth] [app.common.data :as d] - [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] - [app.main.refs :as refs] + [app.common.math :as mth] + [app.common.pages :as cp] [app.main.snap :as snap] [app.util.geom.snap-points :as sp] [beicon.core :as rx] @@ -106,7 +104,7 @@ (hash-map coord fixedv (flip coord) maxv)])))) (mf/defc snap-feedback - [{:keys [shapes page-id filter-shapes zoom modifiers] :as props}] + [{:keys [shapes filter-shapes zoom modifiers] :as props}] (let [state (mf/use-state []) subject (mf/use-memo #(rx/subject)) diff --git a/frontend/src/app/main/ui/workspace/viewport/utils.cljs b/frontend/src/app/main/ui/workspace/viewport/utils.cljs index 092da6bbce..384f381177 100644 --- a/frontend/src/app/main/ui/workspace/viewport/utils.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/utils.cljs @@ -6,14 +6,14 @@ (ns app.main.ui.workspace.viewport.utils (:require - [app.util.dom :as dom] - [app.common.geom.point :as gpt] - [cuerdas.core :as str] [app.common.data :as d] + [app.common.geom.point :as gpt] [app.main.ui.cursors :as cur] - )) + [app.util.dom :as dom] + [cuerdas.core :as str])) -(defn update-transform [node shapes modifiers] +;; TODO: looks like first argument is not necessary. +(defn update-transform [_node shapes modifiers] (doseq [{:keys [id type]} shapes] (let [shape-node (dom/get-element (str "shape-" id)) @@ -30,7 +30,8 @@ shape-node)] (dom/set-attribute node "transform" (str (:displacement modifiers))))))) -(defn remove-transform [node shapes] +;; TODO: looks like first argument is not necessary. +(defn remove-transform [_node shapes] (doseq [{:keys [id type]} shapes] (when-let [node (dom/get-element (str "shape-" id))] (let [node (if (= :frame type) (.-parentNode node) node)] diff --git a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs index 3faa465556..b2851340f3 100644 --- a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs @@ -16,7 +16,6 @@ [app.main.ui.hooks :as hooks] [app.main.ui.workspace.viewport.path-actions :refer [path-actions]] [app.util.dom :as dom] - [app.util.object :as obj] [rumext.alpha :as mf])) (mf/defc pixel-grid @@ -110,13 +109,13 @@ on-pointer-enter (mf/use-callback (mf/deps (:id frame) on-frame-enter) - (fn [event] + (fn [_] (on-frame-enter (:id frame)))) on-pointer-leave (mf/use-callback (mf/deps (:id frame) on-frame-leave) - (fn [event] + (fn [_] (on-frame-leave (:id frame))))] [:text {:x 0 diff --git a/frontend/src/app/main/worker.cljs b/frontend/src/app/main/worker.cljs index de564536dc..c9004a9f00 100644 --- a/frontend/src/app/main/worker.cljs +++ b/frontend/src/app/main/worker.cljs @@ -6,9 +6,7 @@ (ns app.main.worker (:require - [cljs.spec.alpha :as s] [app.config :as cfg] - [app.common.spec :as us] [app.util.worker :as uw])) (defn on-error diff --git a/frontend/src/app/util/avatars.cljs b/frontend/src/app/util/avatars.cljs index ff5afc9e16..acca7decaa 100644 --- a/frontend/src/app/util/avatars.cljs +++ b/frontend/src/app/util/avatars.cljs @@ -6,9 +6,8 @@ (ns app.util.avatars (:require - [cuerdas.core :as str] [app.util.object :as obj] - ["randomcolor" :as rdcolor])) + [cuerdas.core :as str])) (defn generate* [{:keys [name color size] diff --git a/frontend/src/app/util/code_gen.cljs b/frontend/src/app/util/code_gen.cljs index ae07021839..a4069406c3 100644 --- a/frontend/src/app/util/code_gen.cljs +++ b/frontend/src/app/util/code_gen.cljs @@ -33,7 +33,7 @@ color {:color (:stroke-color shape) :opacity (:stroke-opacity shape) :gradient (:stroke-color-gradient shape)}] - (if-not (= :none (:stroke-style shape)) + (when-not (= :none (:stroke-style shape)) (str/format "%spx %s %s" width style (uc/color->background color))))) (def styles-data diff --git a/frontend/src/app/util/color.cljs b/frontend/src/app/util/color.cljs index 8899e6f23b..3c540dc3e8 100644 --- a/frontend/src/app/util/color.cljs +++ b/frontend/src/app/util/color.cljs @@ -7,9 +7,8 @@ (ns app.util.color "Color conversion utils." (:require - [cuerdas.core :as str] - [app.common.math :as math] [app.util.object :as obj] + [cuerdas.core :as str] [goog.color :as gcolor])) (defn rgb->str @@ -31,7 +30,7 @@ [v] (try (into [] (gcolor/hexToRgb v)) - (catch :default e [0 0 0]))) + (catch :default _e [0 0 0]))) (defn rgb->hex [[r g b]] @@ -49,7 +48,7 @@ (defn hex->hsl [hex] (try (into [] (gcolor/hexToHsl hex)) - (catch :default e [0 0 0]))) + (catch :default _e [0 0 0]))) (defn hex->hsla [^string data ^number opacity] @@ -96,7 +95,7 @@ c (nth v 2)] (str a a b b c c)) - :default + :else v)) (defn prepend-hash @@ -135,7 +134,7 @@ :else "transparent"))) -(defn multiple? [{:keys [id file-id value color gradient opacity]}] +(defn multiple? [{:keys [id file-id value color gradient]}] (or (= value :multiple) (= color :multiple) (= gradient :multiple) @@ -144,7 +143,7 @@ (defn color? [^string color-str] (and (not (nil? color-str)) - (not (empty? color-str)) + (seq color-str) (gcolor/isValidColor color-str))) (defn parse-color [^string color-str] diff --git a/frontend/src/app/util/data.cljs b/frontend/src/app/util/data.cljs index c070e31c66..fb0007bb35 100644 --- a/frontend/src/app/util/data.cljs +++ b/frontend/src/app/util/data.cljs @@ -39,7 +39,7 @@ (reduce #(dissoc! %1 %2) (transient data) keys))) (defn dissoc-in - [m [k & ks :as keys]] + [m [k & ks :as _keys]] (if ks (if-let [nextmap (get m k)] (let [newmap (dissoc-in nextmap ks)] diff --git a/frontend/src/app/util/debug.cljs b/frontend/src/app/util/debug.cljs index cfffaf3f33..c3ee88d9f9 100644 --- a/frontend/src/app/util/debug.cljs +++ b/frontend/src/app/util/debug.cljs @@ -1,9 +1,9 @@ (ns app.util.debug "Debugging utils" (:require - [app.util.timers :as timers] - [app.util.object :as obj] [app.common.math :as mth] + [app.util.object :as obj] + [app.util.timers :as timers] [cljs.pprint :refer [pprint]])) (def debug-options #{:bounding-boxes :group :events :rotation-handler :resize-handler :selection-center :export :import #_:simple-selection}) diff --git a/frontend/src/app/util/dom/dnd.cljs b/frontend/src/app/util/dom/dnd.cljs index 3f681b99b4..03bb612008 100644 --- a/frontend/src/app/util/dom/dnd.cljs +++ b/frontend/src/app/util/dom/dnd.cljs @@ -7,9 +7,8 @@ (ns app.util.dom.dnd "Drag & Drop interop helpers." (:require - [app.common.transit :as t] - [app.util.data :refer (read-string)] - [cuerdas.core :as str])) + [app.common.transit :as t] + [cuerdas.core :as str])) ;; This is the official documentation for the dnd API: ;; https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API @@ -40,7 +39,7 @@ (defn trace ;; This function is useful to debug the dnd interface behaviour when something weird occurs. [event data label] - (let [currentTarget (.-currentTarget event) + (let [;;currentTarget (.-currentTarget event) relatedTarget (.-relatedTarget event)] (js/console.log label diff --git a/frontend/src/app/util/forms.cljs b/frontend/src/app/util/forms.cljs index 9db9ca89ad..d2b5d5ce99 100644 --- a/frontend/src/app/util/forms.cljs +++ b/frontend/src/app/util/forms.cljs @@ -10,17 +10,14 @@ [app.common.spec :as us] [app.util.dom :as dom] [app.util.i18n :refer [tr]] - [app.util.timers :as tm] - [beicon.core :as rx] [cljs.spec.alpha :as s] [cuerdas.core :as str] - [potok.core :as ptk] [rumext.alpha :as mf])) ;; --- Handlers Helpers (defn- interpret-problem - [acc {:keys [path pred val via in] :as problem}] + [acc {:keys [path pred via] :as problem}] (cond (and (empty? path) (list? pred) @@ -28,8 +25,8 @@ (let [path (conj path (last (last pred)))] (assoc-in acc path {:code ::missing :type :builtin})) - (and (not (empty? path)) - (not (empty? via))) + (and (seq path) + (seq via)) (assoc-in acc path {:code (last via) :type :builtin}) :else acc)) @@ -37,7 +34,7 @@ (declare create-form-mutator) (defn use-form - [& {:keys [spec validators initial] :as opts}] + [& {:keys [initial] :as opts}] (let [state (mf/useState 0) render (aget state 1) state-ref (mf/use-ref {:data (if (fn? initial) (initial) initial) @@ -126,9 +123,8 @@ (defn on-input-blur [form field] - (fn [event] - (let [target (dom/get-target event) - touched (get @form :touched)] + (fn [_] + (let [touched (get @form :touched)] (when-not (get touched field) (swap! form assoc-in [:touched field] true))))) @@ -136,9 +132,8 @@ (mf/defc field-error [{:keys [form field type] - :or {only (constantly true)} :as props}] - (let [{:keys [code message] :as error} (get-in form [:errors field]) + (let [{:keys [message] :as error} (get-in form [:errors field]) touched? (get-in form [:touched field]) show? (and touched? error message (cond diff --git a/frontend/src/app/util/geom/grid.cljs b/frontend/src/app/util/geom/grid.cljs index bd8f58bd19..97496d18f6 100644 --- a/frontend/src/app/util/geom/grid.cljs +++ b/frontend/src/app/util/geom/grid.cljs @@ -6,8 +6,8 @@ (ns app.util.geom.grid (:require - [app.common.math :as mth] - [app.common.geom.point :as gpt])) + [app.common.geom.point :as gpt] + [app.common.math :as mth])) (def ^:private default-items 12) @@ -35,7 +35,7 @@ margin) gutter (if (= :stretch type) (/ (- width (* item-width size) (* margin 2)) (dec size)) gutter) next-x (fn [cur-val] (+ initial-offset x (* (+ item-width gutter) cur-val))) - next-y (fn [cur-val] y)] + next-y (fn [_] y)] [size item-width item-height next-x next-y])) (defn- calculate-row-grid @@ -49,7 +49,7 @@ :center (/ (- height (* item-height size) (* gutter (dec size))) 2) margin) gutter (if (= :stretch type) (/ (- height (* item-height size) (* margin 2)) (dec size)) gutter) - next-x (fn [cur-val] x) + next-x (fn [_] x) next-y (fn [cur-val] (+ initial-offset y (* (+ item-height gutter) cur-val)))] [size item-width item-height next-x next-y])) @@ -91,7 +91,7 @@ ([shape coord] (mapcat #(grid-snap-points shape % coord) (:grids shape))) - ([shape {:keys [type display params] :as grid} coord] + ([shape {:keys [type params] :as grid} coord] (when (:display grid) (case type :square diff --git a/frontend/src/app/util/geom/snap_points.cljs b/frontend/src/app/util/geom/snap_points.cljs index b9525be109..669a291130 100644 --- a/frontend/src/app/util/geom/snap_points.cljs +++ b/frontend/src/app/util/geom/snap_points.cljs @@ -6,10 +6,8 @@ (ns app.util.geom.snap-points (:require - [cljs.spec.alpha :as s] - [clojure.set :as set] - [app.common.geom.shapes :as gsh] - [app.common.geom.point :as gpt])) + [app.common.geom.point :as gpt] + [app.common.geom.shapes :as gsh])) (defn- selrect-snap-points [{:keys [x y width height]}] #{(gpt/point x y) diff --git a/frontend/src/app/util/http.cljs b/frontend/src/app/util/http.cljs index b1213bd1c0..8c613bb33c 100644 --- a/frontend/src/app/util/http.cljs +++ b/frontend/src/app/util/http.cljs @@ -13,7 +13,6 @@ [app.config :as cfg] [app.util.cache :as c] [app.util.globals :as globals] - [app.util.object :as obj] [app.util.time :as dt] [app.util.webapi :as wapi] [beicon.core :as rx] @@ -55,8 +54,8 @@ {"x-frontend-version" (:full @cfg/version)}) (defn fetch - [{:keys [method uri query headers body timeout mode omit-default-headers] - :or {timeout 10000 mode :cors headers {}}}] + [{:keys [method uri query headers body mode omit-default-headers] + :or {mode :cors headers {}}}] (rx/Observable.create (fn [subscriber] (let [controller (js/AbortController.) @@ -134,7 +133,7 @@ (assoc headers "content-type" "application/transit+json")))) (defn conditional-decode-transit - [{:keys [body headers status] :as response}] + [{:keys [body headers] :as response}] (let [contentype (get headers "content-type")] (if (and (str/starts-with? contentype "application/transit+json") (pos? (count body))) diff --git a/frontend/src/app/util/i18n.cljs b/frontend/src/app/util/i18n.cljs index 870467abdd..1eaf407e32 100644 --- a/frontend/src/app/util/i18n.cljs +++ b/frontend/src/app/util/i18n.cljs @@ -11,7 +11,6 @@ [app.util.globals :as globals] [app.util.object :as obj] [app.util.storage :refer [storage]] - [beicon.core :as rx] [cuerdas.core :as str] [goog.object :as gobj] [okulary.core :as l] @@ -91,7 +90,7 @@ (deftype C [val] IDeref - (-deref [o] val)) + (-deref [_] val)) (defn ^boolean c? [r] diff --git a/frontend/src/app/util/import/parser.cljc b/frontend/src/app/util/import/parser.cljc index 7855017a1b..1ffc490d46 100644 --- a/frontend/src/app/util/import/parser.cljc +++ b/frontend/src/app/util/import/parser.cljc @@ -8,7 +8,6 @@ (:require [app.common.data :as d] [app.common.geom.matrix :as gmt] - [app.common.geom.shapes :as gsh] [app.common.geom.point :as gpt] [app.common.uuid :as uuid] [app.util.color :as uc] diff --git a/frontend/src/app/util/logging.clj b/frontend/src/app/util/logging.clj index 421a9d16e4..f888f1bc8a 100644 --- a/frontend/src/app/util/logging.clj +++ b/frontend/src/app/util/logging.clj @@ -6,9 +6,10 @@ (ns app.util.logging) -(defn- log-expr [form level keyvals] +(defn- log-expr [_form level keyvals] (let [keyvals-map (apply array-map keyvals) - formatter (::formatter keyvals-map 'identity)] + ;;formatter (::formatter keyvals-map 'identity) + ] `(log ~(::logger keyvals-map (str *ns*)) ~level ~(-> keyvals-map diff --git a/frontend/src/app/util/logging.cljs b/frontend/src/app/util/logging.cljs index 559c911b00..b2bfaaff99 100644 --- a/frontend/src/app/util/logging.cljs +++ b/frontend/src/app/util/logging.cljs @@ -11,11 +11,9 @@ (ns app.util.logging (:require - [goog.log :as glog] - [goog.debug.Console :as Console] + [app.common.exceptions :as ex] [cuerdas.core :as str] - [goog.object :as gobj]) - (:import [goog.debug Console]) + [goog.log :as glog]) (:require-macros [app.util.logging])) (defn- logger-name @@ -158,7 +156,7 @@ specials)))))) (defn default-handler - [{:keys [message exception level logger-name]}] + [{:keys [message level logger-name]}] (let [header-styles (str "font-weight: 600; color: " (level->color level)) normal-styles (str "font-weight: 300; color: " (get colors :gray6)) level-name (level->short-name level) @@ -174,7 +172,7 @@ (doseq [[type n v] specials] (case type :js (js/console.log n v) - :error (if (instance? cljs.core.ExceptionInfo v) + :error (if (ex/ex-info? v) (js/console.error (pr-str v)) (js/console.error v)))) (js/console.groupEnd message)) diff --git a/frontend/src/app/util/object.cljs b/frontend/src/app/util/object.cljs index 12aabcb609..0abdd9c90d 100644 --- a/frontend/src/app/util/object.cljs +++ b/frontend/src/app/util/object.cljs @@ -8,9 +8,8 @@ "A collection of helpers for work with javascript objects." (:refer-clojure :exclude [set! get get-in merge clone contains?]) (:require - [cuerdas.core :as str] - [goog.object :as gobj] - ["lodash/omit" :as omit])) + ["lodash/omit" :as omit] + [cuerdas.core :as str])) (defn new [] #js {}) diff --git a/frontend/src/app/util/path/commands.cljs b/frontend/src/app/util/path/commands.cljs index f284a457c5..84a7725ef8 100644 --- a/frontend/src/app/util/path/commands.cljs +++ b/frontend/src/app/util/path/commands.cljs @@ -7,12 +7,7 @@ (ns app.util.path.commands (:require [app.common.data :as d] - [app.common.geom.point :as gpt] - [app.common.geom.shapes.path :as gshp] - [app.util.svg :as usvg] - [cuerdas.core :as str] - [clojure.set :as set] - [app.common.math :as mth])) + [app.common.geom.point :as gpt])) (defn command->point ([prev-pos {:keys [relative params] :as command}] @@ -179,7 +174,7 @@ "Returns the commands involving a point with its indices" [content point] (->> (d/enumerate content) - (filterv (fn [[idx cmd]] (= (command->point cmd) point))))) + (filterv (fn [[_ cmd]] (= (command->point cmd) point))))) (defn prefix->coords [prefix] @@ -192,7 +187,7 @@ (when (and (some? index) (some? prefix) (contains? content index)) - (let [[cx cy :as coords] (prefix->coords prefix)] + (let [[cx cy] (prefix->coords prefix)] (if (= :curve-to (get-in content [index :command])) (gpt/point (get-in content [index :params cx]) (get-in content [index :params cy])) diff --git a/frontend/src/app/util/path/format.cljs b/frontend/src/app/util/path/format.cljs index a79a5a7e50..4b0640f4eb 100644 --- a/frontend/src/app/util/path/format.cljs +++ b/frontend/src/app/util/path/format.cljs @@ -6,10 +6,8 @@ (ns app.util.path.format (:require - [app.common.data :as d] [app.util.path.commands :as upc] - [cuerdas.core :as str] - [app.util.path.subpaths :as ups])) + [cuerdas.core :as str])) (defn command->param-list [command] (let [params (:params command)] @@ -47,7 +45,7 @@ (:x params) "," (:y params))))) -(defn command->string [{:keys [command relative params] :as entry}] +(defn command->string [{:keys [command relative] :as entry}] (let [command-str (case command :move-to "M" :close-path "Z" diff --git a/frontend/src/app/util/path/geom.cljs b/frontend/src/app/util/path/geom.cljs index af99972ee2..0478fff8c7 100644 --- a/frontend/src/app/util/path/geom.cljs +++ b/frontend/src/app/util/path/geom.cljs @@ -6,13 +6,8 @@ (ns app.util.path.geom (:require - [app.common.data :as d] [app.common.geom.point :as gpt] [app.common.geom.shapes.path :as gshp] - [app.util.svg :as usvg] - [cuerdas.core :as str] - [clojure.set :as set] - [app.common.math :as mth] [app.util.path.commands :as upc])) (defn calculate-opposite-handler diff --git a/frontend/src/app/util/path/parser.cljs b/frontend/src/app/util/path/parser.cljs index fc23adc619..7b68caf646 100644 --- a/frontend/src/app/util/path/parser.cljs +++ b/frontend/src/app/util/path/parser.cljs @@ -8,13 +8,10 @@ (:require [app.common.data :as d] [app.common.geom.point :as gpt] - [app.common.geom.shapes.path :as gshp] - [app.common.math :as mth] [app.util.path.arc-to-curve :refer [a2c]] [app.util.path.commands :as upc] [app.util.path.geom :as upg] [app.util.svg :as usvg] - [clojure.set :as set] [cuerdas.core :as str])) ;; @@ -52,7 +49,7 @@ current remain)) (cond-> result - (not (empty? current)) (conj current)))))) + (seq current) (conj current)))))) ;; Path specification ;; https://www.w3.org/TR/SVG11/paths.html @@ -72,7 +69,7 @@ :relative relative :params params})))) -(defmethod parse-command "Z" [cmd] +(defmethod parse-command "Z" [_] [{:command :close-path}]) (defmethod parse-command "L" [cmd] @@ -204,7 +201,7 @@ ;; prev-start : previous move-to necesary for Z commands ;; prev-cc : previous command control point for cubic beziers ;; prev-qc : previous command control point for quadratic curves - (fn [[result prev-pos prev-start prev-cc prev-qc] [command prev]] + (fn [[result prev-pos prev-start prev-cc prev-qc] [command _prev]] (let [command (assoc command :prev-pos prev-pos) command diff --git a/frontend/src/app/util/path/shapes_to_path.cljs b/frontend/src/app/util/path/shapes_to_path.cljs index a1d42ba47d..0fb979bb16 100644 --- a/frontend/src/app/util/path/shapes_to_path.cljs +++ b/frontend/src/app/util/path/shapes_to_path.cljs @@ -40,14 +40,14 @@ height (* radius 2) c bezier-circle-c - c1x (+ x (* (/ width 2) (- 1 c))) + c1x (+ x (* (/ width 2) (- 1 c))) c2x (+ x (* (/ width 2) (+ 1 c))) c1y (+ y (* (/ height 2) (- 1 c))) c2y (+ y (* (/ height 2) (+ 1 c))) h1 (case corner :top-left (assoc from :y c1y) - :top-right (assoc from :x c2x) + :top-right (assoc from :x c2x) :bottom-right (assoc from :y c2y) :bottom-left (assoc from :x c1x)) @@ -67,14 +67,13 @@ ex (+ x width) ey (+ y height) - pc (gpt/point mx my) p1 (gpt/point mx y) p2 (gpt/point ex my) p3 (gpt/point mx ey) p4 (gpt/point x my) c bezier-circle-c - c1x (+ x (* (/ width 2) (- 1 c))) + c1x (+ x (* (/ width 2) (- 1 c))) c2x (+ x (* (/ width 2) (+ 1 c))) c1y (+ y (* (/ height 2) (- 1 c))) c2y (+ y (* (/ height 2) (+ 1 c)))] @@ -90,7 +89,7 @@ [x y width height r1 r2 r3 r4] (let [p1 (gpt/point x (+ y r1)) p2 (gpt/point (+ x r1) y) - + p3 (gpt/point (+ width x (- r2)) y) p4 (gpt/point (+ width x) (+ y r2)) diff --git a/frontend/src/app/util/path/simplify_curve.cljs b/frontend/src/app/util/path/simplify_curve.cljs index c3a400a118..900d66e784 100644 --- a/frontend/src/app/util/path/simplify_curve.cljs +++ b/frontend/src/app/util/path/simplify_curve.cljs @@ -6,14 +6,7 @@ (ns app.util.path.simplify-curve (:require - [app.common.data :as d] - [app.common.geom.point :as gpt] - [app.common.geom.shapes.path :as gshp] - [app.util.path.path-impl-simplify :as impl-simplify] - [app.util.svg :as usvg] - [cuerdas.core :as str] - [clojure.set :as set] - [app.common.math :as mth])) + [app.util.path.path-impl-simplify :as impl-simplify])) (defn simplify "Simplifies a drawing done with the pen tool" diff --git a/frontend/src/app/util/path/tools.cljs b/frontend/src/app/util/path/tools.cljs index 870ddab857..f6409f2216 100644 --- a/frontend/src/app/util/path/tools.cljs +++ b/frontend/src/app/util/path/tools.cljs @@ -80,13 +80,7 @@ in the same vector that results from te previous->next points but with fixed length." [content point] - (let [make-curve-cmd (fn [cmd h1 h2] - (-> cmd - (update :params assoc - :c1x (:x h1) :c1y (:y h1) - :c2x (:x h2) :c2y (:y h2)))) - - indices (upc/point-indices content point) + (let [indices (upc/point-indices content point) vectors (->> indices (mapv (fn [index] (let [cmd (nth content index) prev-i (dec index) @@ -151,10 +145,10 @@ (let [add-curve (fn [content {:keys [index command prev-p next-c next-i]}] (cond-> content - (and (= :line-to (:command command))) + (= :line-to (:command command)) (update index #(line->curve prev-p %)) - (and (= :line-to (:command next-c))) + (= :line-to (:command next-c)) (update next-i #(line->curve point %))))] (->> vectors (reduce add-curve content)))))) @@ -292,7 +286,7 @@ ;; If have a curve the first handler will be relative to the previous ;; point. We change the handler to the new previous point - (and curve? (not (empty? subpath)) (not= old-prev-point new-prev-point)) + (and curve? (seq subpath) (not= old-prev-point new-prev-point)) (update :params merge last-handler)) head-idx (dec (count result)) @@ -394,7 +388,7 @@ result (cond-> result (and (nil? set-a) (nil? set-b)) (conj #{point-a point-b}) - + (and (some? set-a) (nil? set-b)) (add-to-set set-a point-b) diff --git a/frontend/src/app/util/router.cljs b/frontend/src/app/util/router.cljs index d7945580d8..dd3078c75e 100644 --- a/frontend/src/app/util/router.cljs +++ b/frontend/src/app/util/router.cljs @@ -7,13 +7,11 @@ (ns app.util.router (:refer-clojure :exclude [resolve]) (:require - [app.common.data :as d] - [app.config :as cfg] [app.common.uri :as u] + [app.config :as cfg] [app.util.browser-history :as bhistory] [app.util.timers :as ts] [beicon.core :as rx] - [cuerdas.core :as str] [goog.events :as e] [potok.core :as ptk] [reitit.core :as r])) @@ -83,7 +81,7 @@ (dissoc state :exception)) ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (ts/asap #(let [router (:router state) history (:history state) @@ -106,7 +104,7 @@ (deftype NavigateNewWindow [id params qparams] ptk/EffectEvent - (effect [_ state stream] + (effect [_ state _] (let [router (:router state) path (resolve router id params qparams) uri (-> (u/uri cfg/public-uri) diff --git a/frontend/src/app/util/simple_math.cljs b/frontend/src/app/util/simple_math.cljs index c92e8d6de2..34d476d455 100644 --- a/frontend/src/app/util/simple_math.cljs +++ b/frontend/src/app/util/simple_math.cljs @@ -6,15 +6,15 @@ (ns app.util.simple-math (:require - [cljs.spec.alpha :as s] - [clojure.string :refer [index-of]] - [cuerdas.core :as str] - [instaparse.core :as insta] - [app.common.data :as d] - [app.common.exceptions :as ex])) + [app.common.data :as d] + [app.common.exceptions :as ex] + [cljs.spec.alpha :as s] + [clojure.string :refer [index-of]] + [cuerdas.core :as str] + [instaparse.core :as insta])) (def parser - (insta/parser + (insta/parser "opt-expr = '' | expr expr = term ( ('+'|'-') expr)* | ('+'|'-'|'*'|'/') factor diff --git a/frontend/src/app/util/storage.cljs b/frontend/src/app/util/storage.cljs index 2f2e5e9cba..d7e150c61a 100644 --- a/frontend/src/app/util/storage.cljs +++ b/frontend/src/app/util/storage.cljs @@ -6,20 +6,10 @@ (ns app.util.storage (:require - [app.common.exceptions :as ex] [app.common.transit :as t] [app.util.globals :as g] [app.util.timers :as tm])) -(defn- ^boolean is-worker? - [] - (or (= *target* "nodejs") - (not (exists? js/window)))) - -(defn- decode - [v] - (ex/ignoring (t/decode-str v))) - (defn- persist [storage prev curr] (run! (fn [key] @@ -43,7 +33,7 @@ val (.getItem ^js storage key)] (try (assoc res (t/decode-str key) (t/decode-str val)) - (catch :default e + (catch :default _e res)))) {} (range len))))) diff --git a/frontend/src/app/util/svg.cljs b/frontend/src/app/util/svg.cljs index 12c9e0d97c..b0f407f041 100644 --- a/frontend/src/app/util/svg.cljs +++ b/frontend/src/app/util/svg.cljs @@ -6,12 +6,12 @@ (ns app.util.svg (:require - [app.common.uuid :as uuid] [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] [app.common.math :as mth] + [app.common.uuid :as uuid] [cuerdas.core :as str])) ;; Regex for XML ids per Spec @@ -539,11 +539,6 @@ (str/camel) (keyword)))) - (lowercase-key [key] - (-> (d/name key) - (str/lower) - (keyword))) - (format-styles [style-str] (->> (str/split style-str ";") (map str/trim) @@ -593,7 +588,7 @@ (defn replace-attrs-ids "Replaces the ids inside a property" [attrs ids-mapping] - (if (and ids-mapping (not (empty? ids-mapping))) + (if (and ids-mapping (seq ids-mapping)) (update-attr-ids attrs (fn [id] (get ids-mapping id id))) ;; Ids-mapping is null attrs)) @@ -606,7 +601,7 @@ (reduce visit-node result (:content node))))] (visit-node {} content))) -(defn extract-defs [{:keys [tag attrs content] :as node}] +(defn extract-defs [{:keys [attrs] :as node}] (if-not (map? node) [{} node] @@ -646,7 +641,7 @@ (cond (nil? to-check) result - + (checked? to-check) (recur result checked? @@ -672,7 +667,7 @@ scale-x (/ width svg-width) scale-y (/ height svg-height)] - + (gmt/multiply (gmt/matrix) @@ -735,7 +730,7 @@ (let [process-matrix (fn [[_ type params]] (let [params (->> (re-seq number-regex params) - (filter #(-> % first empty? not)) + (filter #(-> % first seq)) (map (comp d/parse-double first)))] {:type type :params params})) @@ -761,7 +756,7 @@ (str (format-move head) (->> other (map format-line) (str/join " "))))) -(defn polyline->path [{:keys [attrs tag] :as node}] +(defn polyline->path [{:keys [attrs] :as node}] (let [tag :path attrs (-> attrs (dissoc :points) @@ -769,14 +764,14 @@ (assoc node :attrs attrs :tag tag))) -(defn polygon->path [{:keys [attrs tag] :as node}] +(defn polygon->path [{:keys [attrs] :as node}] (let [tag :path attrs (-> attrs (dissoc :points) (assoc :d (str (points->path (:points attrs)) "Z")))] (assoc node :attrs attrs :tag tag))) -(defn line->path [{:keys [attrs tag] :as node}] +(defn line->path [{:keys [attrs] :as node}] (let [tag :path {:keys [x1 y1 x2 y2]} attrs attrs (-> attrs @@ -868,7 +863,7 @@ :ratio (calculate-ratio (:width svg-data) (:height svg-data))}] (letfn [(fix-length [prop-length val] (* (get viewbox prop-length) (/ val 100.))) - + (fix-coord [prop-coord prop-length val] (+ (get viewbox prop-coord) (fix-length prop-length val))) @@ -896,7 +891,7 @@ (fix-percent-attrs-viewbox [attrs] (d/mapm fix-percent-attr-viewbox attrs)) - (fix-percent-attr-numeric [attr-key attr-val] + (fix-percent-attr-numeric [_ attr-val] (let [is-percent? (str/ends-with? attr-val "%")] (if is-percent? (str (let [attr-num (d/parse-double attr-val)] diff --git a/frontend/src/app/util/text_editor.cljs b/frontend/src/app/util/text_editor.cljs index ccd7fd8dcc..370f17f2de 100644 --- a/frontend/src/app/util/text_editor.cljs +++ b/frontend/src/app/util/text_editor.cljs @@ -9,14 +9,7 @@ (:require ["./text_editor_impl.js" :as impl] ["draft-js" :as draft] - [app.common.attrs :as attrs] - [app.common.data :as d] - [app.common.text :as txt] - [app.common.uuid :as uuid] - [app.util.array :as arr] - [app.util.object :as obj] - [clojure.walk :as walk] - [cuerdas.core :as str])) + [app.common.text :as txt])) ;; --- CONVERSION diff --git a/frontend/src/app/util/theme.cljs b/frontend/src/app/util/theme.cljs index ae446f5bf6..1030c5eea0 100644 --- a/frontend/src/app/util/theme.cljs +++ b/frontend/src/app/util/theme.cljs @@ -8,13 +8,11 @@ (ns app.util.theme "A theme manager." (:require - [cuerdas.core :as str] - [rumext.alpha :as mf] - [beicon.core :as rx] - [goog.object :as gobj] [app.config :as cfg] [app.util.dom :as dom] - [app.util.storage :refer [storage]])) + [app.util.storage :refer [storage]] + [beicon.core :as rx] + [rumext.alpha :as mf])) (defonce theme (get @storage ::theme cfg/default-theme)) (defonce theme-sub (rx/subject)) diff --git a/frontend/src/app/util/time.cljs b/frontend/src/app/util/time.cljs index 317ff866e7..a32a0e1a4e 100644 --- a/frontend/src/app/util/time.cljs +++ b/frontend/src/app/util/time.cljs @@ -6,21 +6,21 @@ (ns app.util.time (:require - [cuerdas.core :as str] - ["luxon" :as lxn] ["date-fns/formatDistanceToNowStrict" :default dateFnsFormatDistanceToNowStrict] - ["date-fns/locale/el" :default dateFnsLocalesEl] - ["date-fns/locale/fr" :default dateFnsLocalesFr] ["date-fns/locale/ca" :default dateFnsLocalesCa] ["date-fns/locale/de" :default dateFnsLocalesDe] - ["date-fns/locale/ro" :default dateFnsLocalesRo] - ["date-fns/locale/pt-BR" :default dateFnsLocalesPtBr] + ["date-fns/locale/el" :default dateFnsLocalesEl] ["date-fns/locale/en-US" :default dateFnsLocalesEnUs] - ["date-fns/locale/zh-CN" :default dateFnsLocalesZhCn] ["date-fns/locale/es" :default dateFnsLocalesEs] - ["date-fns/locale/tr" :default dateFnsLocalesTr] + ["date-fns/locale/fr" :default dateFnsLocalesFr] + ["date-fns/locale/pt-BR" :default dateFnsLocalesPtBr] + ["date-fns/locale/ro" :default dateFnsLocalesRo] ["date-fns/locale/ru" :default dateFnsLocalesRu] - [app.util.object :as obj])) + ["date-fns/locale/tr" :default dateFnsLocalesTr] + ["date-fns/locale/zh-CN" :default dateFnsLocalesZhCn] + ["luxon" :as lxn] + [app.util.object :as obj] + [cuerdas.core :as str])) (def DateTime lxn/DateTime) (def Duration lxn/Duration) diff --git a/frontend/src/app/util/uri.cljs b/frontend/src/app/util/uri.cljs index fe01825439..3f6d6c1bc7 100644 --- a/frontend/src/app/util/uri.cljs +++ b/frontend/src/app/util/uri.cljs @@ -6,8 +6,8 @@ (ns app.util.uri (:require - [cuerdas.core :as str] - [app.util.object :as obj])) + [app.util.object :as obj] + [cuerdas.core :as str])) (defn uri-name [url] (let [query-idx (str/last-index-of url "?") diff --git a/frontend/src/app/util/webapi.cljs b/frontend/src/app/util/webapi.cljs index ef77aaafc2..e07949567e 100644 --- a/frontend/src/app/util/webapi.cljs +++ b/frontend/src/app/util/webapi.cljs @@ -11,8 +11,7 @@ [app.common.exceptions :as ex] [app.util.object :as obj] [beicon.core :as rx] - [cuerdas.core :as str] - [promesa.core :as p])) + [cuerdas.core :as str])) (defn- file-reader [f] @@ -136,7 +135,7 @@ (rx/create (fn [subs] (let [obs (js/ResizeObserver. - (fn [entries x] + (fn [entries _] (rx/push! subs entries)))] (.observe ^js obs node) (fn [] diff --git a/frontend/src/app/util/websockets.cljs b/frontend/src/app/util/websockets.cljs index 9690110200..8bac581684 100644 --- a/frontend/src/app/util/websockets.cljs +++ b/frontend/src/app/util/websockets.cljs @@ -8,11 +8,8 @@ "A interface to webworkers exposed functionality." (:require [app.common.transit :as t] - [app.common.uri :as u] - [app.config :as cfg] [beicon.core :as rx] - [goog.events :as ev] - [potok.core :as ptk]) + [goog.events :as ev]) (:import goog.net.WebSocket goog.net.WebSocket.EventType)) diff --git a/frontend/src/app/util/worker.cljs b/frontend/src/app/util/worker.cljs index 19d4b3df4e..810d32e294 100644 --- a/frontend/src/app/util/worker.cljs +++ b/frontend/src/app/util/worker.cljs @@ -82,7 +82,7 @@ worker)) (defn- handle-response - [{:keys [payload error dropped] :as response}] + [{:keys [payload error dropped]}] (when-not dropped (if-let [{:keys [data message]} error] (throw (ex-info message data)) diff --git a/frontend/src/app/util/zip.cljs b/frontend/src/app/util/zip.cljs index 84a3759d27..47f3544f65 100644 --- a/frontend/src/app/util/zip.cljs +++ b/frontend/src/app/util/zip.cljs @@ -8,10 +8,9 @@ "Helpers for make zip file (using jszip)." (:require ["jszip" :as zip] - [app.common.data :as d] + [app.util.http :as http] [beicon.core :as rx] - [promesa.core :as p] - [app.util.http :as http])) + [promesa.core :as p])) (defn compress-files [files] diff --git a/frontend/src/app/worker.cljs b/frontend/src/app/worker.cljs index 44cd628f6d..59470139e8 100644 --- a/frontend/src/app/worker.cljs +++ b/frontend/src/app/worker.cljs @@ -6,23 +6,16 @@ (ns app.worker (:require - - [app.common.exceptions :as ex] [app.common.spec :as us] [app.common.transit :as t] - [app.common.uuid :as uuid] - [app.util.object :as obj] - [app.util.worker :as w] - [app.worker.impl :as impl] - [app.worker.selection] - - [app.worker.import] [app.worker.export] + [app.worker.impl :as impl] + [app.worker.import] + [app.worker.selection] [app.worker.snaps] [app.worker.thumbnails] [beicon.core :as rx] [cljs.spec.alpha :as s] - [cuerdas.core :as str] [promesa.core :as p])) ;; --- Messages Handling @@ -38,7 +31,7 @@ (s/def ::message (s/keys - :req-opt [::buffer?] + :opt-un [::buffer?] :req-un [::payload ::sender-id])) (def buffer (rx/subject)) @@ -86,7 +79,7 @@ (defn- drop-message "Sends to the client a notifiction that its messages have been dropped" - [{:keys [sender-id payload] :as message}] + [{:keys [sender-id] :as message}] (us/assert ::message message) (.postMessage js/self (t/encode-str {:reply-to sender-id :dropped true}))) @@ -105,7 +98,7 @@ ;; we also store the last message processed in order to detect ;; posible infinite loops (rx/scan - (fn [[messages dropped last] message] + (fn [[messages dropped _last] message] (let [cmd (get-in message [:payload :cmd]) ;; The previous message is dropped diff --git a/frontend/src/app/worker/impl.cljs b/frontend/src/app/worker/impl.cljs index cfa69ac234..9dfb3bba26 100644 --- a/frontend/src/app/worker/impl.cljs +++ b/frontend/src/app/worker/impl.cljs @@ -7,7 +7,6 @@ (ns app.worker.impl (:require [app.common.pages.changes :as ch] - [app.common.transit :as t] [okulary.core :as l])) (enable-console-print!) diff --git a/frontend/src/app/worker/selection.cljs b/frontend/src/app/worker/selection.cljs index 09cc4041a1..d0a03d6319 100644 --- a/frontend/src/app/worker/selection.cljs +++ b/frontend/src/app/worker/selection.cljs @@ -6,17 +6,14 @@ (ns app.worker.selection (:require - [cljs.spec.alpha :as s] - [okulary.core :as l] [app.common.data :as d] - [app.common.exceptions :as ex] [app.common.geom.shapes :as gsh] [app.common.pages :as cp] - [app.common.spec :as us] [app.common.uuid :as uuid] [app.util.quadtree :as qdt] [app.worker.impl :as impl] - [clojure.set :as set])) + [clojure.set :as set] + [okulary.core :as l])) (defonce state (l/atom {})) @@ -66,8 +63,8 @@ changed-ids (into #{} (comp (filter changes?) (filter #(not= % uuid/zero))) - (set/union (keys old-objects) - (keys new-objects))) + (set/union (set (keys old-objects)) + (set (keys new-objects)))) shapes (->> changed-ids (mapv #(get new-objects %)) (filterv (comp not nil?))) parents-index (cp/generate-child-all-parents-index new-objects shapes) @@ -87,7 +84,7 @@ (create-index new-objects))) (defn- query-index - [{index :index z-index :z-index} rect frame-id include-frames? include-groups? disabled-masks reverse?] + [{index :index z-index :z-index} rect frame-id include-frames? include-groups? reverse?] (let [result (-> (qdt/search index (clj->js rect)) (es6-iterator-seq)) @@ -137,7 +134,7 @@ (defmethod impl/handler :selection/initialize-index - [{:keys [file-id data] :as message}] + [{:keys [data] :as message}] (letfn [(index-page [state page] (let [id (:id page) objects (:objects page)] @@ -154,10 +151,10 @@ nil) (defmethod impl/handler :selection/query - [{:keys [page-id rect frame-id include-frames? include-groups? disabled-masks reverse?] - :or {include-groups? true disabled-masks #{} reverse? false} :as message}] + [{:keys [page-id rect frame-id include-frames? include-groups? reverse?] + :or {include-groups? true reverse? false} :as message}] (when-let [index (get @state page-id)] - (query-index index rect frame-id include-frames? include-groups? disabled-masks reverse?))) + (query-index index rect frame-id include-frames? include-groups? reverse?))) (defmethod impl/handler :selection/query-z-index [{:keys [page-id objects ids]}] diff --git a/frontend/src/app/worker/snaps.cljs b/frontend/src/app/worker/snaps.cljs index a2c3954483..dadd825eef 100644 --- a/frontend/src/app/worker/snaps.cljs +++ b/frontend/src/app/worker/snaps.cljs @@ -7,7 +7,6 @@ (ns app.worker.snaps (:require [app.common.data :as d] - [app.common.pages :as cp] [app.common.uuid :as uuid] [app.util.geom.grid :as gg] [app.util.geom.snap-points :as snap] @@ -99,7 +98,8 @@ changed-ids (into #{} (filter changed?) - (set/union (keys old-objects) (keys new-objects))) + (set/union (set (keys old-objects)) + (set (keys new-objects)))) to-delete (aggregate-data old-objects changed-ids) to-add (aggregate-data new-objects changed-ids) @@ -134,30 +134,25 @@ (reduce add-data $ to-add) (reduce delete-frames $ frames-to-delete)))) -(defn- log-state - "Helper function to print a friendly version of the snap tree. Debugging purposes" - [] - (let [process-frame-data #(d/mapm rt/as-map %) - process-page-data #(d/mapm process-frame-data %)] - (js/console.log "STATE" (clj->js (d/mapm process-page-data @state))))) +;; (defn- log-state +;; "Helper function to print a friendly version of the snap tree. Debugging purposes" +;; [] +;; (let [process-frame-data #(d/mapm rt/as-map %) +;; process-page-data #(d/mapm process-frame-data %)] +;; (js/console.log "STATE" (clj->js (d/mapm process-page-data @state))))) (defn- index-page [state page-id objects] (let [snap-data (initialize-snap-data objects)] (assoc state page-id snap-data))) (defn- update-page [state page-id old-objects new-objects] - (let [changed? #(not= (get old-objects %) (get new-objects %)) - changed-ids (into #{} - (filter changed?) - (set/union (keys old-objects) (keys new-objects))) - - snap-data (get state page-id) + (let [snap-data (get state page-id) snap-data (update-snap-data snap-data old-objects new-objects)] (assoc state page-id snap-data))) ;; Public API (defmethod impl/handler :snaps/initialize-index - [{:keys [file-id data] :as message}] + [{:keys [data] :as message}] ;; Create the index (letfn [(process-page [state page] (let [id (:id page) diff --git a/frontend/src/app/worker/thumbnails.cljs b/frontend/src/app/worker/thumbnails.cljs index bf010d56a9..210dfe31b9 100644 --- a/frontend/src/app/worker/thumbnails.cljs +++ b/frontend/src/app/worker/thumbnails.cljs @@ -6,14 +6,13 @@ (ns app.worker.thumbnails (:require - [rumext.alpha :as mf] - [beicon.core :as rx] - [promesa.core :as p] - [app.main.fonts :as fonts] + ["react-dom/server" :as rds] [app.main.exports :as exports] - [app.worker.impl :as impl] + [app.main.fonts :as fonts] [app.util.http :as http] - ["react-dom/server" :as rds])) + [app.worker.impl :as impl] + [beicon.core :as rx] + [rumext.alpha :as mf])) (defn- handle-response [response]