fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
stuartrexking 2021-02-12T00:06:57.364700Z

kill sexp or just kill works, but how do you paste onto the line below.

peterdee 2021-02-12T00:19:56.365400Z

Newbie question: could someone suggest how to display a modal with fulcro and Semantic UI?

tony.kay 2021-02-12T00:28:39.365500Z

Nice. Good work man!

❤️ 1
stuartrexking 2021-02-12T00:42:40.367300Z

@peterd Are you familiar with Fulcro? If not then the best approach is to learn Fulcro by reading the book https://book.fulcrologic.com and watching the video series https://www.youtube.com/playlist?list=PLVi9lDx-4C_T7jkihlQflyqGqU4xVtsfi. That should get you to a point of understanding where you can open a modal.

Jakub Holý 2021-02-12T13:58:06.377500Z

I would argue that it might be better to start with https://github.com/fulcro-community/guides/blob/main/minimalist-fulcro-tutorial/index.adoc 🙂

Jakub Holý 2021-02-12T13:58:44.378100Z

though Peter already knows these 🙂

tony.kay 2021-02-12T01:05:58.370600Z

So I’m using the IntelliJ “Kill Sexp”, which puts it in the normal copy buffer. So, the key sequence you see me using is: Kill Sexp, Undo, move to new location, OS Paste

tony.kay 2021-02-12T01:07:12.370800Z

I should be using “Copy as Kill”, which doesn’t delete it (and would not need the undo), but I have a strong habit of just using the other because the kb shortcut is easier for me to hit 😄

tony.kay 2021-02-12T01:08:03.371900Z

Now that you’ve asked me to explain it, and it sounds so silly, I’ll probably spend the time making myself use the better shortcut 😜

tony.kay 2021-02-12T01:09:25.373Z

These are all in settings under Cursive:

peterdee 2021-02-12T01:10:03.373400Z

Hi @stuartrexking I’m getting there with Fulcro. I have read the book, watched the videos up to the 6th one or so. @holyjak Minimalist’s Guide is fantastic. I have two apps that do some basics. For example, a chess UI https://github.com/pdenno/chui/blob/main/src/main/app/client.cljs but struggle with javascript interop with things like the modal. You can see my modal attempt there. The semantic UI React modal here https://semantic-ui.com/modules/modal.html#/usage

tony.kay 2021-02-12T01:10:04.373700Z

I use some non-standard mappings, but that’s where to look to set your own. The Help->Show Cursive Cheat Sheet will show you a more readable version of what they are set to (it is updated when you change them)

tony.kay 2021-02-12T01:11:45.373900Z

bleh…I just use semantic ui react and let them deal with the overall mess of Portals and such.

tony.kay 2021-02-12T01:12:19.374100Z

So then it is just a local attribute like :ui/modal-visible? in the query/props that I can toggle true/false to set the modal open.

tony.kay 2021-02-12T01:12:28.374300Z

See fulcro semantic-ui-wrappers

tony.kay 2021-02-12T01:13:05.374500Z

Otherwise, if you really want to implement it yourself (correctly) you’d use React portals to plop the node onto the root for aria compliance, etc.

stuartrexking 2021-02-12T01:14:59.374700Z

Thanks for the detailed answer. I figured you were just going into insert mode and pasting.

stuartrexking 2021-02-12T01:15:11.374900Z

I could hear it in the keystrokes.

peterdee 2021-02-12T01:23:41.375100Z

Thanks! Since I have no idea what a React portal is, I’ll take your advice and stay away! Though I don’t know Fulcro very well yet, I can see that it is built on solid principles and will be very effective for me once I “get it”. Thanks also for creating it!

👍 1
peterdee 2021-02-12T02:25:16.375400Z

Wow, that was easy. I had dinner in that time too!

😁 1
Pragyan Tripathi 2021-02-12T12:11:58.377400Z

Is there any example which show how to use devcards with fulcro?

Jakub Holý 2021-02-12T14:00:03.378400Z

look at fulcro-template. it uses them

Jakub Holý 2021-02-12T14:02:12.378700Z

Actually not decards but Workspaces which is similar https://github.com/fulcrologic/fulcro-template#workspaces-1

2021-02-12T14:48:54.379100Z

I managed to get this working, mostly copying the code from workspaces. https://github.com/dvingo/my-clj-utils https://github.com/dvingo/my-clj-utils/blob/master/src/main/dv/devcards_fulcro3.clj here's an example usage:

(ns app.react-collapse-cards
  (:require
    [my-app.client.ui.collapsible-view :refer [ui-collapse]]
    [com.fulcrologic.fulcro.components :as c :refer [defsc]]
    [dv.devcards-fulcro3 :as f3]))

(defsc CollapseView [this {:ui/keys [open?] :as props}]
  {:query         [:ui/open?]
   :ident         (fn [_] [::id ::card])
   :initial-state {:ui/open? false}}
  [:div
   [:button.ui.button.large
    {:on-click #(m/toggle!! this :ui/open?)} "toggle"]
   (ui-collapse {:isOpened open?}
     "Hello world")])

(f3/make-reagent-card CollapseView)
I noticed devcards library code being included in production builds though, and eventually started using storybook instead (https://github.com/dvingo/my-clj-utils/blob/master/src/main/dv/fulcro_storybook.cljs)

👍 2
Pragyan Tripathi 2021-02-12T15:12:45.379300Z

Storybook looks really great.. will give it a try.. thanks 🙂

2021-02-12T15:33:39.379600Z

nice - this setup here, is where I started https://github.com/lilactown/storybook-cljs

2021-02-12T19:31:40.385Z

I'm still thinking about how to integrate Firestore with Fulcro effectively. Firestore is unusual in that it's not really built for occasional request-response queries, but for streaming. ideally, it would work like this: - app navigates to a page with a list - create a streaming query for a collection from Firestore - burst of "added" events for the current contents - probably merge-component! add/update/delete events into the database? - when the user navigates away from the page, the query can be disconnected again. I don't know Fulcro well enough to know where to put those "mount" and "unmount" hooks, or if that whole approach is misguided.

👍 1
Jakub Holý 2021-02-13T20:52:03.394900Z

What you described makes sense to me, Braden. You can use React life cycle methods wit Fulcro such as component did mount / unmount for this. (Or React hooks, leveraging the hooks support in F.)

2021-02-13T22:11:49.395800Z

okay, I'll take a look. that's why I asked, I was sure there would be some good place to hook into the lifecycle. I'll hook it into the list component's lifecycle, I suppose.

2021-02-13T22:11:54.396Z

thanks!

wilkerlucio 2021-02-12T20:10:32.385800Z

if I were to do that, I would think about where I want things to start listening for data. Of course you cant on every app listen for every state change, but inside of task (consider doing a TODO app here) component for example, you could use hooks to start a FB subscription for the data on that point (and clear up the subscriptions when the component is removed). This way you could do a more fine tuning on the subscriptions, makes sense?

Alex 2021-02-12T21:41:50.386100Z

Hey guys I have the following component

(defsc AccountListItem
  "An account list item"
  [this {:account/keys [id name email active? edit] :as props}]
  {:query [:account/id :account/name :account/email :account/active?
           {:account/edit ['*]}]
   :ident :account/id
   :initLocalState (fn [this _] {:editing? false})}
  (let [editing? (prim/get-state this :editing?)]
    (if editing?
      (account-form props)
      (dom/tr
       (dom/td name)
       (dom/td email)
       (dom/td
        (dom/div :.ui.label.green
                 (if active? "Active" "Inactive")))
       (dom/td
        (dom/button {:onClick
                     (fn []
                        (prim/set-state!
                         this
                         {:editing? (not editing?)})
                        (prim/transact! this `[(app.model.account/use-account-as-form {:account-id ~id})]))}
                    "Edit"))))))
I'm trying to get rid of the `editing?` local state by having a `:account/edit` state on the root which will change when the `edit` button is pressed.  However, when I try to retrieve the value of `:account/edit` on my query I get nil.

Jakub Holý 2021-02-13T20:54:58.395200Z

You could have it at root and use a Link Query to ask for it. Or perhaps better, have it on the parent (table/list component), which would query for it and pass it to each row as a Computed Property.

Alex 2021-02-14T17:08:43.398800Z

@holyjak ah there it is, thank you! this will do.

👍 1
Alex 2021-02-12T21:42:07.386200Z

My Root query looks like the following:

[:main/welcome-message
 #:main{:accounts
        [:component/id
         #:accounts{:accounts
                    [:list/id
                     #:list{:accounts
                            [:account/id
                             :account/name
                             :account/email
                             :account/active?
                             #:account{:edit [*]}]}]}]}]