summaryrefslogtreecommitdiff
path: root/src/views/components.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-03-05 16:36:44 -0800
committercolin <colin@cicadas.surf>2023-03-05 16:36:44 -0800
commitf7abccc38ceda7024ca375d34ed88f4fb561ef02 (patch)
tree432d6673e9e8d53b5fbc43e25a684b654f6dea1d /src/views/components.lisp
parent89d0d687992b41f7f0f9b0d3da19d9d587f06010 (diff)
Reorganized codebase
Diffstat (limited to 'src/views/components.lisp')
-rw-r--r--src/views/components.lisp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/views/components.lisp b/src/views/components.lisp
new file mode 100644
index 0000000..95ed062
--- /dev/null
+++ b/src/views/components.lisp
@@ -0,0 +1,33 @@
+;;;; views/components.lisp -- reusable components
+
+(in-package :dnd)
+
+;;; LIST DATA
+
+(defrender :list ((data list) (class "listview") (item-class "listitem"))
+ "A catch all for rendering lists of renderable data items as unordered
+lists. CLASS is the lass string for the containing list. ITEM-CLASS is
+the class string for the contained list items."
+ (with-html
+ (:ol :class class
+ (dolist (item data)
+ (:li :class item-class (render :list-item item))))))
+
+(defrender :horiz-list ((data list) (class "hlistview") (item-class "listitem"))
+ (with-html
+ (:ol :class class
+ (dolist (item data)
+ (:li :calss item-class (render :list-item item))))))
+
+;;;; PAGE ELEMENTS
+
+(defun navbar ()
+ (with-html
+ (:nav :class "navbar" :aria-label "Navigation"
+ (:div :class "logo" :aria-label "DND logo" "DND")
+ (:ul :class "nav-links" :aria-label "Nav links"
+ (:li (:a :href "/hero" :aria-label "Hero profile" "🧝"))
+ (:li (:a :href "/inventory" :aria-label "Inventory" "🎒"))
+ (:li (:a :href "/quests" :aria-label "Quests" "📜"))
+ (:li (:a :href "/tavern" :aria-label "Tavern" "🍺"))))))
+