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
|
@@ -2,43 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
require "securerandom"
|
|
4
4
|
|
|
5
|
-
# UI::FileField — a drag-and-drop dropzone over a native file input
|
|
5
|
+
# UI::FileField — a drag-and-drop dropzone over a native file input, with
|
|
6
|
+
# previews of what's chosen and, optionally, uploads straight to storage.
|
|
6
7
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
8
|
+
# <%= render(UI::FileField.new(form: f, field: :photos, multiple: true, accept: "image/*",
|
|
9
|
+
# max_size: 5.megabytes, direct_upload: true)) %>
|
|
10
|
+
#
|
|
11
|
+
# The input itself is sr-only, not hidden: it stays in the accessibility tree,
|
|
12
|
+
# and keyboard and the system file dialog come from the real
|
|
13
|
+
# <input type="file">. The dropzone is a <label> around it, so clicking
|
|
14
|
+
# anywhere in it opens the picker with no JavaScript.
|
|
15
|
+
#
|
|
16
|
+
# Each chosen file shows as a tile: a thumbnail for an image, an icon for
|
|
17
|
+
# anything else, its name and size, and a button to take it out again.
|
|
18
|
+
# `accept:` and `max_size:` (bytes) are checked as files are added, dropped
|
|
19
|
+
# ones included, and a file that fails says why instead of being sent.
|
|
20
|
+
# `preview: false` goes back to listing the names under the dropzone.
|
|
21
|
+
#
|
|
22
|
+
# `direct_upload: true` sends each file to storage the moment it's chosen,
|
|
23
|
+
# through Active Storage's direct uploads, with a progress bar on its tile; the
|
|
24
|
+
# form then submits only the uploaded files' signed ids, so a big photo never
|
|
25
|
+
# holds up the form. Sending the form while files are still uploading waits
|
|
26
|
+
# for them, then sends. It needs Active Storage's JavaScript and, for a bucket
|
|
27
|
+
# such as Cloudflare R2 or S3, CORS rules allowing PUT from your site.
|
|
28
|
+
#
|
|
29
|
+
# Bound to a form, the record's current attachments show as tiles too, kept by
|
|
30
|
+
# their signed ids, so removing a tile and saving removes that file.
|
|
14
31
|
class UI::FileField < UI::Base
|
|
15
|
-
def initialize(multiple: false, accept: nil,
|
|
32
|
+
def initialize(multiple: false, accept: nil, preview: true, direct_upload: false, max_size: nil,
|
|
16
33
|
label: nil, label_size: :default, label_weight: :medium,
|
|
17
34
|
hint: nil, required: false, error: nil, disabled: false,
|
|
18
|
-
form: nil, field: nil,
|
|
35
|
+
form: nil, field: nil, existing: nil,
|
|
19
36
|
class: nil, **html_attrs)
|
|
20
|
-
@form
|
|
21
|
-
@field
|
|
22
|
-
@multiple
|
|
23
|
-
@accept
|
|
24
|
-
@
|
|
25
|
-
@
|
|
26
|
-
@
|
|
27
|
-
@
|
|
28
|
-
@
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@
|
|
37
|
+
@form = form
|
|
38
|
+
@field = field
|
|
39
|
+
@multiple = multiple
|
|
40
|
+
@accept = accept
|
|
41
|
+
@preview = preview
|
|
42
|
+
@direct_upload = direct_upload
|
|
43
|
+
@max_size = max_size
|
|
44
|
+
@existing = existing
|
|
45
|
+
@required = required
|
|
46
|
+
@disabled = disabled
|
|
47
|
+
@user_class = binding.local_variable_get(:class)
|
|
48
|
+
@html_attrs = html_attrs
|
|
49
|
+
@wrapper = UI::FormField.new(label: label, hint: hint, error: error,
|
|
50
|
+
required: required, disabled: disabled,
|
|
51
|
+
label_size: label_size, label_weight: label_weight,
|
|
52
|
+
form: form, field: field)
|
|
53
|
+
@input_id = @html_attrs[:id] || "ui-file-field-#{SecureRandom.hex(4)}"
|
|
33
54
|
@html_attrs[:id] = @input_id
|
|
34
55
|
@wrapper.for = @input_id
|
|
35
56
|
end
|
|
36
57
|
|
|
37
58
|
attr_reader :wrapper
|
|
38
59
|
|
|
39
|
-
def form_field?
|
|
40
|
-
|
|
41
|
-
|
|
60
|
+
def form_field? = @form.present? && @field.present?
|
|
61
|
+
def preview? = @preview
|
|
62
|
+
def direct_upload? = @direct_upload
|
|
42
63
|
|
|
43
64
|
def dropzone_classes
|
|
44
65
|
cn(
|
|
@@ -51,6 +72,20 @@ class UI::FileField < UI::Base
|
|
|
51
72
|
)
|
|
52
73
|
end
|
|
53
74
|
|
|
75
|
+
def root_data
|
|
76
|
+
{ controller: "ui--file-field",
|
|
77
|
+
"ui--file-field-preview-value": preview?,
|
|
78
|
+
"ui--file-field-direct-upload-value": direct_upload?,
|
|
79
|
+
"ui--file-field-url-value": (direct_upload_url if direct_upload?),
|
|
80
|
+
"ui--file-field-name-value": signed_id_name,
|
|
81
|
+
"ui--file-field-multiple-value": @multiple,
|
|
82
|
+
"ui--file-field-accept-value": @accept,
|
|
83
|
+
"ui--file-field-max-size-value": @max_size,
|
|
84
|
+
"ui--file-field-required-value": @required,
|
|
85
|
+
"ui--file-field-labels-value": labels.to_json,
|
|
86
|
+
action: "dragover->ui--file-field#dragOver dragleave->ui--file-field#dragLeave drop->ui--file-field#drop" }.compact
|
|
87
|
+
end
|
|
88
|
+
|
|
54
89
|
def html_options
|
|
55
90
|
opts = @html_attrs.dup
|
|
56
91
|
opts[:type] = "file"
|
|
@@ -58,9 +93,10 @@ class UI::FileField < UI::Base
|
|
|
58
93
|
opts[:multiple] = true if @multiple
|
|
59
94
|
opts[:accept] = @accept if @accept
|
|
60
95
|
opts[:disabled] = true if @disabled
|
|
61
|
-
|
|
96
|
+
# A file already kept satisfies `required`; the controller keeps this in step.
|
|
97
|
+
opts[:required] = true if @required && existing_files.empty?
|
|
62
98
|
opts[:"data-ui--file-field-target"] = "input"
|
|
63
|
-
opts[:"data-action"] = "change->ui--file-field#
|
|
99
|
+
opts[:"data-action"] = "change->ui--file-field#chosen"
|
|
64
100
|
opts[:"aria-invalid"] = "true" if wrapper.error?
|
|
65
101
|
opts[:"aria-describedby"] = wrapper.describedby if wrapper.describedby
|
|
66
102
|
opts
|
|
@@ -70,4 +106,119 @@ class UI::FileField < UI::Base
|
|
|
70
106
|
def form_field_options
|
|
71
107
|
html_options.except(:name, :type)
|
|
72
108
|
end
|
|
109
|
+
|
|
110
|
+
# ── Kept and uploaded files ──────────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
# Where a kept or uploaded file's signed id is posted: the field's own
|
|
113
|
+
# name, so Active Storage takes it like an upload.
|
|
114
|
+
def signed_id_name
|
|
115
|
+
name = form_field? ? "#{@form.object_name}[#{@field}]" : @html_attrs[:name].to_s
|
|
116
|
+
return name if name.empty?
|
|
117
|
+
|
|
118
|
+
@multiple && !name.end_with?("[]") ? "#{name}[]" : name
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# The record's current attachments, or `existing:`: anything with a
|
|
122
|
+
# signed_id, filename, byte_size and content_type.
|
|
123
|
+
def existing_files
|
|
124
|
+
return [] unless preview?
|
|
125
|
+
|
|
126
|
+
@existing_files ||= Array(@existing.nil? ? bound_attachments : @existing).map do |file|
|
|
127
|
+
{ signed_id: file.signed_id, name: file.filename.to_s, size: file.byte_size,
|
|
128
|
+
image: file.content_type.to_s.start_with?("image/"), url: file_url(file) }
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def human_size(bytes) = ActiveSupport::NumberHelper.number_to_human_size(bytes)
|
|
133
|
+
|
|
134
|
+
def labels
|
|
135
|
+
{ remove: t("ui.file_field.remove", default: "Remove %{name}"),
|
|
136
|
+
uploading: t("ui.file_field.uploading", default: "Uploading…"),
|
|
137
|
+
uploaded: t("ui.file_field.uploaded", default: "Uploaded"),
|
|
138
|
+
failed: t("ui.file_field.failed", default: "Upload failed"),
|
|
139
|
+
retry: t("ui.file_field.retry", default: "Try again"),
|
|
140
|
+
too_big: t("ui.file_field.too_big", default: "Too big: %{max} at most"),
|
|
141
|
+
max: (human_size(@max_size) if @max_size),
|
|
142
|
+
wrong_type: t("ui.file_field.wrong_type", default: "Not a file this field takes"),
|
|
143
|
+
waiting: t("ui.file_field.waiting", default: "Waiting for the uploads to finish…"),
|
|
144
|
+
added: t("ui.file_field.added", default: "%{name} added"),
|
|
145
|
+
removed: t("ui.file_field.removed", default: "%{name} removed"),
|
|
146
|
+
units: storage_units }
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def tile_classes
|
|
150
|
+
"group relative flex min-w-0 flex-col overflow-hidden rounded-lg border bg-card text-card-foreground " \
|
|
151
|
+
"data-[state=error]:border-destructive"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# One file: its thumbnail or an icon, a button to take it out, a progress
|
|
155
|
+
# bar for an upload, its name and size, and the signed id that keeps it. The
|
|
156
|
+
# controller fills in a blank one for each file chosen.
|
|
157
|
+
def tile(name: "", size: nil, url: nil, image: false, signed_id: nil, state: "kept")
|
|
158
|
+
thumb = image && url.present?
|
|
159
|
+
tag.li(class: tile_classes, data: { "ui--file-field-target": "item", state: state }) do
|
|
160
|
+
safe_join([
|
|
161
|
+
tag.div(class: "relative aspect-square bg-muted") do
|
|
162
|
+
safe_join([
|
|
163
|
+
tag.img(src: url, alt: "", class: "size-full object-cover", hidden: !thumb, data: { role: "thumb" }),
|
|
164
|
+
tag.span(render(UI::Icon.new(name: "file", size: :lg)), hidden: thumb, data: { role: "icon" },
|
|
165
|
+
class: "absolute inset-0 flex items-center justify-center text-muted-foreground"),
|
|
166
|
+
tag.button(render(UI::Icon.new(name: "x", size: :xs)), type: "button",
|
|
167
|
+
aria: { label: labels[:remove].sub("%{name}", name.to_s) },
|
|
168
|
+
class: "absolute end-1.5 top-1.5 flex size-6 items-center justify-center rounded-full border bg-background/90 " \
|
|
169
|
+
"text-foreground shadow-sm hover:bg-background #{UI::Base::FOCUS_RING}",
|
|
170
|
+
data: { action: "ui--file-field#remove", role: "remove" }),
|
|
171
|
+
tag.div(tag.div(class: "h-full w-0 bg-primary transition-[width] duration-200", data: { role: "bar" }),
|
|
172
|
+
hidden: true, role: "progressbar", aria: { valuemin: 0, valuemax: 100, label: name },
|
|
173
|
+
class: "absolute inset-x-0 bottom-0 h-1 bg-foreground/10", data: { role: "progress" })
|
|
174
|
+
])
|
|
175
|
+
end,
|
|
176
|
+
tag.div(class: "min-w-0 p-2") do
|
|
177
|
+
safe_join([
|
|
178
|
+
tag.p(name, title: name, class: "truncate text-xs font-medium", data: { role: "name" }),
|
|
179
|
+
tag.p(size ? human_size(size) : "", class: "line-clamp-2 text-xs text-muted-foreground group-data-[state=error]:text-destructive",
|
|
180
|
+
data: { role: "meta" }),
|
|
181
|
+
tag.button(labels[:retry], type: "button", hidden: true, data: { action: "ui--file-field#retry", role: "retry" },
|
|
182
|
+
class: "mt-1 rounded-sm text-xs font-medium text-primary underline-offset-4 hover:underline #{UI::Base::FOCUS_RING}")
|
|
183
|
+
])
|
|
184
|
+
end,
|
|
185
|
+
(tag.input(type: "hidden", name: signed_id_name, value: signed_id, data: { role: "signed" }) if signed_id)
|
|
186
|
+
])
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
private
|
|
191
|
+
|
|
192
|
+
# The units Rails' number_to_human_size uses, so a size written in the
|
|
193
|
+
# browser matches the ones written here.
|
|
194
|
+
def storage_units
|
|
195
|
+
units = I18n.t("number.human.storage_units.units", default: {})
|
|
196
|
+
{ byte: (units[:byte].is_a?(Hash) ? units[:byte][:other] : units[:byte]) || "Bytes",
|
|
197
|
+
kb: units[:kb] || "KB", mb: units[:mb] || "MB", gb: units[:gb] || "GB" }
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def bound_attachments
|
|
201
|
+
return [] unless form_field? && @form.object.respond_to?(@field)
|
|
202
|
+
|
|
203
|
+
value = @form.object.public_send(@field)
|
|
204
|
+
if value.respond_to?(:attachments) then value.attachments
|
|
205
|
+
elsif value.respond_to?(:attached?) && value.attached? then [ value.attachment ]
|
|
206
|
+
else []
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# An Active Storage file is shown through the app's blob route; anything
|
|
211
|
+
# else passed as `existing:` brings its own url.
|
|
212
|
+
def file_url(file)
|
|
213
|
+
if defined?(ActiveStorage::Attachment) && file.is_a?(ActiveStorage::Attachment)
|
|
214
|
+
helpers.main_app.rails_blob_path(file)
|
|
215
|
+
else
|
|
216
|
+
file.try(:url)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def direct_upload_url
|
|
221
|
+
routes = helpers.respond_to?(:main_app) ? helpers.main_app : helpers
|
|
222
|
+
routes.respond_to?(:rails_direct_uploads_url) ? routes.rails_direct_uploads_url : "/rails/active_storage/direct_uploads"
|
|
223
|
+
end
|
|
73
224
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# One image in a UI::Gallery. Holds what the gallery needs to draw it in three
|
|
4
|
+
# places (the main view, its thumbnail and the zoomed view); it draws nothing
|
|
5
|
+
# itself.
|
|
6
|
+
class UI::Gallery::Image < UI::Base
|
|
7
|
+
attr_reader :src, :alt
|
|
8
|
+
|
|
9
|
+
def initialize(src:, alt:, zoom_src: nil, thumbnail_src: nil)
|
|
10
|
+
@src = src
|
|
11
|
+
@alt = alt
|
|
12
|
+
@zoom_src = zoom_src
|
|
13
|
+
@thumbnail_src = thumbnail_src
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def zoom_src = @zoom_src || @src
|
|
17
|
+
def thumbnail_src = @thumbnail_src || @src
|
|
18
|
+
|
|
19
|
+
def call = nil
|
|
20
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<%= tag.div(**root_attrs) do %>
|
|
2
|
+
<%= tag.div class: "relative min-w-0" do %>
|
|
3
|
+
<%= tag.ul class: track_classes, data: { "ui--gallery-target": "track", action: "scroll->ui--gallery#scrolled pointerdown->ui--gallery#released" } do %>
|
|
4
|
+
<% images.each_with_index do |image, index| %>
|
|
5
|
+
<%= tag.li class: slide_classes, data: { "ui--gallery-target": "slide", zoom_src: asset_path(image.zoom_src), alt: image.alt } do %>
|
|
6
|
+
<%= tag.button(**slide_button_attrs(image, index)) do %>
|
|
7
|
+
<%= render(UI::Image.new(src: image.src, alt: image.alt, rounded: :none, loading: image_loading(index), class: image_classes, draggable: "false")) %>
|
|
8
|
+
<%= tag.span class: "pointer-events-none absolute end-2 top-2 flex rounded-full bg-background/90 p-1.5 text-foreground", aria: { hidden: true } do %><%= render(UI::Icon.new(name: "zoom-in", size: :sm)) %><% end %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% if hover_zoom? %>
|
|
14
|
+
<%= tag.div aria: { hidden: true }, class: cn(UI::Gallery::HOVER_REVEAL, "left-0 top-0 z-10 rounded-sm border border-primary/50 bg-primary/15"), data: { "ui--gallery-target": "lens" } %>
|
|
15
|
+
<%= tag.div aria: { hidden: true }, class: cn(UI::Gallery::HOVER_REVEAL, "start-full top-0 z-50 ms-4 origin-[0_50%] scale-95 overflow-hidden rounded-lg border bg-background bg-no-repeat shadow-lg data-[inside]:start-0 data-[inside]:ms-0 data-[shown]:scale-100 rtl:origin-[100%_50%]"), data: { "ui--gallery-target": "pane" } %>
|
|
16
|
+
<% end %>
|
|
17
|
+
<% if multiple? %>
|
|
18
|
+
<%= render(UI::Button.new(**nav_button_attrs(:previous))) do %><%= render(UI::Icon.new(name: "chevron-left", size: :sm, class: "rtl:rotate-180")) %><% end %>
|
|
19
|
+
<%= render(UI::Button.new(**nav_button_attrs(:next))) do %><%= render(UI::Icon.new(name: "chevron-right", size: :sm, class: "rtl:rotate-180")) %><% end %>
|
|
20
|
+
<% end %>
|
|
21
|
+
<% end %>
|
|
22
|
+
<%= tag.p position_text, class: "sr-only", aria: { live: "polite" }, data: { "ui--gallery-target": "status" } %>
|
|
23
|
+
<% if multiple? %>
|
|
24
|
+
<%= tag.ul class: thumbnail_strip_classes do %>
|
|
25
|
+
<% images.each_with_index do |image, index| %>
|
|
26
|
+
<li class="shrink-0"><%= tag.button(**thumbnail_attrs(index)) do %><%= render(UI::Image.new(src: image.thumbnail_src, alt: "", rounded: :none, class: "size-full object-cover", draggable: "false")) %><% end %></li>
|
|
27
|
+
<% end %>
|
|
28
|
+
<% end %>
|
|
29
|
+
<% end %>
|
|
30
|
+
<%= tag.dialog class: dialog_classes, tabindex: -1,
|
|
31
|
+
aria: { label: t("ui.gallery.dialog", default: "Zoomed image") },
|
|
32
|
+
data: { "ui--gallery-target": "dialog", action: "close->ui--gallery#closed cancel->ui--gallery#cancel" } do %>
|
|
33
|
+
<%= tag.div class: viewport_classes,
|
|
34
|
+
data: { "ui--gallery-target": "viewport",
|
|
35
|
+
action: "click->ui--gallery#viewportClick pointerdown->ui--gallery#panStart pointermove->ui--gallery#panMove " \
|
|
36
|
+
"pointerup->ui--gallery#panEnd pointercancel->ui--gallery#panEnd wheel->ui--gallery#wheel" } do %>
|
|
37
|
+
<%= tag.img alt: "", draggable: "false",
|
|
38
|
+
class: "m-auto max-w-none shrink-0 cursor-zoom-in select-none group-data-[zoomed]/viewport:cursor-grab",
|
|
39
|
+
data: { "ui--gallery-target": "zoomImage", action: "load->ui--gallery#layout" } %>
|
|
40
|
+
<% end %>
|
|
41
|
+
<%= tag.p position_text, class: "sr-only", aria: { live: "polite" }, data: { "ui--gallery-target": "zoomStatus" } %>
|
|
42
|
+
<%= tag.div class: "absolute start-4 top-4 z-10 flex gap-2" do %>
|
|
43
|
+
<%= render(UI::Button.new(**zoom_button_attrs(:out, "Zoom out"))) do %><%= render(UI::Icon.new(name: "zoom-out", size: :sm)) %><% end %>
|
|
44
|
+
<%= render(UI::Button.new(**zoom_button_attrs(:in, "Zoom in"))) do %><%= render(UI::Icon.new(name: "zoom-in", size: :sm)) %><% end %>
|
|
45
|
+
<% end %>
|
|
46
|
+
<%= render(UI::Button.new(variant: :ghost, size: :icon, class: cn(UI::Gallery::OVERLAY_BUTTON, "absolute end-4 top-4 z-10"), aria: { label: t("ui.gallery.close", default: "Close") }, data: { action: "ui--gallery#close" })) do %><%= render(UI::Icon.new(name: "x", size: :sm)) %><% end %>
|
|
47
|
+
<% if multiple? %>
|
|
48
|
+
<%= render(UI::Button.new(**overlay_nav_attrs(:previous))) do %><%= render(UI::Icon.new(name: "chevron-left", size: :sm, class: "rtl:rotate-180")) %><% end %>
|
|
49
|
+
<%= render(UI::Button.new(**overlay_nav_attrs(:next))) do %><%= render(UI::Icon.new(name: "chevron-right", size: :sm, class: "rtl:rotate-180")) %><% end %>
|
|
50
|
+
<% end %>
|
|
51
|
+
<% end %>
|
|
52
|
+
<% end %>
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# A product's photos: one large image, thumbnails to pick another, and two ways
|
|
4
|
+
# to look closer.
|
|
5
|
+
#
|
|
6
|
+
# <%= render(UI::Gallery.new(label: "Photos of the ceramic mug")) do |gallery| %>
|
|
7
|
+
# <% gallery.with_image(src: "mug.jpg", alt: "Mug, front", zoom_src: "mug-2000.jpg", thumbnail_src: "mug-160.jpg") %>
|
|
8
|
+
# <% gallery.with_image(src: "mug-side.jpg", alt: "Mug, from the side") %>
|
|
9
|
+
# <% end %>
|
|
10
|
+
#
|
|
11
|
+
# The main view is a scroll-snap strip, so it swipes on a touch screen with no
|
|
12
|
+
# script involved. Previous and next wrap round, and arrow keys do the same.
|
|
13
|
+
# Only the first image loads with the page. `zoom_src:` and `thumbnail_src:` are
|
|
14
|
+
# optional, and worth giving: the zoomed image only downloads when someone opens
|
|
15
|
+
# it, so it can be much larger than `src:`.
|
|
16
|
+
#
|
|
17
|
+
# Clicking the image opens it by itself over the dimmed page, with zoom and close
|
|
18
|
+
# in the top corners and previous and next at the sides. There, clicking zooms in
|
|
19
|
+
# on that spot and clicking again zooms out; so do the buttons, the + and - keys,
|
|
20
|
+
# 0 to reset, and pinching a trackpad. A zoomed image pans by dragging or
|
|
21
|
+
# scrolling. Clicking outside it or pressing Escape closes it. The image grows
|
|
22
|
+
# out of its place on the page and returns there, and all the movement stops for
|
|
23
|
+
# anyone whose system asks for reduced motion.
|
|
24
|
+
#
|
|
25
|
+
# `zoom: :hover` adds what big shops do: moving a mouse over the image shows a
|
|
26
|
+
# lens on it and that part magnified beside it, `zoom_scale:` times over (2.5 by
|
|
27
|
+
# default). With no room beside it, the magnified part shows over the image. A
|
|
28
|
+
# click still opens the overlay, which is also what touch screens and the
|
|
29
|
+
# keyboard get, having no mouse to hover with.
|
|
30
|
+
#
|
|
31
|
+
# `aspect:` is :square, :landscape or :portrait, and `fit:` is :contain (the whole
|
|
32
|
+
# photo) or :cover (fills the frame, cropping). A single image gets no thumbnails
|
|
33
|
+
# or arrows.
|
|
34
|
+
class UI::Gallery < UI::Base
|
|
35
|
+
ASPECTS = { square: "aspect-square", landscape: "aspect-video", portrait: "aspect-[4/5]" }.freeze
|
|
36
|
+
FITS = { contain: "object-contain", cover: "object-cover" }.freeze
|
|
37
|
+
ZOOMS = %i[overlay hover].freeze
|
|
38
|
+
|
|
39
|
+
HIDE_SCROLLBAR = "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
|
|
40
|
+
|
|
41
|
+
# The lens and pane fade in and out, rather than blinking on and off with `hidden`.
|
|
42
|
+
HOVER_REVEAL = "pointer-events-none invisible absolute opacity-0 transition-[opacity,scale,visibility] duration-150 " \
|
|
43
|
+
"data-[shown]:visible data-[shown]:opacity-100 motion-reduce:transition-none"
|
|
44
|
+
|
|
45
|
+
# Always light on the dark backdrop, whatever the page's theme, ring included.
|
|
46
|
+
# The border keeps them in sight on a dark page, where the backdrop is black too.
|
|
47
|
+
OVERLAY_BUTTON = "rounded-full border border-white/25 bg-black/60 text-white hover:bg-black/80 hover:text-white " \
|
|
48
|
+
"focus:ring-white disabled:bg-black/60! disabled:text-white/50!"
|
|
49
|
+
|
|
50
|
+
renders_many :images, UI::Gallery::Image
|
|
51
|
+
|
|
52
|
+
def initialize(label: nil, aspect: :square, fit: :contain, zoom: :overlay, zoom_scale: 2.5, class: nil, **html_attrs)
|
|
53
|
+
@label = label
|
|
54
|
+
@aspect = ASPECTS.key?(aspect.to_sym) ? aspect.to_sym : :square
|
|
55
|
+
@fit = FITS.key?(fit.to_sym) ? fit.to_sym : :contain
|
|
56
|
+
@zoom = ZOOMS.include?(zoom.to_sym) ? zoom.to_sym : :overlay
|
|
57
|
+
@zoom_scale = zoom_scale
|
|
58
|
+
@user_class = binding.local_variable_get(:class)
|
|
59
|
+
@html_attrs = html_attrs
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def render? = images.any?
|
|
63
|
+
def multiple? = images.size > 1
|
|
64
|
+
def hover_zoom? = @zoom == :hover
|
|
65
|
+
|
|
66
|
+
def root_attrs
|
|
67
|
+
attrs = @html_attrs.except(:data, :aria)
|
|
68
|
+
attrs[:role] = "group"
|
|
69
|
+
attrs[:class] = cn("flex w-full min-w-0 flex-col gap-3", @user_class)
|
|
70
|
+
attrs[:aria] = { label: label, roledescription: t("ui.gallery.roledescription", default: "gallery") }
|
|
71
|
+
.merge(@html_attrs[:aria] || {})
|
|
72
|
+
attrs[:data] = { slot: "gallery", controller: "ui--gallery", zoom: @zoom,
|
|
73
|
+
"ui--gallery-zoom-scale-value": @zoom_scale,
|
|
74
|
+
"ui--gallery-position-value": position_format,
|
|
75
|
+
action: "keydown@window->ui--gallery#keydown resize@window->ui--gallery#layout" }
|
|
76
|
+
.merge(@html_attrs[:data] || {})
|
|
77
|
+
attrs
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def track_classes
|
|
81
|
+
cn("flex snap-x snap-mandatory overflow-x-auto rounded-lg bg-muted", HIDE_SCROLLBAR)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def slide_classes = cn("w-full shrink-0 snap-center", ASPECTS[@aspect])
|
|
85
|
+
|
|
86
|
+
def slide_button_attrs(image, index)
|
|
87
|
+
# One tab stop for the strip: the image showing. The rest are out of sight.
|
|
88
|
+
{ type: "button", tabindex: index.zero? ? 0 : -1,
|
|
89
|
+
class: cn("group/slide relative block size-full rounded-lg transition-all focus:outline-none",
|
|
90
|
+
"focus:ring-2 focus:ring-inset focus:ring-primary", hover_zoom? ? "cursor-crosshair" : "cursor-zoom-in"),
|
|
91
|
+
aria: { label: phrase(t("ui.gallery.zoom", default: "Zoom image %{current}: %{alt}"), current: index + 1, alt: image.alt),
|
|
92
|
+
haspopup: "dialog" },
|
|
93
|
+
data: { action: slide_action, "ui--gallery-index-param": index } }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Covers the window with nothing of its own: only the image and its buttons sit
|
|
97
|
+
# on the backdrop.
|
|
98
|
+
def dialog_classes
|
|
99
|
+
"m-0 size-full max-h-none max-w-none overflow-hidden bg-transparent p-0 outline-none backdrop:bg-black/80"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def viewport_classes
|
|
103
|
+
cn("group/viewport absolute inset-0 flex overflow-auto overscroll-contain", HIDE_SCROLLBAR)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def image_classes = cn("size-full", FITS[@fit])
|
|
107
|
+
|
|
108
|
+
# Only the first image loads with the page. The rest wait to be scrolled to.
|
|
109
|
+
def image_loading(index) = index.zero? ? :eager : :lazy
|
|
110
|
+
|
|
111
|
+
# The padding leaves room for the focus ring, and the margin takes it back, so
|
|
112
|
+
# the first thumbnail lines up with the edge of the image.
|
|
113
|
+
def thumbnail_strip_classes = cn("-mx-1 flex gap-2 overflow-x-auto p-1", HIDE_SCROLLBAR)
|
|
114
|
+
|
|
115
|
+
def thumbnail_attrs(index)
|
|
116
|
+
{ type: "button",
|
|
117
|
+
class: cn("block size-16 shrink-0 overflow-hidden rounded-md border-2 border-transparent opacity-70 hover:opacity-100",
|
|
118
|
+
"aria-current:border-primary aria-current:opacity-100", UI::Base::FOCUS_RING),
|
|
119
|
+
aria: { label: phrase(t("ui.gallery.thumbnail", default: "Show image %{current}"), current: index + 1),
|
|
120
|
+
current: ("true" if index.zero?) }.compact,
|
|
121
|
+
data: { action: "ui--gallery#select", "ui--gallery-index-param": index, "ui--gallery-target": "thumbnail" } }
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def nav_button_attrs(direction)
|
|
125
|
+
edge = direction == :previous ? "start-2" : "end-2"
|
|
126
|
+
{ variant: :outline, size: :icon,
|
|
127
|
+
class: cn("absolute top-1/2 z-10 hidden -translate-y-1/2 rounded-full bg-background/90 sm:inline-flex", edge),
|
|
128
|
+
aria: { label: nav_label(direction) }, data: { action: "ui--gallery##{direction}" } }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def overlay_nav_attrs(direction)
|
|
132
|
+
edge = direction == :previous ? "start-4" : "end-4"
|
|
133
|
+
{ variant: :ghost, size: :icon,
|
|
134
|
+
class: cn(OVERLAY_BUTTON, "absolute top-1/2 z-10 -translate-y-1/2", edge),
|
|
135
|
+
aria: { label: nav_label(direction) }, data: { action: "ui--gallery##{direction}" } }
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def zoom_button_attrs(direction, label)
|
|
139
|
+
{ variant: :ghost, size: :icon, class: OVERLAY_BUTTON,
|
|
140
|
+
aria: { label: t("ui.gallery.zoom_#{direction}", default: label) },
|
|
141
|
+
data: { action: "ui--gallery#zoom#{direction.to_s.capitalize}", "ui--gallery-target": "zoom#{direction.to_s.capitalize}" } }
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def position_text = phrase(position_format, current: 1, total: images.size)
|
|
145
|
+
|
|
146
|
+
private
|
|
147
|
+
|
|
148
|
+
def nav_label(direction) = t("ui.gallery.#{direction}", default: "#{direction.to_s.capitalize} image")
|
|
149
|
+
|
|
150
|
+
def slide_action
|
|
151
|
+
return "ui--gallery#open" unless hover_zoom?
|
|
152
|
+
|
|
153
|
+
"ui--gallery#open pointerenter->ui--gallery#hover pointermove->ui--gallery#hover pointerleave->ui--gallery#hoverEnd"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def label = @label || t("ui.gallery.label", default: "Image gallery")
|
|
157
|
+
def position_format = t("ui.gallery.position", default: "Image %{current} of %{total}")
|
|
158
|
+
|
|
159
|
+
# Filled in here rather than by t(), so the controller can be handed the same
|
|
160
|
+
# text with its placeholders still in it.
|
|
161
|
+
def phrase(format, **values)
|
|
162
|
+
values.reduce(format) { |text, (key, value)| text.sub("%{#{key}}", value.to_s) }
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%=
|
|
1
|
+
<%= svg_tag %>
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# UI::Icon — an SVG icon, drawn into the page on the server.
|
|
4
|
+
#
|
|
5
|
+
# Each icon is a file in app/assets/icons, named as your icon library names
|
|
6
|
+
# it: `UI::Icon.new(name: "rocket")` draws app/assets/icons/rocket.svg. The
|
|
7
|
+
# library is the one in config/velvetkit.yml; `velvetkit:add` copies the
|
|
8
|
+
# icons the components draw, and this adds any other:
|
|
9
|
+
#
|
|
10
|
+
# bin/rails generate velvetkit:icons rocket user
|
|
11
|
+
#
|
|
12
|
+
# There is no JavaScript and nothing to register. An icon with no file draws
|
|
13
|
+
# a dashed square (nothing in production) and logs which file is missing.
|
|
14
|
+
#
|
|
15
|
+
# name: the file's name, without .svg
|
|
16
|
+
# size: xs, sm, default, lg or xl
|
|
17
|
+
# label: makes it an image with this accessible name; without one it is
|
|
18
|
+
# decorative and hidden from assistive technology
|
|
19
|
+
#
|
|
20
|
+
# To keep the SVGs somewhere else, set `config.x.velvetkit.icons_path`.
|
|
3
21
|
class UI::Icon < UI::Base
|
|
4
22
|
variants(
|
|
5
23
|
base: "inline-block shrink-0",
|
|
@@ -15,27 +33,81 @@ class UI::Icon < UI::Base
|
|
|
15
33
|
defaults: { size: :default }
|
|
16
34
|
)
|
|
17
35
|
|
|
36
|
+
# Shown in place of an icon with no file, outside production.
|
|
37
|
+
MISSING = { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2",
|
|
38
|
+
"stroke-dasharray": "3 3", inner: '<rect x="3" y="3" width="18" height="18" rx="2"/>' }.freeze
|
|
39
|
+
|
|
40
|
+
class << self
|
|
41
|
+
def path
|
|
42
|
+
Rails.configuration.x.velvetkit.icons_path || Rails.root.join("app/assets/icons")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# The SVG's attributes and markup, or nil if there's no such file. The
|
|
46
|
+
# library's own size and class are dropped: the component sets those.
|
|
47
|
+
def svg(name)
|
|
48
|
+
return unless name.match?(/\A[\w-]+\z/) # a file name, never a path
|
|
49
|
+
|
|
50
|
+
cache = Rails.configuration.cache_classes ? (@svgs ||= {}) : {}
|
|
51
|
+
cache.fetch(name) do
|
|
52
|
+
file = File.join(path, "#{name}.svg")
|
|
53
|
+
next unless File.file?(file)
|
|
54
|
+
|
|
55
|
+
cache[name] = parse(File.read(file))
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def parse(source)
|
|
62
|
+
open_tag, inner = source.gsub(/<!--.*?-->/m, "").match(%r{<svg\b([^>]*)>(.*)</svg>}m)&.captures
|
|
63
|
+
return unless open_tag
|
|
64
|
+
|
|
65
|
+
attributes = open_tag.scan(/([\w:-]+)\s*=\s*"([^"]*)"/).to_h.except("width", "height", "class")
|
|
66
|
+
{ attributes: attributes.freeze, inner: inner.gsub(/>\s+</, "><").strip.freeze }.freeze
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
18
70
|
def initialize(name:, size: :default, label: nil, class: nil, **html_attrs)
|
|
19
|
-
@name = name
|
|
71
|
+
@name = name.to_s
|
|
20
72
|
@size = size
|
|
21
73
|
@label = label
|
|
22
74
|
@user_class = binding.local_variable_get(:class)
|
|
23
75
|
@html_attrs = html_attrs
|
|
24
76
|
end
|
|
25
77
|
|
|
78
|
+
attr_reader :name
|
|
79
|
+
|
|
26
80
|
def render?
|
|
27
81
|
@name.present?
|
|
28
82
|
end
|
|
29
83
|
|
|
30
|
-
def
|
|
31
|
-
|
|
84
|
+
def svg_tag
|
|
85
|
+
svg = self.class.svg(@name) || missing
|
|
86
|
+
tag.svg(
|
|
87
|
+
svg[:inner].html_safe, # the app's own SVG files
|
|
88
|
+
**svg[:attributes].symbolize_keys,
|
|
89
|
+
**@html_attrs.except(:data, :aria),
|
|
90
|
+
class: cn(variant_classes(size: @size), @user_class),
|
|
91
|
+
data: (@html_attrs[:data] || {}).merge(icon: @name),
|
|
92
|
+
aria: aria_attributes,
|
|
93
|
+
role: (accessible_name ? "img" : nil)
|
|
94
|
+
)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
def accessible_name
|
|
100
|
+
@label || @html_attrs.dig(:aria, :label)
|
|
32
101
|
end
|
|
33
102
|
|
|
34
103
|
def aria_attributes
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
104
|
+
(accessible_name ? { label: accessible_name } : { hidden: true }).merge(@html_attrs[:aria] || {})
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def missing
|
|
108
|
+
Rails.logger&.warn("[UI::Icon] no #{@name}.svg in #{self.class.path}: bin/rails generate velvetkit:icons #{@name}")
|
|
109
|
+
return { attributes: { "data-icon-missing" => "" }, inner: "" } if Rails.env.production?
|
|
110
|
+
|
|
111
|
+
{ attributes: MISSING.except(:inner).transform_keys(&:to_s).merge("data-icon-missing" => ""), inner: MISSING[:inner] }
|
|
40
112
|
end
|
|
41
113
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<%# frozen_string_literal: true %>
|
|
2
|
+
<%= tag.kbd(**root_attrs) do %>
|
|
3
|
+
<% if written? %>
|
|
4
|
+
<%= tag.kbd(content, class: key_class) %>
|
|
5
|
+
<% else %>
|
|
6
|
+
<% steps.each_with_index do |combo, step| %>
|
|
7
|
+
<% if step.positive? %><span class="text-[0.85em] opacity-70"><%= t("ui.kbd.then", default: "then") %></span><% end %>
|
|
8
|
+
<span class="inline-flex items-center gap-0.5">
|
|
9
|
+
<% combo.each_with_index do |key, index| %>
|
|
10
|
+
<% if index.positive? %><span class="opacity-60 group-data-[platform=mac]/kbd:hidden" aria-hidden="true">+</span><% end %>
|
|
11
|
+
<% mac, mac_name, other, other_name = key_labels(key, combo) %>
|
|
12
|
+
<% linux, linux_name = linux_labels(key) %>
|
|
13
|
+
<% if linux %>
|
|
14
|
+
<%= key_tag(mac, mac_name, "hidden group-data-[platform=mac]/kbd:inline-flex") %>
|
|
15
|
+
<%= key_tag(other, other_name, "group-data-[platform=mac]/kbd:hidden group-data-[platform=linux]/kbd:hidden") %>
|
|
16
|
+
<%= key_tag(linux, linux_name, "hidden group-data-[platform=linux]/kbd:inline-flex") %>
|
|
17
|
+
<% elsif mac == other && mac_name == other_name %>
|
|
18
|
+
<%= key_tag(mac, mac_name) %>
|
|
19
|
+
<% else %>
|
|
20
|
+
<%= key_tag(mac, mac_name, "hidden group-data-[platform=mac]/kbd:inline-flex") %>
|
|
21
|
+
<%= key_tag(other, other_name, "group-data-[platform=mac]/kbd:hidden") %>
|
|
22
|
+
<% end %>
|
|
23
|
+
<% end %>
|
|
24
|
+
</span>
|
|
25
|
+
<% end %>
|
|
26
|
+
<% end %>
|
|
27
|
+
<% end %>
|