Add docstrings
This commit is contained in:
parent
3c4e995641
commit
04b3d33af1
1 changed files with 51 additions and 1 deletions
|
@ -10,6 +10,23 @@
|
|||
(in-package :cl-sbt/form)
|
||||
|
||||
(defmacro ctrl (&rest rest)
|
||||
"This macro generates Bootstrap form controls.
|
||||
|
||||
ID: A unique identifier for the input control.
|
||||
|
||||
LABEL: The label text displayed next to the form control.
|
||||
|
||||
TYPE: Specifies the type of input. For example, 'text', 'password', etc.
|
||||
|
||||
PLACEHOLDER: A hint to the user of what can be entered in the control.
|
||||
|
||||
TEXT: Descriptive text about the input field, often used for instructions or
|
||||
details.
|
||||
|
||||
DESCRIBEBY: Refers to the id of the element that describes the input field.
|
||||
|
||||
Example:
|
||||
(ctrl (:id \"inputID\" :label \"Label\" :type \"text\" :placeholder \"Placeholder\" :describeby \"hintID\" :text \"Hint text\"))"
|
||||
`(spinneret:with-html
|
||||
,@(loop for item in rest
|
||||
collect (destructuring-bind (&key id label type placeholder text describeby) item
|
||||
|
@ -21,7 +38,8 @@
|
|||
:class "form-control"
|
||||
:id ,id
|
||||
:placeholder ,placeholder
|
||||
,@(when (stringp describeby) (list :aria-describeby describeby)))
|
||||
,@(when (stringp describeby)
|
||||
(list :aria-describeby describeby)))
|
||||
,(if (stringp text)
|
||||
`(:div :id ,describeby
|
||||
:class "form-text"
|
||||
|
@ -29,6 +47,18 @@
|
|||
nil))))))
|
||||
|
||||
(defmacro ctrl-col (&rest rest)
|
||||
"This macro generates Bootstrap form controls arranged in a column.
|
||||
|
||||
ID: A unique identifier for the input control.
|
||||
|
||||
LABEL: The label text displayed next to the form control.
|
||||
|
||||
TYPE: Specifies the type of input, e.g., 'text', 'password', etc.
|
||||
|
||||
PLACEHOLDER: A hint to the user of what can be entered in the control.
|
||||
|
||||
Example:
|
||||
(ctrl-col (:id \"inputID\" :label \"Label\" :type \"text\" :placeholder \"Placeholder\"))"
|
||||
`(spinneret:with-html
|
||||
,@(loop for item in rest
|
||||
collect (destructuring-bind (&key id label type placeholder) item
|
||||
|
@ -44,12 +74,32 @@
|
|||
:placeholder ,placeholder)))))))
|
||||
|
||||
(defmacro select-option (&rest rest)
|
||||
"This macro generates option elements for a select dropdown.
|
||||
|
||||
CONTENT: The text content displayed for the option.
|
||||
|
||||
VALUE: The value of the option that gets sent when the form is submitted.
|
||||
|
||||
Example:
|
||||
(select-option (:content \"Option 1\" :value \"opt1\"))"
|
||||
`(spinneret:with-html
|
||||
,@(loop for item in rest
|
||||
collect (destructuring-bind (&key content value) item
|
||||
`(:option :value ,value ,content)))))
|
||||
|
||||
(defmacro select ((&key size) &body body)
|
||||
"This macro generates a Bootstrap select dropdown menu.
|
||||
|
||||
SIZE: Specifies the size of the select menu. It can be a number specifying the
|
||||
visible number of options or a string indicating the size, like 'sm' for small
|
||||
or 'lg' for large. The special string 'multiple' can also be used to allow for
|
||||
multiple selections.
|
||||
|
||||
BODY: The contents of the select menu, typically options.
|
||||
|
||||
Example:
|
||||
(select (:size \"sm\")
|
||||
(select-option (:content \"Option 1\" :value \"opt1\")))"
|
||||
(let ((class-attr (cond
|
||||
((null size) "form-select")
|
||||
((numberp size) "form-select")
|
||||
|
|
Loading…
Add table
Reference in a new issue