From bb0120a9044819a4ab7adacc9ee9d821aad8d2a4 Mon Sep 17 00:00:00 2001 From: Daniel Leong Date: Sun, 17 Feb 2019 09:38:31 -0500 Subject: [PATCH] Begin scaffolding out the "campaign workspace" UI Refs #69 Taking notes is great, but you also probably want to be able to organize for the current session. The workspace is where you can layout specific notes and other entities for reference as part of session planning. --- save-syntax.edn | 13 +++++++++++ src/cljs/wish/sheets/dnd5e/campaign.cljs | 7 +++++- src/cljs/wish/views/campaign/base.cljs | 5 ++++- src/cljs/wish/views/campaign/subs.cljs | 14 ++++++++++++ src/cljs/wish/views/campaign/workspace.cljs | 25 +++++++++++++++++++++ 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/cljs/wish/views/campaign/workspace.cljs diff --git a/save-syntax.edn b/save-syntax.edn index 78d2c967..655581c6 100644 --- a/save-syntax.edn +++ b/save-syntax.edn @@ -91,4 +91,17 @@ :n/1 :n/2 :f/3]} + + ; what's currently on the workspace? + ; The Workspace consists of a single "primary" column and a single + ; "secondary" column. Things in the "secondary" column are associated + ; with an entry in the "primary" column for quick reference. On mobile, + ; they may be accessible via a side-swipe; on desktop or tablet, they + ; are placed adjacent to the primary column + :workspace [[:primary/1 :secondary/1 :secondary/2] + + ; each item in the workspace is wrapped in a vector; the + ; first entry is the primary column item, and anything else + ; goes in the secondary column + [:primary/2 :secondary/1]] } diff --git a/src/cljs/wish/sheets/dnd5e/campaign.cljs b/src/cljs/wish/sheets/dnd5e/campaign.cljs index 48a743e5..d6782bce 100644 --- a/src/cljs/wish/sheets/dnd5e/campaign.cljs +++ b/src/cljs/wish/sheets/dnd5e/campaign.cljs @@ -25,7 +25,12 @@ [abilities-display info])] ]) +(defn entity-card [e] + ; TODO + [:div (str e)]) + (defn view [section] [base/campaign-page section - :char-card char-card]) + :char-card char-card + :entity-card entity-card]) diff --git a/src/cljs/wish/views/campaign/base.cljs b/src/cljs/wish/views/campaign/base.cljs index 391ac25f..82c0448e 100644 --- a/src/cljs/wish/views/campaign/base.cljs +++ b/src/cljs/wish/views/campaign/base.cljs @@ -2,13 +2,16 @@ :doc "base"} wish.views.campaign.base (:require [wish.views.campaign.chars-carousel :refer [chars-carousel]] + [wish.views.campaign.workspace :refer [workspace]] [wish.views.error-boundary :refer [error-boundary]])) (defn campaign-page - [_section & {:keys [char-card]}] + [_section & {:keys [char-card entity-card]}] [error-boundary [:div.campaign [chars-carousel char-card] + [workspace + :entity-card entity-card] [:div.info "This is the campaign page." diff --git a/src/cljs/wish/views/campaign/subs.cljs b/src/cljs/wish/views/campaign/subs.cljs index 7670011f..06d114fb 100644 --- a/src/cljs/wish/views/campaign/subs.cljs +++ b/src/cljs/wish/views/campaign/subs.cljs @@ -3,6 +3,20 @@ wish.views.campaign.subs (:require [re-frame.core :refer [reg-sub]])) +(defn- reg-meta-sub + [id getter] + (reg-sub + id + :<- [:sheet-meta] + (fn [sheet _] + (getter sheet)))) + +(reg-meta-sub :meta/workspace :workspace) + +;; +;; Campaign members +;; + (reg-sub ::add-char-candidates :<- [:meta/players] diff --git a/src/cljs/wish/views/campaign/workspace.cljs b/src/cljs/wish/views/campaign/workspace.cljs new file mode 100644 index 00000000..3a1efb60 --- /dev/null +++ b/src/cljs/wish/views/campaign/workspace.cljs @@ -0,0 +1,25 @@ +(ns ^{:author "Daniel Leong" + :doc "Campaign workspace"} + wish.views.campaign.workspace + (:require [wish.util :refer [evt]] + [wish.util.nav :as nav :refer [sheet-url]] + [wish.views.error-boundary :refer [error-boundary]] + [wish.views.widgets :refer [icon link link>evt]] + [wish.views.campaign.events :as events] + [wish.views.campaign.subs :as subs])) + +(defn- id-for [item] + (or (when (keyword? item) + item) + (:id item))) + +(defn workspace-item [entity-card item] + ; TODO + [:div (str item)]) + +(defn workspace [& {:keys [entity-card]}] + (let [workspace (