mirror of
https://github.com/penpot/penpot.git
synced 2025-08-04 04:28:25 +02:00
Reuse attribute keys from token schema
This commit is contained in:
parent
6bb4eec805
commit
28e6db9bb4
2 changed files with 22 additions and 5 deletions
|
@ -7,12 +7,27 @@
|
|||
(ns app.common.types.token
|
||||
(:require
|
||||
[app.common.schema :as sm]
|
||||
[app.common.schema.registry :as sr]))
|
||||
[app.common.schema.registry :as sr]
|
||||
[malli.util :as mu]))
|
||||
|
||||
(defn merge-schemas [& schema-keys]
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; HELPERS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn merge-schemas
|
||||
"Merge registered schemas."
|
||||
[& schema-keys]
|
||||
(let [schemas (map #(get @sr/registry %) schema-keys)]
|
||||
(reduce sm/merge schemas)))
|
||||
|
||||
(defn schema-keys
|
||||
"Converts registed map schema into set of keys."
|
||||
[registered-schema]
|
||||
(->> (get @sr/registry registered-schema)
|
||||
(sm/schema)
|
||||
(mu/keys)
|
||||
(into #{})))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SCHEMA
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -49,6 +64,8 @@
|
|||
[:r3 {:optional true} ::sm/uuid]
|
||||
[:r4 {:optional true} ::sm/uuid]])
|
||||
|
||||
(def border-radius-keys (schema-keys ::border-radius))
|
||||
|
||||
(sm/def! ::dimensions
|
||||
[:map
|
||||
[:width {:optional true} ::sm/uuid]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue