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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1946e018660d08bfab63d5e0a9b9e00e2e41a138bacf878e66832c0eebb0400b
|
|
4
|
+
data.tar.gz: 7b5ae9a20372f619449b42520d0f1d643b9b8d6094437d00715c8faebb883029
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4cb6bacd3d8e0ccc231e5d655ac639d40df556e49d7b02f1aa0feb5d2ccb8f46aa2a99a08853f26ceb789e920d5f4a5e779c29e3a816c28296547a6b6549200
|
|
7
|
+
data.tar.gz: 7624a9d18314e65a4c43a883c9e42b1ac0291ba84b8c5bccb1641a594311384112933abd158ed412877b4b2252f971853ecc5b4d5fbbcbcf000dfe0aaa74aa52
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
New components:
|
|
6
|
+
|
|
7
|
+
- `Timeline`: dated entries down the page (order status, stock history, an
|
|
8
|
+
activity log), drawn as circles, dots or circles in a colour each.
|
|
9
|
+
- `NumberInput`: a number field with - and + buttons that keep counting while
|
|
10
|
+
held; `change` fires once on release, so a cart row submits once.
|
|
11
|
+
- `Gallery`: product photos with thumbnails and swiping, opening over the
|
|
12
|
+
page to zoom and pan, or `zoom: :hover` for a lens and a magnified pane.
|
|
13
|
+
- `Chart`: line, bar, stacked bar, pie and donut charts on Chart.js, with a
|
|
14
|
+
legend, tooltips, keyboard reading, a table of the numbers, and animation.
|
|
15
|
+
The docs site has a Charts section with a page for each.
|
|
16
|
+
|
|
17
|
+
Changes:
|
|
18
|
+
|
|
19
|
+
- `Select` searches the server as you type with `url:` (JSON back), with a
|
|
20
|
+
spinner when it's slow, results remembered for a minute, and choices kept
|
|
21
|
+
when later searches no longer list them.
|
|
22
|
+
- `DatePicker` moves from Cally to Vanilla Calendar Pro and takes
|
|
23
|
+
`range: true` for From and To, with presets such as Last 7 days, two months
|
|
24
|
+
side by side, and a hover preview. Typed dates take digits only, the
|
|
25
|
+
separators go in as you type, and the calendar opens on click or focus.
|
|
26
|
+
- `FileField` shows a tile for each chosen file, checks `accept:` and
|
|
27
|
+
`max_size:`, and with `direct_upload: true` sends each file to storage
|
|
28
|
+
through Active Storage as it's chosen, with a progress bar. Bound to a
|
|
29
|
+
form, it shows the record's attachments.
|
|
30
|
+
- The chart colours, `--chart-1` to `--chart-5`, are now velvet, orange,
|
|
31
|
+
aqua, blue and magenta, checked for colour-blind readers in both themes.
|
|
32
|
+
- `velvetkit:add` puts the bundles Chart, Date Picker and Data Grid load on
|
|
33
|
+
demand (`chart_js.ts`, `vanilla_calendar.ts`, `ag_grid.ts`) into the app's
|
|
34
|
+
JavaScript build: `bun.config.js`, `webpack.config.js`, or a build script
|
|
35
|
+
that lists `application.js`. Before, they were copied but never built, so
|
|
36
|
+
those components failed to load their library.
|
|
37
|
+
|
|
38
|
+
Upgrading an app: re-run `velvetkit:add` for `date_picker`, `select` and
|
|
39
|
+
`file_field`, and copy the new `--chart-*` values into your `velvetkit.css`.
|
|
40
|
+
`date_picker` now needs `vanilla-calendar-pro` instead of `cally`, and loads
|
|
41
|
+
`app/javascript/vanilla_calendar.ts` as its own entry point; `file_field`
|
|
42
|
+
needs `@rails/activestorage`. If you added `chart_js.ts`,
|
|
43
|
+
`vanilla_calendar.ts` or `ag_grid.ts` to your build by hand, `add` leaves
|
|
44
|
+
it as it is.
|
|
45
|
+
|
|
46
|
+
- Fix: Rails 8.1.4.1, for security advisories in Active Storage and Action Pack.
|
|
47
|
+
- Fix: the docs site shows a component added to the catalog without a server
|
|
48
|
+
restart.
|
|
49
|
+
|
|
50
|
+
## 0.3.0 — 2026-11-03
|
|
51
|
+
|
|
52
|
+
- `Stepper`: the steps of a multi-step form, done, current or to come, with
|
|
53
|
+
dots, centred labels, panels moved between in the browser, and links back
|
|
54
|
+
to done steps.
|
|
55
|
+
- `ConfirmDialog`: a styled dialog that answers `data-turbo-confirm`, so every
|
|
56
|
+
existing confirm uses it.
|
|
57
|
+
- `ToggleGroup`: a row of buttons choosing one or several, posting like
|
|
58
|
+
radios or checkboxes.
|
|
59
|
+
- `EmptyState`: an icon, title, text and actions for a page with nothing to
|
|
60
|
+
list.
|
|
61
|
+
- Icons come from Lucide, Tabler or Phosphor, chosen with
|
|
62
|
+
`velvetkit:install --icons=`, and are drawn as inline SVG.
|
|
63
|
+
|
|
64
|
+
## 0.2.2 — 2026-11-02
|
|
65
|
+
|
|
66
|
+
- Fix: the `plus`, `search`, `ellipsis-vertical` and `grip-vertical` icons were
|
|
67
|
+
missing from installs.
|
|
68
|
+
|
|
69
|
+
## 0.2.1 — 2026-11-01
|
|
70
|
+
|
|
71
|
+
- `NavigationMenu`: site navigation with links and panels of rich links that
|
|
72
|
+
open on hover or click.
|
|
73
|
+
|
|
74
|
+
## 0.2.0 — 2026-11-01
|
|
75
|
+
|
|
76
|
+
- `Toast`: stacked messages that dismiss themselves.
|
|
77
|
+
- `SessionTabs`: tabs for open sessions, with a button to add one.
|
|
78
|
+
- `Skeleton` and `FileField`.
|
|
79
|
+
- Fix: `Menu` content positions itself with the fixed strategy, so it isn't
|
|
80
|
+
clipped by a scrolling container.
|
|
81
|
+
- Fix: dependencies updated for security advisories in `addressable` and `rack`.
|
|
82
|
+
|
|
3
83
|
## 0.1.0.beta — 2026-10-26
|
|
4
84
|
|
|
5
85
|
- First release of the component library.
|
data/README.md
CHANGED
|
@@ -139,15 +139,14 @@ bin/rails generate velvetkit:install --namespace=Kit # or under Kit::
|
|
|
139
139
|
|
|
140
140
|
`install` does the following:
|
|
141
141
|
|
|
142
|
-
- writes `config/velvetkit.yml` with the namespace
|
|
142
|
+
- writes `config/velvetkit.yml` with the namespace and icon library
|
|
143
143
|
- adds `view_component` and `tailwind_merge` to the Gemfile
|
|
144
144
|
- adds an acronym inflection when the namespace needs one (`UI`, not `Kit`)
|
|
145
145
|
- copies the base component, design tokens (`app/assets/tailwind/velvetkit.css`),
|
|
146
|
-
translations (`config/locales/velvetkit.en.yml`) and
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
package manager, which it picks from your lockfile
|
|
146
|
+
and translations (`config/locales/velvetkit.en.yml`), and imports the CSS
|
|
147
|
+
from your Tailwind entry point
|
|
148
|
+
- installs `@hotwired/stimulus` and `tw-animate-css` with your package
|
|
149
|
+
manager, which it picks from your lockfile
|
|
151
150
|
|
|
152
151
|
### Add components
|
|
153
152
|
|
|
@@ -161,7 +160,13 @@ bin/rails generate velvetkit:add --all # everything
|
|
|
161
160
|
|
|
162
161
|
- copies the component, its templates and sub-components
|
|
163
162
|
- copies its Stimulus controllers and any lazily-loaded entry points (AG Grid
|
|
164
|
-
for `data_grid`,
|
|
163
|
+
for `data_grid`, Chart.js for `chart`, Vanilla Calendar Pro for `date_picker`),
|
|
164
|
+
and adds those to your JavaScript build: to `bun.config.js`'s `entrypoints`,
|
|
165
|
+
`webpack.config.js`'s `entry`, or a build script that lists `application.js`.
|
|
166
|
+
esbuild's default `app/javascript/*.*` already takes them; for any other setup
|
|
167
|
+
`add` says what to add
|
|
168
|
+
- copies the SVG of every icon it draws into `app/assets/icons`, named for
|
|
169
|
+
your icon library
|
|
165
170
|
- copies its Minitest tests and Lookbook previews. A preview that shows
|
|
166
171
|
components you haven't added is skipped, and `add` tells you which.
|
|
167
172
|
- registers its controllers in `app/javascript/controllers/index.js` when
|
|
@@ -169,10 +174,27 @@ bin/rails generate velvetkit:add --all # everything
|
|
|
169
174
|
- installs any npm packages it needs, and adds any gems it needs (`pagy` for
|
|
170
175
|
`pagination`) to the Gemfile
|
|
171
176
|
|
|
172
|
-
Options: `--namespace=Kit`, `--skip-tests`, `--skip-previews`,
|
|
177
|
+
Options: `--namespace=Kit`, `--icons=tabler`, `--skip-tests`, `--skip-previews`,
|
|
173
178
|
`--skip-packages` (list the packages instead of installing them), and the usual
|
|
174
179
|
`--force`/`--skip` for files that already exist.
|
|
175
180
|
|
|
181
|
+
### Icons
|
|
182
|
+
|
|
183
|
+
Components draw their icons from one library: Lucide (the default), Tabler or
|
|
184
|
+
Phosphor. Choose it with `velvetkit:install --icons=phosphor`. Like shadcn/ui,
|
|
185
|
+
the choice is made when components are copied: they're written with Lucide
|
|
186
|
+
names, and `add` renames every icon for your library and copies its SVG into
|
|
187
|
+
`app/assets/icons`. `Icon` draws the SVG into the page on the server, so
|
|
188
|
+
there's no icon JavaScript.
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
bin/rails generate velvetkit:icons rocket user # add icons for your own views
|
|
192
|
+
bin/rails generate velvetkit:icons # or every one they draw that has no SVG
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
See [Icons](https://velvetkit.com/docs/icons) for switching libraries and
|
|
196
|
+
upgrading from 0.2.
|
|
197
|
+
|
|
176
198
|
### AI agents
|
|
177
199
|
|
|
178
200
|
`install` also writes three files so coding agents use your components
|
|
@@ -21,12 +21,18 @@ module Velvetkit
|
|
|
21
21
|
|
|
22
22
|
class_option :namespace, type: :string,
|
|
23
23
|
desc: "Module for the components (default: #{CONFIG_FILE}, else UI)"
|
|
24
|
+
class_option :icons, type: :string,
|
|
25
|
+
desc: "Icon library: #{Icons::LIBRARIES.keys.join(', ')} (default: #{CONFIG_FILE}, else lucide)"
|
|
24
26
|
class_option :all, type: :boolean, default: false, desc: "Add every component"
|
|
25
27
|
class_option :skip_tests, type: :boolean, default: false, desc: "Don't copy component tests"
|
|
26
28
|
class_option :skip_previews, type: :boolean, default: false, desc: "Don't copy Lookbook previews"
|
|
27
29
|
class_option :skip_packages, type: :boolean, default: false,
|
|
28
30
|
desc: "List the npm packages to add instead of installing them"
|
|
29
31
|
|
|
32
|
+
def check_icon_library
|
|
33
|
+
icon_library
|
|
34
|
+
end
|
|
35
|
+
|
|
30
36
|
def list_components
|
|
31
37
|
return if requested.any?
|
|
32
38
|
|
|
@@ -51,10 +57,19 @@ module Velvetkit
|
|
|
51
57
|
say_status :skip, "#{name} preview, it also shows #{needs.join(', ')}", :yellow
|
|
52
58
|
else
|
|
53
59
|
registry.preview_files(name).each { |file| copy_from_registry(file) }
|
|
60
|
+
copied_previews.concat(registry.preview_files(name))
|
|
54
61
|
end
|
|
55
62
|
end
|
|
56
63
|
end
|
|
57
64
|
|
|
65
|
+
# The icons the components and their previews draw, as SVGs in the
|
|
66
|
+
# app's icon library.
|
|
67
|
+
def copy_icon_files
|
|
68
|
+
return if resolved.empty?
|
|
69
|
+
|
|
70
|
+
copy_icons(resolved.flat_map { |name| registry.component_files(name) } + copied_previews)
|
|
71
|
+
end
|
|
72
|
+
|
|
58
73
|
# Apps that list controllers in a manifest (jsbundling with
|
|
59
74
|
# stimulus:manifest:update) need each one registered; apps that load the
|
|
60
75
|
# directory (importmap, eagerLoadControllersFrom) need nothing.
|
|
@@ -75,6 +90,27 @@ module Velvetkit
|
|
|
75
90
|
end
|
|
76
91
|
end
|
|
77
92
|
|
|
93
|
+
# Bundles a component loads only when it's on the page (Chart.js,
|
|
94
|
+
# Vanilla Calendar Pro, AG Grid) are entry points of their own, so the
|
|
95
|
+
# app's JavaScript build has to know about them. Added where the build
|
|
96
|
+
# lists its entry points; an esbuild glob already takes them; anything
|
|
97
|
+
# else is told what to add.
|
|
98
|
+
def wire_entry_points
|
|
99
|
+
entry_points.each do |entry|
|
|
100
|
+
if exists?("bun.config.js") && read("bun.config.js").match?(/entrypoints:\s*\[/)
|
|
101
|
+
add_to_bun_config(entry)
|
|
102
|
+
elsif exists?("webpack.config.js") && read("webpack.config.js").match?(/entry:\s*\{/)
|
|
103
|
+
add_to_webpack_config(entry)
|
|
104
|
+
elsif build_script&.match?(%r{app/javascript/\*})
|
|
105
|
+
say_status :build, "#{entry} is built by the build script's app/javascript/* already", :blue
|
|
106
|
+
elsif build_script&.match?(%r{app/javascript/application\.[jt]s})
|
|
107
|
+
add_to_build_script(entry)
|
|
108
|
+
else
|
|
109
|
+
say_status :build, "add #{entry} to your JavaScript build as an entry point of its own, like application.js", :yellow
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
78
114
|
def add_gems
|
|
79
115
|
gemfile = File.read(File.join(destination_root, "Gemfile"))
|
|
80
116
|
resolved.flat_map { |name| registry.gems(name).to_a }.uniq.each do |name, version|
|
|
@@ -99,6 +135,10 @@ module Velvetkit
|
|
|
99
135
|
@resolved ||= requested.empty? ? [] : registry.resolve(requested)
|
|
100
136
|
end
|
|
101
137
|
|
|
138
|
+
def copied_previews
|
|
139
|
+
@copied_previews ||= []
|
|
140
|
+
end
|
|
141
|
+
|
|
102
142
|
def requested
|
|
103
143
|
options[:all] ? registry.names : components
|
|
104
144
|
end
|
|
@@ -106,6 +146,43 @@ module Velvetkit
|
|
|
106
146
|
def controllers
|
|
107
147
|
resolved.flat_map { |name| registry.stimulus_controllers(name) }.uniq
|
|
108
148
|
end
|
|
149
|
+
|
|
150
|
+
# app/javascript/chart_js.ts and the like: JavaScript that isn't a
|
|
151
|
+
# Stimulus controller or one of their shared helpers.
|
|
152
|
+
def entry_points
|
|
153
|
+
resolved.flat_map { |name| registry.javascript_files(name) }.uniq
|
|
154
|
+
.select { |file| file.start_with?("app/javascript/") && !file.start_with?("app/javascript/controllers/") }
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def build_script
|
|
158
|
+
return nil unless exists?("package.json")
|
|
159
|
+
|
|
160
|
+
JSON.parse(read("package.json")).dig("scripts", "build")
|
|
161
|
+
rescue JSON::ParserError
|
|
162
|
+
nil
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def add_to_bun_config(entry)
|
|
166
|
+
return if read("bun.config.js").include?(entry)
|
|
167
|
+
|
|
168
|
+
gsub_file "bun.config.js", /(entrypoints:\s*\[)/, %(\\1"#{entry}", )
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def add_to_webpack_config(entry)
|
|
172
|
+
return if read("webpack.config.js").include?(entry)
|
|
173
|
+
|
|
174
|
+
gsub_file "webpack.config.js", /(entry:\s*\{\s*\n)/, %(\\1 #{File.basename(entry, ".*")}: "./#{entry}",\n)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# After application.js in the build script, written the same way ("./" or not).
|
|
178
|
+
def add_to_build_script(entry)
|
|
179
|
+
return if build_script.include?(entry)
|
|
180
|
+
|
|
181
|
+
gsub_file "package.json", %r{((?:\./)?)app/javascript/application\.[jt]s}, "\\0 \\1#{entry}"
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def exists?(file) = File.exist?(File.join(destination_root, file))
|
|
185
|
+
def read(file) = File.read(File.join(destination_root, file))
|
|
109
186
|
end
|
|
110
187
|
end
|
|
111
188
|
end
|
|
@@ -15,6 +15,8 @@ module Velvetkit
|
|
|
15
15
|
"package-lock.json" => "npm install"
|
|
16
16
|
}.freeze
|
|
17
17
|
|
|
18
|
+
ICONS_DIR = "app/assets/icons"
|
|
19
|
+
|
|
18
20
|
private
|
|
19
21
|
|
|
20
22
|
def registry
|
|
@@ -27,12 +29,37 @@ module Velvetkit
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def configured_namespace
|
|
32
|
+
configured("namespace")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# --icons, else config/velvetkit.yml, else lucide.
|
|
36
|
+
def icon_library
|
|
37
|
+
@icon_library ||= Icons.library!(options[:icons] || configured("icons"))
|
|
38
|
+
rescue Error => e
|
|
39
|
+
raise Thor::Error, e.message
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def configured(key)
|
|
30
43
|
config = File.join(destination_root, CONFIG_FILE)
|
|
31
|
-
YAML.load_file(config)&.fetch(
|
|
44
|
+
YAML.load_file(config)&.fetch(key, nil) if File.exist?(config)
|
|
32
45
|
end
|
|
33
46
|
|
|
47
|
+
# Ruby and templates get the app's icon names, then its namespace.
|
|
34
48
|
def copy_from_registry(file)
|
|
35
|
-
|
|
49
|
+
source = registry.read(file)
|
|
50
|
+
source = registry.icons.rewrite(source, icon_library) if file.end_with?(".rb", ".erb")
|
|
51
|
+
create_file kit_namespace.rewrite_path(file), kit_namespace.rewrite(source)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The SVG of every icon the files draw, in the app's library.
|
|
55
|
+
def copy_icons(files)
|
|
56
|
+
icons = registry.icons
|
|
57
|
+
names = files.select { |file| file.end_with?(".rb", ".erb") }
|
|
58
|
+
.flat_map { |file| icons.names_in(registry.read(file)) }.uniq.sort
|
|
59
|
+
names.select { |icon| icons.name(icon, icon_library) }.each do |icon|
|
|
60
|
+
create_file File.join(ICONS_DIR, "#{icons.name(icon, icon_library)}.svg"),
|
|
61
|
+
registry.read(icons.svg_file(icon, icon_library))
|
|
62
|
+
end
|
|
36
63
|
end
|
|
37
64
|
|
|
38
65
|
def install_packages(packages)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require_relative "../helpers"
|
|
5
|
+
|
|
6
|
+
module Velvetkit
|
|
7
|
+
module Generators
|
|
8
|
+
# Puts icon SVGs in app/assets/icons, where the Icon component reads them.
|
|
9
|
+
#
|
|
10
|
+
# Names are the app's icon library's own (config/velvetkit.yml). An icon
|
|
11
|
+
# the kit already ships is copied from the gem; any other is downloaded
|
|
12
|
+
# from the npm CDN, pinned to the version the kit was built against.
|
|
13
|
+
class IconsGenerator < Rails::Generators::Base
|
|
14
|
+
include Helpers
|
|
15
|
+
|
|
16
|
+
SOURCES = "app/{components,views,helpers}/**/*.{rb,erb}"
|
|
17
|
+
|
|
18
|
+
desc <<~DESC
|
|
19
|
+
Add icons to app/assets/icons, from the library in #{CONFIG_FILE}.
|
|
20
|
+
|
|
21
|
+
Name them, or run with none to add every icon the app's own
|
|
22
|
+
components, views and helpers draw that has no SVG yet.
|
|
23
|
+
|
|
24
|
+
bin/rails generate velvetkit:icons rocket user
|
|
25
|
+
bin/rails generate velvetkit:icons
|
|
26
|
+
DESC
|
|
27
|
+
|
|
28
|
+
argument :names, type: :array, default: [], banner: "icon icon ..."
|
|
29
|
+
|
|
30
|
+
class_option :icons, type: :string,
|
|
31
|
+
desc: "Icon library: #{Icons::LIBRARIES.keys.join(', ')} (default: #{CONFIG_FILE}, else lucide)"
|
|
32
|
+
|
|
33
|
+
def add_icons
|
|
34
|
+
wanted = names.any? ? names : (drawn - present)
|
|
35
|
+
return say_status(:icons, "every icon drawn has an SVG in #{ICONS_DIR}", :green) if wanted.empty?
|
|
36
|
+
|
|
37
|
+
failed = wanted.uniq.reject { |name| add(name) }
|
|
38
|
+
return if failed.empty?
|
|
39
|
+
|
|
40
|
+
say_status :error, "no SVG for #{failed.join(', ')}. Browse #{icon_library}'s icons at " \
|
|
41
|
+
"#{Icons::LIBRARIES.dig(icon_library, :browse)}", :red
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def add(name)
|
|
47
|
+
create_file File.join(ICONS_DIR, "#{name}.svg"), shipped(name) || Icons.download(name, icon_library)
|
|
48
|
+
true
|
|
49
|
+
rescue Velvetkit::Error => e
|
|
50
|
+
say_status :missing, e.message, :yellow
|
|
51
|
+
false
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The gem's copy, when the kit draws this icon itself.
|
|
55
|
+
def shipped(name)
|
|
56
|
+
file = File.join(registry.root, "icons", icon_library, "#{name}.svg")
|
|
57
|
+
File.read(file) if name.match?(/\A#{Icons::NAME}\z/o) && File.file?(file)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def drawn
|
|
61
|
+
Dir.glob(SOURCES, base: destination_root).flat_map do |file|
|
|
62
|
+
registry.icons.names_in(File.read(File.join(destination_root, file)))
|
|
63
|
+
end.uniq.sort
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def present
|
|
67
|
+
Dir.glob("*.svg", base: File.join(destination_root, ICONS_DIR)).map { |file| file.delete_suffix(".svg") }
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -11,13 +11,16 @@ module Velvetkit
|
|
|
11
11
|
|
|
12
12
|
desc <<~DESC
|
|
13
13
|
Set the app up for VelvetKit: choose the namespace, and add the base
|
|
14
|
-
component, design tokens
|
|
14
|
+
component, design tokens and translations every component uses, and
|
|
15
|
+
choose the icon library the components draw from.
|
|
15
16
|
|
|
16
|
-
bin/rails generate velvetkit:install --namespace=Kit
|
|
17
|
+
bin/rails generate velvetkit:install --namespace=Kit --icons=phosphor
|
|
17
18
|
DESC
|
|
18
19
|
|
|
19
20
|
class_option :namespace, type: :string, default: Namespace::CANONICAL,
|
|
20
21
|
desc: "Module to put the components under"
|
|
22
|
+
class_option :icons, type: :string, default: Icons::CANONICAL,
|
|
23
|
+
desc: "Icon library: #{Icons::LIBRARIES.keys.join(', ')}"
|
|
21
24
|
class_option :skip_tests, type: :boolean, default: false, desc: "Don't copy the base component's test"
|
|
22
25
|
class_option :skip_packages, type: :boolean, default: false,
|
|
23
26
|
desc: "List the npm packages to add instead of installing them"
|
|
@@ -27,8 +30,10 @@ module Velvetkit
|
|
|
27
30
|
def write_config
|
|
28
31
|
create_file CONFIG_FILE, <<~YAML
|
|
29
32
|
# VelvetKit — https://velvetkit.com
|
|
30
|
-
# `bin/rails generate velvetkit:add` puts components under this module
|
|
33
|
+
# `bin/rails generate velvetkit:add` puts components under this module,
|
|
34
|
+
# with their icons from this library (#{Icons::LIBRARIES.keys.join(', ')}).
|
|
31
35
|
namespace: #{kit_namespace.name}
|
|
36
|
+
icons: #{icon_library}
|
|
32
37
|
YAML
|
|
33
38
|
end
|
|
34
39
|
|
|
@@ -74,16 +79,8 @@ module Velvetkit
|
|
|
74
79
|
inject_into_file entry, %(@import "#{path}";\n), after: /@import ["']tailwindcss["'];?\n/
|
|
75
80
|
end
|
|
76
81
|
|
|
77
|
-
def import_icons
|
|
78
|
-
entry = %w[app/javascript/application.js app/javascript/application.ts].find { |file| exists?(file) }
|
|
79
|
-
return say_status(:js, "import ./velvetkit_icons from your JavaScript entry point", :yellow) unless entry
|
|
80
|
-
return if read(entry).include?("velvetkit_icons")
|
|
81
|
-
|
|
82
|
-
append_to_file entry, %(import "./velvetkit_icons"\n)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
82
|
def add_base_component
|
|
86
|
-
invoke "velvetkit:add", [ "base" ], namespace: kit_namespace.name, skip_tests: options[:skip_tests], skip_packages: true
|
|
83
|
+
invoke "velvetkit:add", [ "base" ], namespace: kit_namespace.name, icons: icon_library, skip_tests: options[:skip_tests], skip_packages: true
|
|
87
84
|
end
|
|
88
85
|
|
|
89
86
|
def add_packages
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "yaml"
|
|
4
|
+
require "net/http"
|
|
5
|
+
|
|
6
|
+
module Velvetkit
|
|
7
|
+
# The icon libraries an app can choose, and how the kit's icons get there.
|
|
8
|
+
#
|
|
9
|
+
# Like shadcn/ui, the choice is made when components are copied, not at
|
|
10
|
+
# runtime. The registry is written with Lucide names; on the way into an
|
|
11
|
+
# app whose config/velvetkit.yml says `icons: phosphor`, every icon name
|
|
12
|
+
# in a component, its test and its preview is swapped for Phosphor's
|
|
13
|
+
# (`circle-alert` → `warning-circle`), and the SVGs it draws are copied to
|
|
14
|
+
# app/assets/icons. After that the app's code names its own library's
|
|
15
|
+
# icons and nothing looks anything up.
|
|
16
|
+
#
|
|
17
|
+
# registry/icons.yml lists every icon the kit and its previews draw, by its
|
|
18
|
+
# Lucide name, with its name in each other library. registry/icons/<library>/
|
|
19
|
+
# holds the SVGs, fetched by `rake icons:sync`.
|
|
20
|
+
class Icons
|
|
21
|
+
CANONICAL = "lucide"
|
|
22
|
+
|
|
23
|
+
# Where each library's SVGs are published, one file per icon.
|
|
24
|
+
LIBRARIES = {
|
|
25
|
+
"lucide" => { package: "lucide-static", version: "0.545.0", file: "icons/%s.svg",
|
|
26
|
+
license: "ISC", browse: "https://lucide.dev/icons" },
|
|
27
|
+
"tabler" => { package: "@tabler/icons", version: "3.50.0", file: "icons/outline/%s.svg",
|
|
28
|
+
license: "MIT", browse: "https://tabler.io/icons" },
|
|
29
|
+
"phosphor" => { package: "@phosphor-icons/core", version: "2.1.1", file: "assets/regular/%s.svg",
|
|
30
|
+
license: "MIT", browse: "https://phosphoricons.com" }
|
|
31
|
+
}.freeze
|
|
32
|
+
|
|
33
|
+
NAME = /[a-z0-9]+(?:-[a-z0-9]+)*/
|
|
34
|
+
|
|
35
|
+
# Each way the kit's source names an icon, in a `name` group (`symbol`
|
|
36
|
+
# for `name: :x`). Only that group is renamed.
|
|
37
|
+
#
|
|
38
|
+
# UI::Icon.new(name: "check") with_leading_icon(name: :x)
|
|
39
|
+
# dismiss_icon: "x" { icon: "sun" }
|
|
40
|
+
# svg[data-icon='x'] (tests)
|
|
41
|
+
PATTERNS = [
|
|
42
|
+
/(?:Icon\.new|_icon)\(\s*name:\s*"(?<name>#{NAME})"/,
|
|
43
|
+
/(?:Icon\.new|_icon)\(\s*name:\s*:(?<symbol>[a-z0-9_]+)\b/,
|
|
44
|
+
/\b(?:\w+_)?icon:\s*"(?<name>#{NAME})"/,
|
|
45
|
+
/data-icon=\\?['"](?<name>#{NAME})/
|
|
46
|
+
].freeze
|
|
47
|
+
|
|
48
|
+
# DEFAULT_ICONS = { default: "info", destructive: "circle-alert" }
|
|
49
|
+
MAP = /ICONS\s*=\s*\{(?<body>.*?)\}/m
|
|
50
|
+
|
|
51
|
+
def self.library!(name)
|
|
52
|
+
name = (name || CANONICAL).to_s
|
|
53
|
+
return name if LIBRARIES.key?(name)
|
|
54
|
+
|
|
55
|
+
raise Error, "Unknown icon library #{name.inspect}. Available: #{LIBRARIES.keys.join(', ')}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
attr_reader :root
|
|
59
|
+
|
|
60
|
+
def initialize(root)
|
|
61
|
+
@root = root
|
|
62
|
+
@names = YAML.load_file(File.join(root, "icons.yml"))
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Every icon the registry knows, by its Lucide name.
|
|
66
|
+
def canonical
|
|
67
|
+
@names.keys
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# An icon's name in `library`, or nil if the registry doesn't map it.
|
|
71
|
+
def name(icon, library)
|
|
72
|
+
return (@names.key?(icon) ? icon : nil) if library == CANONICAL
|
|
73
|
+
|
|
74
|
+
@names.dig(icon, library)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# The Lucide names the source draws. Comments don't count.
|
|
78
|
+
def names_in(source)
|
|
79
|
+
code = without_comments(source)
|
|
80
|
+
names = PATTERNS.flat_map { |pattern| code.to_enum(:scan, pattern).map { icon_in(Regexp.last_match) } }
|
|
81
|
+
code.scan(MAP).flatten.each { |body| names += body.scan(/"(#{NAME})"/o).flatten }
|
|
82
|
+
names.uniq
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# The source with every icon the registry maps renamed for `library`.
|
|
86
|
+
# Names it doesn't map are left alone.
|
|
87
|
+
def rewrite(source, library)
|
|
88
|
+
return source if library == CANONICAL
|
|
89
|
+
|
|
90
|
+
rename = ->(icon) { name(icon, library) || icon }
|
|
91
|
+
source = PATTERNS.reduce(source) do |text, pattern|
|
|
92
|
+
text.gsub(pattern) do |match|
|
|
93
|
+
found = Regexp.last_match
|
|
94
|
+
icon = icon_in(found)
|
|
95
|
+
next match if rename.call(icon) == icon
|
|
96
|
+
|
|
97
|
+
group = found.names.first
|
|
98
|
+
from = found.begin(group) - found.begin(0)
|
|
99
|
+
to = found.end(group) - found.begin(0)
|
|
100
|
+
# A symbol (`name: :x`) becomes a string: most names have a dash.
|
|
101
|
+
from -= 1 if group == "symbol"
|
|
102
|
+
match[0...from] + (group == "symbol" ? %("#{rename.call(icon)}") : rename.call(icon)) + match[to..]
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
source.gsub(MAP) { |map| map.gsub(/"(#{NAME})"/o) { %("#{rename.call(Regexp.last_match(1))}") } }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# The registry's copy of an icon's SVG, by its Lucide name.
|
|
109
|
+
def svg_file(icon, library)
|
|
110
|
+
File.join("icons", library, "#{name(icon, library)}.svg")
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# An icon's SVG, by its name in `library`, from the npm CDN. Tagged with
|
|
114
|
+
# its license, which the ISC and MIT licenses ask copies to keep.
|
|
115
|
+
def self.download(icon, library)
|
|
116
|
+
raise Error, "#{icon.inspect} isn't an icon name" unless icon.match?(/\A#{NAME}\z/o)
|
|
117
|
+
|
|
118
|
+
spec = LIBRARIES.fetch(library)
|
|
119
|
+
uri = URI("https://unpkg.com/#{spec[:package]}@#{spec[:version]}/#{format(spec[:file], icon)}")
|
|
120
|
+
response = fetch(uri)
|
|
121
|
+
unless response.is_a?(Net::HTTPSuccess)
|
|
122
|
+
raise Error, "#{library} has no icon named #{icon.inspect} (#{uri} answered #{response.code}). " \
|
|
123
|
+
"Browse them at #{spec[:browse]}"
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
svg = response.body.sub(/\A\s*<!--.*?-->\s*/m, "").strip
|
|
127
|
+
"<!-- @license #{spec[:package]} v#{spec[:version]} - #{spec[:license]} -->\n#{svg}\n"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def self.fetch(uri, redirects = 3)
|
|
131
|
+
response = Net::HTTP.get_response(uri)
|
|
132
|
+
return response unless response.is_a?(Net::HTTPRedirection) && redirects.positive?
|
|
133
|
+
|
|
134
|
+
fetch(URI.join(uri, response["location"]), redirects - 1)
|
|
135
|
+
end
|
|
136
|
+
private_class_method :fetch
|
|
137
|
+
|
|
138
|
+
private
|
|
139
|
+
|
|
140
|
+
def icon_in(match)
|
|
141
|
+
match.names.include?("symbol") ? match[:symbol].tr("_", "-") : match[:name]
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def without_comments(source)
|
|
145
|
+
source.gsub(/<%#.*?%>/m, "").lines.grep_v(/\A\s*#/).join
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
data/lib/velvetkit/registry.rb
CHANGED
|
@@ -18,9 +18,8 @@ module Velvetkit
|
|
|
18
18
|
FOUNDATION = %w[
|
|
19
19
|
config/locales/velvetkit.en.yml
|
|
20
20
|
app/assets/tailwind/velvetkit.css
|
|
21
|
-
app/javascript/velvetkit_icons.ts
|
|
22
21
|
].freeze
|
|
23
|
-
FOUNDATION_PACKAGES = %w[@hotwired/stimulus
|
|
22
|
+
FOUNDATION_PACKAGES = %w[@hotwired/stimulus tw-animate-css].freeze
|
|
24
23
|
|
|
25
24
|
attr_reader :root
|
|
26
25
|
|
|
@@ -29,6 +28,10 @@ module Velvetkit
|
|
|
29
28
|
@catalog = YAML.load_file(File.join(root, "components.yml"))
|
|
30
29
|
end
|
|
31
30
|
|
|
31
|
+
def icons
|
|
32
|
+
@icons ||= Icons.new(root)
|
|
33
|
+
end
|
|
34
|
+
|
|
32
35
|
def names
|
|
33
36
|
@catalog.fetch("components").keys
|
|
34
37
|
end
|
data/lib/velvetkit/version.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Velvetkit
|
|
4
|
-
|
|
4
|
+
# Not the released version: the release workflow takes that from the tag
|
|
5
|
+
# (v0.3.0 publishes 0.3.0) and writes it here on the runner only, so this
|
|
6
|
+
# file can stay behind. See .github/workflows/release.yml.
|
|
7
|
+
VERSION = "0.4.0"
|
|
5
8
|
end
|
data/lib/velvetkit.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "velvetkit/version"
|
|
4
4
|
require "velvetkit/namespace"
|
|
5
5
|
require "velvetkit/registry"
|
|
6
|
+
require "velvetkit/icons"
|
|
6
7
|
require "velvetkit/reference"
|
|
7
8
|
|
|
8
9
|
# VelvetKit copies ViewComponent UI components into a Rails app, one at a time
|
|
@@ -17,6 +18,13 @@ module Velvetkit
|
|
|
17
18
|
@registry ||= Registry.new(File.expand_path("../registry", __dir__))
|
|
18
19
|
end
|
|
19
20
|
|
|
21
|
+
# Forgets the catalog, so the next call reads components.yml again. The docs
|
|
22
|
+
# site calls it on each code reload in development, so a component added to
|
|
23
|
+
# the catalog shows up without restarting the server.
|
|
24
|
+
def self.reload_registry!
|
|
25
|
+
@registry = nil
|
|
26
|
+
end
|
|
27
|
+
|
|
20
28
|
# Everything an AI agent needs to build UI in an app: the rules, then a
|
|
21
29
|
# reference for each component, all in the app's namespace.
|
|
22
30
|
def self.agent_guide(components, namespace: Namespace.new(Namespace::CANONICAL))
|