summaryrefslogtreecommitdiff
path: root/src/hypnotisml.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-06-25 21:59:39 -0700
committercolin <colin@cicadas.surf>2024-06-25 21:59:39 -0700
commite9f01caf33a9306d4e44cf0f601ce1736fbc2423 (patch)
tree69034824052edd0026db516134e48e1abab0d0e2 /src/hypnotisml.lisp
parentc7d3bc65fcd9b9c0369e61a9a119537c911484e0 (diff)
Add: dom-transform
Diffstat (limited to 'src/hypnotisml.lisp')
-rw-r--r--src/hypnotisml.lisp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp
index e8d204a..b209fc9 100644
--- a/src/hypnotisml.lisp
+++ b/src/hypnotisml.lisp
@@ -135,6 +135,12 @@ uniquely quried in the dom by passing string to .querySelector()"
:default-initargs (:tag :div)
:documentation "A container whose children are to be displayed in a horizontal row.")
+;;; STRUCTURE EDITING
+
+(defun children= (node children)
+ (setf (children node) children)
+ node)
+
;;; STYLING AND ATTRIBUTES
(defun $ (&rest plist)
@@ -165,6 +171,10 @@ present."
(setf (elem-style elem)
(make-styles :list plist))))
+(defun $? (elem prop)
+ (a:when-let (style (elem-style elem))
+ (getf (styles-list style) prop)))
+
(defun @ (&rest plist)
"Create an ATTRIBS instance from PLIST. Any key-value pair in PLIST
whose value is NIL will be ignored."
@@ -202,6 +212,38 @@ already present in the element."
(make-attribs :list plist)))
elem)
+(defun @? (elem attrib)
+ (a:when-let (attribs (elem-attributes elem))
+ (getf (attribs-list attribs) attrib)))
+
+(defun $center (elem)
+ (setf (children elem)
+ (list (apply #'<div>
+ ($ :display "flex"
+ :justify-content "center"
+ :align-items "center"
+ :height "100%")
+ (mapcar #'ensure-elem (children elem)))))
+ elem)
+
+(defun $vcenter (elem)
+ (setf (children elem)
+ (list (apply #'<div>
+ ($ :display "flex"
+ :align-items "center"
+ :height "100%")
+ (mapcar #'ensure-elem (children elem)))))
+ elem)
+
+(defun $hcenter (elem)
+ (setf (children elem)
+ (list (apply #'<div>
+ ($ :display "flex"
+ :justify-content "center"
+ :height "100%")
+ (mapcar #'ensure-elem (children elem)))))
+ elem)
+
;;; RENDERING