nitro_kit 2.0.0.beta.3 → 2.0.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 +37 -0
- data/LICENSE +21 -28
- data/README.md +10 -9
- data/app/assets/stylesheets/nitro_kit.css +1660 -1401
- data/app/components/nitro_kit/accordion.rb +1 -13
- data/app/components/nitro_kit/app_navigation.rb +0 -12
- data/app/components/nitro_kit/app_shell.rb +5 -11
- data/app/components/nitro_kit/appearance_picker.rb +1 -7
- data/app/components/nitro_kit/combobox.rb +366 -21
- data/app/components/nitro_kit/command_palette.rb +7 -20
- data/app/components/nitro_kit/details_table.rb +5 -11
- data/app/components/nitro_kit/dropzone.rb +3 -15
- data/app/components/nitro_kit/field.rb +20 -2
- data/app/components/nitro_kit/pagination.rb +2 -8
- data/app/components/nitro_kit/settings_layout.rb +3 -9
- data/app/javascript/controllers/nk/app_shell_controller.js +2 -2
- data/app/javascript/controllers/nk/combobox_controller.js +308 -22
- data/app/javascript/controllers/nk/combobox_remote.js +70 -0
- data/app/javascript/controllers/nk/dropzone_controller.js +2 -2
- data/app/javascript/controllers/nk/tabs_controller.js +2 -2
- data/config/locales/en.yml +3 -0
- data/docs/agent_guide.md +43 -13
- data/docs/component_contracts.md +90 -61
- data/docs/customization.md +173 -35
- data/docs/initialization_prompt.md +4 -5
- data/docs/migration_1_to_2.md +10 -8
- data/docs/patterns/application_foundation.md +5 -0
- data/docs/patterns/composition.md +61 -0
- data/docs/patterns/crud_resource.md +5 -0
- data/docs/patterns/inset_workspace.md +21 -22
- data/docs/patterns/resource_form.md +65 -0
- data/docs/rails_integration.md +214 -2
- data/lib/generators/nitro_kit/install_generator.rb +5 -4
- data/lib/nitro_kit/installation.rb +327 -68
- data/lib/nitro_kit/migration_inventory.rb +18 -3
- data/lib/nitro_kit/version.rb +1 -1
- data/lib/rails/commands/nitro_kit/nitro_kit_command.rb +2 -2
- data/patterns/README.md +21 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/account_deletion.rb +72 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/base.rb +44 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/page.rb +57 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/preferences.rb +68 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/profile.rb +86 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/security.rb +69 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/sessions.rb +86 -0
- data/patterns/account-settings/files/app/controllers/settings/account_deletions_controller.rb +35 -0
- data/patterns/account-settings/files/app/controllers/settings/base_controller.rb +12 -0
- data/patterns/account-settings/files/app/controllers/settings/other_sessions_controller.rb +8 -0
- data/patterns/account-settings/files/app/controllers/settings/preferences_controller.rb +27 -0
- data/patterns/account-settings/files/app/controllers/settings/profiles_controller.rb +20 -0
- data/patterns/account-settings/files/app/controllers/settings/securities_controller.rb +37 -0
- data/patterns/account-settings/files/app/controllers/settings/sessions_controller.rb +31 -0
- data/patterns/account-settings/files/app/models/account_settings/account_closure.rb +33 -0
- data/patterns/account-settings/files/app/models/account_settings/password_change.rb +42 -0
- data/patterns/account-settings/files/app/models/account_settings/session_summary.rb +45 -0
- data/patterns/account-settings/files/app/models/concerns/user/account_configurable.rb +18 -0
- data/patterns/account-settings/files/config/routes/account_settings.rb +10 -0
- data/patterns/account-settings/files/db/migrate/20260731020000_add_account_settings.rb +27 -0
- data/patterns/account-settings/files/test/controllers/settings/account_settings_flow_test.rb +84 -0
- data/patterns/account-settings/files/test/models/account_settings/password_change_test.rb +40 -0
- data/patterns/account-settings/files/test/system/account_settings_test.rb +52 -0
- data/patterns/account-settings/item.yml +4 -0
- data/patterns/account-settings/pattern.md +44 -0
- data/patterns/application-shell/files/app/assets/stylesheets/ui/application_shell.css +267 -0
- data/patterns/application-shell/files/app/components/ui/application_shell.rb +184 -0
- data/patterns/application-shell/item.yml +4 -0
- data/patterns/application-shell/pattern.md +110 -0
- data/patterns/authentication/files/app/components/ui/authentication/base.rb +11 -0
- data/patterns/authentication/files/app/components/ui/authentication/page.rb +53 -0
- data/patterns/authentication/files/app/components/ui/email_verifications/show.rb +62 -0
- data/patterns/authentication/files/app/components/ui/password_resets/new.rb +65 -0
- data/patterns/authentication/files/app/components/ui/passwords/edit.rb +72 -0
- data/patterns/authentication/files/app/components/ui/sessions/new.rb +58 -0
- data/patterns/authentication/files/app/components/ui/verification_emails/new.rb +59 -0
- data/patterns/authentication/files/app/controllers/concerns/authentication.rb +66 -0
- data/patterns/authentication/files/app/controllers/concerns/safe_return_navigation.rb +37 -0
- data/patterns/authentication/files/app/controllers/email_verifications_controller.rb +39 -0
- data/patterns/authentication/files/app/controllers/password_resets_controller.rb +33 -0
- data/patterns/authentication/files/app/controllers/passwords_controller.rb +51 -0
- data/patterns/authentication/files/app/controllers/sessions_controller.rb +42 -0
- data/patterns/authentication/files/app/controllers/verification_emails_controller.rb +33 -0
- data/patterns/authentication/files/app/jobs/authentication_delivery_job.rb +17 -0
- data/patterns/authentication/files/app/mailers/authentication_mailer.rb +15 -0
- data/patterns/authentication/files/app/models/authentication/credentials.rb +16 -0
- data/patterns/authentication/files/app/models/authentication/email_request.rb +17 -0
- data/patterns/authentication/files/app/models/concerns/user/email_verifiable.rb +40 -0
- data/patterns/authentication/files/app/models/session.rb +5 -0
- data/patterns/authentication/files/app/views/authentication_mailer/email_verification.html.erb +3 -0
- data/patterns/authentication/files/app/views/authentication_mailer/email_verification.text.erb +5 -0
- data/patterns/authentication/files/app/views/authentication_mailer/password_reset.html.erb +3 -0
- data/patterns/authentication/files/app/views/authentication_mailer/password_reset.text.erb +5 -0
- data/patterns/authentication/files/config/routes/authentication.rb +11 -0
- data/patterns/authentication/files/db/migrate/20260731000000_add_authentication_and_recovery.rb +13 -0
- data/patterns/authentication/files/test/controllers/authentication_flow_test.rb +103 -0
- data/patterns/authentication/files/test/controllers/safe_return_navigation_test.rb +18 -0
- data/patterns/authentication/files/test/mailers/authentication_mailer_test.rb +21 -0
- data/patterns/authentication/files/test/models/user_email_verifiable_test.rb +36 -0
- data/patterns/authentication/files/test/system/authentication_flow_test.rb +23 -0
- data/patterns/authentication/item.yml +12 -0
- data/patterns/authentication/pattern.md +54 -0
- data/patterns/crud-resource/files/app/assets/stylesheets/ui/projects.css +4 -0
- data/patterns/crud-resource/files/app/components/ui/projects/form.rb +89 -0
- data/patterns/crud-resource/files/app/components/ui/projects/index.rb +161 -0
- data/patterns/crud-resource/files/app/components/ui/projects/show.rb +84 -0
- data/patterns/crud-resource/files/app/controllers/projects/archivals_controller.rb +23 -0
- data/patterns/crud-resource/files/app/controllers/projects_controller.rb +70 -0
- data/patterns/crud-resource/files/app/models/project/archival.rb +8 -0
- data/patterns/crud-resource/files/app/models/project/event.rb +12 -0
- data/patterns/crud-resource/files/app/models/project/filter.rb +41 -0
- data/patterns/crud-resource/files/app/models/project.rb +41 -0
- data/patterns/crud-resource/files/app/views/projects/edit.html.erb +19 -0
- data/patterns/crud-resource/files/app/views/projects/index.html.erb +18 -0
- data/patterns/crud-resource/files/app/views/projects/new.html.erb +16 -0
- data/patterns/crud-resource/files/app/views/projects/show.html.erb +28 -0
- data/patterns/crud-resource/files/config/routes/crud_resource.rb +7 -0
- data/patterns/crud-resource/files/db/migrate/20260720000000_create_crud_resource.rb +37 -0
- data/patterns/crud-resource/files/test/controllers/projects_controller_test.rb +64 -0
- data/patterns/crud-resource/files/test/models/project_test.rb +34 -0
- data/patterns/crud-resource/files/test/support/crud_resource_test_helpers.rb +25 -0
- data/patterns/crud-resource/files/test/system/projects_crud_test.rb +87 -0
- data/patterns/crud-resource/item.yml +6 -0
- data/patterns/crud-resource/pattern.md +48 -0
- data/patterns/file-uploads/files/app/assets/stylesheets/ui/uploads.css +133 -0
- data/patterns/file-uploads/files/app/components/ui/uploads/base.rb +30 -0
- data/patterns/file-uploads/files/app/components/ui/uploads/index.rb +188 -0
- data/patterns/file-uploads/files/app/components/ui/uploads/page.rb +33 -0
- data/patterns/file-uploads/files/app/controllers/uploads/base_controller.rb +29 -0
- data/patterns/file-uploads/files/app/controllers/uploads/direct_uploads_controller.rb +55 -0
- data/patterns/file-uploads/files/app/controllers/uploads/retries_controller.rb +14 -0
- data/patterns/file-uploads/files/app/controllers/uploads_controller.rb +40 -0
- data/patterns/file-uploads/files/app/jobs/upload_blob_cleanup_job.rb +9 -0
- data/patterns/file-uploads/files/app/jobs/upload_processing_job.rb +10 -0
- data/patterns/file-uploads/files/app/jobs/upload_repair_job.rb +17 -0
- data/patterns/file-uploads/files/app/models/concerns/team/uploadable.rb +9 -0
- data/patterns/file-uploads/files/app/models/upload.rb +295 -0
- data/patterns/file-uploads/files/config/recurring/uploads.yml +7 -0
- data/patterns/file-uploads/files/config/routes/uploads.rb +5 -0
- data/patterns/file-uploads/files/db/migrate/20260802000000_add_file_uploads.rb +30 -0
- data/patterns/file-uploads/files/test/controllers/uploads_flow_test.rb +77 -0
- data/patterns/file-uploads/files/test/fixtures/files/workspace.png.base64 +1 -0
- data/patterns/file-uploads/files/test/fixtures/uploads.yml +17 -0
- data/patterns/file-uploads/files/test/models/upload_test.rb +55 -0
- data/patterns/file-uploads/files/test/system/file_uploads_test.rb +30 -0
- data/patterns/file-uploads/item.yml +4 -0
- data/patterns/file-uploads/pattern.md +71 -0
- data/patterns/nitro-kit-1-upgrade/files/docs/nitro_kit_1_upgrade.md +57 -0
- data/patterns/nitro-kit-1-upgrade/item.yml +4 -0
- data/patterns/nitro-kit-1-upgrade/pattern.md +30 -0
- data/patterns/onboarding/files/app/assets/stylesheets/ui/onboarding.css +55 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/base.rb +11 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/branch_form.rb +36 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/details_form.rb +67 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/invitation_plan_form.rb +48 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/page.rb +75 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/review.rb +51 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/show.rb +32 -0
- data/patterns/onboarding/files/app/controllers/concerns/requires_finished_onboarding.rb +14 -0
- data/patterns/onboarding/files/app/controllers/onboarding/base_controller.rb +30 -0
- data/patterns/onboarding/files/app/controllers/onboarding/branches_controller.rb +16 -0
- data/patterns/onboarding/files/app/controllers/onboarding/completions_controller.rb +13 -0
- data/patterns/onboarding/files/app/controllers/onboarding/details_controller.rb +16 -0
- data/patterns/onboarding/files/app/controllers/onboarding/invitation_plans_controller.rb +20 -0
- data/patterns/onboarding/files/app/controllers/onboardings_controller.rb +7 -0
- data/patterns/onboarding/files/app/jobs/onboarding_invitation_delivery_job.rb +15 -0
- data/patterns/onboarding/files/app/models/concerns/team/onboardable.rb +23 -0
- data/patterns/onboarding/files/app/models/onboarding/completion.rb +17 -0
- data/patterns/onboarding/files/app/models/onboarding/invitation_delivery.rb +14 -0
- data/patterns/onboarding/files/app/models/onboarding.rb +174 -0
- data/patterns/onboarding/files/config/routes/onboarding.rb +11 -0
- data/patterns/onboarding/files/db/migrate/20260731010000_create_onboarding.rb +60 -0
- data/patterns/onboarding/files/test/controllers/onboarding_flow_test.rb +62 -0
- data/patterns/onboarding/files/test/fixtures/onboarding_completions.yml +3 -0
- data/patterns/onboarding/files/test/fixtures/onboardings.yml +25 -0
- data/patterns/onboarding/files/test/jobs/onboarding_invitation_delivery_job_test.rb +18 -0
- data/patterns/onboarding/files/test/models/onboarding_test.rb +60 -0
- data/patterns/onboarding/files/test/system/onboarding_flow_test.rb +39 -0
- data/patterns/onboarding/item.yml +4 -0
- data/patterns/onboarding/pattern.md +53 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/base.rb +39 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/checkout_result.rb +64 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/page.rb +33 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/show.rb +149 -0
- data/patterns/subscription-billing/files/app/controllers/billing/base_controller.rb +16 -0
- data/patterns/subscription-billing/files/app/controllers/billing/checkouts_controller.rb +65 -0
- data/patterns/subscription-billing/files/app/controllers/billing/portals_controller.rb +18 -0
- data/patterns/subscription-billing/files/app/controllers/billing_controller.rb +17 -0
- data/patterns/subscription-billing/files/app/controllers/webhooks/stripe_events_controller.rb +21 -0
- data/patterns/subscription-billing/files/app/jobs/billing/stripe_event_job.rb +16 -0
- data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_job.rb +16 -0
- data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_sweep_job.rb +9 -0
- data/patterns/subscription-billing/files/app/models/billing/checkout.rb +58 -0
- data/patterns/subscription-billing/files/app/models/billing/plan.rb +19 -0
- data/patterns/subscription-billing/files/app/models/billing/stripe_event.rb +73 -0
- data/patterns/subscription-billing/files/app/models/billing/subscription.rb +106 -0
- data/patterns/subscription-billing/files/app/models/concerns/team/billable.rb +36 -0
- data/patterns/subscription-billing/files/config/initializers/stripe.rb +29 -0
- data/patterns/subscription-billing/files/config/routes/subscription_billing.rb +10 -0
- data/patterns/subscription-billing/files/db/migrate/20260801000000_add_subscription_billing.rb +61 -0
- data/patterns/subscription-billing/files/test/controllers/billing_flow_test.rb +60 -0
- data/patterns/subscription-billing/files/test/models/billing/subscription_test.rb +40 -0
- data/patterns/subscription-billing/files/test/system/subscription_billing_test.rb +28 -0
- data/patterns/subscription-billing/item.yml +4 -0
- data/patterns/subscription-billing/pattern.md +59 -0
- data/patterns/team-management/files/app/components/ui/invitations/acceptance.rb +33 -0
- data/patterns/team-management/files/app/components/ui/teams/index.rb +87 -0
- data/patterns/team-management/files/app/components/ui/teams/invitation_form.rb +51 -0
- data/patterns/team-management/files/app/components/ui/teams/member_form.rb +78 -0
- data/patterns/team-management/files/app/components/ui/teams/members.rb +125 -0
- data/patterns/team-management/files/app/controllers/invitations/acceptances_controller.rb +29 -0
- data/patterns/team-management/files/app/controllers/teams/base_controller.rb +18 -0
- data/patterns/team-management/files/app/controllers/teams/invitations_controller.rb +42 -0
- data/patterns/team-management/files/app/controllers/teams/memberships_controller.rb +53 -0
- data/patterns/team-management/files/app/controllers/teams_controller.rb +30 -0
- data/patterns/team-management/files/app/mailers/team_invitation_mailer.rb +10 -0
- data/patterns/team-management/files/app/models/concerns/current_team.rb +13 -0
- data/patterns/team-management/files/app/models/concerns/user_teams.rb +37 -0
- data/patterns/team-management/files/app/models/invitation.rb +41 -0
- data/patterns/team-management/files/app/models/membership.rb +45 -0
- data/patterns/team-management/files/app/models/team.rb +25 -0
- data/patterns/team-management/files/app/views/invitations/acceptances/show.html.erb +1 -0
- data/patterns/team-management/files/app/views/team_invitation_mailer/invite.html.erb +10 -0
- data/patterns/team-management/files/app/views/team_invitation_mailer/invite.text.erb +7 -0
- data/patterns/team-management/files/app/views/teams/index.html.erb +15 -0
- data/patterns/team-management/files/app/views/teams/invitations/new.html.erb +22 -0
- data/patterns/team-management/files/app/views/teams/memberships/edit.html.erb +22 -0
- data/patterns/team-management/files/app/views/teams/memberships/index.html.erb +20 -0
- data/patterns/team-management/files/config/routes/team_management.rb +11 -0
- data/patterns/team-management/files/db/migrate/20260717000000_create_team_management.rb +31 -0
- data/patterns/team-management/files/test/models/invitation_test.rb +28 -0
- data/patterns/team-management/files/test/models/membership_test.rb +29 -0
- data/patterns/team-management/files/test/models/team_test.rb +31 -0
- data/patterns/team-management/files/test/support/team_management_test_helpers.rb +22 -0
- data/patterns/team-management/item.yml +4 -0
- data/patterns/team-management/pattern.md +47 -0
- data/patterns/webhook-deliveries/files/app/assets/stylesheets/ui/webhooks.css +179 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/base.rb +38 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/delivery.rb +160 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/endpoint.rb +149 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/form.rb +75 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/index.rb +142 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/page.rb +33 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/secret.rb +38 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries/replays_controller.rb +13 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries_controller.rb +7 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints/secrets_controller.rb +41 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints_controller.rb +67 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhooks/base_controller.rb +15 -0
- data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_job.rb +9 -0
- data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_repair_job.rb +11 -0
- data/patterns/webhook-deliveries/files/app/models/concerns/team/webhookable.rb +11 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/attempt.rb +30 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/delivery.rb +268 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/endpoint.rb +58 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/event.rb +98 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/secret_reveal.rb +53 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/signature.rb +22 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/transport.rb +176 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_deliveries/show.html.erb +5 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/edit.html.erb +1 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/index.html.erb +6 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/new.html.erb +1 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/secrets/new.html.erb +1 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/show.html.erb +7 -0
- data/patterns/webhook-deliveries/files/config/recurring/webhooks.yml +4 -0
- data/patterns/webhook-deliveries/files/config/routes/webhook_deliveries.rb +10 -0
- data/patterns/webhook-deliveries/files/db/migrate/20260803000000_add_webhook_deliveries.rb +126 -0
- data/patterns/webhook-deliveries/files/test/controllers/webhook_endpoints_flow_test.rb +48 -0
- data/patterns/webhook-deliveries/files/test/models/webhook/delivery_test.rb +70 -0
- data/patterns/webhook-deliveries/files/test/system/webhook_deliveries_test.rb +29 -0
- data/patterns/webhook-deliveries/item.yml +4 -0
- data/patterns/webhook-deliveries/pattern.md +120 -0
- data/plugins/nitro-kit/.codex-plugin/plugin.json +4 -4
- data/plugins/nitro-kit/skills/nitro-kit-hotwire/SKILL.md +7 -9
- data/plugins/nitro-kit/skills/nitro-kit-hotwire/agents/openai.yaml +1 -1
- data/plugins/nitro-kit/skills/nitro-kit-rails/SKILL.md +10 -9
- data/plugins/nitro-kit/skills/nitro-kit-rails/agents/openai.yaml +1 -1
- data/plugins/nitro-kit/skills/nitro-kit-ui/SKILL.md +27 -16
- data/plugins/nitro-kit/skills/nitro-kit-ui/agents/openai.yaml +1 -1
- data/src/stylesheets/nitro_kit/components/accordion.css +40 -40
- data/src/stylesheets/nitro_kit/components/alert.css +7 -6
- data/src/stylesheets/nitro_kit/components/app_navigation.css +50 -41
- data/src/stylesheets/nitro_kit/components/app_shell.css +371 -280
- data/src/stylesheets/nitro_kit/components/appearance_picker.css +38 -38
- data/src/stylesheets/nitro_kit/components/avatar.css +3 -3
- data/src/stylesheets/nitro_kit/components/avatar_stack.css +18 -18
- data/src/stylesheets/nitro_kit/components/badge.css +5 -2
- data/src/stylesheets/nitro_kit/components/button.css +57 -49
- data/src/stylesheets/nitro_kit/components/button_group.css +14 -14
- data/src/stylesheets/nitro_kit/components/checkbox.css +24 -24
- data/src/stylesheets/nitro_kit/components/checkbox_group.css +13 -13
- data/src/stylesheets/nitro_kit/components/combobox.css +152 -25
- data/src/stylesheets/nitro_kit/components/command_palette.css +59 -59
- data/src/stylesheets/nitro_kit/components/control_group.css +71 -54
- data/src/stylesheets/nitro_kit/components/details_table.css +9 -9
- data/src/stylesheets/nitro_kit/components/dialog.css +8 -12
- data/src/stylesheets/nitro_kit/components/dropdown.css +22 -26
- data/src/stylesheets/nitro_kit/components/dropzone.css +97 -100
- data/src/stylesheets/nitro_kit/components/empty_state.css +1 -0
- data/src/stylesheets/nitro_kit/components/field.css +26 -30
- data/src/stylesheets/nitro_kit/components/fieldset.css +2 -2
- data/src/stylesheets/nitro_kit/components/input.css +6 -14
- data/src/stylesheets/nitro_kit/components/layout.css +165 -165
- data/src/stylesheets/nitro_kit/components/page_header.css +3 -3
- data/src/stylesheets/nitro_kit/components/pagination.css +66 -49
- data/src/stylesheets/nitro_kit/components/pagination_bar.css +6 -6
- data/src/stylesheets/nitro_kit/components/palette.css +24 -22
- data/src/stylesheets/nitro_kit/components/progressive_image.css +38 -41
- data/src/stylesheets/nitro_kit/components/radio_button.css +19 -19
- data/src/stylesheets/nitro_kit/components/radio_button_group.css +43 -43
- data/src/stylesheets/nitro_kit/components/rich_text_area.css +4 -4
- data/src/stylesheets/nitro_kit/components/select.css +2 -2
- data/src/stylesheets/nitro_kit/components/settings_layout.css +17 -18
- data/src/stylesheets/nitro_kit/components/settings_section.css +12 -12
- data/src/stylesheets/nitro_kit/components/sheet.css +10 -10
- data/src/stylesheets/nitro_kit/components/stat_grid.css +9 -9
- data/src/stylesheets/nitro_kit/components/switch.css +23 -23
- data/src/stylesheets/nitro_kit/components/table.css +27 -27
- data/src/stylesheets/nitro_kit/components/tabs.css +32 -34
- data/src/stylesheets/nitro_kit/components/toolbar.css +6 -6
- data/src/stylesheets/nitro_kit/components/tooltip.css +26 -28
- data/src/stylesheets/nitro_kit/layers.css +2 -1
- data/src/stylesheets/nitro_kit/reset.css +9 -9
- data/src/stylesheets/nitro_kit/tailwind.css +6 -2
- data/src/stylesheets/nitro_kit/tokens.css +18 -9
- metadata +238 -2
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
class ApplicationShell < Phlex::HTML
|
|
5
|
+
include Phlex::Rails::Helpers::Routes
|
|
6
|
+
|
|
7
|
+
PRODUCT_NAME = "Racecamp"
|
|
8
|
+
|
|
9
|
+
def initialize(
|
|
10
|
+
title:,
|
|
11
|
+
current:,
|
|
12
|
+
actions: [],
|
|
13
|
+
back: nil,
|
|
14
|
+
layout: :sidebar,
|
|
15
|
+
collapsible: false,
|
|
16
|
+
product_name: PRODUCT_NAME,
|
|
17
|
+
logo_url: nil,
|
|
18
|
+
workspace: nil,
|
|
19
|
+
identity: nil,
|
|
20
|
+
navigation: nil
|
|
21
|
+
)
|
|
22
|
+
@title = title
|
|
23
|
+
@current = current
|
|
24
|
+
@actions = actions
|
|
25
|
+
@back = back
|
|
26
|
+
@layout = layout
|
|
27
|
+
@collapsible = collapsible
|
|
28
|
+
@product_name = product_name
|
|
29
|
+
@logo_url = logo_url
|
|
30
|
+
@workspace = workspace
|
|
31
|
+
@identity = identity
|
|
32
|
+
@navigation = navigation
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def view_template(&content)
|
|
36
|
+
raise ArgumentError, "ApplicationShell requires page content" unless content
|
|
37
|
+
|
|
38
|
+
resolve_defaults
|
|
39
|
+
|
|
40
|
+
render NitroKit::AppShell.new(
|
|
41
|
+
id: "application-shell",
|
|
42
|
+
layout: @layout,
|
|
43
|
+
collapsible: @collapsible,
|
|
44
|
+
data: { ui: "application-shell" }
|
|
45
|
+
) do |shell|
|
|
46
|
+
shell.brand { render_brand } unless sidebar?
|
|
47
|
+
shell.navigation { render_navigation }
|
|
48
|
+
shell.topbar { render_toolbar } if sidebar?
|
|
49
|
+
shell.main { render_main(content) }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def resolve_defaults
|
|
56
|
+
@navigation ||= [
|
|
57
|
+
{ key: :projects, label: "Projects", href: projects_path, icon: :folder },
|
|
58
|
+
{ key: :team, label: "Team", href: teams_path, icon: :users }
|
|
59
|
+
]
|
|
60
|
+
@workspace ||= { name: Current.team.name, href: teams_path }
|
|
61
|
+
@identity ||= {
|
|
62
|
+
name: Current.user.team_display_name,
|
|
63
|
+
detail: Current.user.team_email
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def render_navigation
|
|
68
|
+
render NitroKit::AppNavigation.new(id: "application-navigation", label: "Primary navigation") do |navigation|
|
|
69
|
+
navigation.header do
|
|
70
|
+
render_brand
|
|
71
|
+
render_workspace_switcher
|
|
72
|
+
end
|
|
73
|
+
navigation.body { render_navigation_items(navigation) }
|
|
74
|
+
navigation.footer do
|
|
75
|
+
render_command_palette
|
|
76
|
+
render_identity
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def render_brand
|
|
82
|
+
if @logo_url
|
|
83
|
+
img(src: @logo_url, alt: @product_name, width: 132, height: 28, data: { ui: "application-logo" })
|
|
84
|
+
else
|
|
85
|
+
strong { @product_name }
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def render_workspace_switcher
|
|
90
|
+
render NitroKit::Dropdown.new(id: "application-workspace-switcher") do |dropdown|
|
|
91
|
+
dropdown.trigger(
|
|
92
|
+
@workspace.fetch(:name),
|
|
93
|
+
icon_end: :chevrons_up_down,
|
|
94
|
+
size: :md
|
|
95
|
+
)
|
|
96
|
+
dropdown.title("Workspace")
|
|
97
|
+
dropdown.item(@workspace.fetch(:name), href: @workspace.fetch(:href), icon: :check)
|
|
98
|
+
dropdown.item("Manage teams", href: @workspace.fetch(:href), icon: :settings)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def render_navigation_items(navigation)
|
|
103
|
+
@navigation.each do |item|
|
|
104
|
+
navigation.item(
|
|
105
|
+
item.fetch(:label),
|
|
106
|
+
href: item.fetch(:href),
|
|
107
|
+
icon: item[:icon],
|
|
108
|
+
badge: item[:badge],
|
|
109
|
+
current: item.fetch(:key) == @current
|
|
110
|
+
)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def render_identity
|
|
115
|
+
render NitroKit::Dropdown.new(id: "application-account-menu", placement: sidebar? ? :top_start : :bottom_end,
|
|
116
|
+
data: { ui: "account-menu" }) do |menu|
|
|
117
|
+
menu.trigger(icon_end: :chevrons_up_down, label: @identity.fetch(:name)) do
|
|
118
|
+
span(data: { ui: "account-identity" }) do
|
|
119
|
+
render NitroKit::Avatar.new(src: @identity[:avatar_url], alt: @identity.fetch(:name), size: :xs,
|
|
120
|
+
decorative: true)
|
|
121
|
+
span { @identity.fetch(:name) }
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
menu.title(@identity.fetch(:detail))
|
|
125
|
+
menu.item("Account", href: @identity.fetch(:account_href, "/settings/profile"), icon: :circle_user)
|
|
126
|
+
menu.item("Settings", href: @identity.fetch(:settings_href, "/settings/preferences"), icon: :settings)
|
|
127
|
+
menu.separator
|
|
128
|
+
menu.item("Sign out", href: @identity.fetch(:sign_out_href, "/session"), icon: :log_out,
|
|
129
|
+
data: { turbo_method: :delete })
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def render_command_palette
|
|
134
|
+
render NitroKit::CommandPalette.new(
|
|
135
|
+
id: "application-command-palette",
|
|
136
|
+
label: "Search #{@product_name}",
|
|
137
|
+
placeholder: "Search #{@product_name}…"
|
|
138
|
+
) do |palette|
|
|
139
|
+
@navigation.each do |item|
|
|
140
|
+
palette.destination("Go to #{item.fetch(:label)}", href: item.fetch(:href))
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def render_toolbar
|
|
146
|
+
render NitroKit::Toolbar.new(id: "application-toolbar") do |toolbar|
|
|
147
|
+
toolbar.leading do
|
|
148
|
+
render_back if @back
|
|
149
|
+
h1 { @title }
|
|
150
|
+
end
|
|
151
|
+
toolbar.trailing { render_actions } if @actions.any?
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def render_back
|
|
156
|
+
render NitroKit::Button.new(
|
|
157
|
+
"Back",
|
|
158
|
+
href: @back.fetch(:href),
|
|
159
|
+
icon: :arrow_left,
|
|
160
|
+
label: @back.fetch(:label),
|
|
161
|
+
size: :sm
|
|
162
|
+
)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def render_actions
|
|
166
|
+
@actions.each do |action|
|
|
167
|
+
options = action.dup
|
|
168
|
+
label = options.delete(:label)
|
|
169
|
+
render NitroKit::Button.new(label, size: :sm, **options)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def render_main(content)
|
|
174
|
+
div(data: { ui: "application-shell-content" }) do
|
|
175
|
+
render_toolbar unless sidebar?
|
|
176
|
+
render(content)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def sidebar?
|
|
181
|
+
@layout == :sidebar
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Application shell
|
|
2
|
+
|
|
3
|
+
## When to use
|
|
4
|
+
|
|
5
|
+
Use this pattern when authenticated product routes share navigation, workspace context, page titles, and route-level actions. Install it before adding resource, team, settings, or operations flows so those screens compose into one stable frame instead of inventing chrome independently.
|
|
6
|
+
|
|
7
|
+
## Composition checklist
|
|
8
|
+
|
|
9
|
+
Run the page composition checklist in the installed gem's `docs/patterns/composition.md` (`bundle show nitro_kit`) before calling any adapted route finished: one gutter owner, one primary action with destructive buttons kept off rows, populated/empty/invalid/narrow states, and one title scale. This shell's `application_shell.css` is the gutter owner; when the host already has a layout that pads its main region, keep exactly one of the two.
|
|
10
|
+
|
|
11
|
+
## Composition decisions
|
|
12
|
+
|
|
13
|
+
- Keep `NitroKit::AppShell` and `NitroKit::AppNavigation` gem-owned. The application-owned wrapper supplies product identity, destinations, current-route state, workspace context, and account identity.
|
|
14
|
+
- Render one navigation tree. Nitro Kit moves that same tree into the modal drawer at narrow widths; do not maintain separate desktop and mobile menus.
|
|
15
|
+
- Let the shell toolbar own the route title, compact Back affordance, and route-level actions. Body components should not repeat the heading or primary submit.
|
|
16
|
+
- Use the default Button treatment for Back and secondary actions, not ghost buttons or hand-styled links. Keep the Toolbar’s center alignment; do not add vertical margins to align Back with the heading.
|
|
17
|
+
- Keep the title and trailing actions on one row when they fit, including on mobile. Let actions wrap below only when space runs out, preserving header padding. Do not clip the title or hide persistent actions to preserve a one-line header.
|
|
18
|
+
- Associate toolbar submissions with body forms through the native `form` attribute. This keeps one visible primary action without moving form ownership into the shell.
|
|
19
|
+
- Pass a semantic `current` key from the route view. Do not infer navigation state from partial URL matches inside the component.
|
|
20
|
+
- Put the only outer content gutter in the shell. Nested flows may manage their internal rhythm, but they should not add another outer gutter.
|
|
21
|
+
|
|
22
|
+
## Choosing a layout
|
|
23
|
+
|
|
24
|
+
- `sidebar` is the default: persistent navigation in a left rail, with the page title and actions in the header of the content canvas.
|
|
25
|
+
- `topbar` puts workspace selection, destinations, search, and the account avatar in a horizontal navigation bar. The page title and actions sit below it inside the content canvas.
|
|
26
|
+
|
|
27
|
+
Both layouts show the same page content and use the same navigation tree in a
|
|
28
|
+
mobile drawer. Choose based on navigation depth, not toolbar placement.
|
|
29
|
+
|
|
30
|
+
The sidebar stays expanded by default. Pass `collapsible: true` to
|
|
31
|
+
`UI::ApplicationShell` to opt into Nitro Kit's bottom pin toggle and icon rail
|
|
32
|
+
with hover/focus peek. This does not change topbar or mobile drawer behavior.
|
|
33
|
+
|
|
34
|
+
### Inset sidebar treatment
|
|
35
|
+
|
|
36
|
+
The catalog stylesheet presents the desktop `sidebar` layout as an inset
|
|
37
|
+
workspace: the navigation rail sits on a quiet frame while the main region is
|
|
38
|
+
a distinct, elevated canvas. Keep that treatment application-owned; layout selection remains the public `AppShell` API. In
|
|
39
|
+
`sidebar`, the toolbar supplies the top of the same canvas as the main region;
|
|
40
|
+
its seam has no extra gap or duplicated rounded corners.
|
|
41
|
+
|
|
42
|
+
- Inset the main canvas by the same token spacing on every exposed edge,
|
|
43
|
+
except beside the rail, where native navigation padding provides the gap.
|
|
44
|
+
- Give the rail/frame and main canvas visibly different semantic surfaces in
|
|
45
|
+
both light and dark appearances. The canvas should come forward; do not make
|
|
46
|
+
it darker than the rail in dark mode.
|
|
47
|
+
- Remove the shell/sidebar divider where the inset gap already communicates
|
|
48
|
+
structure. Keep the main canvas border and restrained shadow for edge
|
|
49
|
+
definition.
|
|
50
|
+
- Use one radius on the canvas and leave its interior flat. Do not answer the
|
|
51
|
+
inset surface with Cards around every table or section.
|
|
52
|
+
- Keep rail chrome restrained: avoid a second product heading, duplicate page
|
|
53
|
+
actions, and badges that merely repeat dashboard statistics. Badges are for
|
|
54
|
+
actionable counts.
|
|
55
|
+
- Apply the inset only above the shell's narrow breakpoint. Mobile returns to
|
|
56
|
+
Nitro Kit's normal edge-to-edge main region and modal navigation drawer.
|
|
57
|
+
|
|
58
|
+
## Tradeoffs
|
|
59
|
+
|
|
60
|
+
This wrapper deliberately knows the host product's routes and current request context. That coupling is the point: product navigation is application code, while responsive mechanics remain upgradeable in Nitro Kit. If different account areas need genuinely different destination trees, extract small application-owned navigation components rather than adding conditionals for every controller to one universal shell.
|
|
61
|
+
|
|
62
|
+
## Adaptation
|
|
63
|
+
|
|
64
|
+
Rename the product, replace the default projects and teams destinations, and map `Current.team`, `Current.user`, and their display methods to the host application. Keep destination keys stable and pass them from route views. Add badges only for actionable counts. Replace the workspace link with a real switcher when users can belong to multiple teams, and map the account dropdown destinations to the host routes. The identity accepts `account_href`, `settings_href`, and `sign_out_href`; their defaults are `/settings/profile`, `/settings/preferences`, and `/session`. Sign out sends a Turbo DELETE request.
|
|
65
|
+
|
|
66
|
+
Copy `application_shell.css` after Nitro Kit's stylesheet. Keep its rules scoped to `data-ui="application-shell"`; it owns canvas insets, main scrolling, and the single content gutter.
|
|
67
|
+
Navigation owns rail padding; do not add another padded wrapper around it.
|
|
68
|
+
Use the same 24px page gutter on desktop and 16px on mobile rather than
|
|
69
|
+
stacking shell, container, and page padding.
|
|
70
|
+
|
|
71
|
+
## Verification
|
|
72
|
+
|
|
73
|
+
- Exercise sidebar and topbar layouts at wide and narrow widths.
|
|
74
|
+
- For sidebar at desktop width, verify equal main insets on every exposed edge,
|
|
75
|
+
a non-zero canvas radius, no divider stranded inside the rail gap, and clear
|
|
76
|
+
rail/canvas surface separation in light and dark appearances.
|
|
77
|
+
- For sidebar at 390px, verify the main region is edge-to-edge rather than a
|
|
78
|
+
miniature inset card and the same navigation tree moves into the modal drawer.
|
|
79
|
+
- Prove there is one navigation landmark, one current page, one `h1`, and no duplicate shell IDs.
|
|
80
|
+
- Open and close mobile navigation with pointer, keyboard, Escape, and backdrop; verify modal blocking and focus restoration.
|
|
81
|
+
- Follow a navigation link while the drawer is open and verify Turbo closes it before the next page renders.
|
|
82
|
+
- Exercise long destination labels, a long title, no actions, several actions, a Back affordance, and a toolbar-associated form submit.
|
|
83
|
+
- Verify the main region scrolls independently on desktop. At 390px, verify the document has no horizontal overflow and a Back affordance, title, and several actions remain fully visible.
|
|
84
|
+
|
|
85
|
+
Account menus belong in the navigation footer in sidebar layouts,
|
|
86
|
+
and in the navigation chrome for a topbar layout. Use a Dropdown with Account,
|
|
87
|
+
Settings, and Sign out, not a static identity label or a standalone sign-out
|
|
88
|
+
button. Keep the team picker and account trigger full width in the rail.
|
|
89
|
+
Align the logotype with navigation item content. Give the sidebar toolbar 24px
|
|
90
|
+
padding on all four sides and balance the rail's outer left and right gutters.
|
|
91
|
+
|
|
92
|
+
Keep rail spacing compact: native navigation padding only, no additional left
|
|
93
|
+
shell padding or sidebar/content gap. Use an Avatar in the account trigger,
|
|
94
|
+
with the optional identity `avatar_url` and name initials as the fallback.
|
|
95
|
+
|
|
96
|
+
Render page-action Buttons directly in Toolbar.trailing, which already owns
|
|
97
|
+
spacing, alignment, and wrapping. Do not nest a Flex or ButtonGroup for the same job.
|
|
98
|
+
|
|
99
|
+
The shell content element owns page padding and fills the available canvas.
|
|
100
|
+
It has no maximum width. Table pages use that full width; individual form or
|
|
101
|
+
reading pages choose a centered `Container(size: :md)` or `Container(size: :lg)`
|
|
102
|
+
inside the gutter. Do not copy a Container's width limit onto a plain div and
|
|
103
|
+
lose its centering. Navigation destinations
|
|
104
|
+
sit directly in the body unless they form named groups. The navigation footer
|
|
105
|
+
owns its own layout; search and the account dropdown are direct children.
|
|
106
|
+
|
|
107
|
+
Pass `logo_url:` to render an application-owned logo image in the navigation
|
|
108
|
+
header; omit it to use the product name as text. Keep demo branding assets in
|
|
109
|
+
the host application. The topbar navigation spans the shell and aligns with the content canvas’s
|
|
110
|
+
outer edges; the sidebar brand sits directly above the workspace picker.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Authentication
|
|
5
|
+
class Page < Base
|
|
6
|
+
def initialize(title:, description: nil, status: nil, back: nil)
|
|
7
|
+
@title = title
|
|
8
|
+
@description = description
|
|
9
|
+
@status = status
|
|
10
|
+
@back = back
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def view_template(&content)
|
|
14
|
+
raise ArgumentError, "Authentication page requires content" unless content
|
|
15
|
+
|
|
16
|
+
AuthShell(aria: { label: @title }) do
|
|
17
|
+
header(data: { ui: "authentication-brand" }) do
|
|
18
|
+
a(href: root_path) { strong { product_name } }
|
|
19
|
+
end
|
|
20
|
+
Card do |card|
|
|
21
|
+
card.title(@title, level: 1)
|
|
22
|
+
card.description(@description) if @description.present?
|
|
23
|
+
card.body do
|
|
24
|
+
Flex(dir: :col, gap: 4, align: :stretch) do
|
|
25
|
+
render_status if @status
|
|
26
|
+
render(content)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
if @back
|
|
30
|
+
card.divider
|
|
31
|
+
card.footer do
|
|
32
|
+
Button(@back.fetch(:label), href: @back.fetch(:href))
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
def product_name
|
|
41
|
+
Rails.application.class.module_parent_name.titleize
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def render_status
|
|
45
|
+
Alert(variant: @status.fetch(:variant)) do |alert|
|
|
46
|
+
alert.icon NitroKit::Icon.new(@status.fetch(:icon)) if @status[:icon]
|
|
47
|
+
alert.title(@status.fetch(:title))
|
|
48
|
+
alert.description(@status[:description]) if @status[:description]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module EmailVerifications
|
|
5
|
+
class Show < UI::Authentication::Base
|
|
6
|
+
def initialize(user:, token:, token_unavailable: false)
|
|
7
|
+
@user = user
|
|
8
|
+
@token = token
|
|
9
|
+
@token_unavailable = token_unavailable
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def view_template
|
|
13
|
+
render UI::Authentication::Page.new(
|
|
14
|
+
title: @token_unavailable ? "Verification link unavailable" : "Verify your email",
|
|
15
|
+
status: status,
|
|
16
|
+
back: unavailable_back
|
|
17
|
+
) do
|
|
18
|
+
@token_unavailable ? unavailable_copy : confirmation_form
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
def status
|
|
24
|
+
if @token_unavailable
|
|
25
|
+
{
|
|
26
|
+
variant: :destructive,
|
|
27
|
+
icon: :clock_alert,
|
|
28
|
+
title: "This link is invalid or expired",
|
|
29
|
+
description: "It may be malformed, more than two days old, already used, or invalidated by an email change."
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
{
|
|
33
|
+
variant: :default,
|
|
34
|
+
icon: :mail_check,
|
|
35
|
+
title: "Confirm this address",
|
|
36
|
+
description: "Verify #{@user.email_address} before signing in."
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def unavailable_back
|
|
42
|
+
return unless @token_unavailable
|
|
43
|
+
|
|
44
|
+
{ label: "Request a new link", href: new_verification_email_path }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def unavailable_copy
|
|
48
|
+
p { "Request a fresh link to continue securely." }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def confirmation_form
|
|
52
|
+
form_with(
|
|
53
|
+
url: email_verification_path(@token),
|
|
54
|
+
method: :patch,
|
|
55
|
+
builder: NitroKit::FormBuilder
|
|
56
|
+
) do |form|
|
|
57
|
+
form.submit("Verify email", data: { turbo_submits_with: "Verifying…" })
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module PasswordResets
|
|
5
|
+
class New < UI::Authentication::Base
|
|
6
|
+
def initialize(request, sent: false)
|
|
7
|
+
@request = request
|
|
8
|
+
@sent = sent
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def view_template
|
|
12
|
+
render UI::Authentication::Page.new(
|
|
13
|
+
title: @sent ? "Check your inbox" : "Reset your password",
|
|
14
|
+
description: description,
|
|
15
|
+
status: sent_status,
|
|
16
|
+
back: { label: "Back to sign in", href: new_session_path }
|
|
17
|
+
) do
|
|
18
|
+
@sent ? sent_copy : request_form
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
def description
|
|
24
|
+
return if @sent
|
|
25
|
+
|
|
26
|
+
"Enter the email attached to your account. Reset links expire after 15 minutes."
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def sent_status
|
|
30
|
+
return unless @sent
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
variant: :success,
|
|
34
|
+
icon: :mail_check,
|
|
35
|
+
title: "Recovery email requested",
|
|
36
|
+
description: "If that address belongs to an account, a reset link is on its way."
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def sent_copy
|
|
41
|
+
p { "Check spam and quarantine folders before requesting another link." }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def request_form
|
|
45
|
+
form_with(
|
|
46
|
+
model: @request,
|
|
47
|
+
url: password_reset_path,
|
|
48
|
+
builder: NitroKit::FormBuilder
|
|
49
|
+
) do |form|
|
|
50
|
+
form.group do
|
|
51
|
+
form.field(
|
|
52
|
+
:email_address,
|
|
53
|
+
as: :email,
|
|
54
|
+
label: "Account email",
|
|
55
|
+
required: true,
|
|
56
|
+
autocomplete: "email",
|
|
57
|
+
control_html: { autofocus: true }
|
|
58
|
+
)
|
|
59
|
+
form.submit("Send reset link", data: { turbo_submits_with: "Sending…" })
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Passwords
|
|
5
|
+
class Edit < UI::Authentication::Base
|
|
6
|
+
def initialize(user:, token:, token_unavailable: false)
|
|
7
|
+
@user = user
|
|
8
|
+
@token = token
|
|
9
|
+
@token_unavailable = token_unavailable
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def view_template
|
|
13
|
+
render UI::Authentication::Page.new(
|
|
14
|
+
title: @token_unavailable ? "Reset link unavailable" : "Choose a new password",
|
|
15
|
+
status: unavailable_status,
|
|
16
|
+
back: {
|
|
17
|
+
label: @token_unavailable ? "Request a new link" : "Back to sign in",
|
|
18
|
+
href: @token_unavailable ? new_password_reset_path : new_session_path
|
|
19
|
+
}
|
|
20
|
+
) do
|
|
21
|
+
@token_unavailable ? unavailable_copy : password_form
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
def unavailable_status
|
|
27
|
+
return unless @token_unavailable
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
variant: :destructive,
|
|
31
|
+
icon: :clock_alert,
|
|
32
|
+
title: "This link is invalid or expired",
|
|
33
|
+
description: "It may be malformed, more than 15 minutes old, or already invalidated by a password change."
|
|
34
|
+
}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def unavailable_copy
|
|
38
|
+
p { "Request a fresh link to continue securely." }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def password_form
|
|
42
|
+
form_with(
|
|
43
|
+
model: @user,
|
|
44
|
+
url: password_path(@token),
|
|
45
|
+
method: :patch,
|
|
46
|
+
builder: NitroKit::FormBuilder
|
|
47
|
+
) do |form|
|
|
48
|
+
form.group do
|
|
49
|
+
form.field(
|
|
50
|
+
:password,
|
|
51
|
+
as: :password,
|
|
52
|
+
label: "New password",
|
|
53
|
+
required: true,
|
|
54
|
+
autocomplete: "new-password",
|
|
55
|
+
value: nil,
|
|
56
|
+
control_html: { autofocus: true }
|
|
57
|
+
)
|
|
58
|
+
form.field(
|
|
59
|
+
:password_confirmation,
|
|
60
|
+
as: :password,
|
|
61
|
+
label: "Confirm new password",
|
|
62
|
+
required: true,
|
|
63
|
+
autocomplete: "new-password",
|
|
64
|
+
value: nil
|
|
65
|
+
)
|
|
66
|
+
form.submit("Update password", data: { turbo_submits_with: "Updating…" })
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Sessions
|
|
5
|
+
class New < UI::Authentication::Base
|
|
6
|
+
def initialize(credentials)
|
|
7
|
+
@credentials = credentials
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def view_template
|
|
11
|
+
render UI::Authentication::Page.new(
|
|
12
|
+
title: "Sign in",
|
|
13
|
+
status: credential_error,
|
|
14
|
+
back: { label: "Back to the site", href: root_path }
|
|
15
|
+
) do
|
|
16
|
+
form_with(
|
|
17
|
+
model: @credentials,
|
|
18
|
+
url: session_path,
|
|
19
|
+
builder: NitroKit::FormBuilder
|
|
20
|
+
) do |form|
|
|
21
|
+
form.group do
|
|
22
|
+
form.field(
|
|
23
|
+
:email_address,
|
|
24
|
+
as: :email,
|
|
25
|
+
label: "Email address",
|
|
26
|
+
required: true,
|
|
27
|
+
autocomplete: "email",
|
|
28
|
+
control_html: { autofocus: true }
|
|
29
|
+
)
|
|
30
|
+
form.field(
|
|
31
|
+
:password,
|
|
32
|
+
as: :password,
|
|
33
|
+
label: "Password",
|
|
34
|
+
required: true,
|
|
35
|
+
autocomplete: "current-password",
|
|
36
|
+
value: nil
|
|
37
|
+
)
|
|
38
|
+
form.submit("Sign in", data: { turbo_submits_with: "Signing in…" })
|
|
39
|
+
a(href: new_password_reset_path) { "Forgot your password?" }
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
def credential_error
|
|
47
|
+
return unless @credentials.errors[:base].any?
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
variant: :destructive,
|
|
51
|
+
icon: :circle_x,
|
|
52
|
+
title: "We could not sign you in",
|
|
53
|
+
description: @credentials.errors[:base].to_sentence
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module VerificationEmails
|
|
5
|
+
class New < UI::Authentication::Base
|
|
6
|
+
def initialize(request, sent: false)
|
|
7
|
+
@request = request
|
|
8
|
+
@sent = sent
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def view_template
|
|
12
|
+
render UI::Authentication::Page.new(
|
|
13
|
+
title: "Verify your email",
|
|
14
|
+
description: @sent ? nil : "Enter your account email to request a fresh verification link.",
|
|
15
|
+
status: sent_status,
|
|
16
|
+
back: { label: "Back to sign in", href: new_session_path }
|
|
17
|
+
) do
|
|
18
|
+
@sent ? sent_copy : request_form
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
def sent_status
|
|
24
|
+
return unless @sent
|
|
25
|
+
|
|
26
|
+
{
|
|
27
|
+
variant: :success,
|
|
28
|
+
icon: :mail_check,
|
|
29
|
+
title: "Verification email requested",
|
|
30
|
+
description: "If that address needs verification, a link is on its way."
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def sent_copy
|
|
35
|
+
p { "The link expires after two days. Check spam and quarantine folders if it does not arrive." }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def request_form
|
|
39
|
+
form_with(
|
|
40
|
+
model: @request,
|
|
41
|
+
url: verification_email_path,
|
|
42
|
+
builder: NitroKit::FormBuilder
|
|
43
|
+
) do |form|
|
|
44
|
+
form.group do
|
|
45
|
+
form.field(
|
|
46
|
+
:email_address,
|
|
47
|
+
as: :email,
|
|
48
|
+
label: "Account email",
|
|
49
|
+
required: true,
|
|
50
|
+
autocomplete: "email",
|
|
51
|
+
control_html: { autofocus: true }
|
|
52
|
+
)
|
|
53
|
+
form.submit("Send verification link", data: { turbo_submits_with: "Sending…" })
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|