Finalize make-grid-class function
This commit is contained in:
parent
55253c35a7
commit
ab169ace90
1 changed files with 42 additions and 8 deletions
|
@ -53,7 +53,8 @@
|
|||
:text
|
||||
:valign
|
||||
:make-col-class
|
||||
:combine-classes)
|
||||
:combine-classes
|
||||
:make-grid-class)
|
||||
(:documentation "A module for generating Bootstrap utility classes."))
|
||||
|
||||
(in-package :ml-sbt/utility)
|
||||
|
@ -566,9 +567,17 @@ Example 3:
|
|||
|
||||
(defun validate-col-value-p (value)
|
||||
"Validate column-related numeric values."
|
||||
(when (and (integerp value)
|
||||
(<= 0 value 12))
|
||||
t))
|
||||
(and (integerp value)
|
||||
(<= 0 value 12)))
|
||||
|
||||
(defun validate-gutter-value-p (value)
|
||||
"Validate gutter value is between 0-5."
|
||||
(and (integerp value)
|
||||
(<= 0 value 5)))
|
||||
|
||||
(defun validate-alignment-p (value)
|
||||
"Validate alignment value against allowed values."
|
||||
(member value '("start" "center" "end" "around" "between" "evenly") :test #'string=))
|
||||
|
||||
(defun make-grid-class (&key
|
||||
row
|
||||
|
@ -616,7 +625,7 @@ Example:
|
|||
(make-grid-class :col \"auto\") -> \"col col-auto\"
|
||||
(make-grid-class :sm 2) -> \"col-sm-2\"
|
||||
(make-grid-class :row t :col t) -> error
|
||||
(make-grid-class :g 0) -> \"row g-0\""
|
||||
(make-grid-class :row t :g 0) -> \"row g-0\""
|
||||
|
||||
(cond ((and row col)
|
||||
(error "Cannot specify both :row and :col"))
|
||||
|
@ -628,6 +637,8 @@ Example:
|
|||
(error "Cannot specify both :col and :justify-content"))
|
||||
((and col align-items)
|
||||
(error "Cannot specify both :col and :align-items"))
|
||||
((and row order)
|
||||
(error "Cannot specify both :row and :order"))
|
||||
((not (or row col))
|
||||
(error "Specify at least :row or :col")))
|
||||
|
||||
|
@ -635,18 +646,41 @@ Example:
|
|||
(breakpoints
|
||||
(loop :for (key value) :on `(:xs ,xs :sm ,sm :md ,md :lg ,lg :xl ,xl :xxl ,xxl)
|
||||
:by #'cddr
|
||||
:when value :nconc (list key value))))
|
||||
:when (or (stringp value) (validate-col-value-p value)) :nconc (list key value))))
|
||||
|
||||
(when row
|
||||
(push "row" class-strings)
|
||||
(push (format nil "~{row-cols-~(~A~)-~A~^ ~}" breakpoints) class-strings)
|
||||
(when breakpoints
|
||||
(push (format nil "~{row-cols-~(~A~)-~A~^ ~}" breakpoints) class-strings))
|
||||
(when (or (stringp row) (validate-col-value-p row))
|
||||
(push (format nil "row-cols-~A" row) class-strings)))
|
||||
|
||||
(when col
|
||||
(push "col" class-strings)
|
||||
(push (format nil "~{col-~(~A~)-~A~^ ~}" breakpoints) class-strings)
|
||||
(when breakpoints
|
||||
(push (format nil "~{col-~(~A~)-~A~^ ~}" breakpoints) class-strings))
|
||||
(when (or (stringp col) (validate-col-value-p col))
|
||||
(push (format nil "col-~A" col) class-strings)))
|
||||
|
||||
(when (validate-gutter-value-p g)
|
||||
(push (format nil "g-~A" g) class-strings))
|
||||
|
||||
(when (validate-gutter-value-p gx)
|
||||
(push (format nil "gx-~A" gx) class-strings))
|
||||
|
||||
(when (validate-gutter-value-p gy)
|
||||
(push (format nil "gy-~A" gy) class-strings))
|
||||
|
||||
(when (validate-alignment-p align-items)
|
||||
(push (format nil "align-items-~A" align-items) class-strings))
|
||||
|
||||
(when (validate-alignment-p align-self)
|
||||
(push (format nil "align-self-~A" align-self) class-strings))
|
||||
|
||||
(when (validate-alignment-p justify-content)
|
||||
(push (format nil "justify-content-~A" justify-content) class-strings))
|
||||
|
||||
(when (validate-gutter-value-p order)
|
||||
(push (format nil "order-~A" order) class-strings))
|
||||
|
||||
(format nil "~{~A~^ ~}" class-strings)))
|
||||
|
|
Loading…
Add table
Reference in a new issue