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/workspace/sidebar/options/menus/exports.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/exports.cljs index dd62aef455..09b5a6d8f1 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 @@ -20,7 +20,7 @@ [app.util.http :as http] [app.util.i18n :as i18n :refer [tr t]])) -(defn- request-export +(defn request-export [shape exports] (rp/query! :export {:page-id (:page-id shape)