velvetkit 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -7
  3. data/lib/generators/velvetkit/add/add_generator.rb +19 -0
  4. data/lib/generators/velvetkit/helpers.rb +29 -2
  5. data/lib/generators/velvetkit/icons/icons_generator.rb +71 -0
  6. data/lib/generators/velvetkit/install/install_generator.rb +9 -12
  7. data/lib/velvetkit/icons.rb +148 -0
  8. data/lib/velvetkit/registry.rb +5 -2
  9. data/lib/velvetkit/version.rb +1 -1
  10. data/lib/velvetkit.rb +1 -0
  11. data/registry/app/components/ui/alert.rb +1 -1
  12. data/registry/app/components/ui/confirm_dialog.html.erb +13 -0
  13. data/registry/app/components/ui/confirm_dialog.rb +55 -0
  14. data/registry/app/components/ui/empty_state.html.erb +20 -0
  15. data/registry/app/components/ui/empty_state.rb +46 -0
  16. data/registry/app/components/ui/icon.html.erb +1 -1
  17. data/registry/app/components/ui/icon.rb +80 -8
  18. data/registry/app/components/ui/password_input.html.erb +1 -1
  19. data/registry/app/components/ui/stepper/step.html.erb +27 -0
  20. data/registry/app/components/ui/stepper/step.rb +213 -0
  21. data/registry/app/components/ui/stepper.html.erb +19 -0
  22. data/registry/app/components/ui/stepper.rb +145 -0
  23. data/registry/app/components/ui/theme_toggle.rb +2 -4
  24. data/registry/app/components/ui/toast.rb +6 -6
  25. data/registry/app/components/ui/toggle_group/item.html.erb +1 -0
  26. data/registry/app/components/ui/toggle_group/item.rb +85 -0
  27. data/registry/app/components/ui/toggle_group.html.erb +1 -0
  28. data/registry/app/components/ui/toggle_group.rb +79 -0
  29. data/registry/app/javascript/controllers/ui/confirm_dialog_controller.ts +110 -0
  30. data/registry/app/javascript/controllers/ui/stepper_controller.ts +187 -0
  31. data/registry/components.yml +9 -2
  32. data/registry/config/locales/velvetkit.en.yml +11 -0
  33. data/registry/docs/agents.md +7 -4
  34. data/registry/icons/lucide/LICENSE +39 -0
  35. data/registry/icons/lucide/align-center.svg +17 -0
  36. data/registry/icons/lucide/align-left.svg +17 -0
  37. data/registry/icons/lucide/align-right.svg +17 -0
  38. data/registry/icons/lucide/arrow-left.svg +16 -0
  39. data/registry/icons/lucide/arrow-right.svg +16 -0
  40. data/registry/icons/lucide/badge-check.svg +16 -0
  41. data/registry/icons/lucide/bar-chart-3.svg +18 -0
  42. data/registry/icons/lucide/bell.svg +16 -0
  43. data/registry/icons/lucide/bold.svg +15 -0
  44. data/registry/icons/lucide/book-open.svg +16 -0
  45. data/registry/icons/lucide/calendar.svg +18 -0
  46. data/registry/icons/lucide/chart-column.svg +18 -0
  47. data/registry/icons/lucide/check.svg +15 -0
  48. data/registry/icons/lucide/chevron-down.svg +15 -0
  49. data/registry/icons/lucide/chevron-left.svg +15 -0
  50. data/registry/icons/lucide/chevron-right.svg +15 -0
  51. data/registry/icons/lucide/chevrons-up-down.svg +16 -0
  52. data/registry/icons/lucide/circle-alert.svg +17 -0
  53. data/registry/icons/lucide/circle-check.svg +16 -0
  54. data/registry/icons/lucide/cloud.svg +15 -0
  55. data/registry/icons/lucide/credit-card.svg +16 -0
  56. data/registry/icons/lucide/ellipsis-vertical.svg +17 -0
  57. data/registry/icons/lucide/ellipsis.svg +17 -0
  58. data/registry/icons/lucide/eye-off.svg +18 -0
  59. data/registry/icons/lucide/eye.svg +16 -0
  60. data/registry/icons/lucide/file-text.svg +19 -0
  61. data/registry/icons/lucide/folder-kanban.svg +18 -0
  62. data/registry/icons/lucide/git-branch.svg +18 -0
  63. data/registry/icons/lucide/globe.svg +17 -0
  64. data/registry/icons/lucide/graduation-cap.svg +17 -0
  65. data/registry/icons/lucide/grip-vertical.svg +20 -0
  66. data/registry/icons/lucide/home.svg +16 -0
  67. data/registry/icons/lucide/inbox.svg +16 -0
  68. data/registry/icons/lucide/info.svg +17 -0
  69. data/registry/icons/lucide/italic.svg +17 -0
  70. data/registry/icons/lucide/layout-dashboard.svg +18 -0
  71. data/registry/icons/lucide/layout-grid.svg +18 -0
  72. data/registry/icons/lucide/life-buoy.svg +20 -0
  73. data/registry/icons/lucide/list.svg +20 -0
  74. data/registry/icons/lucide/loader.svg +22 -0
  75. data/registry/icons/lucide/lock.svg +16 -0
  76. data/registry/icons/lucide/log-out.svg +17 -0
  77. data/registry/icons/lucide/mail.svg +16 -0
  78. data/registry/icons/lucide/menu.svg +17 -0
  79. data/registry/icons/lucide/message-circle.svg +15 -0
  80. data/registry/icons/lucide/monitor.svg +17 -0
  81. data/registry/icons/lucide/moon.svg +15 -0
  82. data/registry/icons/lucide/newspaper.svg +18 -0
  83. data/registry/icons/lucide/panel-left.svg +16 -0
  84. data/registry/icons/lucide/plus.svg +16 -0
  85. data/registry/icons/lucide/qr-code.svg +26 -0
  86. data/registry/icons/lucide/rocket.svg +18 -0
  87. data/registry/icons/lucide/rotate-cw.svg +16 -0
  88. data/registry/icons/lucide/search.svg +16 -0
  89. data/registry/icons/lucide/settings.svg +16 -0
  90. data/registry/icons/lucide/shield-check.svg +16 -0
  91. data/registry/icons/lucide/shield.svg +15 -0
  92. data/registry/icons/lucide/store.svg +17 -0
  93. data/registry/icons/lucide/sun.svg +23 -0
  94. data/registry/icons/lucide/trash-2.svg +19 -0
  95. data/registry/icons/lucide/underline.svg +16 -0
  96. data/registry/icons/lucide/upload.svg +17 -0
  97. data/registry/icons/lucide/user.svg +16 -0
  98. data/registry/icons/lucide/users.svg +18 -0
  99. data/registry/icons/lucide/workflow.svg +17 -0
  100. data/registry/icons/lucide/x.svg +16 -0
  101. data/registry/icons/phosphor/LICENSE +21 -0
  102. data/registry/icons/phosphor/arrow-clockwise.svg +2 -0
  103. data/registry/icons/phosphor/arrow-left.svg +2 -0
  104. data/registry/icons/phosphor/arrow-right.svg +2 -0
  105. data/registry/icons/phosphor/bell.svg +2 -0
  106. data/registry/icons/phosphor/book-open.svg +2 -0
  107. data/registry/icons/phosphor/calendar-blank.svg +2 -0
  108. data/registry/icons/phosphor/caret-down.svg +2 -0
  109. data/registry/icons/phosphor/caret-left.svg +2 -0
  110. data/registry/icons/phosphor/caret-right.svg +2 -0
  111. data/registry/icons/phosphor/caret-up-down.svg +2 -0
  112. data/registry/icons/phosphor/chart-bar.svg +2 -0
  113. data/registry/icons/phosphor/chat-circle.svg +2 -0
  114. data/registry/icons/phosphor/check-circle.svg +2 -0
  115. data/registry/icons/phosphor/check.svg +2 -0
  116. data/registry/icons/phosphor/cloud.svg +2 -0
  117. data/registry/icons/phosphor/credit-card.svg +2 -0
  118. data/registry/icons/phosphor/desktop.svg +2 -0
  119. data/registry/icons/phosphor/dots-six-vertical.svg +2 -0
  120. data/registry/icons/phosphor/dots-three-vertical.svg +2 -0
  121. data/registry/icons/phosphor/dots-three.svg +2 -0
  122. data/registry/icons/phosphor/envelope.svg +2 -0
  123. data/registry/icons/phosphor/eye-slash.svg +2 -0
  124. data/registry/icons/phosphor/eye.svg +2 -0
  125. data/registry/icons/phosphor/file-text.svg +2 -0
  126. data/registry/icons/phosphor/flow-arrow.svg +2 -0
  127. data/registry/icons/phosphor/gear.svg +2 -0
  128. data/registry/icons/phosphor/git-branch.svg +2 -0
  129. data/registry/icons/phosphor/globe.svg +2 -0
  130. data/registry/icons/phosphor/graduation-cap.svg +2 -0
  131. data/registry/icons/phosphor/grid-four.svg +2 -0
  132. data/registry/icons/phosphor/house.svg +2 -0
  133. data/registry/icons/phosphor/info.svg +2 -0
  134. data/registry/icons/phosphor/kanban.svg +2 -0
  135. data/registry/icons/phosphor/lifebuoy.svg +2 -0
  136. data/registry/icons/phosphor/list.svg +2 -0
  137. data/registry/icons/phosphor/lock.svg +2 -0
  138. data/registry/icons/phosphor/magnifying-glass.svg +2 -0
  139. data/registry/icons/phosphor/moon.svg +2 -0
  140. data/registry/icons/phosphor/newspaper.svg +2 -0
  141. data/registry/icons/phosphor/plus.svg +2 -0
  142. data/registry/icons/phosphor/qr-code.svg +2 -0
  143. data/registry/icons/phosphor/rocket.svg +2 -0
  144. data/registry/icons/phosphor/seal-check.svg +2 -0
  145. data/registry/icons/phosphor/shield-check.svg +2 -0
  146. data/registry/icons/phosphor/shield.svg +2 -0
  147. data/registry/icons/phosphor/sidebar.svg +2 -0
  148. data/registry/icons/phosphor/sign-out.svg +2 -0
  149. data/registry/icons/phosphor/spinner.svg +2 -0
  150. data/registry/icons/phosphor/squares-four.svg +2 -0
  151. data/registry/icons/phosphor/storefront.svg +2 -0
  152. data/registry/icons/phosphor/sun.svg +2 -0
  153. data/registry/icons/phosphor/text-align-center.svg +2 -0
  154. data/registry/icons/phosphor/text-align-left.svg +2 -0
  155. data/registry/icons/phosphor/text-align-right.svg +2 -0
  156. data/registry/icons/phosphor/text-b.svg +2 -0
  157. data/registry/icons/phosphor/text-italic.svg +2 -0
  158. data/registry/icons/phosphor/text-underline.svg +2 -0
  159. data/registry/icons/phosphor/trash.svg +2 -0
  160. data/registry/icons/phosphor/tray.svg +2 -0
  161. data/registry/icons/phosphor/upload-simple.svg +2 -0
  162. data/registry/icons/phosphor/user.svg +2 -0
  163. data/registry/icons/phosphor/users.svg +2 -0
  164. data/registry/icons/phosphor/warning-circle.svg +2 -0
  165. data/registry/icons/phosphor/x.svg +2 -0
  166. data/registry/icons/tabler/LICENSE +21 -0
  167. data/registry/icons/tabler/alert-circle.svg +18 -0
  168. data/registry/icons/tabler/align-center.svg +18 -0
  169. data/registry/icons/tabler/align-left.svg +18 -0
  170. data/registry/icons/tabler/align-right.svg +18 -0
  171. data/registry/icons/tabler/arrow-left.svg +18 -0
  172. data/registry/icons/tabler/arrow-right.svg +18 -0
  173. data/registry/icons/tabler/bell.svg +17 -0
  174. data/registry/icons/tabler/bold.svg +17 -0
  175. data/registry/icons/tabler/book.svg +20 -0
  176. data/registry/icons/tabler/building-store.svg +20 -0
  177. data/registry/icons/tabler/calendar.svg +21 -0
  178. data/registry/icons/tabler/chart-bar.svg +19 -0
  179. data/registry/icons/tabler/check.svg +16 -0
  180. data/registry/icons/tabler/chevron-down.svg +16 -0
  181. data/registry/icons/tabler/chevron-left.svg +16 -0
  182. data/registry/icons/tabler/chevron-right.svg +16 -0
  183. data/registry/icons/tabler/circle-check.svg +17 -0
  184. data/registry/icons/tabler/cloud.svg +16 -0
  185. data/registry/icons/tabler/credit-card.svg +19 -0
  186. data/registry/icons/tabler/device-desktop.svg +19 -0
  187. data/registry/icons/tabler/dots-vertical.svg +18 -0
  188. data/registry/icons/tabler/dots.svg +18 -0
  189. data/registry/icons/tabler/eye-off.svg +18 -0
  190. data/registry/icons/tabler/eye.svg +17 -0
  191. data/registry/icons/tabler/file-text.svg +20 -0
  192. data/registry/icons/tabler/git-branch.svg +21 -0
  193. data/registry/icons/tabler/grip-vertical.svg +21 -0
  194. data/registry/icons/tabler/home.svg +18 -0
  195. data/registry/icons/tabler/inbox.svg +17 -0
  196. data/registry/icons/tabler/info-circle.svg +18 -0
  197. data/registry/icons/tabler/italic.svg +18 -0
  198. data/registry/icons/tabler/layout-dashboard.svg +19 -0
  199. data/registry/icons/tabler/layout-grid.svg +19 -0
  200. data/registry/icons/tabler/layout-kanban.svg +19 -0
  201. data/registry/icons/tabler/layout-sidebar.svg +17 -0
  202. data/registry/icons/tabler/lifebuoy.svg +21 -0
  203. data/registry/icons/tabler/list.svg +21 -0
  204. data/registry/icons/tabler/loader.svg +23 -0
  205. data/registry/icons/tabler/lock.svg +18 -0
  206. data/registry/icons/tabler/logout.svg +18 -0
  207. data/registry/icons/tabler/mail.svg +17 -0
  208. data/registry/icons/tabler/menu-2.svg +18 -0
  209. data/registry/icons/tabler/message-circle.svg +16 -0
  210. data/registry/icons/tabler/moon.svg +16 -0
  211. data/registry/icons/tabler/news.svg +19 -0
  212. data/registry/icons/tabler/plus.svg +17 -0
  213. data/registry/icons/tabler/qrcode.svg +27 -0
  214. data/registry/icons/tabler/rocket.svg +18 -0
  215. data/registry/icons/tabler/rosette-discount-check.svg +17 -0
  216. data/registry/icons/tabler/rotate-clockwise.svg +16 -0
  217. data/registry/icons/tabler/school.svg +17 -0
  218. data/registry/icons/tabler/search.svg +17 -0
  219. data/registry/icons/tabler/selector.svg +17 -0
  220. data/registry/icons/tabler/settings.svg +17 -0
  221. data/registry/icons/tabler/shield-check.svg +17 -0
  222. data/registry/icons/tabler/shield.svg +16 -0
  223. data/registry/icons/tabler/sitemap.svg +20 -0
  224. data/registry/icons/tabler/sun.svg +17 -0
  225. data/registry/icons/tabler/trash.svg +20 -0
  226. data/registry/icons/tabler/underline.svg +17 -0
  227. data/registry/icons/tabler/upload.svg +18 -0
  228. data/registry/icons/tabler/user.svg +17 -0
  229. data/registry/icons/tabler/users.svg +19 -0
  230. data/registry/icons/tabler/world.svg +20 -0
  231. data/registry/icons/tabler/x.svg +17 -0
  232. data/registry/icons.yml +74 -0
  233. data/registry/test/components/previews/ui/confirm_dialog_preview/destructive.html.erb +7 -0
  234. data/registry/test/components/previews/ui/confirm_dialog_preview/in_form.html.erb +6 -0
  235. data/registry/test/components/previews/ui/confirm_dialog_preview/on_link.html.erb +5 -0
  236. data/registry/test/components/previews/ui/confirm_dialog_preview/plain.html.erb +3 -0
  237. data/registry/test/components/previews/ui/confirm_dialog_preview/with_description.html.erb +4 -0
  238. data/registry/test/components/previews/ui/confirm_dialog_preview.rb +20 -0
  239. data/registry/test/components/previews/ui/empty_state_preview/in_card.html.erb +7 -0
  240. data/registry/test/components/previews/ui/empty_state_preview/no_results.html.erb +3 -0
  241. data/registry/test/components/previews/ui/empty_state_preview/outline.html.erb +3 -0
  242. data/registry/test/components/previews/ui/empty_state_preview/with_actions.html.erb +4 -0
  243. data/registry/test/components/previews/ui/empty_state_preview/with_media.html.erb +8 -0
  244. data/registry/test/components/previews/ui/empty_state_preview.rb +26 -0
  245. data/registry/test/components/previews/ui/icon_preview/common.html.erb +19 -3
  246. data/registry/test/components/previews/ui/icon_preview/labelled.html.erb +4 -0
  247. data/registry/test/components/previews/ui/icon_preview/missing.html.erb +3 -0
  248. data/registry/test/components/previews/ui/icon_preview.rb +18 -3
  249. data/registry/test/components/previews/ui/input_group_preview/playground.html.erb +2 -2
  250. data/registry/test/components/previews/ui/input_group_preview.rb +3 -3
  251. data/registry/test/components/previews/ui/stepper_preview/approvals.html.erb +9 -0
  252. data/registry/test/components/previews/ui/stepper_preview/checklist.html.erb +12 -0
  253. data/registry/test/components/previews/ui/stepper_preview/dot_wizard.html.erb +41 -0
  254. data/registry/test/components/previews/ui/stepper_preview/failed_deploy.html.erb +13 -0
  255. data/registry/test/components/previews/ui/stepper_preview/inline.html.erb +31 -0
  256. data/registry/test/components/previews/ui/stepper_preview/onboarding.html.erb +12 -0
  257. data/registry/test/components/previews/ui/stepper_preview/order_tracking.html.erb +10 -0
  258. data/registry/test/components/previews/ui/stepper_preview/price_calculator.html.erb +14 -0
  259. data/registry/test/components/previews/ui/stepper_preview/server_driven.html.erb +20 -0
  260. data/registry/test/components/previews/ui/stepper_preview/sidebar.html.erb +43 -0
  261. data/registry/test/components/previews/ui/stepper_preview/wizard.html.erb +55 -0
  262. data/registry/test/components/previews/ui/stepper_preview.rb +57 -0
  263. data/registry/test/components/previews/ui/toggle_group_preview/icon_only.html.erb +5 -0
  264. data/registry/test/components/previews/ui/toggle_group_preview/in_form.html.erb +11 -0
  265. data/registry/test/components/previews/ui/toggle_group_preview/multiple.html.erb +5 -0
  266. data/registry/test/components/previews/ui/toggle_group_preview/outline.html.erb +5 -0
  267. data/registry/test/components/previews/ui/toggle_group_preview/sizes.html.erb +9 -0
  268. data/registry/test/components/previews/ui/toggle_group_preview/with_icons.html.erb +5 -0
  269. data/registry/test/components/previews/ui/toggle_group_preview.rb +36 -0
  270. data/registry/test/components/ui/accordion/trigger_test.rb +1 -1
  271. data/registry/test/components/ui/alert_test.rb +10 -10
  272. data/registry/test/components/ui/badge_test.rb +3 -3
  273. data/registry/test/components/ui/banner_test.rb +3 -3
  274. data/registry/test/components/ui/breadcrumb/ellipsis_test.rb +2 -2
  275. data/registry/test/components/ui/button_test.rb +17 -14
  276. data/registry/test/components/ui/button_to_test.rb +2 -2
  277. data/registry/test/components/ui/checkbox_test.rb +2 -2
  278. data/registry/test/components/ui/confirm_dialog_test.rb +68 -0
  279. data/registry/test/components/ui/empty_state_test.rb +87 -0
  280. data/registry/test/components/ui/icon_test.rb +60 -20
  281. data/registry/test/components/ui/input_group_test.rb +1 -1
  282. data/registry/test/components/ui/link_test.rb +3 -3
  283. data/registry/test/components/ui/navigation_menu_test.rb +2 -2
  284. data/registry/test/components/ui/session_tabs_test.rb +3 -3
  285. data/registry/test/components/ui/spinner_test.rb +9 -9
  286. data/registry/test/components/ui/stepper_test.rb +239 -0
  287. data/registry/test/components/ui/tabs/trigger_test.rb +2 -2
  288. data/registry/test/components/ui/theme_toggle_test.rb +6 -8
  289. data/registry/test/components/ui/toast_test.rb +11 -10
  290. data/registry/test/components/ui/toggle_group_test.rb +162 -0
  291. metadata +253 -2
  292. data/registry/app/javascript/velvetkit_icons.ts +0 -78
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::EmptyStateTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def test_renders_title_description_and_icon
10
+ render_inline(UI::EmptyState.new(icon: "inbox", title: "No messages", description: "You're all caught up."))
11
+ assert_selector "[data-slot='empty-state'] h3", text: "No messages"
12
+ assert_selector "[data-slot='empty-state'] p", text: "You're all caught up."
13
+ assert_selector "[data-slot='empty-state'] svg[data-icon='inbox']", visible: :all
14
+ end
15
+
16
+ def test_block_is_the_actions_row
17
+ render_inline(UI::EmptyState.new(title: "No projects")) { "<button>Create project</button>".html_safe }
18
+ assert_selector "[data-slot='empty-state'] div.flex-wrap button", text: "Create project"
19
+ end
20
+
21
+ def test_no_actions_row_without_a_block
22
+ render_inline(UI::EmptyState.new(title: "No projects"))
23
+ assert_no_selector "div.flex-wrap"
24
+ end
25
+
26
+ def test_no_icon_box_without_an_icon
27
+ render_inline(UI::EmptyState.new(title: "No projects"))
28
+ assert_no_selector "svg", visible: :all
29
+ assert_no_selector "div.bg-muted"
30
+ end
31
+
32
+ def test_media_replaces_the_icon
33
+ render_inline(UI::EmptyState.new(icon: "inbox", title: "No team")) do |empty|
34
+ empty.with_media { "<img alt='Team' src='/team.png'>".html_safe }
35
+ end
36
+ assert_selector "img[alt='Team']"
37
+ assert_no_selector "svg[data-icon='inbox']", visible: :all
38
+ end
39
+
40
+ def test_heading_level
41
+ render_inline(UI::EmptyState.new(title: "Nothing here", heading_level: 2))
42
+ assert_selector "h2", text: "Nothing here"
43
+ assert_no_selector "h3"
44
+ end
45
+
46
+ def test_heading_level_is_kept_in_range
47
+ render_inline(UI::EmptyState.new(title: "Nothing here", heading_level: 9))
48
+ assert_selector "h6", text: "Nothing here"
49
+ end
50
+
51
+ def test_description_keeps_html
52
+ render_inline(UI::EmptyState.new(description: "Read <a href='/docs'>the guide</a>.".html_safe))
53
+ assert_selector "p a[href='/docs']", text: "the guide"
54
+ end
55
+
56
+ def test_description_escapes_plain_strings
57
+ render_inline(UI::EmptyState.new(description: "<b>bold</b>"))
58
+ assert_no_selector "p b"
59
+ assert_selector "p", text: "<b>bold</b>"
60
+ end
61
+
62
+ def test_default_variant_has_no_border
63
+ render_inline(UI::EmptyState.new(title: "x"))
64
+ classes = page.find("[data-slot='empty-state']")[:class].split
65
+ assert_includes classes, "text-center"
66
+ refute_includes classes, "border-dashed"
67
+ end
68
+
69
+ def test_outline_variant
70
+ render_inline(UI::EmptyState.new(title: "x", variant: :outline))
71
+ classes = page.find("[data-slot='empty-state']")[:class].split
72
+ assert_includes classes, "border"
73
+ assert_includes classes, "border-dashed"
74
+ end
75
+
76
+ def test_user_class_merges
77
+ render_inline(UI::EmptyState.new(title: "x", class: "p-2"))
78
+ classes = page.find("[data-slot='empty-state']")[:class].split
79
+ assert_includes classes, "p-2"
80
+ refute_includes classes, "p-6"
81
+ end
82
+
83
+ def test_html_attrs_pass_through_and_keep_the_slot
84
+ render_inline(UI::EmptyState.new(title: "x", id: "projects-empty", data: { test_id: "empty" }))
85
+ assert_selector "#projects-empty[data-slot='empty-state'][data-test-id='empty']"
86
+ end
87
+ end
@@ -6,77 +6,117 @@ class UI::IconTest < ViewComponent::TestCase
6
6
  def setup_fixtures(*); end
7
7
  def teardown_fixtures(*); end
8
8
 
9
- def test_renders_i_tag_with_lucide_data_attribute
10
- render_inline UI::Icon.new(name: "menu")
11
- icon = page.find("i", visible: :all)
12
- assert_equal "menu", icon["data-lucide"]
9
+ def test_draws_the_svg_file_inline
10
+ render_inline UI::Icon.new(name: "x")
11
+ svg = page.find("svg[data-icon='x']", visible: :all)
12
+ assert svg.has_selector?("path", visible: :all, minimum: 1), "draws the file's shapes"
13
+ assert svg[:viewbox].present?, "keeps the file's viewBox"
14
+ end
15
+
16
+ def test_drops_the_files_own_size_and_class
17
+ render_inline UI::Icon.new(name: "x")
18
+ svg = page.find("svg", visible: :all)
19
+ assert_nil svg[:width]
20
+ assert_nil svg[:height]
21
+ assert_equal %w[h-5 inline-block shrink-0 w-5], svg[:class].split.sort
22
+ end
23
+
24
+ def test_decorative_by_default
25
+ render_inline UI::Icon.new(name: "x")
26
+ svg = page.find("svg", visible: :all)
27
+ assert_equal "true", svg["aria-hidden"]
28
+ assert_nil svg[:role]
29
+ end
30
+
31
+ def test_label_makes_it_an_image
32
+ render_inline UI::Icon.new(name: "x", label: "Close")
33
+ svg = page.find("svg", visible: :all)
34
+ assert_equal "img", svg[:role]
35
+ assert_equal "Close", svg["aria-label"]
36
+ assert_nil svg["aria-hidden"]
37
+ end
38
+
39
+ def test_symbol_names
40
+ render_inline UI::Icon.new(name: :x)
41
+ assert_selector "svg[data-icon='x'] path", visible: :all
42
+ end
43
+
44
+ def test_an_icon_with_no_file_draws_a_placeholder
45
+ render_inline UI::Icon.new(name: "no-such-icon")
46
+ svg = page.find("svg[data-icon='no-such-icon']", visible: :all)
47
+ assert svg["data-icon-missing"]
48
+ assert svg.has_selector?("rect", visible: :all)
49
+ end
50
+
51
+ def test_a_name_is_never_a_path
52
+ render_inline UI::Icon.new(name: "../icons/lucide/x")
53
+ assert_selector "svg[data-icon-missing]", visible: :all
54
+ assert_no_selector "path", visible: :all
13
55
  end
14
56
 
15
57
  def test_default_size_classes
16
58
  render_inline UI::Icon.new(name: "menu")
17
- icon = page.find("i", visible: :all)
18
- classes = icon[:class].split
59
+ classes = page.find("svg", visible: :all)[:class].split
19
60
  assert_includes classes, "w-5"
20
61
  assert_includes classes, "h-5"
21
62
  end
22
63
 
23
64
  def test_size_xs
24
65
  render_inline UI::Icon.new(name: "menu", size: :xs)
25
- icon = page.find("i", visible: :all)
26
- classes = icon[:class].split
66
+ classes = page.find("svg", visible: :all)[:class].split
27
67
  assert_includes classes, "w-3"
28
68
  assert_includes classes, "h-3"
29
69
  end
30
70
 
31
71
  def test_size_sm
32
72
  render_inline UI::Icon.new(name: "menu", size: :sm)
33
- classes = page.find("i", visible: :all)[:class].split
73
+ classes = page.find("svg", visible: :all)[:class].split
34
74
  assert_includes classes, "w-4"
35
75
  assert_includes classes, "h-4"
36
76
  end
37
77
 
38
78
  def test_size_lg
39
79
  render_inline UI::Icon.new(name: "menu", size: :lg)
40
- classes = page.find("i", visible: :all)[:class].split
80
+ classes = page.find("svg", visible: :all)[:class].split
41
81
  assert_includes classes, "w-6"
42
82
  assert_includes classes, "h-6"
43
83
  end
44
84
 
45
85
  def test_size_xl
46
86
  render_inline UI::Icon.new(name: "menu", size: :xl)
47
- classes = page.find("i", visible: :all)[:class].split
87
+ classes = page.find("svg", visible: :all)[:class].split
48
88
  assert_includes classes, "w-8"
49
89
  assert_includes classes, "h-8"
50
90
  end
51
91
 
52
92
  def test_user_class_merges
53
93
  render_inline UI::Icon.new(name: "menu", class: "text-red-500")
54
- classes = page.find("i", visible: :all)[:class].split
94
+ classes = page.find("svg", visible: :all)[:class].split
55
95
  assert_includes classes, "text-red-500"
56
96
  assert_includes classes, "w-5"
57
97
  end
58
98
 
59
99
  def test_renders_nothing_when_name_blank
60
100
  render_inline UI::Icon.new(name: "")
61
- assert_no_selector "i", visible: :all
101
+ assert_no_selector "svg", visible: :all
62
102
  end
63
103
 
64
104
  def test_renders_nothing_when_name_nil
65
105
  render_inline UI::Icon.new(name: nil)
66
- assert_no_selector "i", visible: :all
106
+ assert_no_selector "svg", visible: :all
67
107
  end
68
108
 
69
109
  def test_html_attrs_pass_through
70
110
  render_inline UI::Icon.new(name: "menu", id: "header-menu", aria: { label: "Open menu" })
71
- icon = page.find("i", visible: :all)
72
- assert_equal "header-menu", icon[:id]
73
- assert_equal "Open menu", icon["aria-label"]
111
+ svg = page.find("svg", visible: :all)
112
+ assert_equal "header-menu", svg[:id]
113
+ assert_equal "Open menu", svg["aria-label"]
74
114
  end
75
115
 
76
116
  def test_data_attributes_keep_the_icon_name
77
117
  render_inline(UI::Icon.new(name: "copy", data: { clipboard_target: "idle" }))
78
- icon = page.find("i", visible: :all)
79
- assert_equal "copy", icon["data-lucide"]
80
- assert_equal "idle", icon["data-clipboard-target"]
118
+ svg = page.find("svg", visible: :all)
119
+ assert svg.matches_css?("[data-icon='copy']")
120
+ assert_equal "idle", svg["data-clipboard-target"]
81
121
  end
82
122
  end
@@ -129,7 +129,7 @@ class UI::InputGroupTest < ViewComponent::TestCase
129
129
  end
130
130
  g.with_field(placeholder: "Email")
131
131
  end
132
- assert_selector "[data-slot='input-group-addon'] i[data-lucide='mail']"
132
+ assert_selector "[data-slot='input-group-addon'] svg[data-icon='mail']"
133
133
  end
134
134
 
135
135
  def test_multiple_addons
@@ -79,8 +79,8 @@ class UI::LinkTest < ViewComponent::TestCase
79
79
  end
80
80
 
81
81
  anchor = page.find("a", text: "Continue")
82
- assert_equal "arrow-right", anchor.find("i", visible: :all)["data-lucide"]
83
- assert_match(/<i[^>]*data-lucide="arrow-right".*Continue/m, anchor.native.to_html)
82
+ assert anchor.find("svg", visible: :all).matches_css?("[data-icon='arrow-right']")
83
+ assert_match(/<svg[^>]*data-icon="arrow-right".*Continue/m, anchor.native.to_html)
84
84
  end
85
85
 
86
86
  def test_trailing_icon_renders_after_content
@@ -90,6 +90,6 @@ class UI::LinkTest < ViewComponent::TestCase
90
90
  end
91
91
 
92
92
  anchor = page.find("a", text: "Continue")
93
- assert_match(/Continue.*<i[^>]*data-lucide="arrow-right"/m, anchor.native.to_html)
93
+ assert_match(/Continue.*<svg[^>]*data-icon="arrow-right"/m, anchor.native.to_html)
94
94
  end
95
95
  end
@@ -52,7 +52,7 @@ class UI::NavigationMenuTest < ViewComponent::TestCase
52
52
 
53
53
  def test_trigger_has_a_rotating_chevron
54
54
  render_nav
55
- icon = page.find("button", text: "Getting started").find("[data-lucide='chevron-down']", visible: :all)
55
+ icon = page.find("button", text: "Getting started").find("[data-icon='chevron-down']", visible: :all)
56
56
  assert_includes icon[:class], "group-aria-expanded/nav-item:rotate-180"
57
57
  end
58
58
 
@@ -82,7 +82,7 @@ class UI::NavigationMenuTest < ViewComponent::TestCase
82
82
  nav.with_item(label: "More") { |i| i.with_link(title: "Status", href: "/s", icon: "circle-check", active: true) }
83
83
  end
84
84
  link = page.find("a[href='/s']", visible: :all)
85
- assert link.has_selector?("[data-lucide='circle-check']", visible: :all)
85
+ assert link.has_selector?("[data-icon='circle-check']", visible: :all)
86
86
  assert_includes link[:class], "items-center"
87
87
  assert_equal "page", link["aria-current"]
88
88
  end
@@ -169,16 +169,16 @@ class UI::SessionTabsTest < ViewComponent::TestCase
169
169
  assert_equal "pointerdown->ui--session-tabs#dragStart", handle["data-action"]
170
170
  assert_equal "true", handle["aria-hidden"]
171
171
  assert_includes handle[:class], "touch-none"
172
- assert handle.has_selector?("[data-lucide='grip-vertical']", visible: :all)
172
+ assert handle.has_selector?("[data-icon='grip-vertical']", visible: :all)
173
173
  end
174
174
 
175
175
  def test_controls_reveal_on_hover_and_slide_in
176
176
  render_tabs do |t|
177
177
  t.with_tab(value: "a", move: true, rename: true) { "Alpha" }
178
178
  end
179
- grip = page.find("[data-ui--session-tabs-target='handle'] [data-lucide]", visible: :all)[:class]
179
+ grip = page.find("[data-ui--session-tabs-target='handle'] [data-icon]", visible: :all)[:class]
180
180
  menu = page.find("[data-ui--session-tabs-target='menuTrigger']")[:class]
181
- dots = page.find("[data-ui--session-tabs-target='menuTrigger'] [data-lucide]", visible: :all)[:class]
181
+ dots = page.find("[data-ui--session-tabs-target='menuTrigger'] [data-icon]", visible: :all)[:class]
182
182
  [ grip, menu ].each do |classes|
183
183
  assert_includes classes, "opacity-0"
184
184
  assert_includes classes, "group-hover/tab:opacity-100"
@@ -8,56 +8,56 @@ class UI::SpinnerTest < ViewComponent::TestCase
8
8
 
9
9
  def test_renders_loader_icon_with_animate_spin
10
10
  render_inline UI::Spinner.new
11
- icon = page.find("i", visible: :all)
12
- assert_equal "loader", icon["data-lucide"]
11
+ icon = page.find("svg", visible: :all)
12
+ assert icon.matches_css?("[data-icon='loader']")
13
13
  assert_includes icon[:class].split, "animate-spin"
14
14
  end
15
15
 
16
16
  def test_default_size_classes
17
17
  render_inline UI::Spinner.new
18
- classes = page.find("i", visible: :all)[:class].split
18
+ classes = page.find("svg", visible: :all)[:class].split
19
19
  assert_includes classes, "w-5"
20
20
  assert_includes classes, "h-5"
21
21
  end
22
22
 
23
23
  def test_size_xs
24
24
  render_inline UI::Spinner.new(size: :xs)
25
- classes = page.find("i", visible: :all)[:class].split
25
+ classes = page.find("svg", visible: :all)[:class].split
26
26
  assert_includes classes, "w-3"
27
27
  assert_includes classes, "h-3"
28
28
  end
29
29
 
30
30
  def test_size_sm
31
31
  render_inline UI::Spinner.new(size: :sm)
32
- classes = page.find("i", visible: :all)[:class].split
32
+ classes = page.find("svg", visible: :all)[:class].split
33
33
  assert_includes classes, "w-4"
34
34
  assert_includes classes, "h-4"
35
35
  end
36
36
 
37
37
  def test_size_lg
38
38
  render_inline UI::Spinner.new(size: :lg)
39
- classes = page.find("i", visible: :all)[:class].split
39
+ classes = page.find("svg", visible: :all)[:class].split
40
40
  assert_includes classes, "w-6"
41
41
  assert_includes classes, "h-6"
42
42
  end
43
43
 
44
44
  def test_size_xl
45
45
  render_inline UI::Spinner.new(size: :xl)
46
- classes = page.find("i", visible: :all)[:class].split
46
+ classes = page.find("svg", visible: :all)[:class].split
47
47
  assert_includes classes, "w-8"
48
48
  assert_includes classes, "h-8"
49
49
  end
50
50
 
51
51
  def test_user_class_merges
52
52
  render_inline UI::Spinner.new(class: "text-primary")
53
- classes = page.find("i", visible: :all)[:class].split
53
+ classes = page.find("svg", visible: :all)[:class].split
54
54
  assert_includes classes, "text-primary"
55
55
  assert_includes classes, "animate-spin"
56
56
  end
57
57
 
58
58
  def test_html_attrs_pass_through
59
59
  render_inline UI::Spinner.new(aria: { label: "Loading" })
60
- icon = page.find("i", visible: :all)
60
+ icon = page.find("svg", visible: :all)
61
61
  assert_equal "Loading", icon["aria-label"]
62
62
  end
63
63
  end
@@ -0,0 +1,239 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class UI::StepperTest < ViewComponent::TestCase
6
+ def setup_fixtures(*); end
7
+ def teardown_fixtures(*); end
8
+
9
+ def render_steps(titles = %w[Account Plan Payment], **opts, &block)
10
+ render_inline(UI::Stepper.new(**opts)) do |stepper|
11
+ titles.each { |title| stepper.with_step(title: title) }
12
+ block&.call(stepper)
13
+ end
14
+ end
15
+
16
+ def statuses = page.all("li[data-slot='stepper-step']").map { |li| li["data-status"] }
17
+
18
+ def test_renders_a_labelled_nav_with_an_ordered_list
19
+ render_steps
20
+ assert_selector "nav[aria-label='Progress'] > ol > li", count: 3
21
+ assert_selector "div[data-slot='stepper'][data-orientation='horizontal'][data-variant='default']"
22
+ end
23
+
24
+ def test_label_names_the_nav
25
+ render_steps(label: "Create a project")
26
+ assert_selector "nav[aria-label='Create a project']"
27
+ end
28
+
29
+ def test_steps_before_current_are_complete_and_after_are_upcoming
30
+ render_steps(%w[A B C D], current: 3)
31
+ assert_equal %w[complete complete current upcoming], statuses
32
+ assert_selector "li[data-status='current'][aria-current='step']", text: "C"
33
+ assert_selector "li[aria-current]", count: 1
34
+ end
35
+
36
+ def test_current_past_the_last_step_marks_them_all_complete
37
+ render_steps(current: 4)
38
+ assert_equal %w[complete complete complete], statuses
39
+ refute_selector "li[aria-current]"
40
+ end
41
+
42
+ def test_status_overrides_the_step
43
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
44
+ stepper.with_step(title: "Build")
45
+ stepper.with_step(title: "Test", status: :error)
46
+ stepper.with_step(title: "Deploy", status: :loading)
47
+ end
48
+ assert_equal %w[complete error loading], statuses
49
+ end
50
+
51
+ def test_each_step_says_its_state_to_screen_readers
52
+ render_steps(current: 2)
53
+ step = page.find("li[data-status='complete']")
54
+ assert_includes step.find("span.sr-only", text: "Completed", visible: :all)[:class], "group-data-[status=complete]/step:inline"
55
+ end
56
+
57
+ def test_indicator_draws_the_number_and_a_glyph_for_each_state
58
+ render_steps(current: 2)
59
+ indicator = page.find_all("li")[1].find("span[aria-hidden]", match: :first)
60
+ assert_text "2"
61
+ assert_selector "li svg[data-icon='check']", visible: :all
62
+ assert_selector "li svg[data-icon='loader'].animate-spin", visible: :all
63
+ assert_includes indicator[:class], "group-data-[status=current]/step:ring-4"
64
+ end
65
+
66
+ def test_icon_replaces_the_number
67
+ render_inline(UI::Stepper.new) { |stepper| stepper.with_step(title: "Pay", icon: "credit-card") }
68
+ assert_selector "li svg[data-icon='credit-card']", visible: :all
69
+ end
70
+
71
+ def test_connector_between_steps_but_not_after_the_last
72
+ render_steps
73
+ assert_selector "li span.bg-border", count: 2
74
+ refute_selector "li:last-child span.bg-border"
75
+ end
76
+
77
+ def test_connector_fill_grows_once_the_step_is_done
78
+ render_steps
79
+ fill = page.find("li span.bg-border > span", match: :first, visible: :all)
80
+ assert_includes fill[:class], "scale-x-0"
81
+ assert_includes fill[:class], "group-data-[status=complete]/step:scale-x-100"
82
+ end
83
+
84
+ def test_no_connector
85
+ render_steps(connector: false)
86
+ refute_selector "li span.bg-border"
87
+ end
88
+
89
+ def test_vertical_stacks_with_a_vertical_line
90
+ render_steps(orientation: :vertical)
91
+ assert_selector "div[data-orientation='vertical'] ol.flex-col"
92
+ fill = page.find("li span.bg-border > span", match: :first, visible: :all)
93
+ assert_includes fill[:class], "group-data-[status=complete]/step:scale-y-100"
94
+ end
95
+
96
+ def test_dot_variant_draws_no_number
97
+ render_steps(variant: :dot)
98
+ assert_selector "div[data-variant='dot']"
99
+ refute_selector "li span.size-8"
100
+ assert_selector "li span.size-3", count: 3
101
+ assert page.all("li span.size-3").all? { |dot| dot.text.strip.empty? }
102
+ end
103
+
104
+ def test_center_align_centres_each_step
105
+ render_steps(align: :center)
106
+ assert_selector "li.items-center.text-center", count: 3
107
+ end
108
+
109
+ def test_labels_false_keeps_titles_for_screen_readers
110
+ render_steps(labels: false)
111
+ assert_selector "li div.sr-only", count: 3, visible: :all
112
+ end
113
+
114
+ def test_titles_are_hidden_on_phones_with_a_summary_instead
115
+ render_steps(current: 2)
116
+ assert_selector "li div.\\@max-md\\/stepper\\:sr-only", count: 3, visible: :all
117
+ summary = page.find("p.\\@md\\/stepper\\:hidden[aria-hidden='true']")
118
+ assert_equal "Step 2 of 3: Plan", summary.text
119
+ end
120
+
121
+ def test_descriptions
122
+ render_inline(UI::Stepper.new) { |stepper| stepper.with_step(title: "Account", description: "Name and email") }
123
+ assert_selector "li span", text: "Name and email"
124
+ end
125
+
126
+ def test_done_steps_with_href_link_back_but_the_current_one_does_not
127
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
128
+ stepper.with_step(title: "Account", href: "/signup/account")
129
+ stepper.with_step(title: "Plan", href: "/signup/plan")
130
+ end
131
+ assert_selector "a[href='/signup/account']", text: "Account"
132
+ refute_selector "a[href='/signup/plan']"
133
+ end
134
+
135
+ def test_wires_the_controller_with_the_current_step
136
+ render_steps(current: 2)
137
+ root = page.find("div[data-slot='stepper']")
138
+ controller = "ui--stepper"
139
+ assert_equal controller, root["data-controller"]
140
+ assert_equal "2", root["data-#{controller}-current-value"]
141
+ assert_equal "Step %{current} of %{total}", root["data-#{controller}-summary-value"]
142
+ assert_includes root["data-action"], "#{controller}#keydown"
143
+ assert_selector "li[data-#{controller}-target='step']", count: 3
144
+ end
145
+
146
+ def test_step_blocks_become_panels_and_only_the_current_one_shows
147
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
148
+ stepper.with_step(title: "Account") { "Account fields" }
149
+ stepper.with_step(title: "Plan") { "Plan fields" }
150
+ end
151
+ panels = page.all("div[role='group'][data-step]", visible: :all)
152
+ assert_equal %w[1 2], panels.map { |panel| panel["data-step"] }
153
+ assert panels.first[:hidden]
154
+ refute panels.last[:hidden]
155
+ assert_text "Plan fields"
156
+ assert_equal panels.last["aria-labelledby"], page.find("li span", text: "Plan", exact_text: true)[:id]
157
+ refute_selector "li", text: "Plan fields"
158
+ end
159
+
160
+ def test_inline_layout_puts_each_panel_in_its_step
161
+ render_inline(UI::Stepper.new(orientation: :vertical, layout: :inline)) do |stepper|
162
+ stepper.with_step(title: "Install") { "Get an app" }
163
+ end
164
+ assert_selector "li div[role='group']", text: "Get an app"
165
+ end
166
+
167
+ def test_side_layout_puts_the_steps_beside_the_panels
168
+ render_inline(UI::Stepper.new(orientation: :vertical, layout: :side)) do |stepper|
169
+ stepper.with_step(title: "Format") { "Pick one" }
170
+ end
171
+ assert_selector "div[data-slot='stepper'] > div.grid > nav + div", text: "Pick one"
172
+ end
173
+
174
+ def test_completion_shows_once_every_step_is_done
175
+ render_inline(UI::Stepper.new(current: 2)) do |stepper|
176
+ stepper.with_step(title: "Only") { "Fields" }
177
+ stepper.with_completion { "All done" }
178
+ end
179
+ assert_text "All done"
180
+ refute_selector "p.\\@md\\/stepper\\:hidden"
181
+ end
182
+
183
+ def test_completion_is_hidden_until_then
184
+ render_inline(UI::Stepper.new) do |stepper|
185
+ stepper.with_step(title: "Only") { "Fields" }
186
+ stepper.with_completion { "All done" }
187
+ end
188
+ assert_selector "div[hidden]", text: "All done", visible: :all
189
+ end
190
+
191
+ def test_block_comes_after_the_panels
192
+ render_inline(UI::Stepper.new) do |stepper|
193
+ stepper.with_step(title: "Only") { "Fields" }
194
+ "Buttons"
195
+ end
196
+ assert_match(/Fields.*Buttons/m, page.native.to_html)
197
+ end
198
+
199
+ def test_class_and_attributes_pass_through
200
+ render_steps(class: "max-w-xl", id: "signup", data: { turbo: false })
201
+ root = page.find("div#signup[data-turbo='false']")
202
+ assert_includes root[:class], "max-w-xl"
203
+ assert_selector "li span[id='signup-step-1']"
204
+ end
205
+
206
+ def render_panels(**opts)
207
+ render_inline(UI::Stepper.new(current: 2, **opts)) do |stepper|
208
+ stepper.with_step(title: "Account") { "Account fields" }
209
+ stepper.with_step(title: "Plan") { "Plan fields" }
210
+ stepper.with_step(title: "Payment") { "Card fields" }
211
+ end
212
+ end
213
+
214
+ def test_with_panels_a_done_step_is_a_button_back_to_it
215
+ render_panels
216
+ controller = "ui--stepper"
217
+ back = page.find("li[data-status='complete'] button[type='button']")
218
+ assert_equal "Account", back.text
219
+ refute back.disabled?
220
+ assert_equal "#{controller}#select", back["data-action"]
221
+ assert_equal "click->#{controller}#select", page.find("li[data-status='complete'] span[aria-hidden]", match: :first)["data-action"]
222
+ end
223
+
224
+ def test_steps_not_done_yet_are_disabled_buttons
225
+ render_panels
226
+ assert_selector "li[data-status='current'] button[disabled]", text: "Plan"
227
+ assert_selector "li[data-status='upcoming'] button[disabled]", text: "Payment"
228
+ end
229
+
230
+ def test_navigable_false_keeps_titles_plain
231
+ render_panels(navigable: false)
232
+ refute_selector "li button"
233
+ end
234
+
235
+ def test_without_panels_titles_are_plain
236
+ render_steps(current: 2)
237
+ refute_selector "li button"
238
+ end
239
+ end
@@ -103,8 +103,8 @@ class UI::Tabs::TriggerTest < ViewComponent::TestCase
103
103
  end
104
104
  tabs.with_panel(value: "a") { "panel-a" }
105
105
  end
106
- icon = page.find("[role='tab'][data-value='a'] i", visible: :all)
107
- assert_equal "user", icon["data-lucide"]
106
+ icon = page.find("[role='tab'][data-value='a'] svg", visible: :all)
107
+ assert icon.matches_css?("[data-icon='user']")
108
108
  end
109
109
 
110
110
  def test_line_variant_size_sm
@@ -46,20 +46,18 @@ class UI::ThemeToggleTest < ViewComponent::TestCase
46
46
  end
47
47
  end
48
48
 
49
- # lucide swaps each <i data-lucide> for an <svg> on first render, so the
50
- # element is gone afterwards and the icon cannot be changed by attribute.
51
- # All three are rendered and shown by the preference on <html data-theme>:
49
+ # All three icons are rendered and shown by the preference on <html data-theme>:
52
50
  # the sun for light, which is the default (and before any script runs).
53
51
  def test_trigger_icon_follows_the_preference_with_light_by_default
54
52
  render_inline(UI::ThemeToggle.new)
55
53
  trigger = page.find("button[aria-haspopup]")
56
- icon = ->(name) { trigger.find("i[data-lucide='#{name}']", visible: :all)[:class].split }
57
- sun = icon.("sun")
54
+ icon = ->(selector) { trigger.find(selector, visible: :all)[:class].split }
55
+ sun = icon.("svg[data-icon='sun']")
58
56
  assert_includes sun, "block"
59
57
  assert_includes sun, "in-data-[theme=dark]:hidden"
60
58
  assert_includes sun, "in-data-[theme=system]:hidden"
61
- assert_includes icon.("moon"), "in-data-[theme=dark]:block"
62
- assert_includes icon.("monitor"), "in-data-[theme=system]:block"
59
+ assert_includes icon.("svg[data-icon='moon']"), "in-data-[theme=dark]:block"
60
+ assert_includes icon.("svg[data-icon='monitor']"), "in-data-[theme=system]:block"
63
61
  end
64
62
 
65
63
  def test_html_attrs_passthrough
@@ -80,7 +78,7 @@ class UI::ThemeToggleTest < ViewComponent::TestCase
80
78
  def test_each_option_has_a_check_indicator_shown_only_when_checked
81
79
  render_inline(UI::ThemeToggle.new)
82
80
  page.all("[data-ui--theme-target='option']", visible: :all).each do |option|
83
- check = option.find("i[data-lucide='check']", visible: :all)
81
+ check = option.find("svg[data-icon='check']", visible: :all)
84
82
  assert_includes check[:class].split, "hidden"
85
83
  assert_includes check[:class].split, "group-aria-checked:block"
86
84
  end