2023-07-17 08:37:39 +02:00
|
|
|
;; Bootstrap utilities are a set of CSS classes designed to assist in the
|
|
|
|
;; fine-tuning of various aspects of a web layout. The aim is to give
|
|
|
|
;; developers precise control over visual elements such as spacing, color,
|
|
|
|
;; opacity, sizing, overflow behavior, and many other facets of web design,
|
|
|
|
;; without the need to write custom CSS rules for every situation.
|
|
|
|
|
|
|
|
;; These utility classes are designed to be semantic and easy to understand.
|
|
|
|
;; They provide a common language for developers, allowing team members to
|
|
|
|
;; quickly grasp the purpose of a class without needing to refer to the CSS
|
|
|
|
;; definitions.
|
|
|
|
|
|
|
|
;; Here's a brief overview of some of the key utility areas in Bootstrap:
|
|
|
|
|
|
|
|
;; Spacing Utilities: Bootstrap provides classes for modifying the margin and
|
|
|
|
;; padding of elements. These classes allow for changes to be applied uniformly
|
|
|
|
;; around an element, or targeted to specific sides.
|
|
|
|
|
|
|
|
;; Color Utilities: These classes allow developers to easily apply background
|
|
|
|
;; color to elements, and they're based on the theme colors defined in
|
|
|
|
;; Bootstrap's Sass variables.
|
|
|
|
|
|
|
|
;; Opacity Utilities: With these classes, developers can easily control the
|
|
|
|
;; transparency of an element without modifying its color properties directly.
|
|
|
|
|
|
|
|
;; Overflow Utilities: Bootstrap provides utilities to control how content
|
|
|
|
;; overflows its container. These classes can be used to create scrollable
|
|
|
|
;; areas, hide overflowing content, or automatically wrap overflow.
|
|
|
|
|
|
|
|
;; Sizing Utilities: These utilities offer control over an element's width and
|
|
|
|
;; height. They can be absolute (pixels), relative (%), or based on viewport
|
|
|
|
;; height/width.
|
|
|
|
|
|
|
|
;; Text Utilities: These classes provide a way to change text alignment,
|
|
|
|
;; wrapping, weight, color, and more. They're useful for managing the
|
|
|
|
;; appearance of typography across different viewport sizes.
|
|
|
|
|
|
|
|
;; Display Utilities: These classes control the CSS display property of
|
|
|
|
;; elements, allowing for easy adjustments to visibility and layout across
|
|
|
|
;; different screen sizes.
|
|
|
|
|
2023-07-17 12:54:03 +02:00
|
|
|
(defpackage :cl-sbt/utility
|
2023-07-16 09:19:46 +02:00
|
|
|
(:use :cl)
|
2023-07-16 18:01:02 +02:00
|
|
|
(:export
|
2023-07-17 08:37:39 +02:00
|
|
|
:background
|
|
|
|
:color
|
|
|
|
:opacity
|
|
|
|
:overflow
|
|
|
|
:sizing
|
2023-07-16 18:01:02 +02:00
|
|
|
:spacing
|
2023-07-16 21:02:01 +02:00
|
|
|
:text
|
2023-07-17 08:37:39 +02:00
|
|
|
:valign)
|
2023-07-16 18:01:02 +02:00
|
|
|
(:documentation "A module for generating Bootstrap utility classes."))
|
2023-07-16 09:19:46 +02:00
|
|
|
|
2023-07-17 12:54:03 +02:00
|
|
|
(in-package :cl-sbt/utility)
|
2023-07-16 09:19:46 +02:00
|
|
|
|
2023-07-23 17:55:37 +02:00
|
|
|
(defparameter *colors* '("primary" "secondary" "success" "danger" "warning" "info" "light" "dark" "body" "muted" "white" "transparent"))
|
2023-07-23 14:11:03 +02:00
|
|
|
|
2023-07-26 16:06:15 +02:00
|
|
|
(defparameter *breakpoints* '("xs" "sm" "md" "lg" "xl" "xxl"))
|
|
|
|
|
|
|
|
(defparameter *sides* '("t" "b" "s" "e" "x" "y"))
|
|
|
|
|
2023-07-21 18:23:43 +02:00
|
|
|
(defun string-clean (str)
|
|
|
|
(string-trim " " (string-downcase str)))
|
|
|
|
|
2023-07-23 17:55:37 +02:00
|
|
|
(defun background (&key (color "primary") (gradient nil))
|
2023-07-17 08:37:39 +02:00
|
|
|
"Generates a Bootstrap background class.
|
2023-07-16 09:19:46 +02:00
|
|
|
|
2023-07-23 17:55:37 +02:00
|
|
|
COLOR: Specifies the color, should be 'primary', 'secondary', 'success',
|
|
|
|
'danger', 'warning', 'info', 'light', 'dark', 'body', 'muted', 'white', 'transparent',
|
2023-07-17 08:37:39 +02:00
|
|
|
or nil (default color).
|
2023-07-16 09:19:46 +02:00
|
|
|
|
2023-07-23 17:55:37 +02:00
|
|
|
GRADIENT: Specifies if the background should have a gradient, should be t or
|
|
|
|
nil. If t, it will add a 'bg-gradient' to the class string.
|
2023-07-16 09:19:46 +02:00
|
|
|
|
2023-07-17 08:37:39 +02:00
|
|
|
Example 1:
|
2023-07-23 17:55:37 +02:00
|
|
|
(background :color \"primary\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'bg-primary'
|
2023-07-16 09:19:46 +02:00
|
|
|
|
2023-07-17 08:37:39 +02:00
|
|
|
Example 2:
|
2023-07-23 17:55:37 +02:00
|
|
|
(background :color \"danger\" :gradient t)
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'bg-danger bg-gradient'
|
|
|
|
|
|
|
|
Example 3:
|
2023-07-23 17:55:37 +02:00
|
|
|
(background :color \"light\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'bg-light'
|
|
|
|
|
|
|
|
Example 4:
|
2023-07-23 17:55:37 +02:00
|
|
|
(background :color \"dark\" :gradient t)
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'bg-dark bg-gradient'"
|
2023-07-23 17:55:37 +02:00
|
|
|
(assert (member color *colors* :test #'string=) nil "Color can't be nil")
|
2023-07-23 14:11:03 +02:00
|
|
|
(let ((color-str (format nil "bg-~a" color))
|
2023-07-23 17:55:37 +02:00
|
|
|
(gradient-str (if (null gradient) "" " bg-gradient")))
|
2023-07-21 18:23:43 +02:00
|
|
|
(string-clean (concatenate 'string color-str gradient-str))))
|
2023-07-17 08:37:39 +02:00
|
|
|
|
2023-07-23 14:11:03 +02:00
|
|
|
(defun color (&key (text nil) (background nil) (emphasis nil) (body nil))
|
2023-07-17 08:37:39 +02:00
|
|
|
"Generates a Bootstrap color class.
|
|
|
|
|
2023-07-23 14:11:03 +02:00
|
|
|
TEXT: Specifies the color of the text. Should be :primary, :secondary,
|
|
|
|
:success, :danger, :warning, :info, :light, :dark, :white, :body,
|
|
|
|
:muted, :reset
|
|
|
|
|
|
|
|
BACKGROUND: Specifies the color of the background. Should be :primary,
|
|
|
|
:secondary, :success, :danger, :warning, :info, :light, :dark, :white,
|
|
|
|
:transparent.
|
|
|
|
|
|
|
|
EMPHASIS: Specifies whether the color should be emphasized or not.
|
2023-07-17 08:37:39 +02:00
|
|
|
|
2023-07-23 14:11:03 +02:00
|
|
|
BODY: Specifies whether the color of the text should be body color.
|
2023-07-16 09:19:46 +02:00
|
|
|
|
|
|
|
Example 1:
|
2023-07-17 08:37:39 +02:00
|
|
|
(color :text :primary)
|
|
|
|
; This will generate a string 'text-primary'
|
2023-07-16 09:19:46 +02:00
|
|
|
|
|
|
|
Example 2:
|
2023-07-22 17:52:45 +02:00
|
|
|
(color :background '(:color :danger))
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'bg-danger'
|
2023-07-16 09:19:46 +02:00
|
|
|
|
|
|
|
Example 3:
|
2023-07-22 17:52:45 +02:00
|
|
|
(color :text :info :background '(:color :dark))
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'text-info bg-dark'
|
2023-07-16 09:19:46 +02:00
|
|
|
|
|
|
|
Example 4:
|
2023-07-22 17:52:45 +02:00
|
|
|
(color :text :white :background '(:color :primary))
|
2023-07-23 14:11:03 +02:00
|
|
|
; This will generate a string 'text-white bg-primary'
|
|
|
|
|
|
|
|
Example 5:
|
|
|
|
(color :text :primary :emphasis t)
|
|
|
|
; This will generate a string 'text-primary-emphasis'
|
|
|
|
|
|
|
|
Example 6:
|
|
|
|
(color :body :secondary)
|
|
|
|
; This will generate a string 'text-body-secondary'
|
|
|
|
|
|
|
|
Example 7:
|
|
|
|
(color :body t :emphasis t)
|
|
|
|
; This will generate a string 'text-body-emphasis'"
|
|
|
|
(let* ((text-str (if (null text) "" (format nil "text-~a" text)))
|
|
|
|
(background-str (if (null background) "" (apply #'background background)))
|
|
|
|
(emphasis-str (if (null emphasis) "" "-emphasis"))
|
2023-07-23 19:35:57 +02:00
|
|
|
(body-str (if (null body) "" (if (stringp body)
|
2023-07-23 14:11:03 +02:00
|
|
|
(format nil "text-body-~a" body)
|
2023-07-23 14:34:19 +02:00
|
|
|
"text-body"))))
|
2023-07-23 14:11:03 +02:00
|
|
|
(string-clean (concatenate 'string
|
|
|
|
body-str
|
|
|
|
text-str
|
|
|
|
emphasis-str
|
|
|
|
(when background " ")
|
|
|
|
background-str))))
|
2023-07-16 18:01:02 +02:00
|
|
|
|
2023-07-17 08:37:39 +02:00
|
|
|
(defun opacity (&key (level nil))
|
|
|
|
"Generates a Bootstrap opacity class.
|
2023-07-16 18:01:02 +02:00
|
|
|
|
2023-07-23 20:37:11 +02:00
|
|
|
LEVEL: Specifies the opacity level, should be a number from 0 to 100, or 'auto'.
|
2023-07-16 19:12:40 +02:00
|
|
|
|
|
|
|
Example 1:
|
2023-07-17 08:37:39 +02:00
|
|
|
(opacity :level 25)
|
|
|
|
; This will generate a string 'opacity-25'
|
2023-07-16 19:12:40 +02:00
|
|
|
|
|
|
|
Example 2:
|
2023-07-17 08:37:39 +02:00
|
|
|
(opacity :level 50)
|
|
|
|
; This will generate a string 'opacity-50'
|
2023-07-16 19:12:40 +02:00
|
|
|
|
|
|
|
Example 3:
|
2023-07-17 08:37:39 +02:00
|
|
|
(opacity :level 75)
|
|
|
|
; This will generate a string 'opacity-75'
|
2023-07-16 19:12:40 +02:00
|
|
|
|
|
|
|
Example 4:
|
2023-07-23 20:37:11 +02:00
|
|
|
(opacity :level \"auto\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'opacity-auto'"
|
2023-07-23 20:37:11 +02:00
|
|
|
(assert (or (equal level "auto")
|
|
|
|
(>= level 0)) nil "Level should be 'auto' or positive number")
|
|
|
|
(let ((level-str (if (equal level "auto")
|
|
|
|
"opacity-auto"
|
|
|
|
(format nil "opacity-~d" level))))
|
2023-07-21 18:23:43 +02:00
|
|
|
(string-clean (concatenate 'string level-str))))
|
2023-07-16 21:02:01 +02:00
|
|
|
|
2023-07-17 08:37:39 +02:00
|
|
|
(defun overflow (&key (direction nil) (value nil))
|
|
|
|
"Generates a Bootstrap overflow class.
|
|
|
|
|
2023-07-23 21:08:17 +02:00
|
|
|
DIRECTION: Specifies the direction, should be 'x', 'y', or nil (both directions).
|
2023-07-17 08:37:39 +02:00
|
|
|
|
2023-07-24 12:03:19 +02:00
|
|
|
VALUE: Specifies the overflow value, should be 'auto', 'hidden', 'visible', 'scroll'.
|
2023-07-16 21:02:01 +02:00
|
|
|
|
|
|
|
Example 1:
|
2023-07-23 21:08:17 +02:00
|
|
|
(overflow :direction \"x\" :value \"auto\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'overflow-x-auto'
|
2023-07-16 21:02:01 +02:00
|
|
|
|
|
|
|
Example 2:
|
2023-07-23 21:08:17 +02:00
|
|
|
(overflow :direction \"y\" :value \"hidden\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'overflow-y-hidden'
|
2023-07-16 21:02:01 +02:00
|
|
|
|
|
|
|
Example 3:
|
2023-07-23 21:08:17 +02:00
|
|
|
(overflow :value \"visible\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'overflow-visible'
|
|
|
|
|
|
|
|
Example 4:
|
2023-07-23 21:08:17 +02:00
|
|
|
(overflow :direction \"x\" :value \"scroll\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'overflow-x-scroll'"
|
2023-07-24 12:03:19 +02:00
|
|
|
(assert (member value '("auto" "hidden" "visible" "scroll") :test #'string=)
|
|
|
|
nil
|
|
|
|
"Direction or value should be set as string")
|
2023-07-22 18:47:52 +02:00
|
|
|
(let* ((dir-str (if (null direction)
|
|
|
|
""
|
|
|
|
(format nil "overflow-~a" direction)))
|
2023-07-24 12:03:19 +02:00
|
|
|
(value-str (if (string= dir-str "")
|
|
|
|
(format nil "overflow-~a" value)
|
|
|
|
(format nil "-~a" value))))
|
2023-07-21 18:23:43 +02:00
|
|
|
(string-clean (concatenate 'string dir-str value-str))))
|
2023-07-16 21:02:01 +02:00
|
|
|
|
|
|
|
(defun sizing (&key (direction nil) (size nil))
|
|
|
|
"Generates a Bootstrap sizing class.
|
|
|
|
|
2023-07-21 16:28:59 +02:00
|
|
|
DIRECTION: Specifies the direction, should be :w or :h.
|
2023-07-16 21:02:01 +02:00
|
|
|
|
|
|
|
SIZE: Specifies the size, should be a number from 0 to 100, :25, :50, :75,
|
|
|
|
:100, :auto, or nil (default size).
|
|
|
|
|
|
|
|
Example 1:
|
2023-07-24 18:04:13 +02:00
|
|
|
(sizing :direction \"w\" :size 50)
|
2023-07-16 21:02:01 +02:00
|
|
|
; This will generate a string 'w-50'
|
|
|
|
|
|
|
|
Example 2:
|
2023-07-24 18:04:13 +02:00
|
|
|
(sizing :direction \"h\" :size \"auto\")
|
2023-07-16 21:02:01 +02:00
|
|
|
; This will generate a string 'h-auto'
|
|
|
|
|
|
|
|
Example 3:
|
2023-07-24 18:04:13 +02:00
|
|
|
(sizing :direction \"w\" :size 100)
|
2023-07-16 21:02:01 +02:00
|
|
|
; This will generate a string 'w-100'
|
|
|
|
|
|
|
|
Example 4:
|
2023-07-24 18:04:13 +02:00
|
|
|
(sizing :direction \"h\" :size 75)
|
2023-07-16 21:02:01 +02:00
|
|
|
; This will generate a string 'h-75'"
|
2023-07-24 18:04:13 +02:00
|
|
|
(assert (and (member direction '("w" "h") :test #'string=)
|
|
|
|
(or (equal size "auto") (>= size 0)))
|
|
|
|
nil "DIRECTION and SIZE can't be nil")
|
|
|
|
(let* ((dir-str (format nil "~a-" direction))
|
|
|
|
(size-str (if (equal size "auto")
|
|
|
|
"auto"
|
|
|
|
(if (numberp size)
|
|
|
|
(format nil "~d" size)
|
|
|
|
(format nil "~a" size)))))
|
2023-07-21 18:23:43 +02:00
|
|
|
(string-clean (concatenate 'string dir-str size-str))))
|
2023-07-17 08:37:39 +02:00
|
|
|
|
|
|
|
(defun spacing (&key (property nil) (side nil) (size nil) (breakpoint nil))
|
|
|
|
"Generates a Bootstrap spacing class.
|
|
|
|
|
2023-07-26 16:06:15 +02:00
|
|
|
PROPERTY: Specifies the property, should be 'm' (margin) or 'p' (padding).
|
2023-07-17 08:37:39 +02:00
|
|
|
|
2023-07-26 16:06:15 +02:00
|
|
|
SIDE: Specifies the side, should be 't' (top), 'b' (bottom), 's' (start),
|
|
|
|
'e' (end), 'x' (horizontal), 'y' (vertical), or nil (all sides).
|
2023-07-17 08:37:39 +02:00
|
|
|
|
2023-07-26 16:06:15 +02:00
|
|
|
SIZE: Specifies the size, should be a number from 0 to 5, or 'auto'.
|
2023-07-17 08:37:39 +02:00
|
|
|
|
2023-07-26 16:06:15 +02:00
|
|
|
BREAKPOINT: Specifies the breakpoint, should be 'xs', 'sm', 'md', 'lg', 'xl',
|
|
|
|
or 'xxl', or nil (all breakpoints).
|
2023-07-17 08:37:39 +02:00
|
|
|
|
|
|
|
Example 1:
|
2023-07-26 16:06:15 +02:00
|
|
|
(spacing :property \"m\" :side \"t\" :size 3 :breakpoint \"md\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'mt-md-3'
|
|
|
|
|
|
|
|
Example 2:
|
2023-07-26 16:06:15 +02:00
|
|
|
(spacing :property \"p\" :side \"b\" :size 2 :breakpoint \"lg\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'pb-lg-2', which represents a large breakpoint
|
|
|
|
; with bottom padding of size 2.
|
|
|
|
|
|
|
|
Example 3:
|
2023-07-26 16:06:15 +02:00
|
|
|
(spacing :property \"m\" :size \"auto\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'm-auto', which sets auto margin on all sides
|
|
|
|
; for all breakpoints.
|
|
|
|
|
|
|
|
Example 4:
|
2023-07-26 16:06:15 +02:00
|
|
|
(spacing :property \"p\" :side \"x\" :size 5)
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'px-5', which sets horizontal padding of size 5
|
|
|
|
; for all breakpoints."
|
2023-07-23 09:32:37 +02:00
|
|
|
(assert (and property size) nil "Property and Size needed")
|
2023-07-26 16:06:15 +02:00
|
|
|
(assert (member property '("m" "p") :test #'string=)
|
|
|
|
nil "Property should be 'm' or 'p'")
|
2023-07-23 09:32:37 +02:00
|
|
|
(assert (or (and (numberp size) (>= size 0))
|
2023-07-26 16:06:15 +02:00
|
|
|
(equal size "auto"))
|
|
|
|
nil "Size should be greater than or equal to 0 or 'auto'")
|
|
|
|
(when side (assert (member side *sides* :test #'string=)))
|
|
|
|
(when breakpoint (assert (member breakpoint *breakpoints* :test #'string=)
|
|
|
|
nil "Breakpoint should be 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'"))
|
|
|
|
|
|
|
|
(let ((side-str (if (null side) "" side))
|
|
|
|
(size-str (if (equal size "auto") "-auto" (format nil "-~d" size)))
|
|
|
|
(breakpoint-str (if (null breakpoint) "" (format nil "-~a" breakpoint))))
|
2023-07-21 18:23:43 +02:00
|
|
|
(string-clean
|
2023-07-21 16:28:59 +02:00
|
|
|
(concatenate 'string
|
2023-07-26 16:06:15 +02:00
|
|
|
property
|
2023-07-21 16:28:59 +02:00
|
|
|
side-str
|
2023-07-26 16:06:15 +02:00
|
|
|
breakpoint-str
|
|
|
|
size-str))))
|
2023-07-17 08:37:39 +02:00
|
|
|
|
2023-07-17 08:57:03 +02:00
|
|
|
(defun text (&key (alignment nil) (transform nil) (weight nil) (wrap nil) (monospace nil))
|
2023-07-17 08:37:39 +02:00
|
|
|
"Generates a Bootstrap text utility class.
|
|
|
|
|
|
|
|
ALIGNMENT: Specifies the text alignment. Should be 'start', 'end', 'center'.
|
|
|
|
|
|
|
|
TRANSFORM: Specifies the text transformation. Should be 'lowercase',
|
|
|
|
'uppercase', 'capitalize'.
|
|
|
|
|
|
|
|
WEIGHT: Specifies the text weight. Should be 'bold', 'bolder', 'normal',
|
|
|
|
'light', 'lighter'.
|
|
|
|
|
2023-07-27 10:37:51 +02:00
|
|
|
WRAP: Specifies the text wrapping option. Should be 'wrap' or 'nowrap'.
|
|
|
|
|
2023-07-17 08:37:39 +02:00
|
|
|
MONOSPACE: If true, sets the font to monospace.
|
|
|
|
|
|
|
|
Example 1:
|
2023-07-26 16:06:15 +02:00
|
|
|
(text :alignment \"start\")
|
2023-07-27 10:37:51 +02:00
|
|
|
; Generates a string 'text-start'
|
2023-07-17 08:37:39 +02:00
|
|
|
|
|
|
|
Example 2:
|
2023-07-26 16:06:15 +02:00
|
|
|
(text :transform \"uppercase\")
|
2023-07-27 10:37:51 +02:00
|
|
|
; Generates a string 'text-uppercase'
|
2023-07-17 08:37:39 +02:00
|
|
|
|
|
|
|
Example 3:
|
2023-07-26 16:06:15 +02:00
|
|
|
(text :weight \"bold\" :monospace t)
|
2023-07-27 10:37:51 +02:00
|
|
|
; Generates a string 'fw-bold font-monospace'
|
2023-07-17 08:37:39 +02:00
|
|
|
|
|
|
|
Example 4:
|
2023-07-26 16:06:15 +02:00
|
|
|
(text :alignment \"center\" :transform \"lowercase\")
|
2023-07-27 10:37:51 +02:00
|
|
|
; Generates a string 'text-center text-lowercase'
|
2023-07-21 16:28:59 +02:00
|
|
|
|
|
|
|
Example 5:
|
2023-07-26 16:06:15 +02:00
|
|
|
(text :alignment \"end\" :weight \"light\" :monospace t)
|
2023-07-27 10:37:51 +02:00
|
|
|
; Generates a string 'text-end fw-light font-monospace '
|
2023-07-21 16:28:59 +02:00
|
|
|
|
|
|
|
Example 6:
|
2023-07-26 16:06:15 +02:00
|
|
|
(text :transform \"capitalize\" :wrap \"wrap\")
|
2023-07-27 10:37:51 +02:00
|
|
|
; Generates a string 'text-capitalize text-wrap '
|
2023-07-21 16:28:59 +02:00
|
|
|
|
|
|
|
Example 7:
|
2023-07-26 16:06:15 +02:00
|
|
|
(text :alignment \"center\" :transform \"uppercase\" :weight \"bolder\" :wrap \"nowrap\" :monospace t)
|
2023-07-27 10:37:51 +02:00
|
|
|
; Generates a string 'text-center text-uppercase fw-bolder
|
2023-07-21 18:43:23 +02:00
|
|
|
; text-nowrap font-monospace '"
|
2023-07-26 16:06:15 +02:00
|
|
|
(assert (or alignment transform weight wrap monospace)
|
|
|
|
nil "Provide at least one argument")
|
2023-07-27 10:37:51 +02:00
|
|
|
(when alignment
|
|
|
|
(assert (member alignment '("start" "end" "center") :test #'string=)
|
|
|
|
nil "ALIGNMENT should be of 'start', 'end' or 'center'"))
|
|
|
|
(when transform
|
|
|
|
(assert (member transform '("lowercase" "uppercase" "capitalize") :test #'string=)
|
|
|
|
nil "TRANSFORM should be of 'lowercase', 'uppercase' 'capitalize'"))
|
|
|
|
(when weight
|
|
|
|
(assert (member weight '("bold" "bolder" "normal" "light" "lighter") :test #'string=)
|
|
|
|
nil "WEIGHT should be of 'bold', 'bolder', 'normal', 'light', 'lighter'"))
|
|
|
|
(when wrap
|
|
|
|
(assert (member wrap '("wrap" "nowrap") :test #'string=)
|
|
|
|
nil "WRAP should be of 'wrap' or 'nowrap'"))
|
2023-07-17 08:37:39 +02:00
|
|
|
(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)))
|
2023-07-17 12:54:03 +02:00
|
|
|
(wrap-str (if (null wrap) "" (format nil "text-~a " wrap)))
|
2023-07-17 08:37:39 +02:00
|
|
|
(monospace-str (if (null monospace) "" "font-monospace")))
|
2023-07-21 18:23:43 +02:00
|
|
|
(string-clean (concatenate 'string
|
|
|
|
alignment-str
|
|
|
|
transform-str
|
|
|
|
weight-str
|
|
|
|
wrap-str
|
|
|
|
monospace-str))))
|
|
|
|
|
2023-08-13 09:17:17 +02:00
|
|
|
(defun valign (align)
|
2023-07-17 08:37:39 +02:00
|
|
|
"Generates a Bootstrap vertical align class.
|
|
|
|
|
2023-08-13 09:17:17 +02:00
|
|
|
ALIGN: Specifies the alignment, should be 'baseline', 'top', 'middle', 'bottom',
|
|
|
|
'text-bottom', 'text-top'.
|
2023-07-17 08:37:39 +02:00
|
|
|
|
|
|
|
Example 1:
|
2023-08-13 09:17:17 +02:00
|
|
|
(valign \"baseline\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'align-baseline'
|
|
|
|
|
|
|
|
Example 2:
|
2023-08-13 09:17:17 +02:00
|
|
|
(valign \"top\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'align-top'
|
|
|
|
|
|
|
|
Example 3:
|
2023-08-13 09:17:17 +02:00
|
|
|
(valign \"middle\")
|
2023-07-17 08:37:39 +02:00
|
|
|
; This will generate a string 'align-middle'"
|
|
|
|
(let ((align-str (if (null align) "" (format nil "align-~a" align))))
|
2023-07-21 18:23:43 +02:00
|
|
|
(string-clean align-str)))
|