Use strings instead of keywords
This commit is contained in:
parent
4e4671234a
commit
1ecdcc8394
2 changed files with 20 additions and 20 deletions
|
@ -53,39 +53,39 @@
|
||||||
|
|
||||||
(in-package :cl-sbt/utility)
|
(in-package :cl-sbt/utility)
|
||||||
|
|
||||||
(defparameter *colors* '(:primary :secondary :success :danger :warning :info :light :dark :body :muted :white :transparent))
|
(defparameter *colors* '("primary" "secondary" "success" "danger" "warning" "info" "light" "dark" "body" "muted" "white" "transparent"))
|
||||||
|
|
||||||
(defun string-clean (str)
|
(defun string-clean (str)
|
||||||
(string-trim " " (string-downcase str)))
|
(string-trim " " (string-downcase str)))
|
||||||
|
|
||||||
(defun background (&key (color :primary) (gradient nil))
|
(defun background (&key (color "primary") (gradient nil))
|
||||||
"Generates a Bootstrap background class.
|
"Generates a Bootstrap background class.
|
||||||
|
|
||||||
COLOR: Specifies the color, should be :primary, :secondary, :success,
|
COLOR: Specifies the color, should be 'primary', 'secondary', 'success',
|
||||||
:danger, :warning, :info, :light, :dark, :body, :muted, :white, :transparent,
|
'danger', 'warning', 'info', 'light', 'dark', 'body', 'muted', 'white', 'transparent',
|
||||||
or nil (default color).
|
or nil (default color).
|
||||||
|
|
||||||
GRADIENT: Specifies if the background should have a gradient, should be :t or
|
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.
|
nil. If t, it will add a 'bg-gradient' to the class string.
|
||||||
|
|
||||||
Example 1:
|
Example 1:
|
||||||
(background :color :primary)
|
(background :color \"primary\")
|
||||||
; This will generate a string 'bg-primary'
|
; This will generate a string 'bg-primary'
|
||||||
|
|
||||||
Example 2:
|
Example 2:
|
||||||
(background :color :danger :gradient :t)
|
(background :color \"danger\" :gradient t)
|
||||||
; This will generate a string 'bg-danger bg-gradient'
|
; This will generate a string 'bg-danger bg-gradient'
|
||||||
|
|
||||||
Example 3:
|
Example 3:
|
||||||
(background :color :light)
|
(background :color \"light\")
|
||||||
; This will generate a string 'bg-light'
|
; This will generate a string 'bg-light'
|
||||||
|
|
||||||
Example 4:
|
Example 4:
|
||||||
(background :color :dark :gradient :t)
|
(background :color \"dark\" :gradient t)
|
||||||
; This will generate a string 'bg-dark bg-gradient'"
|
; This will generate a string 'bg-dark bg-gradient'"
|
||||||
(assert (member color *colors*) nil "Color can't be nil")
|
(assert (member color *colors* :test #'string=) nil "Color can't be nil")
|
||||||
(let ((color-str (format nil "bg-~a" color))
|
(let ((color-str (format nil "bg-~a" color))
|
||||||
(gradient-str (if (eq gradient :t) " bg-gradient" "")))
|
(gradient-str (if (null gradient) "" " bg-gradient")))
|
||||||
(string-clean (concatenate 'string color-str gradient-str))))
|
(string-clean (concatenate 'string color-str gradient-str))))
|
||||||
|
|
||||||
(defun color (&key (text nil) (background nil) (emphasis nil) (body nil))
|
(defun color (&key (text nil) (background nil) (emphasis nil) (body nil))
|
||||||
|
|
|
@ -18,17 +18,17 @@
|
||||||
|
|
||||||
(deftest test-background-color
|
(deftest test-background-color
|
||||||
(testing "Generates correct background class with color"
|
(testing "Generates correct background class with color"
|
||||||
(ok (string= (background :color :primary) "bg-primary"))
|
(ok (string= (background :color "primary") "bg-primary"))
|
||||||
(ok (string= (background :color :danger) "bg-danger"))
|
(ok (string= (background :color "danger") "bg-danger"))
|
||||||
(ok (string= (background :color :light) "bg-light"))
|
(ok (string= (background :color "light") "bg-light"))
|
||||||
(ok (string= (background :color :dark) "bg-dark"))))
|
(ok (string= (background :color "dark") "bg-dark"))))
|
||||||
|
|
||||||
(deftest test-background-gradient
|
(deftest test-background-gradient
|
||||||
(testing "Generates correct background class with gradient"
|
(testing "Generates correct background class with gradient"
|
||||||
(ok (string= (background :color :primary :gradient :t) "bg-primary bg-gradient"))
|
(ok (string= (background :color "primary" :gradient t) "bg-primary bg-gradient"))
|
||||||
(ok (string= (background :color :danger :gradient :t) "bg-danger bg-gradient"))
|
(ok (string= (background :color "danger" :gradient t) "bg-danger bg-gradient"))
|
||||||
(ok (string= (background :color :light :gradient :t) "bg-light bg-gradient"))
|
(ok (string= (background :color "light" :gradient t) "bg-light bg-gradient"))
|
||||||
(ok (string= (background :color :dark :gradient :t) "bg-dark bg-gradient"))))
|
(ok (string= (background :color "dark" :gradient t) "bg-dark bg-gradient"))))
|
||||||
|
|
||||||
(deftest test-background-no-arguments
|
(deftest test-background-no-arguments
|
||||||
(testing "Generates correct background class with no arguments"
|
(testing "Generates correct background class with no arguments"
|
||||||
|
|
Loading…
Add table
Reference in a new issue