Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cssectomy #327

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
32a2a18
CSS detached from first component
BnMcGn Oct 3, 2022
2f5fbb3
CSS split out
BnMcGn Oct 5, 2022
d84d115
css-desc table created
BnMcGn Oct 5, 2022
9d217ae
Split out css in v-table
BnMcGn Oct 9, 2022
d56b9e6
Bugfix
BnMcGn Oct 14, 2022
94922f8
Temporary debugging stuff
BnMcGn Oct 14, 2022
979363c
Bugfix
BnMcGn Oct 19, 2022
a0e530b
Add :use-toplevel option
BnMcGn Oct 24, 2022
4587072
Bugfixes for md-circle-icon
BnMcGn Oct 26, 2022
5c08e11
Merge-css: spread :attr
BnMcGn Oct 26, 2022
adc835d
Add :spread-attr as an option
BnMcGn Oct 26, 2022
67e8a61
Bugfixes
BnMcGn Oct 27, 2022
3ad1496
Correct the flatten-attr status of remaining components
BnMcGn Oct 28, 2022
cf863f0
Refactor merge-css
BnMcGn Oct 28, 2022
53bd3af
Css split out
BnMcGn Oct 31, 2022
0d54f6f
Css split out
BnMcGn Nov 2, 2022
0bd9e03
Css splitting completed
BnMcGn Nov 3, 2022
c204e56
Css split out
BnMcGn Nov 4, 2022
ee37bf8
Css split out
BnMcGn Nov 7, 2022
38360b5
Css split out for base datepicker component
BnMcGn Nov 10, 2022
65ff5f6
Bugfixes
BnMcGn Nov 11, 2022
a45213a
Bugfixes
BnMcGn Nov 18, 2022
f061d93
Bugfix and tools
BnMcGn Nov 18, 2022
88d037b
Complete splitting out of class spec
BnMcGn Nov 19, 2022
3d2c757
Bugfixes
BnMcGn Nov 19, 2022
86d94a0
Css split out
BnMcGn Nov 22, 2022
d5351c1
Css split out
BnMcGn Nov 24, 2022
3fd6008
Css split out
BnMcGn Nov 25, 2022
d63918c
Renamed -css-desc -> -css-spec
BnMcGn Nov 25, 2022
7cbed4d
Css split out
BnMcGn Nov 28, 2022
b612760
Sometimes we need metadata
BnMcGn Nov 28, 2022
11c376c
Css split out
BnMcGn Nov 29, 2022
02ddd9a
Css split out
BnMcGn Nov 29, 2022
8ce3700
Css split out
BnMcGn Nov 30, 2022
07182ed
Css split out
BnMcGn Nov 30, 2022
d4552a1
Css split out
BnMcGn Nov 30, 2022
f7c2241
Bugfix
BnMcGn Dec 1, 2022
9f4230f
Css split out
BnMcGn Dec 1, 2022
8be3643
Css split out
BnMcGn Dec 1, 2022
6a077db
Css split out
BnMcGn Dec 1, 2022
ed88351
Css split out
BnMcGn Dec 1, 2022
e7c4178
Css split out
BnMcGn Dec 2, 2022
9dc2047
Css split out
BnMcGn Dec 2, 2022
a851cbb
Css split out
BnMcGn Dec 2, 2022
159f0df
Css split out
BnMcGn Dec 2, 2022
9cfd9d1
Css split out
BnMcGn Dec 2, 2022
96815f6
Tests running
BnMcGn Dec 6, 2022
0545d6c
Change merge-css to handle toplevel :attr
BnMcGn Dec 7, 2022
3995e4e
Bugfix
BnMcGn Dec 7, 2022
c4260c6
Bugfix
BnMcGn Dec 7, 2022
810a062
Bugfix
BnMcGn Dec 9, 2022
488e066
Documentation
BnMcGn Dec 12, 2022
de21d6e
Pass vertical? to buttons
BnMcGn Jan 26, 2023
9971408
Fixes
BnMcGn Feb 1, 2023
c1066fc
Pass more data to css-spec functions
BnMcGn Feb 2, 2023
cf921ed
Bugfix
BnMcGn Apr 1, 2023
0ae0731
Improve button default class handling
BnMcGn Apr 1, 2023
f44e1e4
Bugfix in popover-border
BnMcGn Apr 27, 2023
76bcc0b
Some tests for merge-css
BnMcGn Jun 6, 2023
1297802
More tests for merge-css
BnMcGn Jun 7, 2023
5818813
Add arrow-renderer option
BnMcGn Aug 17, 2023
e630bcd
Merge remote-tracking branch 'upstream/master'
BnMcGn Feb 20, 2024
605d023
Bugfixes
BnMcGn Feb 21, 2024
d85fdf4
Run cljfmt
BnMcGn Feb 21, 2024
675e343
Css split out
BnMcGn Feb 23, 2024
1ba0b8a
Bugfixes
BnMcGn Feb 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ misc/
/shadow-cljs.edn
/.clj-kondo/
/.lsp/
.*
.*
49 changes: 49 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"react": "17.0.2",
"react-dom": "17.0.2",
"shadow-cljs": "2.15.2"
},
"dependencies": {
"karma-cli": "^2.0.0"
}
}
184 changes: 97 additions & 87 deletions src/re_com/alert.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[re-com.close-button :refer [close-button]]
[re-com.config :refer [include-args-desc?]]
[re-com.debug :refer [->attr]]
[re-com.util :refer [deref-or-value]]
[re-com.util :refer [deref-or-value merge-css add-map-to-hiccup-call flatten-attr]]
[re-com.validate :refer [string-or-hiccup? alert-type? alert-types-list
vector-of-maps? css-style? html-attr? parts?] :refer-macros [validate-args-macro]]))

Expand All @@ -17,7 +17,7 @@

(def alert-box-parts-desc
(when include-args-desc?
[{:type :legacy :level 0 :class "rc-alert-box" :impl "[alert-box]"}
[{:type :legacy :level 0 :class "rc-alert" :impl "[alert-box]"}
{:name :heading :level 1 :class "rc-alert-heading" :impl "[h-box]"}
{:name :h4 :level 2 :class "rc-alert-h4" :impl "[:h4]"}
{:name :close-button :level 2 :class "rc-alert-close-button" :impl "[close-button]"}
Expand All @@ -27,6 +27,26 @@
(when include-args-desc?
(-> (map :name alert-box-parts-desc) set)))

(def alert-box-css-spec
{:main {:class (fn [{:keys [alert-type]}]
["rc-alert" "alert" "fade" "in"
(case alert-type
:none nil
:info "alert-success"
:warning "alert-warning"
:danger "alert-danger"
nil)])
:style (fn [{:keys [padding]}]
(merge (flex-child-style "none")
{:padding padding}))}
:heading {:class ["rc-alert-heading"]
:style (fn [{:keys [body]}]
{:margin-bottom (if body "10px" "0px")})}
:h4 {:class ["rc-alert-h4"]
:style {:margin-bottom "0px"}}
:close-button {:class ["rc-alert-close-button"]}
:body {:class ["rc-alert-body"]}})

(def alert-box-args-desc
(when include-args-desc?
[{:name :id :required false :type "anything" :description [:span "a unique identifier, usually an integer or string."]}
Expand All @@ -50,54 +70,40 @@
:as args}]
(or
(validate-args-macro alert-box-args-desc args)
(let [close-alert [close-button
:src (at)
:class (str "rc-alert-close-button " (get-in parts [:close-button :class]))
:style (get-in parts [:close-button :style])
:attr (get-in parts [:close-button :attr])
:on-click #(on-close id)
:div-size 20
:font-size 20]
alert-class (alert-type {:none ""
:info "alert-success"
:warning "alert-warning"
:danger "alert-danger"})]
(let [cmerger (merge-css alert-box-css-spec args)
close-alert (add-map-to-hiccup-call
(cmerger :close-button)
[close-button
:src (at)
:on-click #(on-close id)
:div-size 20
:font-size 20])]
[:div
(merge {:class (str "rc-alert alert fade in " alert-class " " class)
:style (merge (flex-child-style "none")
{:padding padding}
style)}
(->attr args)
attr)
(merge (flatten-attr
(cmerger :main {:alert-type alert-type :padding padding}))
(->attr args))
(when heading
[h-box
:src (at)
:justify :between
:align :center
:class (str "rc-alert-heading " (get-in parts [:heading :class]))
:style (merge {:margin-bottom (if body "10px" "0px")}
(get-in parts [:heading :style]))
:attr (get-in parts [:heading :attr] {})
:children [[:h4
(merge
{:class (str "rc-alert-h4 " (get-in parts [:h4 :class]))
:style (merge {:margin-bottom "0px"}
(get-in parts [:h4 :style]))}
(get-in parts [:h4 :attr])) ;; Override h4
heading]
(when (and closeable? on-close)
close-alert)]])
(add-map-to-hiccup-call
(cmerger :heading {:body body})
[h-box
:src (at)
:justify :between
:align :center
:children [[:h4
(flatten-attr (cmerger :h4))
heading]
(when (and closeable? on-close)
close-alert)]]))
(when body
[h-box
:src (at)
:justify :between
:align :center
:class (str "rc-alert-body " (get-in parts [:body :class]))
:style (get-in parts [:body :style] {})
:attr (get-in parts [:body :attr] {})
:children [[:div body]
(when (and (not heading) closeable? on-close)
close-alert)]])])))
(add-map-to-hiccup-call
(cmerger :body)
[h-box
:src (at)
:justify :between
:align :center
:children [[:div body]
(when (and (not heading) closeable? on-close)
close-alert)]]))])))

;;--------------------------------------------------------------------------------------------------
;; Component: alert-list
Expand All @@ -116,6 +122,14 @@
(when include-args-desc?
(-> (map :name alert-list-parts-desc) set)))

(def alert-list-css-spec
{:wrapper {:class ["rc-alert-list-wrapper"]}
:main {:class ["rc-alert-list"]}
:scroller {:class ["rc-alert-list-scroller"]
:style (fn [{:keys [max-height]}]
{:max-height max-height})}
:v-box {:class ["rc-alert-list-v-box"]}})

(def alert-list-args-desc
(when include-args-desc?
[{:name :alerts :required true :type "vector of maps | r/atom" :validate-fn vector-of-maps? :description "alerts to render (in the order supplied). Can also be a list of maps"}
Expand Down Expand Up @@ -149,43 +163,39 @@
:as args}]
(or
(validate-args-macro alert-list-args-desc args)
(let [alerts (deref-or-value alerts)]
[box
:src src
:debug-as (or debug-as (reflect-current-component))
:class (str "rc-alert-list-wrapper " (get-in parts [:wrapper :class]))
:style (get-in parts [:wrapper :style] {})
:attr (get-in parts [:wrapper :attr] {})
:child [border
:src (at)
:class (str "rc-alert-list " class)
:style style
:attr attr
:padding padding
:border border-style
:child [scroller
:src (at)
:v-scroll :auto
:class (str "rc-alert-list-scroller " (get-in parts [:scroller :class]))
:style (merge {:max-height max-height}
(get-in parts [:scroller :style]))
:attr (get-in parts [:scroller :attr])
:child [v-box
:src (at)
:size "auto"
:class (str "rc-alert-list-v-box " (get-in parts [:v-box :class]))
:style (get-in parts [:v-box :style])
:attr (get-in parts [:v-box :attr])
:children [(for [alert alerts]
(let [{:keys [id alert-type heading body padding closeable?]} alert]
^{:key id} [alert-box
:src (at)
:id id
:alert-type alert-type
:heading heading
:body body
:padding padding
:closeable? closeable?
:on-close on-close
:class alert-class
:style (merge alert-style (:style alert))]))]]]]])))
(let [alerts (deref-or-value alerts)
cmerger (merge-css alert-list-css-spec args)]
(add-map-to-hiccup-call
(cmerger :wrapper)
[box
:src src
:debug-as (or debug-as (reflect-current-component))
:child (add-map-to-hiccup-call
(cmerger :main)
[border
:src (at)
:padding padding
:border border-style
:child (add-map-to-hiccup-call
(cmerger :scroller {:max-height max-height})
[scroller
:src (at)
:v-scroll :auto
:child (add-map-to-hiccup-call
(cmerger :v-box)
[v-box
:src (at)
:size "auto"
:children [(for [alert alerts]
(let [{:keys [id alert-type heading body padding closeable?]} alert]
^{:key id} [alert-box
:src (at)
:id id
:alert-type alert-type
:heading heading
:body body
:padding padding
:closeable? closeable?
:on-close on-close
:class alert-class
:style (merge alert-style (:style alert))]))]])])])]))))
Loading