Adds i18n for shadow options menu

This commit is contained in:
alonso.torres 2020-09-24 21:30:36 +02:00
parent 091de20934
commit 92db554ae7
6 changed files with 174 additions and 119 deletions

View file

@ -11,7 +11,6 @@
"The main logic for SVG export functionality."
(:require
[rumext.alpha :as mf]
[cuerdas.core :as str]
[app.common.uuid :as uuid]
[app.common.pages :as cp]
[app.common.pages-helpers :as cph]

View file

@ -21,8 +21,7 @@
(defn extract-style-attrs
[shape]
(let [stroke-style (:stroke-style shape :none)
attrs #js {;:filter (when (not= :frame (:type shape)) (str "url(#filter_" (:id shape) ")"))
:fill (or (:fill-color shape) "transparent")
attrs #js {:fill (or (:fill-color shape) "transparent")
:fillOpacity (:fill-opacity shape nil)
:rx (:rx shape nil)
:ry (:ry shape nil)}]

View file

@ -23,7 +23,7 @@
base-props (unchecked-get props "base-props")
elem-name (unchecked-get props "elem-name")
{:keys [x y width height]} (geom/shape->rect-shape shape)
id (uuid/next)
stroke-id (mf/use-var (uuid/next))
stroke-style (:stroke-style shape :none)
stroke-position (:stroke-alignment shape :center)]
(cond
@ -34,7 +34,7 @@
;; Inner alignment: display the shape with double width stroke,
;; and clip the result with the original shape without stroke.
(= stroke-position :inner)
(let [clip-id (str "clip-" id)
(let [clip-id (str "clip-" @stroke-id)
clip-props (-> (obj/merge! #js {} base-props)
(obj/merge! #js {:stroke nil
@ -61,7 +61,7 @@
;; without stroke
(= stroke-position :outer)
(let [mask-id (str "mask-" id)
(let [mask-id (str "mask-" @stroke-id)
stroke-width (.-strokeWidth ^js base-props)
mask-props1 (-> (obj/merge! #js {} base-props)
(obj/merge! #js {:stroke "white"

View file

@ -11,8 +11,6 @@
"The main container for a frame in viewer mode"
(:require
[rumext.alpha :as mf]
[cuerdas.core :as str]
[app.common.uuid :as uuid]
[app.common.data :as d]
[app.common.pages :as cp]
[app.common.pages-helpers :as cph]

View file

@ -18,7 +18,8 @@
[app.main.ui.workspace.sidebar.options.common :refer [advanced-options]]
[app.main.ui.workspace.sidebar.options.rows.input-row :refer [input-row]]
[app.main.ui.workspace.sidebar.options.rows.color-row :refer [color-row]]
[app.util.dom :as dom]))
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [t]]))
(defn create-shadow []
(let [id (uuid/next)]
@ -37,7 +38,8 @@
(mf/defc shadow-entry
[{:keys [ids index value]}]
(let [open-shadow (mf/use-state false)
(let [locale (i18n/use-locale)
open-shadow (mf/use-state false)
basic-offset-x-ref (mf/use-ref nil)
basic-offset-y-ref (mf/use-ref nil)
@ -124,8 +126,8 @@
:on-change (fn [event]
(let [value (-> event dom/get-target dom/get-value d/read-string)]
(st/emit! (dwc/update-shapes ids #(assoc-in % [:shadow index :style] value)))))}
[:option {:value ":drop-shadow"} "Drop shadow"]
[:option {:value ":inner-shadow"} "Inner shadow"]]]
[:option {:value ":drop-shadow"} (t locale "workspace.options.shadow-options.drop-shadow")]
[:option {:value ":inner-shadow"} (t locale "workspace.options.shadow-options.inner-shadow")]]]
[:div.row-grid-2
[:div.input-element
@ -136,7 +138,7 @@
:on-click (select-text adv-offset-x-ref)
:on-change (update-attr index :offset-x valid-number? basic-offset-x-ref)
:default-value (:offset-x value)}]
[:span.after "X"]]
[:span.after (t locale "workspace.options.shadow-options.offsetx")]]
[:div.input-element
[:input.input-text {:type "number"
@ -146,7 +148,7 @@
:on-click (select-text adv-offset-y-ref)
:on-change (update-attr index :offset-y valid-number? basic-offset-y-ref)
:default-value (:offset-y value)}]
[:span.after "Y"]]]
[:span.after (t locale "workspace.options.shadow-options.offsety")]]]
[:div.row-grid-2
[:div.input-element
@ -158,7 +160,7 @@
:on-change (update-attr index :blur valid-number? basic-blur-ref)
:min 0
:default-value (:blur value)}]
[:span.after "Blur"]]
[:span.after (t locale "workspace.options.shadow-options.blur")]]
[:div.input-element
[:input.input-text {:type "number"
@ -169,7 +171,7 @@
:on-change (update-attr index :spread valid-number?)
:min 0
:default-value (:spread value)}]
[:span.after "Spread"]]]
[:span.after (t locale "workspace.options.shadow-options.spread")]]]
[:div.color-row-wrap
[:& color-row {:color {:value (:color value) :opacity (:opacity value)}
@ -179,12 +181,13 @@
(mf/defc shadow-menu
[{:keys [ids type values] :as props}]
(let [on-add-shadow
(let [locale (i18n/use-locale)
on-add-shadow
(fn []
(st/emit! (dwc/update-shapes ids #(update % :shadow (fnil conj []) (create-shadow)) )))]
[:div.element-set.shadow-options
[:div.element-set-title
[:span "Shadow"]
[:span (t locale "workspace.options.shadow-options.title")]
[:div.add-page {:on-click on-add-shadow} i/close]]
(when (seq (:shadow values))