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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +80 -0
- data/README.md +30 -8
- data/lib/generators/velvetkit/add/add_generator.rb +77 -0
- data/lib/generators/velvetkit/helpers.rb +29 -2
- data/lib/generators/velvetkit/icons/icons_generator.rb +71 -0
- data/lib/generators/velvetkit/install/install_generator.rb +9 -12
- data/lib/velvetkit/icons.rb +148 -0
- data/lib/velvetkit/registry.rb +5 -2
- data/lib/velvetkit/version.rb +4 -1
- data/lib/velvetkit.rb +8 -0
- data/registry/app/assets/tailwind/velvetkit.css +90 -155
- data/registry/app/components/ui/alert.rb +1 -1
- data/registry/app/components/ui/chart.html.erb +47 -0
- data/registry/app/components/ui/chart.rb +177 -0
- data/registry/app/components/ui/command/group.rb +27 -0
- data/registry/app/components/ui/command/item.rb +64 -0
- data/registry/app/components/ui/command.html.erb +41 -0
- data/registry/app/components/ui/command.rb +122 -0
- data/registry/app/components/ui/confirm_dialog.html.erb +13 -0
- data/registry/app/components/ui/confirm_dialog.rb +55 -0
- data/registry/app/components/ui/date_picker.html.erb +58 -64
- data/registry/app/components/ui/date_picker.rb +199 -75
- data/registry/app/components/ui/empty_state.html.erb +20 -0
- data/registry/app/components/ui/empty_state.rb +46 -0
- data/registry/app/components/ui/file_field.html.erb +14 -4
- data/registry/app/components/ui/file_field.rb +179 -28
- data/registry/app/components/ui/gallery/image.rb +20 -0
- data/registry/app/components/ui/gallery.html.erb +52 -0
- data/registry/app/components/ui/gallery.rb +164 -0
- data/registry/app/components/ui/icon.html.erb +1 -1
- data/registry/app/components/ui/icon.rb +80 -8
- data/registry/app/components/ui/kbd.html.erb +27 -0
- data/registry/app/components/ui/kbd.rb +134 -0
- data/registry/app/components/ui/number_input.html.erb +11 -0
- data/registry/app/components/ui/number_input.rb +103 -0
- data/registry/app/components/ui/password_input.html.erb +1 -1
- data/registry/app/components/ui/progress/segment.rb +25 -0
- data/registry/app/components/ui/progress.html.erb +25 -0
- data/registry/app/components/ui/progress.rb +182 -0
- data/registry/app/components/ui/select.html.erb +24 -5
- data/registry/app/components/ui/select.rb +44 -5
- data/registry/app/components/ui/stepper/step.html.erb +27 -0
- data/registry/app/components/ui/stepper/step.rb +213 -0
- data/registry/app/components/ui/stepper.html.erb +19 -0
- data/registry/app/components/ui/stepper.rb +145 -0
- data/registry/app/components/ui/theme_toggle.rb +2 -4
- data/registry/app/components/ui/timeline/item.html.erb +21 -0
- data/registry/app/components/ui/timeline/item.rb +145 -0
- data/registry/app/components/ui/timeline.html.erb +1 -0
- data/registry/app/components/ui/timeline.rb +42 -0
- data/registry/app/components/ui/toast.rb +6 -6
- data/registry/app/components/ui/toggle_group/item.html.erb +1 -0
- data/registry/app/components/ui/toggle_group/item.rb +85 -0
- data/registry/app/components/ui/toggle_group.html.erb +1 -0
- data/registry/app/components/ui/toggle_group.rb +79 -0
- data/registry/app/javascript/chart_js.ts +37 -0
- data/registry/app/javascript/controllers/ui/_internal/date_format.ts +74 -0
- data/registry/app/javascript/controllers/ui/_internal/shortcut.ts +80 -0
- data/registry/app/javascript/controllers/ui/chart_controller.ts +585 -0
- data/registry/app/javascript/controllers/ui/command_controller.ts +454 -0
- data/registry/app/javascript/controllers/ui/confirm_dialog_controller.ts +110 -0
- data/registry/app/javascript/controllers/ui/date_picker_controller.ts +247 -82
- data/registry/app/javascript/controllers/ui/file_field_controller.ts +288 -16
- data/registry/app/javascript/controllers/ui/gallery_controller.ts +568 -0
- data/registry/app/javascript/controllers/ui/kbd_controller.ts +60 -0
- data/registry/app/javascript/controllers/ui/number_input_controller.ts +111 -0
- data/registry/app/javascript/controllers/ui/progress_controller.ts +87 -0
- data/registry/app/javascript/controllers/ui/select_controller.ts +198 -8
- data/registry/app/javascript/controllers/ui/stepper_controller.ts +187 -0
- data/registry/app/javascript/vanilla_calendar.ts +15 -0
- data/registry/components.yml +28 -5
- data/registry/config/locales/velvetkit.en.yml +84 -0
- data/registry/docs/agents.md +7 -4
- data/registry/icons/lucide/LICENSE +39 -0
- data/registry/icons/lucide/align-center.svg +17 -0
- data/registry/icons/lucide/align-left.svg +17 -0
- data/registry/icons/lucide/align-right.svg +17 -0
- data/registry/icons/lucide/arrow-left.svg +16 -0
- data/registry/icons/lucide/arrow-right.svg +16 -0
- data/registry/icons/lucide/badge-check.svg +16 -0
- data/registry/icons/lucide/bar-chart-3.svg +18 -0
- data/registry/icons/lucide/bell.svg +16 -0
- data/registry/icons/lucide/bold.svg +15 -0
- data/registry/icons/lucide/book-open.svg +16 -0
- data/registry/icons/lucide/calendar.svg +18 -0
- data/registry/icons/lucide/chart-column.svg +18 -0
- data/registry/icons/lucide/check.svg +15 -0
- data/registry/icons/lucide/chevron-down.svg +15 -0
- data/registry/icons/lucide/chevron-left.svg +15 -0
- data/registry/icons/lucide/chevron-right.svg +15 -0
- data/registry/icons/lucide/chevrons-up-down.svg +16 -0
- data/registry/icons/lucide/circle-alert.svg +17 -0
- data/registry/icons/lucide/circle-check.svg +16 -0
- data/registry/icons/lucide/cloud.svg +15 -0
- data/registry/icons/lucide/credit-card.svg +16 -0
- data/registry/icons/lucide/download.svg +17 -0
- data/registry/icons/lucide/ellipsis-vertical.svg +17 -0
- data/registry/icons/lucide/ellipsis.svg +17 -0
- data/registry/icons/lucide/eye-off.svg +18 -0
- data/registry/icons/lucide/eye.svg +16 -0
- data/registry/icons/lucide/file-plus.svg +18 -0
- data/registry/icons/lucide/file-text.svg +19 -0
- data/registry/icons/lucide/file.svg +16 -0
- data/registry/icons/lucide/folder-kanban.svg +18 -0
- data/registry/icons/lucide/folder.svg +15 -0
- data/registry/icons/lucide/git-branch.svg +18 -0
- data/registry/icons/lucide/globe.svg +17 -0
- data/registry/icons/lucide/graduation-cap.svg +17 -0
- data/registry/icons/lucide/grip-vertical.svg +20 -0
- data/registry/icons/lucide/home.svg +16 -0
- data/registry/icons/lucide/inbox.svg +16 -0
- data/registry/icons/lucide/info.svg +17 -0
- data/registry/icons/lucide/italic.svg +17 -0
- data/registry/icons/lucide/keyboard.svg +23 -0
- data/registry/icons/lucide/layout-dashboard.svg +18 -0
- data/registry/icons/lucide/layout-grid.svg +18 -0
- data/registry/icons/lucide/life-buoy.svg +20 -0
- data/registry/icons/lucide/list.svg +20 -0
- data/registry/icons/lucide/loader.svg +22 -0
- data/registry/icons/lucide/lock.svg +16 -0
- data/registry/icons/lucide/log-out.svg +17 -0
- data/registry/icons/lucide/mail.svg +16 -0
- data/registry/icons/lucide/menu.svg +17 -0
- data/registry/icons/lucide/message-circle.svg +15 -0
- data/registry/icons/lucide/minus.svg +15 -0
- data/registry/icons/lucide/monitor.svg +17 -0
- data/registry/icons/lucide/moon.svg +15 -0
- data/registry/icons/lucide/newspaper.svg +18 -0
- data/registry/icons/lucide/package.svg +18 -0
- data/registry/icons/lucide/panel-left.svg +16 -0
- data/registry/icons/lucide/pause.svg +16 -0
- data/registry/icons/lucide/percent.svg +17 -0
- data/registry/icons/lucide/plus.svg +16 -0
- data/registry/icons/lucide/printer.svg +17 -0
- data/registry/icons/lucide/qr-code.svg +26 -0
- data/registry/icons/lucide/receipt.svg +17 -0
- data/registry/icons/lucide/rocket.svg +18 -0
- data/registry/icons/lucide/rotate-cw.svg +16 -0
- data/registry/icons/lucide/search.svg +16 -0
- data/registry/icons/lucide/settings.svg +16 -0
- data/registry/icons/lucide/shield-check.svg +16 -0
- data/registry/icons/lucide/shield.svg +15 -0
- data/registry/icons/lucide/store.svg +17 -0
- data/registry/icons/lucide/sun-moon.svg +19 -0
- data/registry/icons/lucide/sun.svg +23 -0
- data/registry/icons/lucide/trash-2.svg +19 -0
- data/registry/icons/lucide/truck.svg +19 -0
- data/registry/icons/lucide/underline.svg +16 -0
- data/registry/icons/lucide/upload.svg +17 -0
- data/registry/icons/lucide/user-plus.svg +18 -0
- data/registry/icons/lucide/user.svg +16 -0
- data/registry/icons/lucide/users.svg +18 -0
- data/registry/icons/lucide/workflow.svg +17 -0
- data/registry/icons/lucide/x.svg +16 -0
- data/registry/icons/lucide/zoom-in.svg +18 -0
- data/registry/icons/lucide/zoom-out.svg +17 -0
- data/registry/icons/phosphor/LICENSE +21 -0
- data/registry/icons/phosphor/arrow-clockwise.svg +2 -0
- data/registry/icons/phosphor/arrow-left.svg +2 -0
- data/registry/icons/phosphor/arrow-right.svg +2 -0
- data/registry/icons/phosphor/bell.svg +2 -0
- data/registry/icons/phosphor/book-open.svg +2 -0
- data/registry/icons/phosphor/calendar-blank.svg +2 -0
- data/registry/icons/phosphor/caret-down.svg +2 -0
- data/registry/icons/phosphor/caret-left.svg +2 -0
- data/registry/icons/phosphor/caret-right.svg +2 -0
- data/registry/icons/phosphor/caret-up-down.svg +2 -0
- data/registry/icons/phosphor/chart-bar.svg +2 -0
- data/registry/icons/phosphor/chat-circle.svg +2 -0
- data/registry/icons/phosphor/check-circle.svg +2 -0
- data/registry/icons/phosphor/check.svg +2 -0
- data/registry/icons/phosphor/circle-half.svg +2 -0
- data/registry/icons/phosphor/cloud.svg +2 -0
- data/registry/icons/phosphor/credit-card.svg +2 -0
- data/registry/icons/phosphor/desktop.svg +2 -0
- data/registry/icons/phosphor/dots-six-vertical.svg +2 -0
- data/registry/icons/phosphor/dots-three-vertical.svg +2 -0
- data/registry/icons/phosphor/dots-three.svg +2 -0
- data/registry/icons/phosphor/download-simple.svg +2 -0
- data/registry/icons/phosphor/envelope.svg +2 -0
- data/registry/icons/phosphor/eye-slash.svg +2 -0
- data/registry/icons/phosphor/eye.svg +2 -0
- data/registry/icons/phosphor/file-plus.svg +2 -0
- data/registry/icons/phosphor/file-text.svg +2 -0
- data/registry/icons/phosphor/file.svg +2 -0
- data/registry/icons/phosphor/flow-arrow.svg +2 -0
- data/registry/icons/phosphor/folder.svg +2 -0
- data/registry/icons/phosphor/gear.svg +2 -0
- data/registry/icons/phosphor/git-branch.svg +2 -0
- data/registry/icons/phosphor/globe.svg +2 -0
- data/registry/icons/phosphor/graduation-cap.svg +2 -0
- data/registry/icons/phosphor/grid-four.svg +2 -0
- data/registry/icons/phosphor/house.svg +2 -0
- data/registry/icons/phosphor/info.svg +2 -0
- data/registry/icons/phosphor/kanban.svg +2 -0
- data/registry/icons/phosphor/keyboard.svg +2 -0
- data/registry/icons/phosphor/lifebuoy.svg +2 -0
- data/registry/icons/phosphor/list.svg +2 -0
- data/registry/icons/phosphor/lock.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass-minus.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass-plus.svg +2 -0
- data/registry/icons/phosphor/magnifying-glass.svg +2 -0
- data/registry/icons/phosphor/minus.svg +2 -0
- data/registry/icons/phosphor/moon.svg +2 -0
- data/registry/icons/phosphor/newspaper.svg +2 -0
- data/registry/icons/phosphor/package.svg +2 -0
- data/registry/icons/phosphor/pause.svg +2 -0
- data/registry/icons/phosphor/percent.svg +2 -0
- data/registry/icons/phosphor/plus.svg +2 -0
- data/registry/icons/phosphor/printer.svg +2 -0
- data/registry/icons/phosphor/qr-code.svg +2 -0
- data/registry/icons/phosphor/receipt.svg +2 -0
- data/registry/icons/phosphor/rocket.svg +2 -0
- data/registry/icons/phosphor/seal-check.svg +2 -0
- data/registry/icons/phosphor/shield-check.svg +2 -0
- data/registry/icons/phosphor/shield.svg +2 -0
- data/registry/icons/phosphor/sidebar.svg +2 -0
- data/registry/icons/phosphor/sign-out.svg +2 -0
- data/registry/icons/phosphor/spinner.svg +2 -0
- data/registry/icons/phosphor/squares-four.svg +2 -0
- data/registry/icons/phosphor/storefront.svg +2 -0
- data/registry/icons/phosphor/sun.svg +2 -0
- data/registry/icons/phosphor/text-align-center.svg +2 -0
- data/registry/icons/phosphor/text-align-left.svg +2 -0
- data/registry/icons/phosphor/text-align-right.svg +2 -0
- data/registry/icons/phosphor/text-b.svg +2 -0
- data/registry/icons/phosphor/text-italic.svg +2 -0
- data/registry/icons/phosphor/text-underline.svg +2 -0
- data/registry/icons/phosphor/trash.svg +2 -0
- data/registry/icons/phosphor/tray.svg +2 -0
- data/registry/icons/phosphor/truck.svg +2 -0
- data/registry/icons/phosphor/upload-simple.svg +2 -0
- data/registry/icons/phosphor/user-plus.svg +2 -0
- data/registry/icons/phosphor/user.svg +2 -0
- data/registry/icons/phosphor/users.svg +2 -0
- data/registry/icons/phosphor/warning-circle.svg +2 -0
- data/registry/icons/phosphor/x.svg +2 -0
- data/registry/icons/tabler/LICENSE +21 -0
- data/registry/icons/tabler/alert-circle.svg +18 -0
- data/registry/icons/tabler/align-center.svg +18 -0
- data/registry/icons/tabler/align-left.svg +18 -0
- data/registry/icons/tabler/align-right.svg +18 -0
- data/registry/icons/tabler/arrow-left.svg +18 -0
- data/registry/icons/tabler/arrow-right.svg +18 -0
- data/registry/icons/tabler/bell.svg +17 -0
- data/registry/icons/tabler/bold.svg +17 -0
- data/registry/icons/tabler/book.svg +20 -0
- data/registry/icons/tabler/building-store.svg +20 -0
- data/registry/icons/tabler/calendar.svg +21 -0
- data/registry/icons/tabler/chart-bar.svg +19 -0
- data/registry/icons/tabler/check.svg +16 -0
- data/registry/icons/tabler/chevron-down.svg +16 -0
- data/registry/icons/tabler/chevron-left.svg +16 -0
- data/registry/icons/tabler/chevron-right.svg +16 -0
- data/registry/icons/tabler/circle-check.svg +17 -0
- data/registry/icons/tabler/cloud.svg +16 -0
- data/registry/icons/tabler/credit-card.svg +19 -0
- data/registry/icons/tabler/device-desktop.svg +19 -0
- data/registry/icons/tabler/dots-vertical.svg +18 -0
- data/registry/icons/tabler/dots.svg +18 -0
- data/registry/icons/tabler/download.svg +18 -0
- data/registry/icons/tabler/eye-off.svg +18 -0
- data/registry/icons/tabler/eye.svg +17 -0
- data/registry/icons/tabler/file-plus.svg +19 -0
- data/registry/icons/tabler/file-text.svg +20 -0
- data/registry/icons/tabler/file.svg +17 -0
- data/registry/icons/tabler/folder.svg +16 -0
- data/registry/icons/tabler/git-branch.svg +21 -0
- data/registry/icons/tabler/grip-vertical.svg +21 -0
- data/registry/icons/tabler/home.svg +18 -0
- data/registry/icons/tabler/inbox.svg +17 -0
- data/registry/icons/tabler/info-circle.svg +18 -0
- data/registry/icons/tabler/italic.svg +18 -0
- data/registry/icons/tabler/keyboard.svg +23 -0
- data/registry/icons/tabler/layout-dashboard.svg +19 -0
- data/registry/icons/tabler/layout-grid.svg +19 -0
- data/registry/icons/tabler/layout-kanban.svg +19 -0
- data/registry/icons/tabler/layout-sidebar.svg +17 -0
- data/registry/icons/tabler/lifebuoy.svg +21 -0
- data/registry/icons/tabler/list.svg +21 -0
- data/registry/icons/tabler/loader.svg +23 -0
- data/registry/icons/tabler/lock.svg +18 -0
- data/registry/icons/tabler/logout.svg +18 -0
- data/registry/icons/tabler/mail.svg +17 -0
- data/registry/icons/tabler/menu-2.svg +18 -0
- data/registry/icons/tabler/message-circle.svg +16 -0
- data/registry/icons/tabler/minus.svg +16 -0
- data/registry/icons/tabler/moon.svg +16 -0
- data/registry/icons/tabler/news.svg +19 -0
- data/registry/icons/tabler/package.svg +20 -0
- data/registry/icons/tabler/percentage.svg +18 -0
- data/registry/icons/tabler/player-pause.svg +17 -0
- data/registry/icons/tabler/plus.svg +17 -0
- data/registry/icons/tabler/printer.svg +18 -0
- data/registry/icons/tabler/qrcode.svg +27 -0
- data/registry/icons/tabler/receipt.svg +16 -0
- data/registry/icons/tabler/rocket.svg +18 -0
- data/registry/icons/tabler/rosette-discount-check.svg +17 -0
- data/registry/icons/tabler/rotate-clockwise.svg +16 -0
- data/registry/icons/tabler/school.svg +17 -0
- data/registry/icons/tabler/search.svg +17 -0
- data/registry/icons/tabler/selector.svg +17 -0
- data/registry/icons/tabler/settings.svg +17 -0
- data/registry/icons/tabler/shield-check.svg +17 -0
- data/registry/icons/tabler/shield.svg +16 -0
- data/registry/icons/tabler/sitemap.svg +20 -0
- data/registry/icons/tabler/sun-moon.svg +21 -0
- data/registry/icons/tabler/sun.svg +17 -0
- data/registry/icons/tabler/trash.svg +20 -0
- data/registry/icons/tabler/truck.svg +18 -0
- data/registry/icons/tabler/underline.svg +17 -0
- data/registry/icons/tabler/upload.svg +18 -0
- data/registry/icons/tabler/user-plus.svg +19 -0
- data/registry/icons/tabler/user.svg +17 -0
- data/registry/icons/tabler/users.svg +19 -0
- data/registry/icons/tabler/world.svg +20 -0
- data/registry/icons/tabler/x.svg +17 -0
- data/registry/icons/tabler/zoom-in.svg +19 -0
- data/registry/icons/tabler/zoom-out.svg +18 -0
- data/registry/icons.yml +90 -0
- data/registry/test/components/previews/ui/chart_preview/cash_flow.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/donut.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/margin.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/pie.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/sales.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/stock.html.erb +6 -0
- data/registry/test/components/previews/ui/chart_preview/takings.html.erb +8 -0
- data/registry/test/components/previews/ui/chart_preview.rb +46 -0
- data/registry/test/components/previews/ui/command_preview/_picked.html.erb +14 -0
- data/registry/test/components/previews/ui/command_preview/dialog.html.erb +24 -0
- data/registry/test/components/previews/ui/command_preview/inline.html.erb +16 -0
- data/registry/test/components/previews/ui/command_preview/playground.html.erb +15 -0
- data/registry/test/components/previews/ui/command_preview/server_search.html.erb +24 -0
- data/registry/test/components/previews/ui/command_preview/shortcuts.html.erb +12 -0
- data/registry/test/components/previews/ui/command_preview/till.html.erb +17 -0
- data/registry/test/components/previews/ui/command_preview.rb +25 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/destructive.html.erb +7 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/in_form.html.erb +6 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/on_link.html.erb +5 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/plain.html.erb +3 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview/with_description.html.erb +4 -0
- data/registry/test/components/previews/ui/confirm_dialog_preview.rb +20 -0
- data/registry/test/components/previews/ui/date_picker_preview/custom_presets.html.erb +6 -0
- data/registry/test/components/previews/ui/date_picker_preview/in_form.html.erb +11 -0
- data/registry/test/components/previews/ui/date_picker_preview/range.html.erb +5 -0
- data/registry/test/components/previews/ui/date_picker_preview/states.html.erb +4 -3
- data/registry/test/components/previews/ui/date_picker_preview.rb +26 -6
- data/registry/test/components/previews/ui/empty_state_preview/in_card.html.erb +7 -0
- data/registry/test/components/previews/ui/empty_state_preview/no_results.html.erb +3 -0
- data/registry/test/components/previews/ui/empty_state_preview/outline.html.erb +3 -0
- data/registry/test/components/previews/ui/empty_state_preview/with_actions.html.erb +4 -0
- data/registry/test/components/previews/ui/empty_state_preview/with_media.html.erb +8 -0
- data/registry/test/components/previews/ui/empty_state_preview.rb +26 -0
- data/registry/test/components/previews/ui/file_field_preview/multiple_files.html.erb +1 -1
- data/registry/test/components/previews/ui/file_field_preview/product_photos.html.erb +12 -0
- data/registry/test/components/previews/ui/file_field_preview/single_image.html.erb +4 -0
- data/registry/test/components/previews/ui/file_field_preview.rb +32 -5
- data/registry/test/components/previews/ui/gallery_preview/hover_zoom.html.erb +13 -0
- data/registry/test/components/previews/ui/gallery_preview/landscape.html.erb +5 -0
- data/registry/test/components/previews/ui/gallery_preview/product_page.html.erb +13 -0
- data/registry/test/components/previews/ui/gallery_preview/single.html.erb +3 -0
- data/registry/test/components/previews/ui/gallery_preview.rb +45 -0
- data/registry/test/components/previews/ui/icon_preview/common.html.erb +19 -3
- data/registry/test/components/previews/ui/icon_preview/labelled.html.erb +4 -0
- data/registry/test/components/previews/ui/icon_preview/missing.html.erb +3 -0
- data/registry/test/components/previews/ui/icon_preview.rb +18 -3
- data/registry/test/components/previews/ui/input_group_preview/playground.html.erb +2 -2
- data/registry/test/components/previews/ui/input_group_preview.rb +3 -3
- data/registry/test/components/previews/ui/kbd_preview/bound.html.erb +20 -0
- data/registry/test/components/previews/ui/kbd_preview/keys.html.erb +13 -0
- data/registry/test/components/previews/ui/kbd_preview/menu.html.erb +13 -0
- data/registry/test/components/previews/ui/kbd_preview/search_field.html.erb +8 -0
- data/registry/test/components/previews/ui/kbd_preview/shortcuts_list.html.erb +17 -0
- data/registry/test/components/previews/ui/kbd_preview/till.html.erb +23 -0
- data/registry/test/components/previews/ui/kbd_preview/tooltip_and_buttons.html.erb +14 -0
- data/registry/test/components/previews/ui/kbd_preview.rb +32 -0
- data/registry/test/components/previews/ui/number_input_preview/cart.html.erb +11 -0
- data/registry/test/components/previews/ui/number_input_preview/decimals.html.erb +4 -0
- data/registry/test/components/previews/ui/number_input_preview/sizes.html.erb +5 -0
- data/registry/test/components/previews/ui/number_input_preview/states.html.erb +7 -0
- data/registry/test/components/previews/ui/number_input_preview/stock_adjustment.html.erb +3 -0
- data/registry/test/components/previews/ui/number_input_preview.rb +36 -0
- data/registry/test/components/previews/ui/progress_preview/file_upload.html.erb +36 -0
- data/registry/test/components/previews/ui/progress_preview/free_shipping.html.erb +4 -0
- data/registry/test/components/previews/ui/progress_preview/indeterminate.html.erb +4 -0
- data/registry/test/components/previews/ui/progress_preview/sizes_and_tones.html.erb +8 -0
- data/registry/test/components/previews/ui/progress_preview/steps.html.erb +9 -0
- data/registry/test/components/previews/ui/progress_preview/storage.html.erb +8 -0
- data/registry/test/components/previews/ui/progress_preview/storage_by_category.html.erb +7 -0
- data/registry/test/components/previews/ui/progress_preview/tasks_by_status.html.erb +14 -0
- data/registry/test/components/previews/ui/progress_preview/traffic_by_source.html.erb +15 -0
- data/registry/test/components/previews/ui/progress_preview.rb +46 -0
- data/registry/test/components/previews/ui/select_preview/server_search.html.erb +22 -0
- data/registry/test/components/previews/ui/select_preview.rb +5 -0
- data/registry/test/components/previews/ui/stepper_preview/approvals.html.erb +9 -0
- data/registry/test/components/previews/ui/stepper_preview/checklist.html.erb +12 -0
- data/registry/test/components/previews/ui/stepper_preview/dot_wizard.html.erb +41 -0
- data/registry/test/components/previews/ui/stepper_preview/failed_deploy.html.erb +13 -0
- data/registry/test/components/previews/ui/stepper_preview/inline.html.erb +31 -0
- data/registry/test/components/previews/ui/stepper_preview/onboarding.html.erb +12 -0
- data/registry/test/components/previews/ui/stepper_preview/order_tracking.html.erb +10 -0
- data/registry/test/components/previews/ui/stepper_preview/price_calculator.html.erb +14 -0
- data/registry/test/components/previews/ui/stepper_preview/server_driven.html.erb +20 -0
- data/registry/test/components/previews/ui/stepper_preview/sidebar.html.erb +43 -0
- data/registry/test/components/previews/ui/stepper_preview/wizard.html.erb +55 -0
- data/registry/test/components/previews/ui/stepper_preview.rb +57 -0
- data/registry/test/components/previews/ui/timeline_preview/activity_log.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/colored.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/colored_by_meaning.html.erb +7 -0
- data/registry/test/components/previews/ui/timeline_preview/failed_delivery.html.erb +6 -0
- data/registry/test/components/previews/ui/timeline_preview/order_status.html.erb +9 -0
- data/registry/test/components/previews/ui/timeline_preview/real_dates.html.erb +5 -0
- data/registry/test/components/previews/ui/timeline_preview/stock_history.html.erb +6 -0
- data/registry/test/components/previews/ui/timeline_preview.rb +40 -0
- data/registry/test/components/previews/ui/toggle_group_preview/icon_only.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview/in_form.html.erb +11 -0
- data/registry/test/components/previews/ui/toggle_group_preview/multiple.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview/outline.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview/sizes.html.erb +9 -0
- data/registry/test/components/previews/ui/toggle_group_preview/with_icons.html.erb +5 -0
- data/registry/test/components/previews/ui/toggle_group_preview.rb +36 -0
- data/registry/test/components/ui/accordion/trigger_test.rb +1 -1
- data/registry/test/components/ui/alert_test.rb +10 -10
- data/registry/test/components/ui/badge_test.rb +3 -3
- data/registry/test/components/ui/banner_test.rb +3 -3
- data/registry/test/components/ui/breadcrumb/ellipsis_test.rb +2 -2
- data/registry/test/components/ui/button_test.rb +17 -14
- data/registry/test/components/ui/button_to_test.rb +2 -2
- data/registry/test/components/ui/chart_test.rb +187 -0
- data/registry/test/components/ui/checkbox_test.rb +2 -2
- data/registry/test/components/ui/command/group_test.rb +19 -0
- data/registry/test/components/ui/command/item_test.rb +47 -0
- data/registry/test/components/ui/command_test.rb +110 -0
- data/registry/test/components/ui/confirm_dialog_test.rb +68 -0
- data/registry/test/components/ui/date_picker_test.rb +129 -111
- data/registry/test/components/ui/empty_state_test.rb +87 -0
- data/registry/test/components/ui/file_field_test.rb +105 -9
- data/registry/test/components/ui/gallery_test.rb +192 -0
- data/registry/test/components/ui/icon_test.rb +60 -20
- data/registry/test/components/ui/input_group_test.rb +1 -1
- data/registry/test/components/ui/kbd_test.rb +150 -0
- data/registry/test/components/ui/link_test.rb +3 -3
- data/registry/test/components/ui/navigation_menu_test.rb +2 -2
- data/registry/test/components/ui/number_input_test.rb +155 -0
- data/registry/test/components/ui/progress_test.rb +188 -0
- data/registry/test/components/ui/select_test.rb +62 -0
- data/registry/test/components/ui/session_tabs_test.rb +3 -3
- data/registry/test/components/ui/spinner_test.rb +9 -9
- data/registry/test/components/ui/stepper_test.rb +239 -0
- data/registry/test/components/ui/tabs/trigger_test.rb +2 -2
- data/registry/test/components/ui/theme_toggle_test.rb +6 -8
- data/registry/test/components/ui/timeline_test.rb +175 -0
- data/registry/test/components/ui/toast_test.rb +11 -10
- data/registry/test/components/ui/toggle_group_test.rb +162 -0
- metadata +399 -3
- data/registry/app/javascript/cally.ts +0 -8
- data/registry/app/javascript/velvetkit_icons.ts +0 -78
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class UI::GalleryTest < ViewComponent::TestCase
|
|
6
|
+
def setup_fixtures(*); end
|
|
7
|
+
def teardown_fixtures(*); end
|
|
8
|
+
|
|
9
|
+
def render_gallery(count: 3, **opts)
|
|
10
|
+
render_inline(UI::Gallery.new(**opts)) do |gallery|
|
|
11
|
+
count.times { |i| gallery.with_image(src: "/photo-#{i}.jpg", alt: "Photo #{i}") }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_renders_nothing_without_images
|
|
16
|
+
render_gallery(count: 0)
|
|
17
|
+
assert_no_selector "[data-slot='gallery']"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_renders_a_labelled_group_with_the_controller
|
|
21
|
+
render_gallery(label: "Mug photos")
|
|
22
|
+
assert_selector "[data-slot='gallery'][role='group'][aria-label='Mug photos'][data-controller='ui--gallery']"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_each_image_gets_a_slide_a_thumbnail_and_its_alt
|
|
26
|
+
render_gallery
|
|
27
|
+
assert_selector "[data-ui--gallery-target='slide']", count: 3
|
|
28
|
+
assert_selector "[data-ui--gallery-target='thumbnail']", count: 3
|
|
29
|
+
assert_selector "[data-ui--gallery-target='slide'] img[alt='Photo 1'][src='/photo-1.jpg']"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_only_the_first_slide_loads_with_the_page
|
|
33
|
+
render_gallery
|
|
34
|
+
slides = page.all("[data-ui--gallery-target='slide'] img").map { |img| img[:loading] }
|
|
35
|
+
assert_equal %w[eager lazy lazy], slides
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_thumbnails_are_decorative_images_in_named_buttons
|
|
39
|
+
render_gallery
|
|
40
|
+
assert_selector "button[aria-label='Show image 2'] img[alt='']"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_only_the_first_thumbnail_starts_current
|
|
44
|
+
render_gallery
|
|
45
|
+
assert_selector "[data-ui--gallery-target='thumbnail'][aria-current='true']", count: 1
|
|
46
|
+
assert_selector "button[aria-label='Show image 1'][aria-current='true']"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_thumbnail_src_and_zoom_src_are_used_where_given
|
|
50
|
+
render_inline(UI::Gallery.new) do |gallery|
|
|
51
|
+
gallery.with_image(src: "/m.jpg", alt: "A", zoom_src: "/large.jpg", thumbnail_src: "/small.jpg")
|
|
52
|
+
gallery.with_image(src: "/n.jpg", alt: "B")
|
|
53
|
+
end
|
|
54
|
+
assert_selector "button[aria-label='Show image 1'] img[src='/small.jpg']"
|
|
55
|
+
assert_selector "[data-ui--gallery-target='slide'][data-zoom-src='/large.jpg']"
|
|
56
|
+
assert_selector "button[aria-label='Show image 2'] img[src='/n.jpg']"
|
|
57
|
+
assert_selector "[data-ui--gallery-target='slide'][data-zoom-src='/n.jpg']"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_the_large_image_is_not_asked_for_until_opened
|
|
61
|
+
render_inline(UI::Gallery.new) { |gallery| gallery.with_image(src: "/m.jpg", alt: "A", zoom_src: "/large.jpg") }
|
|
62
|
+
assert_no_selector "img[src='/large.jpg']", visible: :all
|
|
63
|
+
assert_no_selector "dialog img[src]", visible: :all
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_clicking_a_slide_opens_it_at_its_index
|
|
67
|
+
render_gallery
|
|
68
|
+
button = page.find("button[aria-label='Zoom image 2: Photo 1']")
|
|
69
|
+
assert_equal "ui--gallery#open", button["data-action"]
|
|
70
|
+
assert_equal "1", button["data-ui--gallery-index-param"]
|
|
71
|
+
assert_equal "button", button[:type]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_only_the_image_showing_is_a_tab_stop
|
|
75
|
+
render_gallery
|
|
76
|
+
stops = page.all("[data-ui--gallery-target='slide'] button").map { |button| button[:tabindex] }
|
|
77
|
+
assert_equal %w[0 -1 -1], stops
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_overlay_is_just_the_image_on_a_transparent_backdrop
|
|
81
|
+
render_gallery
|
|
82
|
+
dialog = page.find("dialog", visible: :all)
|
|
83
|
+
assert_includes dialog[:class], "bg-transparent"
|
|
84
|
+
assert_includes dialog[:class], "backdrop:bg-black/80"
|
|
85
|
+
assert_selector "dialog img", count: 1, visible: :all
|
|
86
|
+
assert_no_selector "dialog [data-ui--gallery-target='thumbnail']", visible: :all
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_escape_goes_through_the_closing_animation
|
|
90
|
+
render_gallery
|
|
91
|
+
assert_includes page.find("dialog", visible: :all)["data-action"], "cancel->ui--gallery#cancel"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_overlay_buttons_sit_in_the_top_corners_and_at_the_ends
|
|
95
|
+
render_gallery
|
|
96
|
+
assert_selector "dialog .start-4.top-4 button[aria-label='Zoom in']", visible: :all
|
|
97
|
+
assert_selector "dialog .start-4.top-4 button[aria-label='Zoom out']", visible: :all
|
|
98
|
+
assert_selector "dialog button.end-4.top-4[aria-label='Close']", visible: :all
|
|
99
|
+
assert_selector "dialog button.start-4.top-1\\/2[aria-label='Previous image']", visible: :all
|
|
100
|
+
assert_selector "dialog button.end-4.top-1\\/2[aria-label='Next image']", visible: :all
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_overlay_is_the_default_with_no_hover_zoom
|
|
104
|
+
render_gallery
|
|
105
|
+
assert_selector "[data-slot='gallery'][data-zoom='overlay']"
|
|
106
|
+
assert_no_selector "[data-ui--gallery-target='lens']", visible: :all
|
|
107
|
+
assert_no_selector "[data-ui--gallery-target='pane']", visible: :all
|
|
108
|
+
assert_equal "ui--gallery#open", page.find("button[aria-label='Zoom image 1: Photo 0']")["data-action"]
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_hover_zoom_adds_a_lens_and_pane_and_still_opens_the_overlay_on_click
|
|
112
|
+
render_gallery(zoom: :hover)
|
|
113
|
+
assert_selector "[data-slot='gallery'][data-zoom='hover'][data-ui--gallery-zoom-scale-value='2.5']"
|
|
114
|
+
assert_selector "[data-ui--gallery-target='lens'].invisible[aria-hidden='true']", visible: :all
|
|
115
|
+
assert_selector "[data-ui--gallery-target='pane'].invisible[aria-hidden='true']", visible: :all
|
|
116
|
+
assert_no_selector "[data-ui--gallery-target='pane'][data-shown]", visible: :all
|
|
117
|
+
action = page.find("button[aria-label='Zoom image 1: Photo 0']")["data-action"]
|
|
118
|
+
assert_includes action, "ui--gallery#open"
|
|
119
|
+
assert_includes action, "pointermove->ui--gallery#hover"
|
|
120
|
+
assert_includes action, "pointerleave->ui--gallery#hoverEnd"
|
|
121
|
+
assert_selector "dialog", visible: :all
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_zoom_scale_can_be_set
|
|
125
|
+
render_gallery(zoom: :hover, zoom_scale: 4)
|
|
126
|
+
assert_selector "[data-ui--gallery-zoom-scale-value='4']"
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_unknown_zoom_falls_back_to_overlay
|
|
130
|
+
render_gallery(zoom: :spin)
|
|
131
|
+
assert_selector "[data-slot='gallery'][data-zoom='overlay']"
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_overlay_is_a_named_dialog_with_its_controls
|
|
135
|
+
render_gallery
|
|
136
|
+
assert_selector "dialog[aria-label='Zoomed image'][data-ui--gallery-target='dialog']", visible: :all
|
|
137
|
+
assert_selector "dialog button[aria-label='Zoom in'][data-action='ui--gallery#zoomIn']", visible: :all
|
|
138
|
+
assert_selector "dialog button[aria-label='Zoom out'][data-action='ui--gallery#zoomOut']", visible: :all
|
|
139
|
+
assert_selector "dialog button[aria-label='Close'][data-action='ui--gallery#close']", visible: :all
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_arrows_in_both_views
|
|
143
|
+
render_gallery
|
|
144
|
+
assert_selector "button[aria-label='Previous image'][data-action='ui--gallery#previous']", count: 2, visible: :all
|
|
145
|
+
assert_selector "button[aria-label='Next image'][data-action='ui--gallery#next']", count: 2, visible: :all
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def test_a_single_image_has_no_thumbnails_or_arrows_but_still_zooms
|
|
149
|
+
render_gallery(count: 1)
|
|
150
|
+
assert_no_selector "[data-ui--gallery-target='thumbnail']"
|
|
151
|
+
assert_no_selector "button[aria-label='Next image']", visible: :all
|
|
152
|
+
assert_selector "button[aria-label='Zoom image 1: Photo 0']"
|
|
153
|
+
assert_selector "dialog", visible: :all
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_status_says_where_you_are
|
|
157
|
+
render_gallery
|
|
158
|
+
assert_selector "[data-ui--gallery-target='status'][aria-live='polite']", text: "Image 1 of 3"
|
|
159
|
+
assert_equal "Image %{current} of %{total}", page.find("[data-slot='gallery']")["data-ui--gallery-position-value"]
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def test_aspect_and_fit
|
|
163
|
+
{ square: "aspect-square", landscape: "aspect-video" }.each do |aspect, css|
|
|
164
|
+
render_gallery(aspect: aspect)
|
|
165
|
+
assert_selector "[data-ui--gallery-target='slide'].#{css}", count: 3
|
|
166
|
+
end
|
|
167
|
+
render_gallery(fit: :cover)
|
|
168
|
+
assert_selector "[data-ui--gallery-target='slide'] img.object-cover", count: 3
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def test_unknown_aspect_and_fit_fall_back
|
|
172
|
+
render_gallery(aspect: :round, fit: :stretch)
|
|
173
|
+
assert_selector "[data-ui--gallery-target='slide'].aspect-square img.object-contain", count: 3
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def test_buttons_keep_the_kits_focus_ring
|
|
177
|
+
render_gallery
|
|
178
|
+
assert_selector "button[aria-label='Show image 1'].focus\\:ring-primary"
|
|
179
|
+
assert_selector "button[aria-label='Next image'].focus\\:ring-primary", count: 1, visible: :all
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def test_overlay_buttons_ring_in_white_to_show_on_the_dark_backdrop
|
|
183
|
+
render_gallery
|
|
184
|
+
assert_selector "dialog button[aria-label='Next image'].focus\\:ring-white", visible: :all
|
|
185
|
+
assert_selector "dialog button[aria-label='Close'].focus\\:ring-white", visible: :all
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def test_class_and_html_attributes_pass_through
|
|
189
|
+
render_gallery(class: "max-w-md", id: "photos", data: { foo: "bar" })
|
|
190
|
+
assert_selector "#photos.max-w-md[data-foo='bar'][data-controller='ui--gallery']"
|
|
191
|
+
end
|
|
192
|
+
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
|
|
10
|
-
render_inline UI::Icon.new(name: "
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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("
|
|
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("
|
|
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("
|
|
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("
|
|
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 "
|
|
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 "
|
|
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
|
-
|
|
72
|
-
assert_equal "header-menu",
|
|
73
|
-
assert_equal "Open menu",
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
assert_equal "idle",
|
|
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']
|
|
132
|
+
assert_selector "[data-slot='input-group-addon'] svg[data-icon='mail']"
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
def test_multiple_addons
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_helper"
|
|
4
|
+
|
|
5
|
+
class UI::KbdTest < ViewComponent::TestCase
|
|
6
|
+
def setup_fixtures(*); end
|
|
7
|
+
def teardown_fixtures(*); end
|
|
8
|
+
|
|
9
|
+
MAC = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/130.0 Safari/537.36"
|
|
10
|
+
WINDOWS = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/130.0 Safari/537.36"
|
|
11
|
+
LINUX = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/130.0 Safari/537.36"
|
|
12
|
+
ANDROID = "Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 Chrome/130.0 Mobile Safari/537.36"
|
|
13
|
+
CHROME_OS = "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 Chrome/130.0 Safari/537.36"
|
|
14
|
+
|
|
15
|
+
def render_kbd(*args, agent: WINDOWS, **opts, &block)
|
|
16
|
+
vc_test_request.user_agent = agent
|
|
17
|
+
render_inline(UI::Kbd.new(*args, **opts), &block)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_a_letter_on_its_own_is_lowercase_since_that_is_what_you_type
|
|
21
|
+
render_kbd("K")
|
|
22
|
+
assert_selector "kbd[data-slot='kbd'][data-controller='ui--kbd'] > span > kbd", exact_text: "k"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_a_letter_with_a_modifier_is_a_capital_and_shift_is_written_out
|
|
26
|
+
render_kbd("mod+k")
|
|
27
|
+
assert_selector "kbd", exact_text: "K"
|
|
28
|
+
render_kbd("shift+g")
|
|
29
|
+
assert_selector "span.sr-only", text: "Shift", visible: :all
|
|
30
|
+
assert_selector "kbd", exact_text: "G"
|
|
31
|
+
render_kbd("alt+n")
|
|
32
|
+
assert_selector "kbd", exact_text: "N"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_guesses_the_platform_from_the_user_agent
|
|
36
|
+
render_kbd("mod+k", agent: MAC)
|
|
37
|
+
assert_selector "[data-slot='kbd'][data-platform='mac']"
|
|
38
|
+
render_kbd("mod+k", agent: WINDOWS)
|
|
39
|
+
assert_selector "[data-slot='kbd'][data-platform='other']"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_linux_is_its_own_platform_but_not_android_or_chrome_os
|
|
43
|
+
{ LINUX => "linux", ANDROID => "other", CHROME_OS => "other" }.each do |agent, platform|
|
|
44
|
+
render_kbd("mod+k", agent: agent)
|
|
45
|
+
assert_selector "[data-slot='kbd'][data-platform='#{platform}']"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_the_windows_key_is_super_on_linux
|
|
50
|
+
render_kbd("cmd+l", agent: LINUX)
|
|
51
|
+
linux = page.find("kbd.hidden.group-data-\\[platform\\=linux\\]\\/kbd\\:inline-flex", visible: :all)
|
|
52
|
+
assert_equal "Super", linux.text(:all)
|
|
53
|
+
other = page.find("kbd.group-data-\\[platform\\=linux\\]\\/kbd\\:hidden", visible: :all)
|
|
54
|
+
assert_equal "Win", other.find("span[aria-hidden]", visible: :all).text(:all)
|
|
55
|
+
assert_includes other[:class], "group-data-[platform=mac]/kbd:hidden"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_other_keys_show_the_same_on_linux_as_on_windows
|
|
59
|
+
render_kbd("mod+alt+k", agent: LINUX)
|
|
60
|
+
assert_no_selector "kbd.group-data-\\[platform\\=linux\\]\\/kbd\\:inline-flex", visible: :all
|
|
61
|
+
assert_selector "kbd.group-data-\\[platform\\=mac\\]\\/kbd\\:hidden", text: "Ctrl"
|
|
62
|
+
assert_selector "kbd.group-data-\\[platform\\=mac\\]\\/kbd\\:hidden", text: "Alt"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_mod_is_command_on_a_mac_and_ctrl_elsewhere_shown_by_platform
|
|
66
|
+
render_kbd("mod+k")
|
|
67
|
+
mac = page.find("kbd.hidden", visible: :all)
|
|
68
|
+
assert_includes mac[:class], "group-data-[platform=mac]/kbd:inline-flex"
|
|
69
|
+
assert_equal "⌘", mac.find("span[aria-hidden]", visible: :all).text(:all)
|
|
70
|
+
assert_equal "Command", mac.find("span.sr-only", visible: :all).text(:all)
|
|
71
|
+
other = page.find("kbd.group-data-\\[platform\\=mac\\]\\/kbd\\:hidden")
|
|
72
|
+
assert_equal "Ctrl", other.find("span[aria-hidden]").text
|
|
73
|
+
assert_equal "Control", other.find("span.sr-only", visible: :all).text(:all)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_a_plus_between_keys_only_off_a_mac
|
|
77
|
+
render_kbd("ctrl+shift+p")
|
|
78
|
+
assert_selector "span[aria-hidden='true'].group-data-\\[platform\\=mac\\]\\/kbd\\:hidden", text: "+", count: 2
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_symbols_carry_their_names_for_screen_readers
|
|
82
|
+
render_kbd("shift+enter")
|
|
83
|
+
assert_selector "span.sr-only", text: "Shift", visible: :all
|
|
84
|
+
assert_selector "span.sr-only", text: "Return", visible: :all
|
|
85
|
+
assert_selector "kbd", text: "Enter"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_aliases_and_keys_that_read_the_same_everywhere
|
|
89
|
+
render_kbd("escape")
|
|
90
|
+
assert_equal [ "Esc" ], page.all("[data-slot='kbd'] kbd span[aria-hidden]").map(&:text)
|
|
91
|
+
assert_selector "span.sr-only", text: "Escape", visible: :all, count: 1
|
|
92
|
+
render_kbd("space")
|
|
93
|
+
assert_selector "[data-slot='kbd'] kbd", text: "Space"
|
|
94
|
+
assert_no_selector "span.sr-only", visible: :all
|
|
95
|
+
render_kbd("option+up")
|
|
96
|
+
assert_selector "span.sr-only", text: "Option", visible: :all
|
|
97
|
+
assert_selector "kbd", text: "Alt"
|
|
98
|
+
assert_selector "span.sr-only", text: "Up Arrow", visible: :all, count: 1
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_other_keys_are_shown_as_written
|
|
102
|
+
render_kbd("F5")
|
|
103
|
+
assert_selector "kbd > span > kbd", text: "F5"
|
|
104
|
+
render_kbd("/")
|
|
105
|
+
assert_selector "kbd > span > kbd", text: "/"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_a_sequence_says_then_between_its_steps
|
|
109
|
+
render_kbd(%w[g i])
|
|
110
|
+
assert_selector "[data-slot='kbd'] > span", text: "then"
|
|
111
|
+
assert_equal %w[g i], page.all("[data-slot='kbd'] kbd").map(&:text)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_a_written_key_is_shown_as_given
|
|
115
|
+
render_kbd { "Fn" }
|
|
116
|
+
assert_selector "[data-slot='kbd'] > kbd", text: "Fn"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_sizes
|
|
120
|
+
render_kbd("k", size: :lg)
|
|
121
|
+
assert_selector "kbd kbd.h-6.text-sm"
|
|
122
|
+
render_kbd("k", size: :nonsense)
|
|
123
|
+
assert_selector "kbd kbd.h-5.text-xs"
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_takes_its_colour_from_the_text_around_it
|
|
127
|
+
render_kbd("k")
|
|
128
|
+
assert_selector "[data-slot='kbd'].text-current\\/80"
|
|
129
|
+
assert_selector "kbd kbd.border-current\\/15"
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_binding_hands_the_shortcut_to_the_controller
|
|
133
|
+
render_kbd("mod+s", bind: true)
|
|
134
|
+
assert_selector "[data-ui--kbd-keys-value='mod+s'][data-ui--kbd-target-value='']"
|
|
135
|
+
render_kbd("mod+s", bind: "#save")
|
|
136
|
+
assert_selector "[data-ui--kbd-keys-value='mod+s'][data-ui--kbd-target-value='#save']"
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def test_a_sequence_or_an_unbound_hint_is_not_bound
|
|
140
|
+
render_kbd(%w[g i], bind: true)
|
|
141
|
+
assert_no_selector "[data-ui--kbd-keys-value]"
|
|
142
|
+
render_kbd("mod+s")
|
|
143
|
+
assert_no_selector "[data-ui--kbd-keys-value]"
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_passes_class_and_attributes_through
|
|
147
|
+
render_kbd("k", class: "ms-auto", id: "hint", data: { testid: "kbd" })
|
|
148
|
+
assert_selector "kbd#hint.ms-auto[data-testid='kbd'][data-controller='ui--kbd']"
|
|
149
|
+
end
|
|
150
|
+
end
|
|
@@ -79,8 +79,8 @@ class UI::LinkTest < ViewComponent::TestCase
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
anchor = page.find("a", text: "Continue")
|
|
82
|
-
|
|
83
|
-
assert_match(/<
|
|
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.*<
|
|
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-
|
|
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-
|
|
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
|