mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Convert kebab keys into camelCase
This commit is contained in:
parent
47d75e7e2a
commit
96a7cf2e98
2 changed files with 21 additions and 10 deletions
|
@ -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,6 +22,14 @@
|
||||||
[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
|
||||||
|
@ -28,9 +38,10 @@
|
||||||
(let [input-props (cond-> input-props
|
(let [input-props (cond-> input-props
|
||||||
;; 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]]))
|
||||||
|
|
|
@ -84,19 +84,19 @@
|
||||||
: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"
|
||||||
:input-props {:defaultValue @name
|
:input-props {:default-value @name
|
||||||
:autoFocus true
|
:auto-focus true
|
||||||
:onChange on-update-name}}]
|
: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
|
||||||
:input-props {:defaultValue @token-value
|
:input-props {:default-value @token-value
|
||||||
:onChange #(on-update-state-field idx %)}}])])
|
:on-change #(on-update-state-field idx %)}}])])
|
||||||
[:& tokens.common/labeled-input {:label "Description"
|
[:& tokens.common/labeled-input {:label "Description"
|
||||||
:input-props {:defaultValue @description
|
:input-props {:default-value @description
|
||||||
:onChange #(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…
Reference in a new issue