helix

2021-11-18T13:04:40.087100Z

Hi, Iโ€™m trying to get headlessui working in my app using Helix.

2021-11-18T13:04:47.087400Z

(ns website.core
  (:require [helix.core :refer [defnc $ <>]]
            [helix.dom :as  d]
            ["react-dom" :as rdom]
            ["@headlessui/react" :refer [Switch]]))

(def switch-label  #(. Switch -Label))
(def switch-group #(. Switch -Group))

(defnc my-component []

  (switch-group
     (switch-label "Dooo")
     (Switch {:checked true
              :class "relative inline-flex items-center h-6 rounded-full w-11 bg-gray-200"})))

(defn ^:export start
  []
  (rdom/render ($ my-component) (js/document.getElementById "app")))

2021-11-18T13:05:58.088700Z

I know my Switch is missing a bunch of props but its getting switch-group and switch-label to play nicely.

2021-11-18T13:07:01.089500Z

So I guess my question comes down to this, how does one go about using a lib such as HeadlessUI in Helix?

2021-11-18T13:14:43.089800Z

Using

(def switch-label  (. Switch -Label))
(def switch-group (. Switch -Group))

(defnc my-component []

  (switch-group
     (switch-label "Foo")
     (Switch {:checked true
              :class "relative inline-flex items-center h-6 rounded-full w-11 bg-gray-200"})))

2021-11-18T13:15:34.090Z

Results in this error

2021-11-18T13:31:30.090800Z

Iโ€™m idiotโ€ฆ ignore me. Just in case any one ever stumbles on this

2021-11-18T13:31:33.091100Z

(ns website.core
  (:require [helix.core :refer [defnc $ <>]]
            [helix.dom :as  d]
            ["react-dom" :as rdom]
            ["@headlessui/react" :as ui]))

(def switch-label ui/Switch.Label)
(def switch-group ui/Switch.Group)

(defnc my-component []

  
  ($ switch-group
    ($ switch-label "Hello?")
   ($ ui/Switch {:checked true
                :className "relative inline-flex items-center h-6 rounded-full w-11 bg-gray-200"})))

๐Ÿ‘ 3
๐Ÿ‘๐Ÿป 1
2021-11-18T13:31:36.091300Z

That works

lilactown 2021-11-18T16:37:49.091700Z

nice! glad you figured it out

lilactown 2021-11-18T16:38:37.092400Z

I recently used headlessui for their popover menu ๐Ÿ˜„ I felt ready to answer when I started reading and then you came to the conclusion already!