mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
commit
144b164fa0
3 changed files with 24 additions and 22 deletions
|
@ -119,8 +119,7 @@
|
||||||
(def rotation-keys (schema-keys ::rotation))
|
(def rotation-keys (schema-keys ::rotation))
|
||||||
|
|
||||||
(sm/def! ::tokens
|
(sm/def! ::tokens
|
||||||
[:map {:title "Applied Tokens"
|
[:map {:title "Applied Tokens"}])
|
||||||
:closed true}])
|
|
||||||
|
|
||||||
(sm/def! ::applied-tokens
|
(sm/def! ::applied-tokens
|
||||||
(merge-schemas ::tokens
|
(merge-schemas ::tokens
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
(ns app.main.ui.workspace.tokens.common
|
(ns app.main.ui.workspace.tokens.common
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
;; Helpers ---------------------------------------------------------------------
|
;; Helpers ---------------------------------------------------------------------
|
||||||
|
@ -20,20 +22,26 @@
|
||||||
[pos coll]
|
[pos coll]
|
||||||
(into (subvec coll 0 pos) (subvec coll (inc pos))))
|
(into (subvec coll 0 pos) (subvec coll (inc pos))))
|
||||||
|
|
||||||
|
(defn camel-keys [m]
|
||||||
|
(->> m
|
||||||
|
(d/deep-mapm
|
||||||
|
(fn [[k v]]
|
||||||
|
(if (or (keyword? k) (string? k))
|
||||||
|
[(keyword (str/camel (name k))) v]
|
||||||
|
[k v])))))
|
||||||
|
|
||||||
;; Components ------------------------------------------------------------------
|
;; Components ------------------------------------------------------------------
|
||||||
|
|
||||||
(mf/defc labeled-input
|
(mf/defc labeled-input
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[{:keys [input-ref label default-value on-change auto-focus? auto-complete?]}]
|
[{:keys [label input-props auto-complete?]}]
|
||||||
(let [input-props (cond-> {:ref input-ref
|
(let [input-props (cond-> input-props
|
||||||
:default-value default-value
|
|
||||||
:autoFocus auto-focus?
|
|
||||||
:on-change on-change}
|
|
||||||
;; Disable auto-complete on form fields for proprietary password managers
|
;; Disable auto-complete on form fields for proprietary password managers
|
||||||
;; https://github.com/orgs/tokens-studio/projects/69/views/11?pane=issue&itemId=63724204
|
;; https://github.com/orgs/tokens-studio/projects/69/views/11?pane=issue&itemId=63724204
|
||||||
(not auto-complete?) (assoc :data-1p-ignore true
|
(not auto-complete?) (assoc "data-1p-ignore" true
|
||||||
:data-lpignore true
|
"data-lpignore" true
|
||||||
:autoComplete "off"))]
|
:auto-complete "off")
|
||||||
|
:always camel-keys)]
|
||||||
[:label {:class (stl/css :labeled-input)}
|
[:label {:class (stl/css :labeled-input)}
|
||||||
[:span {:class (stl/css :label)} label]
|
[:span {:class (stl/css :label)} label]
|
||||||
[:& :input input-props]]))
|
[:& :input input-props]]))
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
|
|
||||||
name (mf/use-var (or (:name token) ""))
|
name (mf/use-var (or (:name token) ""))
|
||||||
on-update-name #(reset! name (dom/get-target-val %))
|
on-update-name #(reset! name (dom/get-target-val %))
|
||||||
name-ref (mf/use-ref)
|
|
||||||
|
|
||||||
token-value (mf/use-var (or (:value token) ""))
|
token-value (mf/use-var (or (:value token) ""))
|
||||||
|
|
||||||
|
@ -79,29 +78,25 @@
|
||||||
(st/emit! (dt/add-token token))
|
(st/emit! (dt/add-token token))
|
||||||
(modal/hide!)))]
|
(modal/hide!)))]
|
||||||
|
|
||||||
(mf/use-effect
|
|
||||||
(fn []
|
|
||||||
(dom/focus! (mf/ref-val name-ref))))
|
|
||||||
|
|
||||||
[:form
|
[:form
|
||||||
{:class (stl/css :shadow)
|
{:class (stl/css :shadow)
|
||||||
:style (clj->js style)
|
:style (clj->js style)
|
||||||
:on-submit on-submit}
|
:on-submit on-submit}
|
||||||
[:div {:class (stl/css :token-rows)}
|
[:div {:class (stl/css :token-rows)}
|
||||||
[:& tokens.common/labeled-input {:label "Name"
|
[:& tokens.common/labeled-input {:label "Name"
|
||||||
:default-value @name
|
:input-props {:default-value @name
|
||||||
:on-change on-update-name
|
:auto-focus true
|
||||||
:input-ref name-ref}]
|
:on-change on-update-name}}]
|
||||||
(for [[idx {:keys [type label]}] (d/enumerate @state)]
|
(for [[idx {:keys [type label]}] (d/enumerate @state)]
|
||||||
[:* {:key (str "form-field-" idx)}
|
[:* {:key (str "form-field-" idx)}
|
||||||
(case type
|
(case type
|
||||||
:box-shadow [:p "TODO BOX SHADOW"]
|
:box-shadow [:p "TODO BOX SHADOW"]
|
||||||
[:& tokens.common/labeled-input {:label label
|
[:& tokens.common/labeled-input {:label label
|
||||||
:default-value @token-value
|
:input-props {:default-value @token-value
|
||||||
:on-change #(on-update-state-field idx %)}])])
|
:on-change #(on-update-state-field idx %)}}])])
|
||||||
[:& tokens.common/labeled-input {:label "Description"
|
[:& tokens.common/labeled-input {:label "Description"
|
||||||
:default-value @description
|
:input-props {:default-value @description
|
||||||
:on-change #(on-update-description %)}]
|
:on-change #(on-update-description %)}}]
|
||||||
[:div {:class (stl/css :button-row)}
|
[:div {:class (stl/css :button-row)}
|
||||||
[:button {:class (stl/css :button)
|
[:button {:class (stl/css :button)
|
||||||
:type "submit"}
|
:type "submit"}
|
||||||
|
|
Loading…
Add table
Reference in a new issue