feat: add icon support to button, alert, badge, and form input

Button:
- :icon-left, :icon-right props for buttons with leading/trailing icons
- :icon prop for icon-only buttons (square padding via .btn-icon class)
- Icon size scales with button size (sm→sm, md/lg→sm/md)

Alert:
- Auto-assigns variant-specific icons (circle-check, alert-triangle,
  alert-circle, info) per variant
- :icon-name prop to override default, false to suppress
- Layout restructured with .alert-icon + .alert-content wrapper

Badge:
- :icon-name prop adds a leading icon before text
- .badge-icon CSS scales icon to match badge font size

Form input:
- :icon-left and :icon-right props on form-input
- Wraps input in .form-input-wrap with absolutely-positioned icon spans
- Padding adjusts automatically via .form-input--icon-left/right

All three dev targets (hiccup, replicant, squint) updated with demos.
This commit is contained in:
Florian Schroedl
2026-03-05 19:33:55 +01:00
parent e3132a3cb4
commit 93edebf144
15 changed files with 438 additions and 122 deletions

View File

@@ -1,6 +1,7 @@
(ns ui.badge-test
(:require [clojure.test :refer [deftest is testing]]
[ui.badge :as badge]))
[ui.badge :as badge]
[ui.icon :as icon]))
(deftest badge-class-list-test
(testing "default variant (primary)"
@@ -29,3 +30,14 @@
(testing "extra class gets appended"
(let [result (badge/badge {:class "extra"} "X")]
(is (= "badge extra" (get-in result [1 :class]))))))
(deftest badge-icon-test
(testing "badge with icon-name renders icon before text"
(let [result (badge/badge {:icon-name :check} "Done")]
(is (= :span (first result)))
(is (= :svg (first (nth result 2)))) ;; icon is first child
(is (= "Done" (nth result 3))))) ;; text is second child
(testing "badge without icon-name has no icon"
(let [result (badge/badge {} "Plain")]
(is (= "Plain" (nth result 2))))))