Skip to content

Instantly share code, notes, and snippets.

@andreortiz82
Created May 8, 2019 13:39
Show Gist options
  • Save andreortiz82/2b1b70c1fe5ff6197c7820d93365ae01 to your computer and use it in GitHub Desktop.
Save andreortiz82/2b1b70c1fe5ff6197c7820d93365ae01 to your computer and use it in GitHub Desktop.
Drag Drop
(ns gallery.prototypes.trialboard
(:require [cljsjs.react-beautiful-dnd]
[rum.core :as rum]))
(def drag-drop-context
(.createFactory js/React (.-DragDropContext js/ReactBeautifulDnd)))
(def droppable
(.createFactory js/React (.-Droppable js/ReactBeautifulDnd)))
(def draggable
(.createFactory js/React (.-Draggable js/ReactBeautifulDnd)))
(rum/defcs View
< (rum/local {:foo nil})
[state]
(let [local-state (:rum/local state)
{:keys [foo]} @local-state]
[:main
[:div
(drag-drop-context {:onDragEnd #(js/console.log %)}
(droppable {:droppable-id "list" :type "my-list"}
[:ul
(map-indexed
(fn [index value]
(draggable {:draggable-id value :index index}
[:li value]))
["Larry" "Moe" "Curly" "Shemp"])]))]]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment