From e9f01caf33a9306d4e44cf0f601ce1736fbc2423 Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 25 Jun 2024 21:59:39 -0700 Subject: Add: dom-transform --- src/hypnotisml.lisp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/hypnotisml.lisp') 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 #'
+ ($ :display "flex" + :justify-content "center" + :align-items "center" + :height "100%") + (mapcar #'ensure-elem (children elem))))) + elem) + +(defun $vcenter (elem) + (setf (children elem) + (list (apply #'
+ ($ :display "flex" + :align-items "center" + :height "100%") + (mapcar #'ensure-elem (children elem))))) + elem) + +(defun $hcenter (elem) + (setf (children elem) + (list (apply #'
+ ($ :display "flex" + :justify-content "center" + :height "100%") + (mapcar #'ensure-elem (children elem))))) + elem) + ;;; RENDERING -- cgit v1.2.3