2023-07-14 16:07:27 +02:00
;;https://getbootstrap.com/docs/5.3/components/list-group/
;; Bootstrap's List Group component is a flexible and versatile component used
;; for displaying a series of content which can be a mix of various types, like
;; text, links, buttons, etc., in a list format. This component is typically
;; used for showing a list of items within a card, a sidebar, or a dropdown
;; menu.
;; The component is highly customizable, allowing for different styles and
;; effects. By default, the List Group items are styled as plain text, but can
;; be modified into clickable elements or buttons. The List Group component
;; also supports contextual classes for styling list items with different
;; states, such as success, warning, danger, and so on.
;; In addition to this, the List Group component supports adding badges to list
;; items, making it suitable for a wide range of applications, such as a list
;; of emails with the number of unread messages, a list of tasks with their
;; completion status, and so on.
2023-07-08 06:59:03 +02:00
2023-07-11 19:36:56 +02:00
( defpackage cl-sbt-list-group
( :use :cl )
( :export
:item
2023-07-14 16:07:27 +02:00
:list-group )
( :documentation "A Common Lisp package for generating Bootstrap List Group components. This package provides macros for generating Bootstrap List Group components, a versatile element used to display a series of content in a list format. The `item` macro creates a Bootstrap list group item, which can contain any series of forms. The `list-group` macro generates a Bootstrap list group, which is a collection of list group items. Bootstrap's List Group components are highly customizable and can be used in a wide range of scenarios. They can be displayed as plain text or clickable elements, support adding badges, and can be styled with different contextual classes." ) )
2023-07-11 19:36:56 +02:00
( in-package :cl-sbt-list-group )
2023-07-11 19:42:04 +02:00
( defmacro item ( &body body )
2023-07-11 19:36:56 +02:00
" This macro generates a Bootstrap list group item.
2023-07-14 16:07:27 +02:00
BODY: The contents of the list group item. It should be a sequence of forms
which will be used as the contents of the list group item.
Example usage:
( item \"This is a list group item\" )
( item ( :p \"This is a list group item\" ) ) "
2023-07-08 06:59:03 +02:00
` ( spinneret:with-html
( :li :class "list-group-item" ,@ body ) ) )
( defmacro list-group ( &rest rest )
2023-07-11 19:36:56 +02:00
" This macro generates a Bootstrap list group.
2023-07-14 16:07:27 +02:00
REST: A sequence of items to be included in the list group. Each item is a
keyword-value pair, where the keyword is ' :content ' and the value is the
content of the item.
Example usage:
( list-group ( :content \"First item\" ) ( :content \"Second item\" ) ) "
2023-07-08 06:59:03 +02:00
` ( spinneret:with-html
( :ul :class "list-group list-group-flush"
,@ ( loop for item in rest
collect ( destructuring-bind ( &key content ) item
2023-07-11 19:42:04 +02:00
` ( item , content ) ) ) ) ) )