-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add preliminary chars carousel widget
Refs #69 Mostly just ensures sheets are loaded; styling to come... eventually
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
(ns ^{:author "Daniel Leong" | ||
:doc "Campaign-viewer for D&D 5e"} | ||
wish.sheets.dnd5e.campaign) | ||
wish.sheets.dnd5e.campaign | ||
(:require [wish.views.campaign.chars-carousel :refer [chars-carousel]])) | ||
|
||
(defn char-card [c] | ||
[:div.character | ||
(:name c)]) | ||
|
||
(defn view | ||
[section] | ||
[:div | ||
[chars-carousel char-card] | ||
"TODO Campaign"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(ns ^{:author "Daniel Leong" | ||
:doc "campaign.chars-carousel"} | ||
wish.views.campaign.chars-carousel | ||
(:require [wish.util :refer [<sub >evt]] | ||
[wish.views.error-boundary :refer [error-boundary]])) | ||
|
||
(defn- sheet-loader [sheet] | ||
[:div "Loading " (:name sheet) "..."]) | ||
|
||
(defn- sources-loader [sheet] | ||
[:div "Loading " (:name sheet) "..."]) | ||
|
||
(defn- char-sheet-loader | ||
[sheet-id content-fn] | ||
(let [sheet (<sub [:provided-sheet sheet-id])] | ||
(if (:sources sheet) | ||
(if-let [source (<sub [:sheet-source sheet-id])] | ||
; sheet is ready; render! | ||
[error-boundary | ||
[content-fn sheet]] | ||
|
||
(do | ||
(>evt [:load-sheet-source! sheet (:sources sheet)]) | ||
[sources-loader sheet])) | ||
|
||
; either we don't have the sheet at all, or it's just | ||
; a stub with no actual data; either way, load it! | ||
(do | ||
(>evt [:load-sheet! sheet-id]) | ||
[sheet-loader sheet])))) | ||
|
||
(defn chars-carousel [chars-card-view] | ||
(if-let [members (seq (<sub [:campaign-members]))] | ||
[:div.carousel-container | ||
[:div.carousel | ||
|
||
(for [c members] | ||
^{:key (:id c)} | ||
[:div.card | ||
[char-sheet-loader | ||
(:id c) | ||
chars-card-view]])]] | ||
|
||
[:div.empty-carousel | ||
"No characters in this campaign... yet!"])) |