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

35
test/ui/alert_test.clj Normal file
View File

@@ -0,0 +1,35 @@
(ns ui.alert-test
(:require [clojure.test :refer [deftest is testing]]
[ui.alert :as alert]))
(deftest alert-class-list-test
(testing "neutral (no variant)"
(is (= ["alert"] (alert/alert-class-list {}))))
(testing "explicit variants"
(is (= ["alert" "alert-success"] (alert/alert-class-list {:variant :success})))
(is (= ["alert" "alert-warning"] (alert/alert-class-list {:variant :warning})))
(is (= ["alert" "alert-danger"] (alert/alert-class-list {:variant :danger})))
(is (= ["alert" "alert-info"] (alert/alert-class-list {:variant :info})))))
(deftest alert-classes-test
(testing "space-joined output"
(is (= "alert" (alert/alert-classes {})))
(is (= "alert alert-success" (alert/alert-classes {:variant :success})))))
(deftest alert-component-test
(testing "basic alert renders correct hiccup"
(let [result (alert/alert {:variant :success :title "Done!"} "Saved.")]
(is (= :div (first result)))
(is (= "alert alert-success" (get-in result [1 :class])))
(is (= "alert" (get-in result [1 :role])))))
(testing "alert with title includes title paragraph"
(let [result (alert/alert {:title "Title"} "Body")]
(is (some #(and (vector? %) (= "alert-title" (get-in % [1 :class])))
(rest (rest result))))))
(testing "alert without title has no title paragraph"
(let [result (alert/alert {} "Body")]
(is (not (some #(and (vector? %) (= "alert-title" (get-in % [1 :class])))
(rest (rest result))))))))