-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavbar.lisp
48 lines (38 loc) · 1003 Bytes
/
navbar.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
;;;; navbar.lisp
(defparameter *navbar-groups* '())
(defclass navbar-group ()
((name
:initarg :name
:accessor name
:documentation "Name of the group")
(links
:initform '()
:accessor links
:documentation "List of the displayed links"))
(:documentation "A named navbar group"))
(defclass link ()
((name
:initarg :name
:accessor name
:documentation "Visible name of the link")
(link
:initarg :link
:accessor link
:documentation "Where the links"))
(:documentation "Models a link with a visible name"))
(defgeneric render (renderable)
(:documentation "Renders object to html"))
(defmethod render ((renderable link))
(make-link (name renderable) (link renderable)))
(defmethod render ((renderable navbar-group)) ;TODO: Break links into lists of two links
(let ((links (mapcar 'render (links renderable))))
`(:div
:class "container"
(:b ,(name renderable))
(:div
:class "content"
,links))))
(defun make-link (name link)
`(:a
:href ,link
,name))