diff options
Diffstat (limited to 'src/hypnotisml.lisp')
-rw-r--r-- | src/hypnotisml.lisp | 42 |
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 |