velvetkit 0.2.2 → 0.4.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 (458) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -0
  3. data/README.md +30 -8
  4. data/lib/generators/velvetkit/add/add_generator.rb +77 -0
  5. data/lib/generators/velvetkit/helpers.rb +29 -2
  6. data/lib/generators/velvetkit/icons/icons_generator.rb +71 -0
  7. data/lib/generators/velvetkit/install/install_generator.rb +9 -12
  8. data/lib/velvetkit/icons.rb +148 -0
  9. data/lib/velvetkit/registry.rb +5 -2
  10. data/lib/velvetkit/version.rb +4 -1
  11. data/lib/velvetkit.rb +8 -0
  12. data/registry/app/assets/tailwind/velvetkit.css +90 -155
  13. data/registry/app/components/ui/alert.rb +1 -1
  14. data/registry/app/components/ui/chart.html.erb +47 -0
  15. data/registry/app/components/ui/chart.rb +177 -0
  16. data/registry/app/components/ui/command/group.rb +27 -0
  17. data/registry/app/components/ui/command/item.rb +64 -0
  18. data/registry/app/components/ui/command.html.erb +41 -0
  19. data/registry/app/components/ui/command.rb +122 -0
  20. data/registry/app/components/ui/confirm_dialog.html.erb +13 -0
  21. data/registry/app/components/ui/confirm_dialog.rb +55 -0
  22. data/registry/app/components/ui/date_picker.html.erb +58 -64
  23. data/registry/app/components/ui/date_picker.rb +199 -75
  24. data/registry/app/components/ui/empty_state.html.erb +20 -0
  25. data/registry/app/components/ui/empty_state.rb +46 -0
  26. data/registry/app/components/ui/file_field.html.erb +14 -4
  27. data/registry/app/components/ui/file_field.rb +179 -28
  28. data/registry/app/components/ui/gallery/image.rb +20 -0
  29. data/registry/app/components/ui/gallery.html.erb +52 -0
  30. data/registry/app/components/ui/gallery.rb +164 -0
  31. data/registry/app/components/ui/icon.html.erb +1 -1
  32. data/registry/app/components/ui/icon.rb +80 -8
  33. data/registry/app/components/ui/kbd.html.erb +27 -0
  34. data/registry/app/components/ui/kbd.rb +134 -0
  35. data/registry/app/components/ui/number_input.html.erb +11 -0
  36. data/registry/app/components/ui/number_input.rb +103 -0
  37. data/registry/app/components/ui/password_input.html.erb +1 -1
  38. data/registry/app/components/ui/progress/segment.rb +25 -0
  39. data/registry/app/components/ui/progress.html.erb +25 -0
  40. data/registry/app/components/ui/progress.rb +182 -0
  41. data/registry/app/components/ui/select.html.erb +24 -5
  42. data/registry/app/components/ui/select.rb +44 -5
  43. data/registry/app/components/ui/stepper/step.html.erb +27 -0
  44. data/registry/app/components/ui/stepper/step.rb +213 -0
  45. data/registry/app/components/ui/stepper.html.erb +19 -0
  46. data/registry/app/components/ui/stepper.rb +145 -0
  47. data/registry/app/components/ui/theme_toggle.rb +2 -4
  48. data/registry/app/components/ui/timeline/item.html.erb +21 -0
  49. data/registry/app/components/ui/timeline/item.rb +145 -0
  50. data/registry/app/components/ui/timeline.html.erb +1 -0
  51. data/registry/app/components/ui/timeline.rb +42 -0
  52. data/registry/app/components/ui/toast.rb +6 -6
  53. data/registry/app/components/ui/toggle_group/item.html.erb +1 -0
  54. data/registry/app/components/ui/toggle_group/item.rb +85 -0
  55. data/registry/app/components/ui/toggle_group.html.erb +1 -0
  56. data/registry/app/components/ui/toggle_group.rb +79 -0
  57. data/registry/app/javascript/chart_js.ts +37 -0
  58. data/registry/app/javascript/controllers/ui/_internal/date_format.ts +74 -0
  59. data/registry/app/javascript/controllers/ui/_internal/shortcut.ts +80 -0
  60. data/registry/app/javascript/controllers/ui/chart_controller.ts +585 -0
  61. data/registry/app/javascript/controllers/ui/command_controller.ts +454 -0
  62. data/registry/app/javascript/controllers/ui/confirm_dialog_controller.ts +110 -0
  63. data/registry/app/javascript/controllers/ui/date_picker_controller.ts +247 -82
  64. data/registry/app/javascript/controllers/ui/file_field_controller.ts +288 -16
  65. data/registry/app/javascript/controllers/ui/gallery_controller.ts +568 -0
  66. data/registry/app/javascript/controllers/ui/kbd_controller.ts +60 -0
  67. data/registry/app/javascript/controllers/ui/number_input_controller.ts +111 -0
  68. data/registry/app/javascript/controllers/ui/progress_controller.ts +87 -0
  69. data/registry/app/javascript/controllers/ui/select_controller.ts +198 -8
  70. data/registry/app/javascript/controllers/ui/stepper_controller.ts +187 -0
  71. data/registry/app/javascript/vanilla_calendar.ts +15 -0
  72. data/registry/components.yml +28 -5
  73. data/registry/config/locales/velvetkit.en.yml +84 -0
  74. data/registry/docs/agents.md +7 -4
  75. data/registry/icons/lucide/LICENSE +39 -0
  76. data/registry/icons/lucide/align-center.svg +17 -0
  77. data/registry/icons/lucide/align-left.svg +17 -0
  78. data/registry/icons/lucide/align-right.svg +17 -0
  79. data/registry/icons/lucide/arrow-left.svg +16 -0
  80. data/registry/icons/lucide/arrow-right.svg +16 -0
  81. data/registry/icons/lucide/badge-check.svg +16 -0
  82. data/registry/icons/lucide/bar-chart-3.svg +18 -0
  83. data/registry/icons/lucide/bell.svg +16 -0
  84. data/registry/icons/lucide/bold.svg +15 -0
  85. data/registry/icons/lucide/book-open.svg +16 -0
  86. data/registry/icons/lucide/calendar.svg +18 -0
  87. data/registry/icons/lucide/chart-column.svg +18 -0
  88. data/registry/icons/lucide/check.svg +15 -0
  89. data/registry/icons/lucide/chevron-down.svg +15 -0
  90. data/registry/icons/lucide/chevron-left.svg +15 -0
  91. data/registry/icons/lucide/chevron-right.svg +15 -0
  92. data/registry/icons/lucide/chevrons-up-down.svg +16 -0
  93. data/registry/icons/lucide/circle-alert.svg +17 -0
  94. data/registry/icons/lucide/circle-check.svg +16 -0
  95. data/registry/icons/lucide/cloud.svg +15 -0
  96. data/registry/icons/lucide/credit-card.svg +16 -0
  97. data/registry/icons/lucide/download.svg +17 -0
  98. data/registry/icons/lucide/ellipsis-vertical.svg +17 -0
  99. data/registry/icons/lucide/ellipsis.svg +17 -0
  100. data/registry/icons/lucide/eye-off.svg +18 -0
  101. data/registry/icons/lucide/eye.svg +16 -0
  102. data/registry/icons/lucide/file-plus.svg +18 -0
  103. data/registry/icons/lucide/file-text.svg +19 -0
  104. data/registry/icons/lucide/file.svg +16 -0
  105. data/registry/icons/lucide/folder-kanban.svg +18 -0
  106. data/registry/icons/lucide/folder.svg +15 -0
  107. data/registry/icons/lucide/git-branch.svg +18 -0
  108. data/registry/icons/lucide/globe.svg +17 -0
  109. data/registry/icons/lucide/graduation-cap.svg +17 -0
  110. data/registry/icons/lucide/grip-vertical.svg +20 -0
  111. data/registry/icons/lucide/home.svg +16 -0
  112. data/registry/icons/lucide/inbox.svg +16 -0
  113. data/registry/icons/lucide/info.svg +17 -0
  114. data/registry/icons/lucide/italic.svg +17 -0
  115. data/registry/icons/lucide/keyboard.svg +23 -0
  116. data/registry/icons/lucide/layout-dashboard.svg +18 -0
  117. data/registry/icons/lucide/layout-grid.svg +18 -0
  118. data/registry/icons/lucide/life-buoy.svg +20 -0
  119. data/registry/icons/lucide/list.svg +20 -0
  120. data/registry/icons/lucide/loader.svg +22 -0
  121. data/registry/icons/lucide/lock.svg +16 -0
  122. data/registry/icons/lucide/log-out.svg +17 -0
  123. data/registry/icons/lucide/mail.svg +16 -0
  124. data/registry/icons/lucide/menu.svg +17 -0
  125. data/registry/icons/lucide/message-circle.svg +15 -0
  126. data/registry/icons/lucide/minus.svg +15 -0
  127. data/registry/icons/lucide/monitor.svg +17 -0
  128. data/registry/icons/lucide/moon.svg +15 -0
  129. data/registry/icons/lucide/newspaper.svg +18 -0
  130. data/registry/icons/lucide/package.svg +18 -0
  131. data/registry/icons/lucide/panel-left.svg +16 -0
  132. data/registry/icons/lucide/pause.svg +16 -0
  133. data/registry/icons/lucide/percent.svg +17 -0
  134. data/registry/icons/lucide/plus.svg +16 -0
  135. data/registry/icons/lucide/printer.svg +17 -0
  136. data/registry/icons/lucide/qr-code.svg +26 -0
  137. data/registry/icons/lucide/receipt.svg +17 -0
  138. data/registry/icons/lucide/rocket.svg +18 -0
  139. data/registry/icons/lucide/rotate-cw.svg +16 -0
  140. data/registry/icons/lucide/search.svg +16 -0
  141. data/registry/icons/lucide/settings.svg +16 -0
  142. data/registry/icons/lucide/shield-check.svg +16 -0
  143. data/registry/icons/lucide/shield.svg +15 -0
  144. data/registry/icons/lucide/store.svg +17 -0
  145. data/registry/icons/lucide/sun-moon.svg +19 -0
  146. data/registry/icons/lucide/sun.svg +23 -0
  147. data/registry/icons/lucide/trash-2.svg +19 -0
  148. data/registry/icons/lucide/truck.svg +19 -0
  149. data/registry/icons/lucide/underline.svg +16 -0
  150. data/registry/icons/lucide/upload.svg +17 -0
  151. data/registry/icons/lucide/user-plus.svg +18 -0
  152. data/registry/icons/lucide/user.svg +16 -0
  153. data/registry/icons/lucide/users.svg +18 -0
  154. data/registry/icons/lucide/workflow.svg +17 -0
  155. data/registry/icons/lucide/x.svg +16 -0
  156. data/registry/icons/lucide/zoom-in.svg +18 -0
  157. data/registry/icons/lucide/zoom-out.svg +17 -0
  158. data/registry/icons/phosphor/LICENSE +21 -0
  159. data/registry/icons/phosphor/arrow-clockwise.svg +2 -0
  160. data/registry/icons/phosphor/arrow-left.svg +2 -0
  161. data/registry/icons/phosphor/arrow-right.svg +2 -0
  162. data/registry/icons/phosphor/bell.svg +2 -0
  163. data/registry/icons/phosphor/book-open.svg +2 -0
  164. data/registry/icons/phosphor/calendar-blank.svg +2 -0
  165. data/registry/icons/phosphor/caret-down.svg +2 -0
  166. data/registry/icons/phosphor/caret-left.svg +2 -0
  167. data/registry/icons/phosphor/caret-right.svg +2 -0
  168. data/registry/icons/phosphor/caret-up-down.svg +2 -0
  169. data/registry/icons/phosphor/chart-bar.svg +2 -0
  170. data/registry/icons/phosphor/chat-circle.svg +2 -0
  171. data/registry/icons/phosphor/check-circle.svg +2 -0
  172. data/registry/icons/phosphor/check.svg +2 -0
  173. data/registry/icons/phosphor/circle-half.svg +2 -0
  174. data/registry/icons/phosphor/cloud.svg +2 -0
  175. data/registry/icons/phosphor/credit-card.svg +2 -0
  176. data/registry/icons/phosphor/desktop.svg +2 -0
  177. data/registry/icons/phosphor/dots-six-vertical.svg +2 -0
  178. data/registry/icons/phosphor/dots-three-vertical.svg +2 -0
  179. data/registry/icons/phosphor/dots-three.svg +2 -0
  180. data/registry/icons/phosphor/download-simple.svg +2 -0
  181. data/registry/icons/phosphor/envelope.svg +2 -0
  182. data/registry/icons/phosphor/eye-slash.svg +2 -0
  183. data/registry/icons/phosphor/eye.svg +2 -0
  184. data/registry/icons/phosphor/file-plus.svg +2 -0
  185. data/registry/icons/phosphor/file-text.svg +2 -0
  186. data/registry/icons/phosphor/file.svg +2 -0
  187. data/registry/icons/phosphor/flow-arrow.svg +2 -0
  188. data/registry/icons/phosphor/folder.svg +2 -0
  189. data/registry/icons/phosphor/gear.svg +2 -0
  190. data/registry/icons/phosphor/git-branch.svg +2 -0
  191. data/registry/icons/phosphor/globe.svg +2 -0
  192. data/registry/icons/phosphor/graduation-cap.svg +2 -0
  193. data/registry/icons/phosphor/grid-four.svg +2 -0
  194. data/registry/icons/phosphor/house.svg +2 -0
  195. data/registry/icons/phosphor/info.svg +2 -0
  196. data/registry/icons/phosphor/kanban.svg +2 -0
  197. data/registry/icons/phosphor/keyboard.svg +2 -0
  198. data/registry/icons/phosphor/lifebuoy.svg +2 -0
  199. data/registry/icons/phosphor/list.svg +2 -0
  200. data/registry/icons/phosphor/lock.svg +2 -0
  201. data/registry/icons/phosphor/magnifying-glass-minus.svg +2 -0
  202. data/registry/icons/phosphor/magnifying-glass-plus.svg +2 -0
  203. data/registry/icons/phosphor/magnifying-glass.svg +2 -0
  204. data/registry/icons/phosphor/minus.svg +2 -0
  205. data/registry/icons/phosphor/moon.svg +2 -0
  206. data/registry/icons/phosphor/newspaper.svg +2 -0
  207. data/registry/icons/phosphor/package.svg +2 -0
  208. data/registry/icons/phosphor/pause.svg +2 -0
  209. data/registry/icons/phosphor/percent.svg +2 -0
  210. data/registry/icons/phosphor/plus.svg +2 -0
  211. data/registry/icons/phosphor/printer.svg +2 -0
  212. data/registry/icons/phosphor/qr-code.svg +2 -0
  213. data/registry/icons/phosphor/receipt.svg +2 -0
  214. data/registry/icons/phosphor/rocket.svg +2 -0
  215. data/registry/icons/phosphor/seal-check.svg +2 -0
  216. data/registry/icons/phosphor/shield-check.svg +2 -0
  217. data/registry/icons/phosphor/shield.svg +2 -0
  218. data/registry/icons/phosphor/sidebar.svg +2 -0
  219. data/registry/icons/phosphor/sign-out.svg +2 -0
  220. data/registry/icons/phosphor/spinner.svg +2 -0
  221. data/registry/icons/phosphor/squares-four.svg +2 -0
  222. data/registry/icons/phosphor/storefront.svg +2 -0
  223. data/registry/icons/phosphor/sun.svg +2 -0
  224. data/registry/icons/phosphor/text-align-center.svg +2 -0
  225. data/registry/icons/phosphor/text-align-left.svg +2 -0
  226. data/registry/icons/phosphor/text-align-right.svg +2 -0
  227. data/registry/icons/phosphor/text-b.svg +2 -0
  228. data/registry/icons/phosphor/text-italic.svg +2 -0
  229. data/registry/icons/phosphor/text-underline.svg +2 -0
  230. data/registry/icons/phosphor/trash.svg +2 -0
  231. data/registry/icons/phosphor/tray.svg +2 -0
  232. data/registry/icons/phosphor/truck.svg +2 -0
  233. data/registry/icons/phosphor/upload-simple.svg +2 -0
  234. data/registry/icons/phosphor/user-plus.svg +2 -0
  235. data/registry/icons/phosphor/user.svg +2 -0
  236. data/registry/icons/phosphor/users.svg +2 -0
  237. data/registry/icons/phosphor/warning-circle.svg +2 -0
  238. data/registry/icons/phosphor/x.svg +2 -0
  239. data/registry/icons/tabler/LICENSE +21 -0
  240. data/registry/icons/tabler/alert-circle.svg +18 -0
  241. data/registry/icons/tabler/align-center.svg +18 -0
  242. data/registry/icons/tabler/align-left.svg +18 -0
  243. data/registry/icons/tabler/align-right.svg +18 -0
  244. data/registry/icons/tabler/arrow-left.svg +18 -0
  245. data/registry/icons/tabler/arrow-right.svg +18 -0
  246. data/registry/icons/tabler/bell.svg +17 -0
  247. data/registry/icons/tabler/bold.svg +17 -0
  248. data/registry/icons/tabler/book.svg +20 -0
  249. data/registry/icons/tabler/building-store.svg +20 -0
  250. data/registry/icons/tabler/calendar.svg +21 -0
  251. data/registry/icons/tabler/chart-bar.svg +19 -0
  252. data/registry/icons/tabler/check.svg +16 -0
  253. data/registry/icons/tabler/chevron-down.svg +16 -0
  254. data/registry/icons/tabler/chevron-left.svg +16 -0
  255. data/registry/icons/tabler/chevron-right.svg +16 -0
  256. data/registry/icons/tabler/circle-check.svg +17 -0
  257. data/registry/icons/tabler/cloud.svg +16 -0
  258. data/registry/icons/tabler/credit-card.svg +19 -0
  259. data/registry/icons/tabler/device-desktop.svg +19 -0
  260. data/registry/icons/tabler/dots-vertical.svg +18 -0
  261. data/registry/icons/tabler/dots.svg +18 -0
  262. data/registry/icons/tabler/download.svg +18 -0
  263. data/registry/icons/tabler/eye-off.svg +18 -0
  264. data/registry/icons/tabler/eye.svg +17 -0
  265. data/registry/icons/tabler/file-plus.svg +19 -0
  266. data/registry/icons/tabler/file-text.svg +20 -0
  267. data/registry/icons/tabler/file.svg +17 -0
  268. data/registry/icons/tabler/folder.svg +16 -0
  269. data/registry/icons/tabler/git-branch.svg +21 -0
  270. data/registry/icons/tabler/grip-vertical.svg +21 -0
  271. data/registry/icons/tabler/home.svg +18 -0
  272. data/registry/icons/tabler/inbox.svg +17 -0
  273. data/registry/icons/tabler/info-circle.svg +18 -0
  274. data/registry/icons/tabler/italic.svg +18 -0
  275. data/registry/icons/tabler/keyboard.svg +23 -0
  276. data/registry/icons/tabler/layout-dashboard.svg +19 -0
  277. data/registry/icons/tabler/layout-grid.svg +19 -0
  278. data/registry/icons/tabler/layout-kanban.svg +19 -0
  279. data/registry/icons/tabler/layout-sidebar.svg +17 -0
  280. data/registry/icons/tabler/lifebuoy.svg +21 -0
  281. data/registry/icons/tabler/list.svg +21 -0
  282. data/registry/icons/tabler/loader.svg +23 -0
  283. data/registry/icons/tabler/lock.svg +18 -0
  284. data/registry/icons/tabler/logout.svg +18 -0
  285. data/registry/icons/tabler/mail.svg +17 -0
  286. data/registry/icons/tabler/menu-2.svg +18 -0
  287. data/registry/icons/tabler/message-circle.svg +16 -0
  288. data/registry/icons/tabler/minus.svg +16 -0
  289. data/registry/icons/tabler/moon.svg +16 -0
  290. data/registry/icons/tabler/news.svg +19 -0
  291. data/registry/icons/tabler/package.svg +20 -0
  292. data/registry/icons/tabler/percentage.svg +18 -0
  293. data/registry/icons/tabler/player-pause.svg +17 -0
  294. data/registry/icons/tabler/plus.svg +17 -0
  295. data/registry/icons/tabler/printer.svg +18 -0
  296. data/registry/icons/tabler/qrcode.svg +27 -0
  297. data/registry/icons/tabler/receipt.svg +16 -0
  298. data/registry/icons/tabler/rocket.svg +18 -0
  299. data/registry/icons/tabler/rosette-discount-check.svg +17 -0
  300. data/registry/icons/tabler/rotate-clockwise.svg +16 -0
  301. data/registry/icons/tabler/school.svg +17 -0
  302. data/registry/icons/tabler/search.svg +17 -0
  303. data/registry/icons/tabler/selector.svg +17 -0
  304. data/registry/icons/tabler/settings.svg +17 -0
  305. data/registry/icons/tabler/shield-check.svg +17 -0
  306. data/registry/icons/tabler/shield.svg +16 -0
  307. data/registry/icons/tabler/sitemap.svg +20 -0
  308. data/registry/icons/tabler/sun-moon.svg +21 -0
  309. data/registry/icons/tabler/sun.svg +17 -0
  310. data/registry/icons/tabler/trash.svg +20 -0
  311. data/registry/icons/tabler/truck.svg +18 -0
  312. data/registry/icons/tabler/underline.svg +17 -0
  313. data/registry/icons/tabler/upload.svg +18 -0
  314. data/registry/icons/tabler/user-plus.svg +19 -0
  315. data/registry/icons/tabler/user.svg +17 -0
  316. data/registry/icons/tabler/users.svg +19 -0
  317. data/registry/icons/tabler/world.svg +20 -0
  318. data/registry/icons/tabler/x.svg +17 -0
  319. data/registry/icons/tabler/zoom-in.svg +19 -0
  320. data/registry/icons/tabler/zoom-out.svg +18 -0
  321. data/registry/icons.yml +90 -0
  322. data/registry/test/components/previews/ui/chart_preview/cash_flow.html.erb +6 -0
  323. data/registry/test/components/previews/ui/chart_preview/donut.html.erb +6 -0
  324. data/registry/test/components/previews/ui/chart_preview/margin.html.erb +6 -0
  325. data/registry/test/components/previews/ui/chart_preview/pie.html.erb +6 -0
  326. data/registry/test/components/previews/ui/chart_preview/sales.html.erb +6 -0
  327. data/registry/test/components/previews/ui/chart_preview/stock.html.erb +6 -0
  328. data/registry/test/components/previews/ui/chart_preview/takings.html.erb +8 -0
  329. data/registry/test/components/previews/ui/chart_preview.rb +46 -0
  330. data/registry/test/components/previews/ui/command_preview/_picked.html.erb +14 -0
  331. data/registry/test/components/previews/ui/command_preview/dialog.html.erb +24 -0
  332. data/registry/test/components/previews/ui/command_preview/inline.html.erb +16 -0
  333. data/registry/test/components/previews/ui/command_preview/playground.html.erb +15 -0
  334. data/registry/test/components/previews/ui/command_preview/server_search.html.erb +24 -0
  335. data/registry/test/components/previews/ui/command_preview/shortcuts.html.erb +12 -0
  336. data/registry/test/components/previews/ui/command_preview/till.html.erb +17 -0
  337. data/registry/test/components/previews/ui/command_preview.rb +25 -0
  338. data/registry/test/components/previews/ui/confirm_dialog_preview/destructive.html.erb +7 -0
  339. data/registry/test/components/previews/ui/confirm_dialog_preview/in_form.html.erb +6 -0
  340. data/registry/test/components/previews/ui/confirm_dialog_preview/on_link.html.erb +5 -0
  341. data/registry/test/components/previews/ui/confirm_dialog_preview/plain.html.erb +3 -0
  342. data/registry/test/components/previews/ui/confirm_dialog_preview/with_description.html.erb +4 -0
  343. data/registry/test/components/previews/ui/confirm_dialog_preview.rb +20 -0
  344. data/registry/test/components/previews/ui/date_picker_preview/custom_presets.html.erb +6 -0
  345. data/registry/test/components/previews/ui/date_picker_preview/in_form.html.erb +11 -0
  346. data/registry/test/components/previews/ui/date_picker_preview/range.html.erb +5 -0
  347. data/registry/test/components/previews/ui/date_picker_preview/states.html.erb +4 -3
  348. data/registry/test/components/previews/ui/date_picker_preview.rb +26 -6
  349. data/registry/test/components/previews/ui/empty_state_preview/in_card.html.erb +7 -0
  350. data/registry/test/components/previews/ui/empty_state_preview/no_results.html.erb +3 -0
  351. data/registry/test/components/previews/ui/empty_state_preview/outline.html.erb +3 -0
  352. data/registry/test/components/previews/ui/empty_state_preview/with_actions.html.erb +4 -0
  353. data/registry/test/components/previews/ui/empty_state_preview/with_media.html.erb +8 -0
  354. data/registry/test/components/previews/ui/empty_state_preview.rb +26 -0
  355. data/registry/test/components/previews/ui/file_field_preview/multiple_files.html.erb +1 -1
  356. data/registry/test/components/previews/ui/file_field_preview/product_photos.html.erb +12 -0
  357. data/registry/test/components/previews/ui/file_field_preview/single_image.html.erb +4 -0
  358. data/registry/test/components/previews/ui/file_field_preview.rb +32 -5
  359. data/registry/test/components/previews/ui/gallery_preview/hover_zoom.html.erb +13 -0
  360. data/registry/test/components/previews/ui/gallery_preview/landscape.html.erb +5 -0
  361. data/registry/test/components/previews/ui/gallery_preview/product_page.html.erb +13 -0
  362. data/registry/test/components/previews/ui/gallery_preview/single.html.erb +3 -0
  363. data/registry/test/components/previews/ui/gallery_preview.rb +45 -0
  364. data/registry/test/components/previews/ui/icon_preview/common.html.erb +19 -3
  365. data/registry/test/components/previews/ui/icon_preview/labelled.html.erb +4 -0
  366. data/registry/test/components/previews/ui/icon_preview/missing.html.erb +3 -0
  367. data/registry/test/components/previews/ui/icon_preview.rb +18 -3
  368. data/registry/test/components/previews/ui/input_group_preview/playground.html.erb +2 -2
  369. data/registry/test/components/previews/ui/input_group_preview.rb +3 -3
  370. data/registry/test/components/previews/ui/kbd_preview/bound.html.erb +20 -0
  371. data/registry/test/components/previews/ui/kbd_preview/keys.html.erb +13 -0
  372. data/registry/test/components/previews/ui/kbd_preview/menu.html.erb +13 -0
  373. data/registry/test/components/previews/ui/kbd_preview/search_field.html.erb +8 -0
  374. data/registry/test/components/previews/ui/kbd_preview/shortcuts_list.html.erb +17 -0
  375. data/registry/test/components/previews/ui/kbd_preview/till.html.erb +23 -0
  376. data/registry/test/components/previews/ui/kbd_preview/tooltip_and_buttons.html.erb +14 -0
  377. data/registry/test/components/previews/ui/kbd_preview.rb +32 -0
  378. data/registry/test/components/previews/ui/number_input_preview/cart.html.erb +11 -0
  379. data/registry/test/components/previews/ui/number_input_preview/decimals.html.erb +4 -0
  380. data/registry/test/components/previews/ui/number_input_preview/sizes.html.erb +5 -0
  381. data/registry/test/components/previews/ui/number_input_preview/states.html.erb +7 -0
  382. data/registry/test/components/previews/ui/number_input_preview/stock_adjustment.html.erb +3 -0
  383. data/registry/test/components/previews/ui/number_input_preview.rb +36 -0
  384. data/registry/test/components/previews/ui/progress_preview/file_upload.html.erb +36 -0
  385. data/registry/test/components/previews/ui/progress_preview/free_shipping.html.erb +4 -0
  386. data/registry/test/components/previews/ui/progress_preview/indeterminate.html.erb +4 -0
  387. data/registry/test/components/previews/ui/progress_preview/sizes_and_tones.html.erb +8 -0
  388. data/registry/test/components/previews/ui/progress_preview/steps.html.erb +9 -0
  389. data/registry/test/components/previews/ui/progress_preview/storage.html.erb +8 -0
  390. data/registry/test/components/previews/ui/progress_preview/storage_by_category.html.erb +7 -0
  391. data/registry/test/components/previews/ui/progress_preview/tasks_by_status.html.erb +14 -0
  392. data/registry/test/components/previews/ui/progress_preview/traffic_by_source.html.erb +15 -0
  393. data/registry/test/components/previews/ui/progress_preview.rb +46 -0
  394. data/registry/test/components/previews/ui/select_preview/server_search.html.erb +22 -0
  395. data/registry/test/components/previews/ui/select_preview.rb +5 -0
  396. data/registry/test/components/previews/ui/stepper_preview/approvals.html.erb +9 -0
  397. data/registry/test/components/previews/ui/stepper_preview/checklist.html.erb +12 -0
  398. data/registry/test/components/previews/ui/stepper_preview/dot_wizard.html.erb +41 -0
  399. data/registry/test/components/previews/ui/stepper_preview/failed_deploy.html.erb +13 -0
  400. data/registry/test/components/previews/ui/stepper_preview/inline.html.erb +31 -0
  401. data/registry/test/components/previews/ui/stepper_preview/onboarding.html.erb +12 -0
  402. data/registry/test/components/previews/ui/stepper_preview/order_tracking.html.erb +10 -0
  403. data/registry/test/components/previews/ui/stepper_preview/price_calculator.html.erb +14 -0
  404. data/registry/test/components/previews/ui/stepper_preview/server_driven.html.erb +20 -0
  405. data/registry/test/components/previews/ui/stepper_preview/sidebar.html.erb +43 -0
  406. data/registry/test/components/previews/ui/stepper_preview/wizard.html.erb +55 -0
  407. data/registry/test/components/previews/ui/stepper_preview.rb +57 -0
  408. data/registry/test/components/previews/ui/timeline_preview/activity_log.html.erb +7 -0
  409. data/registry/test/components/previews/ui/timeline_preview/colored.html.erb +7 -0
  410. data/registry/test/components/previews/ui/timeline_preview/colored_by_meaning.html.erb +7 -0
  411. data/registry/test/components/previews/ui/timeline_preview/failed_delivery.html.erb +6 -0
  412. data/registry/test/components/previews/ui/timeline_preview/order_status.html.erb +9 -0
  413. data/registry/test/components/previews/ui/timeline_preview/real_dates.html.erb +5 -0
  414. data/registry/test/components/previews/ui/timeline_preview/stock_history.html.erb +6 -0
  415. data/registry/test/components/previews/ui/timeline_preview.rb +40 -0
  416. data/registry/test/components/previews/ui/toggle_group_preview/icon_only.html.erb +5 -0
  417. data/registry/test/components/previews/ui/toggle_group_preview/in_form.html.erb +11 -0
  418. data/registry/test/components/previews/ui/toggle_group_preview/multiple.html.erb +5 -0
  419. data/registry/test/components/previews/ui/toggle_group_preview/outline.html.erb +5 -0
  420. data/registry/test/components/previews/ui/toggle_group_preview/sizes.html.erb +9 -0
  421. data/registry/test/components/previews/ui/toggle_group_preview/with_icons.html.erb +5 -0
  422. data/registry/test/components/previews/ui/toggle_group_preview.rb +36 -0
  423. data/registry/test/components/ui/accordion/trigger_test.rb +1 -1
  424. data/registry/test/components/ui/alert_test.rb +10 -10
  425. data/registry/test/components/ui/badge_test.rb +3 -3
  426. data/registry/test/components/ui/banner_test.rb +3 -3
  427. data/registry/test/components/ui/breadcrumb/ellipsis_test.rb +2 -2
  428. data/registry/test/components/ui/button_test.rb +17 -14
  429. data/registry/test/components/ui/button_to_test.rb +2 -2
  430. data/registry/test/components/ui/chart_test.rb +187 -0
  431. data/registry/test/components/ui/checkbox_test.rb +2 -2
  432. data/registry/test/components/ui/command/group_test.rb +19 -0
  433. data/registry/test/components/ui/command/item_test.rb +47 -0
  434. data/registry/test/components/ui/command_test.rb +110 -0
  435. data/registry/test/components/ui/confirm_dialog_test.rb +68 -0
  436. data/registry/test/components/ui/date_picker_test.rb +129 -111
  437. data/registry/test/components/ui/empty_state_test.rb +87 -0
  438. data/registry/test/components/ui/file_field_test.rb +105 -9
  439. data/registry/test/components/ui/gallery_test.rb +192 -0
  440. data/registry/test/components/ui/icon_test.rb +60 -20
  441. data/registry/test/components/ui/input_group_test.rb +1 -1
  442. data/registry/test/components/ui/kbd_test.rb +150 -0
  443. data/registry/test/components/ui/link_test.rb +3 -3
  444. data/registry/test/components/ui/navigation_menu_test.rb +2 -2
  445. data/registry/test/components/ui/number_input_test.rb +155 -0
  446. data/registry/test/components/ui/progress_test.rb +188 -0
  447. data/registry/test/components/ui/select_test.rb +62 -0
  448. data/registry/test/components/ui/session_tabs_test.rb +3 -3
  449. data/registry/test/components/ui/spinner_test.rb +9 -9
  450. data/registry/test/components/ui/stepper_test.rb +239 -0
  451. data/registry/test/components/ui/tabs/trigger_test.rb +2 -2
  452. data/registry/test/components/ui/theme_toggle_test.rb +6 -8
  453. data/registry/test/components/ui/timeline_test.rb +175 -0
  454. data/registry/test/components/ui/toast_test.rb +11 -10
  455. data/registry/test/components/ui/toggle_group_test.rb +162 -0
  456. metadata +399 -3
  457. data/registry/app/javascript/cally.ts +0 -8
  458. data/registry/app/javascript/velvetkit_icons.ts +0 -78
@@ -0,0 +1,12 @@
1
+ <%# Each photo uploads as soon as it's chosen, with a progress bar, and the form
2
+ sends only the uploaded photos' ids. Saving while a photo is still on its
3
+ way waits for it, then saves. The two already on the product show as tiles;
4
+ take one out and save, and it's gone. Bound to a form, those come from the
5
+ record: render(UI::FileField.new(form: f, field: :photos, ...)). %>
6
+ <form action="/demo/products/1" method="post" class="flex max-w-xl flex-col items-start gap-4">
7
+ <input type="hidden" name="_method" value="patch">
8
+ <%= render(UI::FileField.new(name: "product[photos][]", label: "Photos", hint: "PNG or JPG, up to 5 MB each",
9
+ multiple: true, accept: "image/*", max_size: 5.megabytes, direct_upload: true,
10
+ existing: UI::FileFieldPreview.kept_photos)) %>
11
+ <%= render(UI::Button.new(type: :submit)) { "Save product" } %>
12
+ </form>
@@ -0,0 +1,4 @@
1
+ <%# One file: choosing another replaces it. Without direct_upload the file goes with the form. %>
2
+ <div class="max-w-xs">
3
+ <%= render(UI::FileField.new(name: "store[logo]", label: "Store logo", hint: "Square works best", accept: "image/*")) %>
4
+ </div>
@@ -1,18 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UI::FileFieldPreview < ViewComponent::Preview
4
+ # A stand-in for an Active Storage attachment: what UI::FileField reads to
5
+ # show a file the record already has.
6
+ KeptFile = Struct.new(:signed_id, :filename, :byte_size, :content_type, :url, keyword_init: true)
7
+
8
+ def self.photo(title, color)
9
+ svg = "<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><rect width='100%' height='100%' fill='#{color}'/>" \
10
+ "<text x='50%' y='50%' dy='.35em' text-anchor='middle' font-family='sans-serif' font-size='64' fill='#fff'>#{title}</text></svg>"
11
+ "data:image/svg+xml,#{ERB::Util.url_encode(svg)}"
12
+ end
13
+
14
+ def self.kept_photos
15
+ [ [ "Front", "#793cbb" ], [ "Side", "#1baf7a" ] ].map.with_index do |(title, color), index|
16
+ KeptFile.new(signed_id: "kept-#{index}", filename: "mug-#{title.downcase}.svg", byte_size: 182_000 + (index * 41_000),
17
+ content_type: "image/svg+xml", url: photo(title, color))
18
+ end
19
+ end
20
+
4
21
  # @label Playground
5
22
  # @param label text
6
23
  # @param hint text
7
24
  # @param multiple toggle
25
+ # @param preview toggle
26
+ # @param direct_upload toggle
8
27
  # @param disabled toggle
9
- def playground(label: "Avatar", hint: "PNG or JPG, up to 5MB", multiple: false, disabled: false)
10
- render(UI::FileField.new(label: label, hint: hint, multiple: multiple, disabled: disabled))
28
+ def playground(label: "Photos", hint: "PNG or JPG, up to 5 MB", multiple: true, preview: true, direct_upload: false,
29
+ disabled: false)
30
+ render(UI::FileField.new(label: label, hint: hint, multiple: multiple, preview: preview, direct_upload: direct_upload,
31
+ disabled: disabled, accept: "image/*", max_size: 5.megabytes, name: "photos"))
11
32
  end
12
33
 
13
- # @label With Error
14
- def with_error; render_with_template; end
34
+ # @label Product Photos, Uploaded Straight Away
35
+ def product_photos; render_with_template; end
36
+
37
+ # @label One Image
38
+ def single_image; render_with_template; end
15
39
 
16
- # @label Multiple Files
40
+ # @label Names Only, No Previews
17
41
  def multiple_files; render_with_template; end
42
+
43
+ # @label With Error
44
+ def with_error; render_with_template; end
18
45
  end
@@ -0,0 +1,13 @@
1
+ <div class="grid max-w-3xl gap-8 sm:grid-cols-2">
2
+ <%= render(UI::Gallery.new(label: "Photos of the ceramic mug", zoom: :hover)) do |gallery| %>
3
+ <% UI::GalleryPreview.photos.each do |title, src| %>
4
+ <% gallery.with_image(src: src, alt: "Ceramic mug: #{title}") %>
5
+ <% end %>
6
+ <% end %>
7
+ <div class="space-y-3">
8
+ <h2 class="text-xl font-semibold">Ceramic mug</h2>
9
+ <p class="text-lg">$14.00</p>
10
+ <p class="text-sm text-muted-foreground">Hand-glazed stoneware that holds 350 ml. Move your mouse over the photo to magnify it, or click to open the overlay.</p>
11
+ <%= render(UI::Button.new) { "Add to cart" } %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,5 @@
1
+ <%= render(UI::Gallery.new(label: "Photos of the workshop", aspect: :landscape, fit: :cover, class: "max-w-xl")) do |gallery| %>
2
+ <% UI::GalleryPreview::PHOTOS.first(3).each do |title, color, background| %>
3
+ <% gallery.with_image(src: UI::GalleryPreview.photo(title, color, background, width: 1600, height: 1000), alt: "Workshop: #{title}") %>
4
+ <% end %>
5
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <div class="grid max-w-3xl gap-8 sm:grid-cols-2">
2
+ <%= render(UI::Gallery.new(label: "Photos of the ceramic mug")) do |gallery| %>
3
+ <% UI::GalleryPreview.photos.each do |title, src| %>
4
+ <% gallery.with_image(src: src, alt: "Ceramic mug: #{title}") %>
5
+ <% end %>
6
+ <% end %>
7
+ <div class="space-y-3">
8
+ <h2 class="text-xl font-semibold">Ceramic mug</h2>
9
+ <p class="text-lg">$14.00</p>
10
+ <p class="text-sm text-muted-foreground">Hand-glazed stoneware that holds 350 ml. Click the photo to see it over the page and zoom in.</p>
11
+ <%= render(UI::Button.new) { "Add to cart" } %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,3 @@
1
+ <%= render(UI::Gallery.new(label: "Photo of the ceramic mug", class: "max-w-sm")) do |gallery| %>
2
+ <% gallery.with_image(src: UI::GalleryPreview.photos.first.last, alt: "Ceramic mug: Front") %>
3
+ <% end %>
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UI::GalleryPreview < ViewComponent::Preview
4
+ # Drawn here so the previews need no image files. The fine grid shows off zoom.
5
+ PHOTOS = [ [ "Front", "#7c3aed", "#ede9fe" ], [ "Side", "#0f766e", "#ccfbf1" ], [ "Handle", "#b45309", "#fef3c7" ],
6
+ [ "Base", "#be123c", "#ffe4e6" ], [ "In use", "#1d4ed8", "#dbeafe" ] ].freeze
7
+
8
+ def self.photo(title, color, background, width: 1600, height: 1600)
9
+ grid = (0..(width / 40)).map { |i| "<path d='M#{i * 40} 0V#{height}' stroke='#{color}' stroke-opacity='.15'/>" }.join +
10
+ (0..(height / 40)).map { |i| "<path d='M0 #{i * 40}H#{width}' stroke='#{color}' stroke-opacity='.15'/>" }.join
11
+ svg = "<svg xmlns='http://www.w3.org/2000/svg' width='#{width}' height='#{height}'>" \
12
+ "<rect width='100%' height='100%' fill='#{background}'/>#{grid}" \
13
+ "<circle cx='#{width / 2}' cy='#{height / 2}' r='#{[ width, height ].min / 4}' fill='#{color}'/>" \
14
+ "<text x='50%' y='50%' dy='.35em' text-anchor='middle' font-family='sans-serif' " \
15
+ "font-size='#{[ width, height ].min / 14}' fill='#fff'>#{title}</text></svg>"
16
+ "data:image/svg+xml,#{ERB::Util.url_encode(svg)}"
17
+ end
18
+
19
+ def self.photos = PHOTOS.map { |title, color, background| [ title, photo(title, color, background) ] }
20
+
21
+ # @label Playground
22
+ # @param zoom select { choices: [overlay, hover] }
23
+ # @param zoom_scale number { min: 1.5, max: 5, step: 0.5 }
24
+ # @param aspect select { choices: [square, landscape, portrait] }
25
+ # @param fit select { choices: [contain, cover] }
26
+ # @param count number { min: 1, max: 5 }
27
+ def playground(zoom: :overlay, zoom_scale: 2.5, aspect: :square, fit: :contain, count: 5)
28
+ render(UI::Gallery.new(label: "Photos of the ceramic mug", zoom: zoom.to_sym, zoom_scale: zoom_scale.to_f,
29
+ aspect: aspect.to_sym, fit: fit.to_sym, class: "max-w-md")) do |gallery|
30
+ self.class.photos.first(count.to_i).each { |title, src| gallery.with_image(src: src, alt: "Ceramic mug: #{title}") }
31
+ end
32
+ end
33
+
34
+ # @label Overlay
35
+ def product_page; render_with_template; end
36
+
37
+ # @label Hover Zoom
38
+ def hover_zoom; render_with_template; end
39
+
40
+ # @label Landscape, Cropped to Fill
41
+ def landscape; render_with_template; end
42
+
43
+ # @label One Image
44
+ def single; render_with_template; end
45
+ end
@@ -1,8 +1,24 @@
1
1
  <div class="grid grid-cols-6 gap-4">
2
- <% %w[menu arrow-right globe badge-check circle-alert x circle-check eye eye-off lock chevrons-up-down layout-dashboard panel-left user loader].each do |name| %>
2
+ <% [
3
+ UI::Icon.new(name: "menu"),
4
+ UI::Icon.new(name: "arrow-right"),
5
+ UI::Icon.new(name: "globe"),
6
+ UI::Icon.new(name: "badge-check"),
7
+ UI::Icon.new(name: "circle-alert"),
8
+ UI::Icon.new(name: "x"),
9
+ UI::Icon.new(name: "circle-check"),
10
+ UI::Icon.new(name: "eye"),
11
+ UI::Icon.new(name: "eye-off"),
12
+ UI::Icon.new(name: "lock"),
13
+ UI::Icon.new(name: "chevrons-up-down"),
14
+ UI::Icon.new(name: "layout-dashboard"),
15
+ UI::Icon.new(name: "panel-left"),
16
+ UI::Icon.new(name: "user"),
17
+ UI::Icon.new(name: "loader"),
18
+ ].each do |icon| %>
3
19
  <div class="flex flex-col items-center gap-1 p-2 border rounded-md">
4
- <%= render(UI::Icon.new(name: name)) %>
5
- <span class="text-xs text-muted-foreground"><%= name %></span>
20
+ <%= render(icon) %>
21
+ <span class="text-xs text-muted-foreground"><%= icon.name %></span>
6
22
  </div>
7
23
  <% end %>
8
24
  </div>
@@ -0,0 +1,4 @@
1
+ <div class="flex items-center gap-6 text-sm">
2
+ <%= render(UI::Icon.new(name: "circle-alert", label: "Warning", class: "text-destructive")) %>
3
+ <span class="inline-flex items-center gap-2"><%= render(UI::Icon.new(name: "mail", size: :sm)) %> Email us</span>
4
+ </div>
@@ -0,0 +1,3 @@
1
+ <%# No app/assets/icons/not-installed-yet.svg, so this draws a dashed square %>
2
+ <% name = "not-installed-yet" %>
3
+ <%= render(UI::Icon.new(name: name)) %>
@@ -2,10 +2,10 @@
2
2
 
3
3
  class UI::IconPreview < ViewComponent::Preview
4
4
  # @label Playground
5
- # @param name text "Lucide icon name (must be registered in app/javascript/lucide-icon.ts)"
5
+ # @param icon text "An SVG in app/assets/icons, without .svg"
6
6
  # @param size select { choices: [xs, sm, default, lg, xl] }
7
- def playground(name: "menu", size: :default)
8
- render(UI::Icon.new(name: name, size: size.to_sym))
7
+ def playground(icon: "menu", size: :default)
8
+ render(UI::Icon.new(name: icon, size: size.to_sym))
9
9
  end
10
10
 
11
11
  # @label All Sizes
@@ -17,4 +17,19 @@ class UI::IconPreview < ViewComponent::Preview
17
17
  def common
18
18
  render_with_template
19
19
  end
20
+
21
+ # A label makes the icon an image with that accessible name. Without one
22
+ # it is decorative and hidden from screen readers, which is right next to
23
+ # text that already says the same thing.
24
+ # @label With a Label
25
+ def labelled
26
+ render_with_template
27
+ end
28
+
29
+ # An icon with no SVG in app/assets/icons draws this dashed square, and
30
+ # the log names the file. Add it with `bin/rails generate velvetkit:icons`.
31
+ # @label Missing Icon
32
+ def missing
33
+ render_with_template
34
+ end
20
35
  end
@@ -2,11 +2,11 @@
2
2
  <div class="max-w-sm">
3
3
  <%= render(UI::InputGroup.new) do |g| %>
4
4
  <% if left_icon %>
5
- <%= g.with_addon(align: "inline-start") { render(UI::Icon.new(name: icon_name)) } %>
5
+ <%= g.with_addon(align: "inline-start") { render(UI::Icon.new(name: addon_icon)) } %>
6
6
  <% end %>
7
7
  <%= g.with_field(type: :email, placeholder: "you@example.com", error: error, disabled: disabled) %>
8
8
  <% if right_icon %>
9
- <%= g.with_addon(align: "inline-end") { render(UI::Icon.new(name: icon_name)) } %>
9
+ <%= g.with_addon(align: "inline-end") { render(UI::Icon.new(name: addon_icon)) } %>
10
10
  <% end %>
11
11
  <% end %>
12
12
  </div>
@@ -4,12 +4,12 @@ class UI::InputGroupPreview < ViewComponent::Preview
4
4
  # @label Playground
5
5
  # @param left_icon toggle
6
6
  # @param right_icon toggle
7
- # @param icon_name text
7
+ # @param addon_icon text
8
8
  # @param align select { choices: [inline-start, inline-end] }
9
9
  # @param error toggle
10
10
  # @param disabled toggle
11
- def playground(left_icon: true, right_icon: false, icon_name: "mail", align: "inline-start", error: false, disabled: false)
12
- render_with_template(locals: { left_icon: left_icon, right_icon: right_icon, icon_name: icon_name, align: align, error: error, disabled: disabled })
11
+ def playground(left_icon: true, right_icon: false, addon_icon: "mail", align: "inline-start", error: false, disabled: false)
12
+ render_with_template(locals: { left_icon: left_icon, right_icon: right_icon, addon_icon: addon_icon, align: align, error: error, disabled: disabled })
13
13
  end
14
14
 
15
15
  # @label All Addons
@@ -0,0 +1,20 @@
1
+ <%# bind: true makes the shortcut press the button the hint is in. Try them. %>
2
+ <div id="kbd-bound-demo" class="max-w-md space-y-4">
3
+ <%= render(UI::Textarea.new(name: "note", rows: 3, placeholder: "Write something, then save with the shortcut…", aria: { label: "Note" })) %>
4
+ <div class="flex flex-wrap items-center gap-3">
5
+ <%= render(UI::Button.new(data: { demo: "save" })) do %>Save <%= render(UI::Kbd.new("mod+s", size: :sm, bind: true)) %><% end %>
6
+ <%= render(UI::Button.new(variant: :outline, data: { demo: "clear" })) do %>Clear <%= render(UI::Kbd.new("alt+c", size: :sm, bind: true)) %><% end %>
7
+ <span class="text-sm text-muted-foreground" data-demo="status" role="status"></span>
8
+ </div>
9
+ </div>
10
+ <script>
11
+ (() => {
12
+ const root = document.getElementById("kbd-bound-demo");
13
+ const status = root.querySelector('[data-demo="status"]');
14
+ const note = root.querySelector("textarea");
15
+ root.querySelector('[data-demo="save"]').addEventListener("click", () => {
16
+ status.textContent = `Saved at ${new Date().toLocaleTimeString([], { hour: "numeric", minute: "2-digit", second: "2-digit" })}`;
17
+ });
18
+ root.querySelector('[data-demo="clear"]').addEventListener("click", () => { note.value = ""; status.textContent = "Cleared"; note.focus(); });
19
+ })();
20
+ </script>
@@ -0,0 +1,13 @@
1
+ <%# On a Mac these show ⌘ ⌥ ⇧ symbols; elsewhere Ctrl, Alt and Shift, with a +.
2
+ cmd is ⌘ on a Mac, the Windows key on Windows, and Super on Linux. %>
3
+ <dl class="grid max-w-md grid-cols-[1fr_auto] items-center gap-x-8 gap-y-3 text-sm">
4
+ <% [["One key", "k"], ["Escape", "esc"], ["Enter", "enter"], ["Arrows", "up"], ["A combination", "mod+k"],
5
+ ["Three keys", "mod+shift+p"], ["Option, or Alt", "alt+n"], ["Command, Win or Super", "cmd+l"], ["A symbol", "?"], ["Function key", "F5"]].each do |name, keys| %>
6
+ <dt class="text-muted-foreground"><%= name %></dt>
7
+ <dd><%= render(UI::Kbd.new(keys)) %></dd>
8
+ <% end %>
9
+ <dt class="text-muted-foreground">A sequence</dt>
10
+ <dd><%= render(UI::Kbd.new(%w[g i])) %></dd>
11
+ <dt class="text-muted-foreground">Written as given</dt>
12
+ <dd><%= render(UI::Kbd.new) { "Fn" } %></dd>
13
+ </dl>
@@ -0,0 +1,13 @@
1
+ <%= render(UI::Menu.new) do |menu| %>
2
+ <% menu.with_trigger(variant: :outline) { "Edit" } %>
3
+ <% menu.with_content(class: "w-56") do |content| %>
4
+ <% content.with_item do %>Undo<%= render(UI::Kbd.new("mod+z", size: :sm, class: "ms-auto")) %><% end %>
5
+ <% content.with_item do %>Redo<%= render(UI::Kbd.new("mod+shift+z", size: :sm, class: "ms-auto")) %><% end %>
6
+ <% content.with_divider %>
7
+ <% content.with_item do %>Cut<%= render(UI::Kbd.new("mod+x", size: :sm, class: "ms-auto")) %><% end %>
8
+ <% content.with_item do %>Copy<%= render(UI::Kbd.new("mod+c", size: :sm, class: "ms-auto")) %><% end %>
9
+ <% content.with_item do %>Paste<%= render(UI::Kbd.new("mod+v", size: :sm, class: "ms-auto")) %><% end %>
10
+ <% content.with_divider %>
11
+ <% content.with_item(variant: :destructive) do %>Delete<%= render(UI::Kbd.new("backspace", size: :sm, class: "ms-auto")) %><% end %>
12
+ <% end %>
13
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <%# Press / anywhere on the page (not in a field) to jump to the search box. %>
2
+ <div class="max-w-sm">
3
+ <%= render(UI::InputGroup.new) do |g| %>
4
+ <%= g.with_addon(align: "inline-start") { |a| a.with_icon(name: "search") } %>
5
+ <%= g.with_field(id: "kbd-demo-search", type: :search, placeholder: "Search docs…", aria: { label: "Search docs" }) %>
6
+ <%= g.with_addon(align: "inline-end") { render(UI::Kbd.new("/", bind: "#kbd-demo-search")) } %>
7
+ <% end %>
8
+ </div>
@@ -0,0 +1,17 @@
1
+ <%= render(UI::Card.new(class: "max-w-md")) do |card| %>
2
+ <% card.with_header do |header| %>
3
+ <% header.with_title { "Keyboard shortcuts" } %>
4
+ <% header.with_description { "Press ? to see this list again." } %>
5
+ <% end %>
6
+ <% card.with_content do %>
7
+ <% [["Navigation", [["Go to inbox", %w[g i]], ["Go to drafts", %w[g d]], ["Search", "/"]]],
8
+ ["Messages", [["New message", "c"], ["Reply", "r"], ["Send", "mod+enter"], ["Archive", "e"]]]].each do |group, rows| %>
9
+ <h4 class="mt-4 mb-2 text-xs font-medium tracking-wide text-muted-foreground uppercase first:mt-0"><%= group %></h4>
10
+ <dl class="divide-y text-sm">
11
+ <% rows.each do |action, keys| %>
12
+ <div class="flex items-center justify-between py-2"><dt><%= action %></dt><dd><%= render(UI::Kbd.new(keys)) %></dd></div>
13
+ <% end %>
14
+ </dl>
15
+ <% end %>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <%# A point-of-sale screen, where cashiers keep their hands on the keyboard. The keys work. %>
2
+ <div id="kbd-till-demo" class="max-w-lg space-y-3 rounded-lg border p-4">
3
+ <div class="flex items-baseline justify-between">
4
+ <span class="text-sm text-muted-foreground">Sale #1042 · 3 items</span>
5
+ <span class="text-2xl font-semibold tabular-nums">$27.40</span>
6
+ </div>
7
+ <div class="grid grid-cols-2 gap-2 sm:grid-cols-4">
8
+ <%= render(UI::Button.new(variant: :outline, class: "justify-between", data: { demo: "New sale" })) do %>New sale <%= render(UI::Kbd.new("F2", size: :sm, bind: true)) %><% end %>
9
+ <%= render(UI::Button.new(variant: :outline, class: "justify-between", data: { demo: "Discount" })) do %>Discount <%= render(UI::Kbd.new("F6", size: :sm, bind: true)) %><% end %>
10
+ <%= render(UI::Button.new(variant: :outline, class: "justify-between", data: { demo: "Cancelled" })) do %>Cancel <%= render(UI::Kbd.new("esc", size: :sm, bind: true)) %><% end %>
11
+ <%= render(UI::Button.new(class: "justify-between", data: { demo: "Paid" })) do %>Pay <%= render(UI::Kbd.new("F4", size: :sm, bind: true)) %><% end %>
12
+ </div>
13
+ <p class="text-sm text-muted-foreground" data-demo="status" role="status">Press a key.</p>
14
+ </div>
15
+ <script>
16
+ (() => {
17
+ const root = document.getElementById("kbd-till-demo");
18
+ const status = root.querySelector('[data-demo="status"]');
19
+ root.querySelectorAll("button[data-demo]").forEach((button) => {
20
+ button.addEventListener("click", () => { status.textContent = button.dataset.demo; });
21
+ });
22
+ })();
23
+ </script>
@@ -0,0 +1,14 @@
1
+ <%# The key takes its colours from where it sits: dark tooltip, filled or outline button. %>
2
+ <div class="flex flex-wrap items-center gap-4">
3
+ <%= render(UI::Tooltip.new) do |tooltip| %>
4
+ <% tooltip.with_trigger do %>
5
+ <%= render(UI::Button.new(variant: :outline, size: :icon, aria: { label: "Bold" })) { render(UI::Icon.new(name: "bold", size: :sm)) } %>
6
+ <% end %>
7
+ <% tooltip.with_content do %>
8
+ <span class="flex items-center gap-2">Bold <%= render(UI::Kbd.new("mod+b", size: :sm)) %></span>
9
+ <% end %>
10
+ <% end %>
11
+ <%= render(UI::Button.new) do %>New note <%= render(UI::Kbd.new("n", size: :sm)) %><% end %>
12
+ <%= render(UI::Button.new(variant: :outline)) do %>Cancel <%= render(UI::Kbd.new("esc", size: :sm)) %><% end %>
13
+ <%= render(UI::Button.new(variant: :secondary)) do %>Send <%= render(UI::Kbd.new("mod+enter", size: :sm)) %><% end %>
14
+ </div>
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UI::KbdPreview < ViewComponent::Preview
4
+ # @label Playground
5
+ # @param keys text "Keys joined by +, like mod+shift+k"
6
+ # @param then_keys text "A second step, for a sequence like G then I"
7
+ # @param size select { choices: [sm, default, lg] }
8
+ def playground(keys: "mod+k", then_keys: "", size: :default)
9
+ render(UI::Kbd.new([ keys, then_keys.presence ].compact, size: size.to_sym))
10
+ end
11
+
12
+ # @label Keys and Shortcuts
13
+ def keys; render_with_template; end
14
+
15
+ # @label In a Search Field
16
+ def search_field; render_with_template; end
17
+
18
+ # @label In a Menu
19
+ def menu; render_with_template; end
20
+
21
+ # @label In a Tooltip and on Buttons
22
+ def tooltip_and_buttons; render_with_template; end
23
+
24
+ # @label Shortcuts That Work
25
+ def bound; render_with_template; end
26
+
27
+ # @label Shortcuts List
28
+ def shortcuts_list; render_with_template; end
29
+
30
+ # @label Billing Keys at a Till
31
+ def till; render_with_template; end
32
+ end
@@ -0,0 +1,11 @@
1
+ <ul class="flex max-w-md flex-col divide-y">
2
+ <% [ [ "Oat milk, 1 L", "$3.20", 2 ], [ "Filter coffee, 250 g", "$11.50", 1 ], [ "Ceramic mug", "$14.00", 4 ] ].each do |name, price, quantity| %>
3
+ <li class="flex items-center justify-between gap-4 py-3">
4
+ <span class="min-w-0 text-sm">
5
+ <span class="block font-medium"><%= name %></span>
6
+ <span class="text-muted-foreground"><%= price %></span>
7
+ </span>
8
+ <%= render(UI::NumberInput.new(value: quantity, min: 1, max: 20, name: "quantity[]", "aria-label": "Quantity of #{name}", class: "w-28 shrink-0")) %>
9
+ </li>
10
+ <% end %>
11
+ </ul>
@@ -0,0 +1,4 @@
1
+ <div class="flex w-48 flex-col gap-4">
2
+ <%= render(UI::NumberInput.new(label: "Weight (kg)", value: 1.5, min: 0, step: 0.25, name: "weight", hint: "In steps of 0.25")) %>
3
+ <%= render(UI::NumberInput.new(label: "Any amount", value: 2.75, min: 0, step: "any", name: "amount", hint: "Buttons move by 1")) %>
4
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="flex w-48 flex-col gap-4">
2
+ <%= render(UI::NumberInput.new(size: :sm, label: "Small", value: 1, min: 0, name: "small")) %>
3
+ <%= render(UI::NumberInput.new(label: "Default", value: 2, min: 0, name: "default")) %>
4
+ <%= render(UI::NumberInput.new(size: :lg, label: "Large, for touch screens", value: 3, min: 0, name: "large")) %>
5
+ </div>
@@ -0,0 +1,7 @@
1
+ <div class="flex w-48 flex-col gap-4">
2
+ <%= render(UI::NumberInput.new(label: "At its minimum", value: 1, min: 1, max: 5, name: "at_min")) %>
3
+ <%= render(UI::NumberInput.new(label: "At its maximum", value: 5, min: 1, max: 5, name: "at_max")) %>
4
+ <%= render(UI::NumberInput.new(label: "Disabled", value: 3, disabled: true, name: "disabled")) %>
5
+ <%= render(UI::NumberInput.new(label: "Read only", value: 3, readonly: true, name: "readonly")) %>
6
+ <%= render(UI::NumberInput.new(label: "With an error", value: 0, error: "Must be at least 1", name: "invalid")) %>
7
+ </div>
@@ -0,0 +1,3 @@
1
+ <div class="w-48">
2
+ <%= render(UI::NumberInput.new(label: "Adjust stock by", value: 0, name: "adjustment", hint: "Negative to write stock off")) %>
3
+ </div>
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UI::NumberInputPreview < ViewComponent::Preview
4
+ # @label Playground
5
+ # @param size select { choices: [sm, default, lg] }
6
+ # @param label text
7
+ # @param hint text
8
+ # @param value number
9
+ # @param min number
10
+ # @param max number
11
+ # @param step number
12
+ # @param disabled toggle
13
+ # @param readonly toggle
14
+ # @param error text
15
+ def playground(size: :default, label: "Quantity", hint: "", value: 2, min: 1, max: 10, step: 1,
16
+ disabled: false, readonly: false, error: "")
17
+ render(UI::NumberInput.new(size: size.to_sym, label: label.presence, hint: hint.presence, value: value, min: min,
18
+ max: max, step: step, disabled: disabled, readonly: readonly,
19
+ error: error.presence, name: "quantity", class: "w-40"))
20
+ end
21
+
22
+ # @label Sizes
23
+ def sizes; render_with_template; end
24
+
25
+ # @label Cart Rows
26
+ def cart; render_with_template; end
27
+
28
+ # @label Decimal Steps
29
+ def decimals; render_with_template; end
30
+
31
+ # @label Stock Adjustment, Below Zero Allowed
32
+ def stock_adjustment; render_with_template; end
33
+
34
+ # @label States
35
+ def states; render_with_template; end
36
+ end
@@ -0,0 +1,36 @@
1
+ <%# Stands in for a real upload: DirectUpload's progress event would set the same attribute. %>
2
+ <div id="progress-upload-demo" class="grid max-w-sm gap-4">
3
+ <%= render(UI::Progress.new(value: 0, max: 4.2, label: "quarterly-report.pdf", value_text: "%{value} of %{max} MB",
4
+ show_value: true, data: { demo: "bar" })) %>
5
+ <div class="flex items-center gap-3">
6
+ <%= render(UI::Button.new(size: :sm, data: { demo: "start" })) { "Upload" } %>
7
+ <span class="text-sm text-muted-foreground" data-demo="status" role="status"></span>
8
+ </div>
9
+ </div>
10
+ <script>
11
+ (() => {
12
+ const root = document.getElementById("progress-upload-demo");
13
+ const bar = root.querySelector('[data-demo="bar"]');
14
+ const status = root.querySelector('[data-demo="status"]');
15
+ const start = root.querySelector('[data-demo="start"]');
16
+ let timer;
17
+
18
+ start.addEventListener("click", () => {
19
+ clearInterval(timer);
20
+ let sent = 0;
21
+ start.disabled = true;
22
+ status.textContent = "";
23
+ bar.setAttribute("data-ui--progress-value-value", "0");
24
+ timer = setInterval(() => {
25
+ sent = Math.min(4.2, sent + 0.15 + Math.random() * 0.35);
26
+ bar.setAttribute("data-ui--progress-value-value", sent.toFixed(1));
27
+ }, 250);
28
+ });
29
+
30
+ bar.addEventListener("ui--progress:complete", () => {
31
+ clearInterval(timer);
32
+ start.disabled = false;
33
+ status.textContent = "Uploaded";
34
+ });
35
+ })();
36
+ </script>
@@ -0,0 +1,4 @@
1
+ <div class="max-w-sm space-y-2 rounded-lg border p-4">
2
+ <p class="text-sm"><span class="font-medium">$12.50 more</span> for free shipping</p>
3
+ <%= render(UI::Progress.new(value: 37.5, max: 50, size: :sm, value_text: "$%{value} of $%{max}", aria: { label: "Towards free shipping" })) %>
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="grid max-w-sm gap-6">
2
+ <%= render(UI::Progress.new(label: "Preparing your export")) %>
3
+ <%= render(UI::Progress.new(size: :sm, aria: { label: "Loading results" })) %>
4
+ </div>
@@ -0,0 +1,8 @@
1
+ <div class="grid max-w-sm gap-6">
2
+ <%= render(UI::Progress.new(value: 30, size: :sm, label: "Small", show_value: true)) %>
3
+ <%= render(UI::Progress.new(value: 55, label: "Default", show_value: true)) %>
4
+ <%= render(UI::Progress.new(value: 80, size: :lg, label: "Large", show_value: true)) %>
5
+ <%= render(UI::Progress.new(value: 100, tone: :success, label: "Success", show_value: true)) %>
6
+ <%= render(UI::Progress.new(value: 85, tone: :warning, label: "Warning", show_value: true)) %>
7
+ <%= render(UI::Progress.new(value: 97, tone: :destructive, label: "Destructive", show_value: true)) %>
8
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= render(UI::Card.new(class: "max-w-sm")) do |card| %>
2
+ <% card.with_header do |header| %>
3
+ <% header.with_title { "Finish setting up your profile" } %>
4
+ <% header.with_description { "Profiles with a photo and a bio get more replies." } %>
5
+ <% end %>
6
+ <% card.with_content do %>
7
+ <%= render(UI::Progress.new(value: 3, max: 5, value_text: "%{value} of %{max} done", show_value: true, label: "Profile")) %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <div class="grid max-w-sm gap-6">
2
+ <%= render(UI::Progress.new(value: 6.4, max: 15, label: "Photos", value_text: "%{value} GB of %{max} GB", show_value: true)) %>
3
+ <%= render(UI::Progress.new(value: 12.9, max: 15, tone: :warning, label: "Mailbox", value_text: "%{value} GB of %{max} GB", show_value: true)) %>
4
+ <div class="space-y-1.5">
5
+ <%= render(UI::Progress.new(value: 14.8, max: 15, tone: :destructive, label: "Shared drive", value_text: "%{value} GB of %{max} GB", show_value: true)) %>
6
+ <p class="text-sm text-muted-foreground">Almost full. New files won't sync until you free up space.</p>
7
+ </div>
8
+ </div>
@@ -0,0 +1,7 @@
1
+ <%= render(UI::Progress.new(max: 15, label: "Storage", value_text: "%{value} GB of %{max} GB", segment_text: "%{value} GB",
2
+ show_value: true, class: "max-w-md")) do |progress| %>
3
+ <% progress.with_segment(value: 6.4, label: "Photos") %>
4
+ <% progress.with_segment(value: 3.1, label: "Mail") %>
5
+ <% progress.with_segment(value: 2, label: "Documents") %>
6
+ <% progress.with_segment(value: 0.6, label: "Other") %>
7
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <%# Two segments of a total, with the rest left as the track: "to do". %>
2
+ <%= render(UI::Card.new(class: "max-w-md")) do |card| %>
3
+ <% card.with_header do |header| %>
4
+ <% header.with_title { "Website relaunch" } %>
5
+ <% header.with_description { "40 tasks, due Friday" } %>
6
+ <% end %>
7
+ <% card.with_content do %>
8
+ <%= render(UI::Progress.new(max: 40, size: :lg, label: "Tasks", value_text: "%{value} of %{max} underway or done",
9
+ segment_text: "%{value} tasks", show_value: true)) do |progress| %>
10
+ <% progress.with_segment(value: 22, label: "Done", color: 3) %>
11
+ <% progress.with_segment(value: 9, label: "In review", color: 4) %>
12
+ <% end %>
13
+ <% end %>
14
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%# No max:, so the segments fill the bar and the legend shows each one's share. %>
2
+ <%= render(UI::Card.new(class: "max-w-md")) do |card| %>
3
+ <% card.with_header do |header| %>
4
+ <% header.with_title { "Where visitors came from" } %>
5
+ <% header.with_description { "9,500 visits in the last 30 days" } %>
6
+ <% end %>
7
+ <% card.with_content do %>
8
+ <%= render(UI::Progress.new(size: :lg, aria: { label: "Visits by source" })) do |progress| %>
9
+ <% progress.with_segment(value: 5_210, label: "Search") %>
10
+ <% progress.with_segment(value: 2_870, label: "Direct") %>
11
+ <% progress.with_segment(value: 1_045, label: "Social") %>
12
+ <% progress.with_segment(value: 375, label: "Email") %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>