summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-06-28 23:00:16 -0700
committercolin <colin@cicadas.surf>2024-06-28 23:00:16 -0700
commitb7da7a19e98b80fdf044d3e910d866e464653b85 (patch)
tree393a5954df9a87546f61bce4fe3091c345f0cf8d /src
parenta2c30e8b368a527a645f048648d1d2ca12593fb2 (diff)
reorg
Diffstat (limited to 'src')
-rw-r--r--src/dom-transform.lisp9
-rw-r--r--src/hypnotisml.lisp15
-rw-r--r--src/package.lisp23
3 files changed, 35 insertions, 12 deletions
diff --git a/src/dom-transform.lisp b/src/dom-transform.lisp
index 803a7f4..0afe608 100644
--- a/src/dom-transform.lisp
+++ b/src/dom-transform.lisp
@@ -32,8 +32,7 @@
(defun empty-queue (q)
(not (or (car q) (cdr q))))
-(defun ensure-parent (parent nodes)
- (loop :for node :in nodes :do (setf (parent node) parent)))
+
(defun expand-walk (top node clauses)
(a:with-gensyms (new-children frontier top-var parent)
@@ -54,13 +53,13 @@
(:replace
(push `(,guard
(let ((,node ,phrase-body))
- (setf (parent ,node) ,parent)
- (push ,node ,new-children)))
+ ;(setf (parent ,node) ,parent)
+ (pushnew ,node ,new-children :test #'eq)))
conditional-exprs))
(:splice
(push `(,guard
(let ((,node ,phrase-body))
- (ensure-parent ,parent ,node)
+ ;(ensure-parent ,parent ,node)
(setf ,new-children
(nconc (reverse ,node) ,new-children))))
conditional-exprs))))))))
diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp
index ab06b6f..b70a8a8 100644
--- a/src/hypnotisml.lisp
+++ b/src/hypnotisml.lisp
@@ -89,12 +89,19 @@
(children :type node-list)
:documentation "The base class for all UI elements.")
+(defun ensure-parent (parent nodes)
+ (loop :for node :in nodes :do (setf (parent node) parent)))
+
(defmethod initialize-instance :around ((elem elem) &key)
(call-next-method)
- (loop :for child :in (children elem)
- :do (setf (parent child) elem))
+ (ensure-parent elem (children elem))
elem)
+;; WARNING... THIS'LL SLOW YA DOWN
+(defmethod (setf children) :after (new-children (elem elem))
+ (ensure-parent elem new-children))
+
+
(defun elem-query-selector (elem)
"Returns a CSS query selector string for the ELEM. ELEMs can be
uniquely quried in the dom by passing string to .querySelector()"
@@ -252,6 +259,8 @@ already present in the element."
elem)
+
+
;;; RENDERING
(defgeneric html (elem stream)
@@ -567,7 +576,7 @@ E.g. :1/2, :1, :3/4"
(defmacro <grid> (&rest content-specs)
`(<div>
($ :display "grid")
- ,@(loop :for (row col content) :in content-specs
+ ,@(loop :for ((row col) content . _) :on content-specs :by #'cddr
:unless (and (rational-name-p row)
(rational-name-p col))
:do (error "Bad thing to be a grid content spec: ~s"
diff --git a/src/package.lisp b/src/package.lisp
index c811dad..5743aa3 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -4,6 +4,13 @@
(:use #:cl)
(:local-nicknames
(#:a #:alexandria))
+
+ ;; general
+ (:export
+ #:elemp
+ #:elem-tag
+ #:parent)
+
;; Core Html Elements
(:export
#:<a>
@@ -140,7 +147,9 @@
;; layout constructors
(:export
#:<vert>
- #:<horz>)
+ #:<horz>
+ #:<grid>
+ #:defgrid)
;; element properties
(:export
@@ -153,10 +162,16 @@
#:$~
#:$?)
- ;; parenscript macros
+ ;; styling helpers
(:export
- #:$$
- #:$$replace)
+ #:$center
+ #:$vcenter
+ #:$hcenter)
+
+ ;; parenscript macros
+ ;; (:export
+ ;; #:$$
+ ;; #:$$replace)
;; transforms and structure editing
(:export