Skip to content

Instantly share code, notes, and snippets.

@dupuchba
dupuchba / magicast.clj
Created February 24, 2022 16:43
ClojureDart Magicasting
;; Example 1: inlined dart List
(w/Column. :children #dart [(w/Text. "aa")])
;; Example 2: not inlined dart list
(let [t #dart [(w/Text. "aa")]]
(w/Column. :children t))
;; Example 3: PV with inlined widget
(w/Column. :children [(w/Text. "aa")])

Keybase proof

I hereby claim:

  • I am dupuchba on github.
  • I am baptiste87 (https://keybase.io/baptiste87) on keybase.
  • I have a public key ASA2VnY6k-hVHEZJm7-x7BLGW8GJw-i6iI3WT6Wl7YSSHgo

To claim this, I am signing this object:

(require 'package)
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/")
t)
(add-to-list 'package-archives
(ns formfulcro.ui.root
(:require
[fulcro.client.mutations :as m :refer [defmutation]]
[fulcro.client.data-fetch :as df]
#?(:cljs [fulcro.client.dom :as dom] :clj [fulcro.client.dom-server :as dom])
[formfulcro.api.mutations :as api]
[fulcro.client.primitives :as prim :refer [defsc]]
[fulcro.i18n :as i18n :refer [tr trf]]
[fulcro.ui.elements :as ele]
@dupuchba
dupuchba / parsehtml.clj
Created October 24, 2017 16:00 — forked from seltzer1717/parsehtml.clj
Converts Bootstrap HTML to ClojureScript Om Code
;; Converts Bootstrap HTML into ClojureScript Om code
;; Formats output as well
;; Useful when you want to mock a Bootstrap layout but then convert to ClojureScript Om code.
(ns com.seltzer1717.term.server.parsehtml
(:import
(java.io
FileReader
FileWriter
BufferedReader
BufferedWriter)
;; =============================================================================
;; Initial Data
(def init-data {:app/lists [{:id 1
:elements [{:id 1
:text "This is a draggable element 1"}
{:id 2
:text "This is a draggable element 2"}
{:id 3
:text "This is a draggable element 3"}
{:id 4
(defn move-element [state from to element]
(letfn [(remove* [elements ref]
(into [] (remove #{ref} elements)))
(add* [elements ref]
(into [] (cond-> elements
(not (some #{ref} elements)) (conj ref))))]
(-> state
(update-in (conj from :elements) remove* element)
(update-in (conj to :elements) add* element))))
(om/app-state reconciler)
=>
#object[cljs.core.Atom
{:val {:app/lists [[:list/by-id 1] [:list/by-id 2] [:list/by-id 3]],
:element/by-id {1 {:id 1, :text "This is a draggable element 1"},
2 {:id 2, :text "This is a draggable element 2"},
3 {:id 3, :text "This is a draggable element 3"},
4 {:id 4, :text "This is a draggable element 4"},
5 {:id 5, :text "This is a draggable element 5"},
6 {:id 6, :text "This is a draggable element 6"},
(defui Element
static om/Ident
(ident [this {:keys [id]}]
[:element/by-id id])
static om/IQuery
(query [this]
[:id :text])
Object
(render [this]
(let [{:keys [id text]} (om/props this)
(defui ElementList
static om/Ident
(ident [this {:keys [id]}]
[:list/by-id id])
static om/IQuery
(query [this]
[:id {:elements (om/get-query Element)}])
Object
(on-drag-start [this element]
(om/transact! this `[(element/drag {:from ~(om/get-ident this) :element ~element}) :app/lists]))