Skip to content

Instantly share code, notes, and snippets.

Baptiste DUPUCH dupuchba

Block or report user

Report or block dupuchba

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

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:

View init
(require 'package)
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/")
t)
(add-to-list 'package-archives
View form.cljs
(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 Oct 24, 2017 — forked from seltzer1717/parsehtml.clj
Converts Bootstrap HTML to ClojureScript Om Code
View parsehtml.clj
;; 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)
View final.cljs
;; =============================================================================
;; 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
View step5.cljs
(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))))
View step4-4.cljs
(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"},
View step4-3.cljs
(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)
View step4-2.cljs
(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]))
View step4-1.cljs
(defmulti mutate om/dispatch)
(defmethod mutate 'element/drag
[{:keys [state]} _ params]
{:value {:keys [:elements/dragged]}
:action (fn []
(if-not (empty? params)
(swap! state assoc :elements/dragged params)
(swap! state assoc :elements/dragged nil)))})
You can’t perform that action at this time.