Update utility

This commit is contained in:
Marcus Kammer 2023-07-21 16:28:59 +02:00
parent 73c9bd8ba3
commit 9f6a9048b0

View file

@ -133,9 +133,9 @@ Example 4:
(opacity :level :auto)
; This will generate a string 'opacity-auto'"
(let ((level-str (if (null level) "" (if (eq level :auto)
"auto"
(format nil "~d" level)))))
(string-downcase (concatenate 'string "opacity-" level-str " "))))
"opacity-auto"
(format nil "opacity-~d" level)))))
(string-downcase (concatenate 'string level-str " "))))
(defun overflow (&key (direction nil) (value nil))
"Generates a Bootstrap overflow class.
@ -161,41 +161,40 @@ Example 4:
; This will generate a string 'overflow-x-scroll'"
(let* ((dir-str (if (null direction) "" (format nil "-~a" direction)))
(value-str (if (null value) "" (string value)))
(class-str (concatenate 'string "overflow" dir-str "-" value-str)))
(string-downcase class-str " ")))
(class-str (concatenate 'string "overflow" dir-str "-" value-str " ")))
(string-downcase class-str)))
(defun sizing (&key (direction nil) (size nil))
"Generates a Bootstrap sizing class.
DIRECTION: Specifies the direction, should be :width or :height.
DIRECTION: Specifies the direction, should be :w or :h.
SIZE: Specifies the size, should be a number from 0 to 100, :25, :50, :75,
:100, :auto, or nil (default size).
Example 1:
(sizing :direction :width :size 50)
(sizing :direction :w :size 50)
; This will generate a string 'w-50'
Example 2:
(sizing :direction :height :size :auto)
(sizing :direction :h :size :auto)
; This will generate a string 'h-auto'
Example 3:
(sizing :direction :width :size :100)
(sizing :direction :w :size :100)
; This will generate a string 'w-100'
Example 4:
(sizing :direction :height :size 75)
(sizing :direction :h :size 75)
; This will generate a string 'h-75'"
(let* ((dir-str (if (null direction) "" (string direction)))
(let* ((dir-str (if (null direction) "" (format nil "~a-" direction)))
(size-str (if (null size) ""
(if (eq size :auto)
"auto"
(if (numberp size)
(format nil "~d" size)
(format nil "~a" size)))))
(class-str (concatenate 'string dir-str "-" size-str " ")))
(string-downcase class-str)))
(if (eq size :auto)
"auto"
(if (numberp size)
(format nil "~d" size)
(format nil "~a" size))))))
(string-downcase (concatenate 'string dir-str size-str " "))))
(defun spacing (&key (property nil) (side nil) (size nil) (breakpoint nil))
"Generates a Bootstrap spacing class.
@ -211,28 +210,33 @@ BREAKPOINT: Specifies the breakpoint, should be :xs, :sm, :md, :lg, :xl, or
:xxl, or nil (all breakpoints).
Example 1:
(spacing (:property :m :side :t :size 3 :breakpoint :md))
(spacing :property :m :side :t :size 3 :breakpoint :md)
; This will generate a string 'mt-md-3'
Example 2:
(spacing (:property :p :side :b :size 2 :breakpoint :lg))
(spacing :property :p :side :b :size 2 :breakpoint :lg)
; This will generate a string 'pb-lg-2', which represents a large breakpoint
; with bottom padding of size 2.
Example 3:
(spacing (:property :m :size :auto))
(spacing :property :m :size :auto)
; This will generate a string 'm-auto', which sets auto margin on all sides
; for all breakpoints.
Example 4:
(spacing (:property :p :side :x :size 5))
(spacing :property :p :side :x :size 5)
; This will generate a string 'px-5', which sets horizontal padding of size 5
; for all breakpoints."
(let ((property-str (if (null property) "" (string property)))
(side-str (if (null side) "" (string side)))
(let ((property-str (if (null property) "" (format nil "~a" property)))
(side-str (if (null side) "" (format nil "~a" side)))
(size-str (if (null size) "" (if (eq size :auto) "auto" (format nil "~d" size))))
(breakpoint-str (if (null breakpoint) "" (format nil "~a-" breakpoint))))
(string-downcase (concatenate 'string property-str side-str "-" breakpoint-str size-str " "))))
(breakpoint-str (if (null breakpoint) "" (format nil "~a" breakpoint))))
(string-downcase
(concatenate 'string
property-str
side-str
(if breakpoint "-" "") breakpoint-str
(if size "-" "") size-str))))
(defun text (&key (alignment nil) (transform nil) (weight nil) (wrap nil) (monospace nil))
"Generates a Bootstrap text utility class.
@ -261,7 +265,19 @@ Example 3:
Example 4:
(text :alignment :center :transform :lowercase)
; This will generate a string 'text-center text-lowercase'"
; This will generate a string 'text-center text-lowercase'
Example 5:
(text :alignment :end :weight :light :monospace t)
; This will generate a string 'text-end fw-light font-monospace '
Example 6:
(text :transform :capitalize :wrap :wrap)
; This will generate a string 'text-capitalize text-wrap '
Example 7:
(text :alignment :center :transform :uppercase :weight :bolder :wrap :nowrap :monospace t)
; This will generate a string 'text-center text-uppercase fw-bolder text-nowrap font-monospace '"
(let ((alignment-str (if (null alignment) "" (format nil "text-~a " alignment)))
(transform-str (if (null transform) "" (format nil "text-~a " transform)))
(weight-str (if (null weight) "" (format nil "fw-~a " weight)))