-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
316 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/checkouts | ||
/target | ||
/resources/public/js | ||
/node_modules | ||
.cpcache | ||
.idea | ||
.lsp | ||
.shadow-cljs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{:paths ["src" "target" "resources"] | ||
:deps {arttuka/reagent-material-ui {:mvn/version "5.2.4-0" | ||
:deps {arttuka/reagent-material-ui {:mvn/version "5.4.3-0" | ||
#_#_:exclusions [arttuka/reagent-material-ui-js]} | ||
cljsjs/react {:mvn/version "17.0.2-0"} | ||
cljsjs/react-dom {:mvn/version "17.0.2-0"} | ||
com.bhauman/figwheel-main {:mvn/version "0.2.13"}} | ||
com.bhauman/figwheel-main {:mvn/version "0.2.16"}} | ||
:aliases {:run-dev {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]} | ||
:run-npm {:main-opts ["-m" "figwheel.main" "-b" "npm" "-r"]}}} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(ns example.select | ||
(:require-macros [reagent-mui.util :refer [react-component]]) | ||
(:require [reagent.core :as r] | ||
[reagent-mui.styles :as styles] | ||
[reagent-mui.base.use-select :refer [use-select]] | ||
[reagent-mui.util :refer [use-effect use-ref use-state wrap-all-js-functions]])) | ||
|
||
(def root (styles/styled "div" {:position "relative"})) | ||
|
||
(def toggle (styles/styled "div" {:width 256 | ||
:border "1px solid #CDD2D7" | ||
:background-color "var(--color, white)" | ||
:padding 10 | ||
:display "inline-flex" | ||
:align-items "center" | ||
:justify-content "center" | ||
"& .placeholder" {:opacity "0.8"}})) | ||
|
||
(def listbox (styles/styled "div" {:padding 5 | ||
:list-style "none" | ||
:position "absolute" | ||
:width "100%" | ||
:border "1px solid #CDD2D7" | ||
:outline 0 | ||
"&.hidden" {:opacity 0 | ||
:visibility "hidden" | ||
:transition "opacity 0.4s 0.5s ease, visibility 0.4s 0.5s step-end"} | ||
"& > li" {:padding 8 | ||
"&:hover" {:background-color "#E7EBF0"} | ||
"&[aria-selected='true']" {:background-color "#E0E3E7"}}})) | ||
|
||
(def component (react-component [{:keys [options placeholder]}] | ||
(let [listbox-ref (use-ref nil) | ||
[listbox-visible? set-listbox-visible] (use-state false) | ||
{:keys [get-button-props get-listbox-props get-option-props value]} (wrap-all-js-functions | ||
(use-select {:listbox-ref listbox-ref | ||
:options options}))] | ||
(use-effect #(when listbox-visible? | ||
(some-> (.-current listbox-ref) (.focus))) | ||
#js [listbox-visible?]) | ||
[root {:on-mouse-over #(set-listbox-visible true) | ||
:on-mouse-out #(set-listbox-visible false) | ||
:on-focus #(set-listbox-visible true) | ||
:on-blur #(set-listbox-visible false)} | ||
[toggle (merge {:style {"--color" value}} | ||
(get-button-props)) | ||
(or value [:span.placeholder placeholder])] | ||
[listbox (merge {:class-name (when-not listbox-visible? "hidden")} | ||
(get-listbox-props)) | ||
(for [option options] | ||
^{:key (:value option)} [:li (get-option-props option) | ||
(:label option)])]]))) |