uses popper for dropdown.
This commit is contained in:
@@ -84,7 +84,7 @@ c.clearChoices();
|
||||
:popper nil})
|
||||
:x-modelable "value.value"
|
||||
:x-model (:x-model params)
|
||||
:x-init "popper = Popper.createPopper($refs.input, $refs.dropdown, {placement: 'bottom-start', strategy: 'fixed'})"
|
||||
:x-init "popper = Popper.createPopper($refs.input, $refs.dropdown, {placement: 'bottom-start', strategy: 'fixed', modifiers: {name: 'offset', options: {offset: [0, 20]}}})"
|
||||
}
|
||||
[:a {:class (-> (hh/add-class (or (:class params) "") default-input-classes)
|
||||
(hh/add-class "cursor-pointer"))
|
||||
@@ -113,7 +113,7 @@ c.clearChoices();
|
||||
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}
|
||||
svg/drop-down]]]
|
||||
|
||||
[:ul.dropdown-contents {:class "bg-gray-100 dark:bg-gray-600 rounded-lg shadow-lg py-1 w-max z-50"
|
||||
[:ul.dropdown-contents {:class "bg-gray-100 dark:bg-gray-600 rounded-lg shadow-2xl w-max z-50"
|
||||
"x-ref" "dropdown"
|
||||
"@keydown.escape" "open = false; value = {value: '', label: '' }"
|
||||
"x-transition:enter" "ease-[cubic-bezier(.3,2.3,.6,1)] duration-200"
|
||||
@@ -124,15 +124,20 @@ c.clearChoices();
|
||||
"x-transition:leave-end" "!opacity-0 !mt-0"
|
||||
"x-show " "open"
|
||||
"x-trap" "open"
|
||||
"@click.outside" "open=false; console.log('is this ihid')"}
|
||||
[:input {:type "text" :class (hh/add-class (or (:class params) "") default-input-classes)
|
||||
"@click.outside" "open=false;"}
|
||||
|
||||
[:input {:type "text"
|
||||
:class (-> (:class params)
|
||||
(or "")
|
||||
(hh/add-class default-input-classes)
|
||||
(hh/replace-wildcard ["rounded" "border"] "border-bottom bg-gray-100 rounded-t-lg w-full"))
|
||||
"x-model" "search"
|
||||
"placeholder" (:placeholder params)
|
||||
"@keydown.down.prevent" "active ++; active = active >= elements.length - 1 ? elements.length - 1 : active"
|
||||
"@keydown.up.prevent" "active --; active = active < 0 ? 0 : active"
|
||||
"@keydown.enter.prevent" "open = false; value = elements.length > 0 ? $data.elements[active] : {'value': '', label: ''}; console.log('are we here')"
|
||||
"@keydown.enter.prevent" "open = false; value = elements.length > 0 ? $data.elements[active] : {'value': '', label: ''};"
|
||||
"x-init" "$watch('search', s => { if($el.value.length > 2) {fetch(baseUrl + s).then(data=>data.json()).then(data => {elements = data; active=-1}) }})"}]
|
||||
[:div.dropdown-options
|
||||
[:div.dropdown-options {:class "rounded-b-lg overflow-hidden"}
|
||||
[:template {:x-for "(element, index) in elements"}
|
||||
[:li [:a {:class "px-4 py-2 flex gap-2 items-center outline-0 focus:bg-neutral-100 hover:bg-neutral-100 whitespace-nowrap [&.active]:bg-primary-300 [&.active]:dark:bg-primary-700 text-gray-800 dark:text-gray-100"
|
||||
:href "#"
|
||||
@@ -143,9 +148,11 @@ c.clearChoices();
|
||||
"x-html" "element.label"}]]]
|
||||
[:template {:x-if "elements.length == 0"}
|
||||
[:li {:class "px-4 py-2 flex gap-2 items-center outline-0 focus:bg-neutral-100 hover:bg-neutral-100 whitespace-nowrap [&.active]:bg-primary-500 text-gray-800 dark:text-gray-100 text-xs "}
|
||||
"No results found"]]]]])
|
||||
"No results found"]]]
|
||||
]])
|
||||
|
||||
|
||||
;; TODO fix search modal
|
||||
(defn use-size [size]
|
||||
(if (= :small size)
|
||||
(str " " "text-xs p-2")
|
||||
|
||||
@@ -66,7 +66,6 @@ input[type=number] {
|
||||
contents
|
||||
[:script {:src "/js/flowbite.min.js"}]
|
||||
|
||||
[:div#tooltip.bg-red-500.p-12 {:role "tooltip"}]
|
||||
[:div#modal-holder
|
||||
{:tabindex "-1", :class "fixed top-0 left-0 z-[99] flex items-center justify-center w-screen h-screen"
|
||||
"x-show" "open"
|
||||
@@ -85,11 +84,7 @@ input[type=number] {
|
||||
"x-transition:leave-start" "!bg-opacity-50"
|
||||
"x-transition:leave-end" "!bg-opacity-0"}
|
||||
|
||||
;; TODO to get this right i think what needs to happen is to just set this up as having a single
|
||||
;; div that is forced to the maximum allowed size. inside that will be a div that just centers
|
||||
;; the elements, allowing it to grow as necessar. Then make the modal on the inside of this
|
||||
;; div just use flexbox to make the inside part be the part that scrolls
|
||||
[:div {;;:class (str "sm:m-12 flex justify-center items-center bg-green-500 items-stretch inset-0")
|
||||
[:div {
|
||||
:class "flex h-full w-full justify-stretch md:justify-center items-stretch md:items-center "
|
||||
"x-trap.inert.noscroll" "open"
|
||||
"x-trap.inert" "open"
|
||||
|
||||
Reference in New Issue
Block a user