0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 16:21:57 -05:00

Fix linter issues on frontend (part 4).

This commit is contained in:
Andrey Antukh 2021-06-17 16:29:52 +02:00 committed by Andrés Moya
parent 30e77556db
commit e0846ce00e
26 changed files with 130 additions and 195 deletions

View file

@ -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])

View file

@ -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}]))]])))

View file

@ -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)

View file

@ -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")]]

View file

@ -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)

View file

@ -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)))

View file

@ -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"))]])]))

View file

@ -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)

View file

@ -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)

View file

@ -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
[]

View file

@ -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

View file

@ -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)))

View file

@ -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)

View file

@ -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

View file

@ -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)))

View file

@ -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]

View file

@ -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)

View file

@ -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])}]

View file

@ -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])

View file

@ -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]))

View file

@ -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")}]]]]]]))

View file

@ -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)))

View file

@ -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))

View file

@ -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))))

View file

@ -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)))))

View file

@ -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)