feat: add 13 components adapted from Oat UI

Components (.cljc + .css + tests):
- Alert (success/warning/danger/info variants)
- Badge (primary/secondary/outline/success/warning/danger)
- Card (card/card-header/card-body/card-footer)
- Accordion (collapsible with open/closed state)
- Table (headers/rows, striped/bordered variants)
- Dialog (modal with header/body/footer sections)
- Breadcrumb (nav with active item)
- Pagination (current/total with prev/next)
- Progress (value bar with color variants)
- Spinner (sm/md/lg sizes)
- Skeleton (line/box/circle/heading placeholders)
- Switch (toggle with checked/disabled states)
- Tooltip (hover text via data-tooltip attr)

CSS-only additions:
- Form elements (inputs, selects, checkboxes, radios, range, groups)
- Grid (12-column system with offsets, responsive)
- Utilities (flex, spacing, alignment, sr-only)

Also adds warning/fg-on-warning tokens to light and dark themes.
All 3 dev targets updated with full component showcase.
40 tests, 213 assertions, all passing.
This commit is contained in:
Florian Schroedl
2026-03-03 11:37:05 +01:00
parent d55e3d3a90
commit 18043cb150
47 changed files with 2556 additions and 106 deletions

76
src/ui/table.cljc Normal file
View File

@@ -0,0 +1,76 @@
(ns ui.table
(:require [clojure.string :as str]))
#?(:squint (defn- kw-name [s] s)
:cljs (defn- kw-name [s] (name s))
:clj (defn- kw-name [s] (name s)))
(defn table-class-list
"Generate a vector of CSS class strings for a table.
Variants: nil (default), :striped, :bordered."
[{:keys [variant]}]
(cond-> ["table"]
variant (conj (str "table--" (kw-name variant)))))
(defn table-classes
"Generate CSS class string for a table."
[opts]
(str/join " " (table-class-list opts)))
(defn table
"Render a table element.
Props:
:headers - vector of column header strings
:rows - vector of row vectors (each row is a vector of cell values)
:variant - nil, :striped, :bordered
:class - additional CSS classes
:attrs - additional HTML attributes"
[{:keys [headers rows variant class attrs] :as _props}]
#?(:squint
(let [classes (cond-> (table-classes {:variant variant})
class (str " " class))
base-attrs (merge {:class classes} attrs)]
[:div {:class "table-wrapper"}
[:table base-attrs
(when (seq headers)
[:thead
(into [:tr]
(map (fn [h] [:th h]) headers))])
(into [:tbody]
(map (fn [row]
(into [:tr]
(map (fn [cell] [:td cell]) row)))
rows))]])
:cljs
(let [cls (table-class-list {:variant variant})
classes (cond-> cls class (conj class))
base-attrs (merge {:class classes} attrs)]
[:div {:class ["table-wrapper"]}
[:table base-attrs
(when (seq headers)
[:thead
(into [:tr]
(map (fn [h] [:th h]) headers))])
(into [:tbody]
(map (fn [row]
(into [:tr]
(map (fn [cell] [:td cell]) row)))
rows))]])
:clj
(let [classes (cond-> (table-classes {:variant variant})
class (str " " class))
base-attrs (merge {:class classes} attrs)]
[:div {:class "table-wrapper"}
[:table base-attrs
(when (seq headers)
[:thead
(into [:tr]
(map (fn [h] [:th h]) headers))])
(into [:tbody]
(map (fn [row]
(into [:tr]
(map (fn [cell] [:td cell]) row)))
rows))]])))