mirror of
https://github.com/penpot/penpot.git
synced 2025-06-24 14:26:59 +02:00
♻️ Remove mf/props obj from DS components
This commit is contained in:
parent
b561ad033c
commit
603e41bbfd
28 changed files with 25 additions and 55 deletions
|
@ -22,8 +22,7 @@
|
|||
[:maybe [:enum "primary" "secondary" "ghost" "destructive"]]]])
|
||||
|
||||
(mf/defc button*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:button}
|
||||
{::mf/schema schema:button}
|
||||
[{:keys [variant icon children class on-ref] :rest props}]
|
||||
(let [variant (or variant "primary")
|
||||
class (dm/str class " " (stl/css-case :button true
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
[:maybe [:enum "primary" "secondary" "ghost" "destructive" "action"]]]])
|
||||
|
||||
(mf/defc icon-button*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:icon-button}
|
||||
{::mf/schema schema:icon-button}
|
||||
[{:keys [class icon icon-class variant aria-label children tooltip-id] :rest props}]
|
||||
(let [variant (or variant "primary")
|
||||
class (dm/str class " " (stl/css-case :icon-button true
|
||||
|
|
|
@ -62,8 +62,7 @@
|
|||
[:has-error {:optional true} :boolean]])
|
||||
|
||||
(mf/defc combobox*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:combobox}
|
||||
{::mf/schema schema:combobox}
|
||||
[{:keys [id options class placeholder disabled has-error default-selected max-length on-change] :rest props}]
|
||||
(let [is-open* (mf/use-state false)
|
||||
is-open (deref is-open*)
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
[:hint-type {:optional true} [:maybe [:enum "hint" "error" "warning"]]]])
|
||||
|
||||
(mf/defc input*
|
||||
{::mf/props :obj
|
||||
::mf/forward-ref true
|
||||
{::mf/forward-ref true
|
||||
::mf/schema schema:input}
|
||||
[{:keys [id class label is-optional type max-length variant hint-message hint-type] :rest props} ref]
|
||||
(let [id (or id (mf/use-id))
|
||||
|
|
|
@ -69,8 +69,7 @@
|
|||
[:on-change {:optional true} fn?]])
|
||||
|
||||
(mf/defc select*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:select}
|
||||
{::mf/schema schema:select}
|
||||
[{:keys [options class disabled default-selected on-change] :rest props}]
|
||||
(let [open* (mf/use-state false)
|
||||
open (deref open*)
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
[rumext.v2 :as mf]))
|
||||
|
||||
(mf/defc option*
|
||||
{::mf/props :obj
|
||||
::mf/private true}
|
||||
{::mf/private true}
|
||||
[{:keys [id label icon aria-label on-click selected set-ref focused] :rest props}]
|
||||
|
||||
[:> :li {:value id
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
[:class {:optional true} :string]])
|
||||
|
||||
(mf/defc hint-message*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema::hint-message}
|
||||
{::mf/schema schema::hint-message}
|
||||
[{:keys [id class message type] :rest props}]
|
||||
(let [type (d/nilv type :hint)]
|
||||
[:> "div" {:class (dm/str class " " (stl/css-case
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
[:slot-end {:optional true} [:maybe some?]]])
|
||||
|
||||
(mf/defc input-field*
|
||||
{::mf/props :obj
|
||||
::mf/forward-ref true
|
||||
{::mf/forward-ref true
|
||||
::mf/schema schema:input-field}
|
||||
[{:keys [id icon has-hint hint-type class type max-length variant slot-start slot-end] :rest props} ref]
|
||||
(let [input-ref (mf/use-ref)
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
[:class {:optional true} :string]])
|
||||
|
||||
(mf/defc label*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema::label}
|
||||
{::mf/schema schema::label}
|
||||
[{:keys [class for is-optional children] :rest props}]
|
||||
(let [is-optional (or is-optional false)
|
||||
props (mf/spread-props props {:class (dm/str class " " (stl/css :label))
|
||||
|
|
|
@ -300,8 +300,7 @@
|
|||
[:maybe [:enum "s" "m"]]]])
|
||||
|
||||
(mf/defc icon*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:icon}
|
||||
{::mf/schema schema:icon}
|
||||
[{:keys [icon-id size class] :rest props}]
|
||||
(let [class (dm/str (or class "") " " (stl/css :icon))
|
||||
props (mf/spread-props props {:class class :width icon-size-m :height icon-size-m})
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
(def raw-svg-list "A collection of all raw SVG assets" (collect-raw-svgs))
|
||||
|
||||
(mf/defc raw-svg*
|
||||
{::mf/props :obj}
|
||||
[{:keys [id] :rest props}]
|
||||
(assert (contains? raw-svg-list id) "invalid raw svg id")
|
||||
[:> "svg" props
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
[:typography [:and :string [:fn #(valid-typography? (dm/str %))]]]])
|
||||
|
||||
(mf/defc heading*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:heading}
|
||||
{::mf/schema schema:heading}
|
||||
[{:keys [level typography class children] :rest props}]
|
||||
|
||||
(let [level (or level "1")
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
[:typography [:and :string [:fn #(valid-typography? (dm/str %))]]]])
|
||||
|
||||
(mf/defc text*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:text}
|
||||
{::mf/schema schema:text}
|
||||
[{:keys [as typography children class] :rest props}]
|
||||
|
||||
(let [as (if (or (empty? as) (nil? as)) "p" as)
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
[:icon-id [:and :string [:fn #(contains? token-status-list %)]]]])
|
||||
|
||||
(mf/defc token-status-icon*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:token-status-icon}
|
||||
{::mf/schema schema:token-status-icon}
|
||||
[{:keys [icon-id class] :rest props}]
|
||||
(let [class (dm/str (or class "") " " (stl/css :token-icon))
|
||||
props (mf/spread-props props {:class class :width "14px" :height "14px"})
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
[rumext.v2 :as mf]))
|
||||
|
||||
(mf/defc tab*
|
||||
{::mf/props :obj
|
||||
::mf/private true}
|
||||
{::mf/private true}
|
||||
[{:keys [selected icon label aria-label id on-ref] :rest props}]
|
||||
(let [class (stl/css-case :tab true
|
||||
:selected selected)
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
(mf/defc context-notification*
|
||||
"Persistent notifications, they do not disappear.
|
||||
These are contextual messages in specific areas of the tool, usually in modals and Dashboard area, and are mainly informative."
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:context-notification}
|
||||
{::mf/schema schema:context-notification}
|
||||
[{:keys [class type appearance level is-html children] :rest props}]
|
||||
(let [class (dm/str class " " (stl/css-case :contextual-notification true
|
||||
:contain-html is-html
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
[:on-toggle-detail {:optional true} [:maybe fn?]]])
|
||||
|
||||
(mf/defc notification-pill*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:notification-pill}
|
||||
{::mf/schema schema:notification-pill}
|
||||
[{:keys [level type is-html appearance detail children show-detail on-toggle-detail]}]
|
||||
(let [class (stl/css-case :appearance-neutral (= appearance :neutral)
|
||||
:appearance-ghost (= appearance :ghost)
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
[:on-toggle-detail {:optional true} [:maybe fn?]]])
|
||||
|
||||
(mf/defc toast*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:toast}
|
||||
{::mf/schema schema:toast}
|
||||
[{:keys [class level appearance type is-html children detail show-detail on-close on-toggle-detail] :rest props}]
|
||||
(let [class (dm/str class " " (stl/css :toast))
|
||||
level (if (string? level)
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
[:snapshots [:vector [:fn valid-date?]]]])
|
||||
|
||||
(mf/defc autosaved-milestone*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:milestone}
|
||||
{::mf/schema schema:milestone}
|
||||
[{:keys [class active versionToggled label autosavedMessage snapshots
|
||||
onClickSnapshotMenu onToggleExpandSnapshots] :rest props}]
|
||||
(let [class (d/append-class class (stl/css-case :milestone true :is-selected active))
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
[:maybe [:enum "S" "M" "L"]]]])
|
||||
|
||||
(mf/defc avatar*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:avatar}
|
||||
{::mf/schema schema:avatar}
|
||||
|
||||
[{:keys [tag class name color url selected variant] :rest props}]
|
||||
(let [variant (or variant "S")
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
[:title :string]])
|
||||
|
||||
(mf/defc cta*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:cta}
|
||||
{::mf/schema schema:cta}
|
||||
[{:keys [class title children] :rest props}]
|
||||
|
||||
(let [class (d/append-class class (stl/css :cta))
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
[:type {:optional true} [:maybe [:enum 1 2]]]])
|
||||
|
||||
(mf/defc empty-placeholder*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:empty-placeholder}
|
||||
{::mf/schema schema:empty-placeholder}
|
||||
[{:keys [class title subtitle type children] :rest props}]
|
||||
|
||||
(let [class (dm/str class " " (stl/css :empty-placeholder))
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
[:on-blur {:optional true} fn?]])
|
||||
|
||||
(mf/defc input-with-meta*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:input-with-meta}
|
||||
{::mf/schema schema:input-with-meta}
|
||||
[{:keys [value meta on-blur] :rest props}]
|
||||
(let [editing* (mf/use-state false)
|
||||
editing? (deref editing*)
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
[:onKeyDownInput {:optional true} [:maybe [:fn fn?]]]])
|
||||
|
||||
(mf/defc user-milestone*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:milestone}
|
||||
{::mf/schema schema:milestone}
|
||||
[{:keys [class active editing user label date
|
||||
onOpenMenu onFocusInput onBlurInput onKeyDownInput] :rest props}]
|
||||
(let [class (d/append-class class (stl/css-case :milestone true :is-selected active))
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
[rumext.v2 :as mf]))
|
||||
|
||||
(mf/defc story-grid*
|
||||
{::mf/props :obj}
|
||||
[{:keys [children size style] :rest other}]
|
||||
(let [class (stl/css :story-grid)
|
||||
size (or size 16)
|
||||
|
@ -22,21 +21,18 @@
|
|||
[:> "article" props children]))
|
||||
|
||||
(mf/defc story-grid-cell*
|
||||
{::mf/props :obj}
|
||||
[{:keys [children] :rest other}]
|
||||
(let [class (stl/css :story-grid-cell)
|
||||
props (mf/spread-props other {:class class})]
|
||||
[:> "article" props children]))
|
||||
|
||||
(mf/defc story-header*
|
||||
{::mf/props :obj}
|
||||
[{:keys [children] :rest other}]
|
||||
(let [class (stl/css :story-header)
|
||||
props (mf/spread-props other {:class class})]
|
||||
[:> "header" props children]))
|
||||
|
||||
(mf/defc story-grid-row*
|
||||
{::mf/props :obj}
|
||||
[{:keys [children] :rest other}]
|
||||
(let [class (stl/css :story-grid-row)
|
||||
props (mf/spread-props other {:class class})]
|
||||
|
|
|
@ -116,8 +116,7 @@
|
|||
[:maybe [:enum "top" "bottom" "left" "right" "top-right" "bottom-right" "bottom-left" "top-left"]]]])
|
||||
|
||||
(mf/defc tooltip*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:tooltip}
|
||||
{::mf/schema schema:tooltip}
|
||||
[{:keys [class id children tooltip-content placement offset delay] :rest props}]
|
||||
(let [placement* (mf/use-state #(d/nilv placement "top"))
|
||||
placement (deref placement*)
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
[:typography {:optional true} :string]])
|
||||
|
||||
(mf/defc date*
|
||||
{::mf/props :obj
|
||||
::mf/schema schema:date}
|
||||
{::mf/schema schema:date}
|
||||
[{:keys [class date selected typography] :rest props}]
|
||||
(let [class (d/append-class class (stl/css-case :date true :is-selected selected))
|
||||
date (cond-> date (not (dt/datetime? date)) dt/datetime)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue