Closed MawiraIke closed 3 years ago
Fair to note that the re-com components are edited as follows;
The re-com components, p
and p-span
do not receive any editing
The re-com components below are considered to have the child which is the indicated key
modal-panel
-> :child
alert-box
-> :body
box
-> :child
scroller
-> :child
border
-> :child
checkbox
-> :label
The keyword args are added to a map and then the child is added after.
For example the box
[re-com/box :src (at)
:size "1"
:child [border
:border "1px dashed red"
:child [box :height "100px" :child "Hello"]]
:align :center]
is transformed to
[re-com/box { :src (at) <== the map is added
:size "1"
:align :center } [border <== child is conjoined after the map
:border "1px dashed red"
:child [box :height "100px" :child "Hello"]]]
Space is not preserved after the first child
The following re-com components are assumed to have the key :children
h-box
v-box
The keyword arguments are added to a map and then children are added recursively after
For example the v-box
below
[v-box :src (at)
:size "1"
:justify :center
:children [[re-com/v-box :src (at)
:size "1"
:children [[label :title "Moved"]]
:align :center]
is transformed to
[v-box { :src (at) <== map is added
:size "1"
:justify :center } [re-com/v-box :src (at) <== children are added after the map
:size "1"
:children [[label :title "Moved"]]
:align :center]
Note that space is not preserved in the children
The following are treated as splits
h-split
v-split
The keys :panel-1
and panel-2
are added in the right order outside the map
For example consider the h-split
[rc/h-split :src (at)
:panel-1 [left-panel]
:panel-2 [right-panel]
:size "300px"]
It is transformed to
[rc/h-split { :src (at) <== the map is added
:size "300px" } [left-panel] [right-panel]] <== the panels are added after the map
Space is preserved within the map
All other components are treated as to have no special reformatting and all their keyword arguments are wrapped in a map preserving whitespace. For example a button like
[button
:label "This is the label"
:style {:color "red"}
:on-click nil
:class "class-name"]
is edited as follows
[button { <== the map is added
:label "This is the label"
:style {:color "red"}
:on-click nil
:class "class-name" } ]
The detail you provide above should be included at the end of the README
Thanks @mike-thompson-day8 @superstructor I have merged your suggestions to the latest commit
Nice, thanks @MawiraIke 👍🏻 😄
Adds script and fixes #275
The instructions to run the script are in the directory
re-com/scripts/kwargs-to-map/README.md