create-pet-adopt 0.0.0 → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/index.js +920 -0
- package/package.json +43 -1
- package/template/.env.example +136 -0
- package/template/.pet-adopt/template.json +581 -0
- package/template/LICENSE +21 -0
- package/template/README.md +109 -0
- package/template/_gitignore +28 -0
- package/template/_pnpm-lock.yaml +9251 -0
- package/template/assets/sample-pet.png +0 -0
- package/template/components.json +25 -0
- package/template/docker-compose.yml +110 -0
- package/template/drizzle/pg/0000_initial.sql +176 -0
- package/template/drizzle/pg/0001_greedy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0002_fuzzy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0003_thin_multiple_man.sql +1 -0
- package/template/drizzle/pg/0004_boring_norman_osborn.sql +15 -0
- package/template/drizzle/pg/0005_bitter_proemial_gods.sql +3 -0
- package/template/drizzle/pg/0006_friendly_black_knight.sql +2 -0
- package/template/drizzle/pg/0007_wise_ozymandias.sql +11 -0
- package/template/drizzle/pg/0008_messy_human_fly.sql +2 -0
- package/template/drizzle/pg/0009_amused_lady_bullseye.sql +1 -0
- package/template/drizzle/pg/0010_cute_mauler.sql +7 -0
- package/template/drizzle/pg/0011_clear_purple_man.sql +3 -0
- package/template/drizzle/pg/0012_tiresome_gunslinger.sql +2 -0
- package/template/drizzle/pg/0013_awesome_wong.sql +18 -0
- package/template/drizzle/pg/0014_fantastic_sumo.sql +12 -0
- package/template/drizzle/pg/0015_pink_carnage.sql +12 -0
- package/template/drizzle/pg/0016_sloppy_king_bedlam.sql +2 -0
- package/template/drizzle/pg/0017_steep_warhawk.sql +15 -0
- package/template/drizzle/pg/0018_mixed_otto_octavius.sql +4 -0
- package/template/drizzle/pg/0019_talented_rocket_raccoon.sql +1 -0
- package/template/drizzle/pg/0020_worthless_zodiak.sql +19 -0
- package/template/drizzle/pg/0021_adorable_squadron_supreme.sql +1 -0
- package/template/drizzle/pg/0022_soft_pixie.sql +5 -0
- package/template/drizzle/pg/0023_fluffy_quasar.sql +1 -0
- package/template/drizzle/pg/0024_uneven_ken_ellis.sql +2 -0
- package/template/drizzle/pg/0025_rich_white_queen.sql +3 -0
- package/template/drizzle/pg/0026_spooky_komodo.sql +16 -0
- package/template/drizzle/pg/0027_big_thunderbolts.sql +2 -0
- package/template/drizzle/pg/meta/0000_snapshot.json +1265 -0
- package/template/drizzle/pg/meta/0001_snapshot.json +1272 -0
- package/template/drizzle/pg/meta/0002_snapshot.json +1278 -0
- package/template/drizzle/pg/meta/0003_snapshot.json +1284 -0
- package/template/drizzle/pg/meta/0004_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0005_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0006_snapshot.json +1414 -0
- package/template/drizzle/pg/meta/0007_snapshot.json +1485 -0
- package/template/drizzle/pg/meta/0008_snapshot.json +1504 -0
- package/template/drizzle/pg/meta/0009_snapshot.json +1510 -0
- package/template/drizzle/pg/meta/0010_snapshot.json +1556 -0
- package/template/drizzle/pg/meta/0011_snapshot.json +1574 -0
- package/template/drizzle/pg/meta/0012_snapshot.json +1586 -0
- package/template/drizzle/pg/meta/0013_snapshot.json +1730 -0
- package/template/drizzle/pg/meta/0014_snapshot.json +1805 -0
- package/template/drizzle/pg/meta/0015_snapshot.json +1883 -0
- package/template/drizzle/pg/meta/0016_snapshot.json +1897 -0
- package/template/drizzle/pg/meta/0017_snapshot.json +2013 -0
- package/template/drizzle/pg/meta/0018_snapshot.json +1988 -0
- package/template/drizzle/pg/meta/0019_snapshot.json +1994 -0
- package/template/drizzle/pg/meta/0020_snapshot.json +2108 -0
- package/template/drizzle/pg/meta/0021_snapshot.json +2114 -0
- package/template/drizzle/pg/meta/0022_snapshot.json +2126 -0
- package/template/drizzle/pg/meta/0023_snapshot.json +2132 -0
- package/template/drizzle/pg/meta/0024_snapshot.json +2151 -0
- package/template/drizzle/pg/meta/0025_snapshot.json +2169 -0
- package/template/drizzle/pg/meta/0026_snapshot.json +2294 -0
- package/template/drizzle/pg/meta/0027_snapshot.json +2330 -0
- package/template/drizzle/pg/meta/_journal.json +202 -0
- package/template/drizzle/sqlite/0000_initial.sql +176 -0
- package/template/drizzle/sqlite/0001_easy_sebastian_shaw.sql +1 -0
- package/template/drizzle/sqlite/0002_past_king_cobra.sql +1 -0
- package/template/drizzle/sqlite/0003_organic_masked_marvel.sql +1 -0
- package/template/drizzle/sqlite/0004_panoramic_inhumans.sql +15 -0
- package/template/drizzle/sqlite/0005_small_sunset_bain.sql +19 -0
- package/template/drizzle/sqlite/0006_narrow_medusa.sql +2 -0
- package/template/drizzle/sqlite/0007_gray_grandmaster.sql +10 -0
- package/template/drizzle/sqlite/0008_chief_toxin.sql +1 -0
- package/template/drizzle/sqlite/0009_vengeful_tag.sql +1 -0
- package/template/drizzle/sqlite/0010_kind_klaw.sql +7 -0
- package/template/drizzle/sqlite/0011_overrated_meltdown.sql +3 -0
- package/template/drizzle/sqlite/0012_robust_next_avengers.sql +2 -0
- package/template/drizzle/sqlite/0013_melodic_kitty_pryde.sql +18 -0
- package/template/drizzle/sqlite/0014_stormy_cyclops.sql +12 -0
- package/template/drizzle/sqlite/0015_parallel_mongu.sql +11 -0
- package/template/drizzle/sqlite/0016_grey_quicksilver.sql +2 -0
- package/template/drizzle/sqlite/0017_daily_psylocke.sql +15 -0
- package/template/drizzle/sqlite/0018_whole_redwing.sql +4 -0
- package/template/drizzle/sqlite/0019_spotty_mandroid.sql +1 -0
- package/template/drizzle/sqlite/0020_wild_wendell_rand.sql +19 -0
- package/template/drizzle/sqlite/0021_calm_lockheed.sql +1 -0
- package/template/drizzle/sqlite/0022_lonely_emma_frost.sql +5 -0
- package/template/drizzle/sqlite/0023_elite_tony_stark.sql +1 -0
- package/template/drizzle/sqlite/0024_little_lily_hollister.sql +1 -0
- package/template/drizzle/sqlite/0025_tough_shotgun.sql +3 -0
- package/template/drizzle/sqlite/0026_faithful_mephistopheles.sql +16 -0
- package/template/drizzle/sqlite/0027_rapid_arclight.sql +2 -0
- package/template/drizzle/sqlite/meta/0000_snapshot.json +1237 -0
- package/template/drizzle/sqlite/meta/0001_snapshot.json +1245 -0
- package/template/drizzle/sqlite/meta/0002_snapshot.json +1252 -0
- package/template/drizzle/sqlite/meta/0003_snapshot.json +1259 -0
- package/template/drizzle/sqlite/meta/0004_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0005_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0006_snapshot.json +1384 -0
- package/template/drizzle/sqlite/meta/0007_snapshot.json +1459 -0
- package/template/drizzle/sqlite/meta/0008_snapshot.json +1479 -0
- package/template/drizzle/sqlite/meta/0009_snapshot.json +1486 -0
- package/template/drizzle/sqlite/meta/0010_snapshot.json +1533 -0
- package/template/drizzle/sqlite/meta/0011_snapshot.json +1554 -0
- package/template/drizzle/sqlite/meta/0012_snapshot.json +1568 -0
- package/template/drizzle/sqlite/meta/0013_snapshot.json +1687 -0
- package/template/drizzle/sqlite/meta/0014_snapshot.json +1769 -0
- package/template/drizzle/sqlite/meta/0015_snapshot.json +1852 -0
- package/template/drizzle/sqlite/meta/0016_snapshot.json +1867 -0
- package/template/drizzle/sqlite/meta/0017_snapshot.json +1973 -0
- package/template/drizzle/sqlite/meta/0018_snapshot.json +1944 -0
- package/template/drizzle/sqlite/meta/0019_snapshot.json +1951 -0
- package/template/drizzle/sqlite/meta/0020_snapshot.json +2077 -0
- package/template/drizzle/sqlite/meta/0021_snapshot.json +2084 -0
- package/template/drizzle/sqlite/meta/0022_snapshot.json +2098 -0
- package/template/drizzle/sqlite/meta/0023_snapshot.json +2105 -0
- package/template/drizzle/sqlite/meta/0024_snapshot.json +2125 -0
- package/template/drizzle/sqlite/meta/0025_snapshot.json +2146 -0
- package/template/drizzle/sqlite/meta/0026_snapshot.json +2265 -0
- package/template/drizzle/sqlite/meta/0027_snapshot.json +2280 -0
- package/template/drizzle/sqlite/meta/_journal.json +202 -0
- package/template/drizzle.pg.config.ts +8 -0
- package/template/drizzle.sqlite.config.ts +8 -0
- package/template/eslint.config.mjs +22 -0
- package/template/next.config.ts +153 -0
- package/template/package.json +102 -0
- package/template/pet-adopt.blocks.ts +9 -0
- package/template/pet-adopt.config.ts +17 -0
- package/template/pnpm-workspace.yaml +19 -0
- package/template/postcss.config.mjs +5 -0
- package/template/scripts/check-routes.ts +405 -0
- package/template/scripts/check-schemas.ts +58 -0
- package/template/scripts/migrate-all.ts +25 -0
- package/template/scripts/migrate-on-build.ts +71 -0
- package/template/scripts/migrate.ts +20 -0
- package/template/scripts/plugin-generate.ts +92 -0
- package/template/scripts/reset-password.ts +45 -0
- package/template/scripts/reset-two-factor.ts +53 -0
- package/template/scripts/seed.ts +79 -0
- package/template/scripts/setup-env.ts +91 -0
- package/template/scripts/storage-check.ts +53 -0
- package/template/src/app/(admin)/admin/account/AccountForms.tsx +194 -0
- package/template/src/app/(admin)/admin/account/page.tsx +59 -0
- package/template/src/app/(admin)/admin/activity/page.tsx +76 -0
- package/template/src/app/(admin)/admin/authentication/archived/page.tsx +24 -0
- package/template/src/app/(admin)/admin/authentication/layout.tsx +20 -0
- package/template/src/app/(admin)/admin/authentication/page.tsx +36 -0
- package/template/src/app/(admin)/admin/authentication/providers/page.tsx +33 -0
- package/template/src/app/(admin)/admin/email/layout.tsx +21 -0
- package/template/src/app/(admin)/admin/email/page.tsx +43 -0
- package/template/src/app/(admin)/admin/email/templates/page.tsx +38 -0
- package/template/src/app/(admin)/admin/error.tsx +36 -0
- package/template/src/app/(admin)/admin/layout.tsx +26 -0
- package/template/src/app/(admin)/admin/loading.tsx +9 -0
- package/template/src/app/(admin)/admin/media/[id]/page.tsx +97 -0
- package/template/src/app/(admin)/admin/media/page.tsx +34 -0
- package/template/src/app/(admin)/admin/media/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/page.tsx +79 -0
- package/template/src/app/(admin)/admin/pages/PageForm.tsx +604 -0
- package/template/src/app/(admin)/admin/pages/[id]/page.tsx +51 -0
- package/template/src/app/(admin)/admin/pages/new/page.tsx +19 -0
- package/template/src/app/(admin)/admin/pages/page.tsx +49 -0
- package/template/src/app/(admin)/admin/pets/PetForm.tsx +437 -0
- package/template/src/app/(admin)/admin/pets/[id]/page.tsx +41 -0
- package/template/src/app/(admin)/admin/pets/new/page.tsx +26 -0
- package/template/src/app/(admin)/admin/pets/page.tsx +70 -0
- package/template/src/app/(admin)/admin/pets/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/plugins/[plugin]/[[...path]]/page.tsx +73 -0
- package/template/src/app/(admin)/admin/plugins/page.tsx +66 -0
- package/template/src/app/(admin)/admin/settings/SettingsForm.tsx +644 -0
- package/template/src/app/(admin)/admin/settings/email/page.tsx +9 -0
- package/template/src/app/(admin)/admin/settings/page.tsx +40 -0
- package/template/src/app/(admin)/admin/settings/templates/page.tsx +9 -0
- package/template/src/app/(admin)/admin/theme/[id]/page.tsx +28 -0
- package/template/src/app/(admin)/admin/theme/page.tsx +30 -0
- package/template/src/app/(admin)/admin/users/page.tsx +33 -0
- package/template/src/app/(admin)/layout.tsx +75 -0
- package/template/src/app/(admin)/providers.tsx +42 -0
- package/template/src/app/(auth)/admin/confirm-email/page.tsx +40 -0
- package/template/src/app/(auth)/admin/invite/page.tsx +38 -0
- package/template/src/app/(auth)/admin/login/DemoSignIn.tsx +69 -0
- package/template/src/app/(auth)/admin/login/page.tsx +83 -0
- package/template/src/app/(auth)/admin/reset-password/page.tsx +73 -0
- package/template/src/app/(auth)/error.tsx +9 -0
- package/template/src/app/(auth)/layout.tsx +71 -0
- package/template/src/app/(editor)/EditorToast.tsx +43 -0
- package/template/src/app/(editor)/edit/[id]/PageEditor.tsx +586 -0
- package/template/src/app/(editor)/edit/[id]/actions.ts +139 -0
- package/template/src/app/(editor)/edit/[id]/page.tsx +76 -0
- package/template/src/app/(editor)/edit/[id]/preview/page.tsx +81 -0
- package/template/src/app/(editor)/edit/email/[id]/EmailEditor.tsx +236 -0
- package/template/src/app/(editor)/edit/email/[id]/page.tsx +64 -0
- package/template/src/app/(editor)/edit/theme-preview/page.tsx +94 -0
- package/template/src/app/(editor)/editor.css +223 -0
- package/template/src/app/(editor)/error.tsx +32 -0
- package/template/src/app/(editor)/layout.tsx +67 -0
- package/template/src/app/(frontend)/[slug]/page.tsx +53 -0
- package/template/src/app/(frontend)/fonts.ts +8 -0
- package/template/src/app/(frontend)/layout.tsx +107 -0
- package/template/src/app/(frontend)/not-found.tsx +16 -0
- package/template/src/app/(frontend)/page.tsx +42 -0
- package/template/src/app/(frontend)/pets/[slug]/page.tsx +92 -0
- package/template/src/app/(frontend)/pets/page.tsx +42 -0
- package/template/src/app/(frontend)/styles.css +537 -0
- package/template/src/app/(setup)/error.tsx +9 -0
- package/template/src/app/(setup)/layout.tsx +41 -0
- package/template/src/app/(setup)/setup/page.tsx +105 -0
- package/template/src/app/(setup)/setup/storage-check.ts +43 -0
- package/template/src/app/api/auth/[...all]/route.ts +144 -0
- package/template/src/app/health/route.ts +9 -0
- package/template/src/app/media/[...path]/route.ts +45 -0
- package/template/src/app/media/email/[name]/route.ts +60 -0
- package/template/src/app/robots.ts +19 -0
- package/template/src/app/sitemap.ts +24 -0
- package/template/src/components/admin/AdminNav.tsx +153 -0
- package/template/src/components/admin/AdminShell.tsx +107 -0
- package/template/src/components/admin/DemoNotice.tsx +31 -0
- package/template/src/components/admin/EmailConfirmBanner.tsx +44 -0
- package/template/src/components/admin/EmptyState.tsx +10 -0
- package/template/src/components/admin/ErrorSummary.tsx +72 -0
- package/template/src/components/admin/MediaDetails.tsx +218 -0
- package/template/src/components/admin/MediaGrid.tsx +307 -0
- package/template/src/components/admin/MediaLibrary.tsx +103 -0
- package/template/src/components/admin/MediaPager.tsx +66 -0
- package/template/src/components/admin/PageHeader.tsx +22 -0
- package/template/src/components/admin/PhoneInput.tsx +128 -0
- package/template/src/components/admin/PluginWidgetBoundary.tsx +38 -0
- package/template/src/components/admin/PluginWidgets.tsx +51 -0
- package/template/src/components/admin/RemountOnNavigate.tsx +37 -0
- package/template/src/components/admin/StatusBadge.tsx +16 -0
- package/template/src/components/admin/UploadPhotosDialog.tsx +387 -0
- package/template/src/components/admin/UserAvatar.tsx +18 -0
- package/template/src/components/admin/UserMenu.tsx +118 -0
- package/template/src/components/admin/ViewSiteLink.tsx +24 -0
- package/template/src/components/admin/account/ConnectedProviders.tsx +91 -0
- package/template/src/components/admin/account/DeleteAccountCard.tsx +136 -0
- package/template/src/components/admin/account/EmailCard.tsx +137 -0
- package/template/src/components/admin/account/ProfilePicture.tsx +159 -0
- package/template/src/components/admin/activity/ActivityFilters.tsx +146 -0
- package/template/src/components/admin/activity/ActivityLog.tsx +159 -0
- package/template/src/components/admin/activity/RecentActivity.tsx +52 -0
- package/template/src/components/admin/demo-mode.tsx +17 -0
- package/template/src/components/admin/nav-items.ts +47 -0
- package/template/src/components/admin/pages/PageDetails.tsx +198 -0
- package/template/src/components/admin/pages/PageVersions.tsx +296 -0
- package/template/src/components/admin/pages/PagesTable.tsx +467 -0
- package/template/src/components/admin/pets/FilterBar.tsx +154 -0
- package/template/src/components/admin/pets/PetCard.tsx +170 -0
- package/template/src/components/admin/pets/PetList.tsx +112 -0
- package/template/src/components/admin/pets/PetListSkeleton.tsx +84 -0
- package/template/src/components/admin/pets/PetPagination.tsx +91 -0
- package/template/src/components/admin/pets/form/AgeFields.tsx +132 -0
- package/template/src/components/admin/pets/form/LocationFields.tsx +231 -0
- package/template/src/components/admin/pets/form/MediaPickerDialog.tsx +359 -0
- package/template/src/components/admin/pets/form/PhotosField.tsx +176 -0
- package/template/src/components/admin/pets/form/RichTextField.tsx +438 -0
- package/template/src/components/admin/pets/form/SeoImageField.tsx +87 -0
- package/template/src/components/admin/pets/form/SeoPreview.tsx +142 -0
- package/template/src/components/admin/pets/form/fields.tsx +434 -0
- package/template/src/components/admin/pets/form/rich-text-extensions.ts +45 -0
- package/template/src/components/admin/pets/timeline/PetTimeline.tsx +297 -0
- package/template/src/components/admin/pets/timeline/TimelineEntryForm.tsx +289 -0
- package/template/src/components/admin/pets/timeline/TimelinePhotosField.tsx +173 -0
- package/template/src/components/admin/plugins/PluginNotReady.tsx +28 -0
- package/template/src/components/admin/plugins/PluginOverview.tsx +121 -0
- package/template/src/components/admin/plugins/SendTestEmail.tsx +70 -0
- package/template/src/components/admin/settings/AuthProviders.tsx +373 -0
- package/template/src/components/admin/settings/AuthenticationNav.tsx +42 -0
- package/template/src/components/admin/settings/EmailNav.tsx +40 -0
- package/template/src/components/admin/settings/EmailSettingsForm.tsx +325 -0
- package/template/src/components/admin/settings/EmailTemplates.tsx +551 -0
- package/template/src/components/admin/settings/RegionFields.tsx +203 -0
- package/template/src/components/admin/site-time.tsx +26 -0
- package/template/src/components/admin/theme/ThemeEditor.tsx +467 -0
- package/template/src/components/admin/theme/ThemeLibrary.tsx +339 -0
- package/template/src/components/admin/theme/ThemeSwatches.tsx +30 -0
- package/template/src/components/admin/theme/theme-utils.ts +32 -0
- package/template/src/components/admin/two-factor/BackupCodeList.tsx +54 -0
- package/template/src/components/admin/two-factor/TwoFactorCard.tsx +237 -0
- package/template/src/components/admin/two-factor/TwoFactorRequired.tsx +52 -0
- package/template/src/components/admin/two-factor/TwoFactorSetup.tsx +180 -0
- package/template/src/components/admin/use-unsaved-changes.tsx +101 -0
- package/template/src/components/admin/users/ArchivedAccounts.tsx +159 -0
- package/template/src/components/admin/users/InviteDialogs.tsx +131 -0
- package/template/src/components/admin/users/TwoFactorRoles.tsx +80 -0
- package/template/src/components/admin/users/UserDialogs.tsx +681 -0
- package/template/src/components/admin/users/UsersTable.tsx +374 -0
- package/template/src/components/admin/view-only.tsx +43 -0
- package/template/src/components/auth/AcceptInviteForm.tsx +123 -0
- package/template/src/components/auth/AuthNav.tsx +80 -0
- package/template/src/components/auth/ConfirmEmailForm.tsx +73 -0
- package/template/src/components/auth/LoginForm.tsx +250 -0
- package/template/src/components/auth/PageError.tsx +37 -0
- package/template/src/components/auth/ProviderSignIn.tsx +53 -0
- package/template/src/components/auth/ResetPasswordForm.tsx +267 -0
- package/template/src/components/demo/DemoBanner.tsx +38 -0
- package/template/src/components/demo/SiteDemoBanner.tsx +22 -0
- package/template/src/components/demo/wording.ts +21 -0
- package/template/src/components/setup/SetupAccountForm.tsx +93 -0
- package/template/src/components/setup/SetupDone.tsx +95 -0
- package/template/src/components/setup/SetupNav.tsx +49 -0
- package/template/src/components/setup/SetupSampleContent.tsx +67 -0
- package/template/src/components/setup/SetupSiteForm.tsx +104 -0
- package/template/src/components/setup/SetupThemePicker.tsx +73 -0
- package/template/src/components/setup/SkipSetup.tsx +35 -0
- package/template/src/components/site/BuilderContent.tsx +46 -0
- package/template/src/components/site/CopyButton.tsx +28 -0
- package/template/src/components/site/ImageCarousel.tsx +52 -0
- package/template/src/components/site/PetCard.tsx +32 -0
- package/template/src/components/site/PetCatalog.tsx +106 -0
- package/template/src/components/site/PetGallery.tsx +75 -0
- package/template/src/components/site/PetTimeline.tsx +82 -0
- package/template/src/components/site/RemountOnNavigate.tsx +13 -0
- package/template/src/components/site/RichText.tsx +56 -0
- package/template/src/components/site/SmartLink.tsx +37 -0
- package/template/src/components/site/SocialIcons.tsx +26 -0
- package/template/src/components/site/ThemePreviewBridge.tsx +29 -0
- package/template/src/components/site/ThemeStyle.tsx +22 -0
- package/template/src/components/site/ThemeToggle.tsx +36 -0
- package/template/src/components/site/WhatsAppButton.tsx +27 -0
- package/template/src/components/site/timeline-format.ts +20 -0
- package/template/src/db/client.ts +702 -0
- package/template/src/db/compare-tables.ts +41 -0
- package/template/src/db/migrate.ts +28 -0
- package/template/src/db/plugin-migrations.ts +167 -0
- package/template/src/db/schema/pg.ts +484 -0
- package/template/src/db/schema/sqlite.ts +492 -0
- package/template/src/instrumentation.ts +110 -0
- package/template/src/lib/activity.ts +29 -0
- package/template/src/lib/admin/call-action.ts +19 -0
- package/template/src/lib/admin/initials.ts +9 -0
- package/template/src/lib/admin/media-cache.ts +16 -0
- package/template/src/lib/admin/media-page.ts +3 -0
- package/template/src/lib/admin/pet-form.ts +242 -0
- package/template/src/lib/admin/pets-cache.ts +22 -0
- package/template/src/lib/admin/unwrap-client.ts +11 -0
- package/template/src/lib/admin/unwrap.ts +38 -0
- package/template/src/lib/admin/use-media-list.ts +41 -0
- package/template/src/lib/admin/use-pet-list.ts +58 -0
- package/template/src/lib/age.ts +117 -0
- package/template/src/lib/auth-provider-errors.ts +38 -0
- package/template/src/lib/cache.ts +69 -0
- package/template/src/lib/color-mode.ts +48 -0
- package/template/src/lib/demo.ts +78 -0
- package/template/src/lib/email-address.ts +9 -0
- package/template/src/lib/email-template.ts +691 -0
- package/template/src/lib/links.ts +78 -0
- package/template/src/lib/mail-error.ts +38 -0
- package/template/src/lib/media-name.ts +31 -0
- package/template/src/lib/options.ts +134 -0
- package/template/src/lib/pagination.ts +28 -0
- package/template/src/lib/pet-placeholders.ts +34 -0
- package/template/src/lib/pet-seo.ts +40 -0
- package/template/src/lib/pet-timeline.ts +62 -0
- package/template/src/lib/phone.ts +129 -0
- package/template/src/lib/places.ts +84 -0
- package/template/src/lib/queries.ts +549 -0
- package/template/src/lib/revalidate.ts +32 -0
- package/template/src/lib/rich-text.ts +215 -0
- package/template/src/lib/seo.ts +121 -0
- package/template/src/lib/slugify.ts +11 -0
- package/template/src/lib/theme.ts +546 -0
- package/template/src/lib/utils.ts +2 -0
- package/template/src/lib/whatsapp.ts +29 -0
- package/template/src/lib/zod-schema/auth.ts +56 -0
- package/template/src/lib/zod-schema/page.ts +57 -0
- package/template/src/lib/zod-schema/pet-timeline.ts +118 -0
- package/template/src/lib/zod-schema/pet.ts +172 -0
- package/template/src/lib/zod-schema/settings.ts +162 -0
- package/template/src/plugins/host.ts +117 -0
- package/template/src/plugins/icon.ts +89 -0
- package/template/src/plugins/registry.ts +369 -0
- package/template/src/plugins/storage-rules.ts +87 -0
- package/template/src/plugins/storage.ts +184 -0
- package/template/src/puck/actions.ts +46 -0
- package/template/src/puck/config.tsx +1693 -0
- package/template/src/puck/data.ts +196 -0
- package/template/src/puck/demo-mode.tsx +20 -0
- package/template/src/puck/email-config.tsx +267 -0
- package/template/src/puck/icons.tsx +76 -0
- package/template/src/puck/media-picker.tsx +273 -0
- package/template/src/puck/padding.tsx +71 -0
- package/template/src/puck/pet-page-config.tsx +511 -0
- package/template/src/puck/pet-picker.tsx +40 -0
- package/template/src/puck/plugin-block-data.ts +91 -0
- package/template/src/puck/plugin-blocks.tsx +235 -0
- package/template/src/puck/plugin-choice-field.tsx +87 -0
- package/template/src/puck/sanitize.ts +107 -0
- package/template/src/puck/server.ts +36 -0
- package/template/src/puck/types.ts +41 -0
- package/template/src/server/actions/activity.ts +48 -0
- package/template/src/server/actions/auth-providers.ts +171 -0
- package/template/src/server/actions/auth.ts +217 -0
- package/template/src/server/actions/demo.ts +30 -0
- package/template/src/server/actions/email-change.ts +80 -0
- package/template/src/server/actions/email-templates.ts +144 -0
- package/template/src/server/actions/email.ts +70 -0
- package/template/src/server/actions/media.ts +127 -0
- package/template/src/server/actions/pages.ts +159 -0
- package/template/src/server/actions/password-reset.ts +80 -0
- package/template/src/server/actions/pet-timeline.ts +75 -0
- package/template/src/server/actions/pets.ts +74 -0
- package/template/src/server/actions/places.ts +36 -0
- package/template/src/server/actions/settings.ts +29 -0
- package/template/src/server/actions/setup.ts +72 -0
- package/template/src/server/actions/themes.ts +80 -0
- package/template/src/server/actions/two-factor.ts +306 -0
- package/template/src/server/actions/users.ts +200 -0
- package/template/src/server/activity.ts +409 -0
- package/template/src/server/auth-errors.ts +17 -0
- package/template/src/server/auth-providers.ts +359 -0
- package/template/src/server/auth.ts +266 -0
- package/template/src/server/avatars.ts +263 -0
- package/template/src/server/demo-site.ts +169 -0
- package/template/src/server/email-change.ts +278 -0
- package/template/src/server/email-templates.ts +350 -0
- package/template/src/server/email.ts +442 -0
- package/template/src/server/invites.ts +143 -0
- package/template/src/server/media-url.ts +20 -0
- package/template/src/server/media.ts +236 -0
- package/template/src/server/pages.ts +812 -0
- package/template/src/server/password-reset.ts +158 -0
- package/template/src/server/pending-links.ts +46 -0
- package/template/src/server/pet-timeline.ts +181 -0
- package/template/src/server/pets.ts +555 -0
- package/template/src/server/places.ts +113 -0
- package/template/src/server/privacy.ts +21 -0
- package/template/src/server/provider-endpoints.ts +94 -0
- package/template/src/server/provider-guard.ts +157 -0
- package/template/src/server/result.ts +280 -0
- package/template/src/server/sample-content.ts +368 -0
- package/template/src/server/search-text.ts +43 -0
- package/template/src/server/secret-box.ts +38 -0
- package/template/src/server/session.ts +154 -0
- package/template/src/server/settings.ts +361 -0
- package/template/src/server/setup.ts +110 -0
- package/template/src/server/sitemap.ts +88 -0
- package/template/src/server/storage.ts +267 -0
- package/template/src/server/strip-metadata.ts +357 -0
- package/template/src/server/themes.ts +195 -0
- package/template/src/server/throttle.ts +258 -0
- package/template/src/server/two-factor-codes.ts +32 -0
- package/template/src/server/two-factor.ts +158 -0
- package/template/src/server/types.ts +198 -0
- package/template/src/server/uploads.ts +137 -0
- package/template/src/server/users.ts +500 -0
- package/template/tsconfig.json +44 -0
- package/template/ui/components.json +25 -0
- package/template/ui/package.json +12 -0
- package/template/ui/src/components/alert-dialog.tsx +187 -0
- package/template/ui/src/components/avatar.tsx +108 -0
- package/template/ui/src/components/badge.tsx +51 -0
- package/template/ui/src/components/button.tsx +57 -0
- package/template/ui/src/components/card.tsx +102 -0
- package/template/ui/src/components/carousel.tsx +245 -0
- package/template/ui/src/components/checkbox.tsx +27 -0
- package/template/ui/src/components/combobox.tsx +297 -0
- package/template/ui/src/components/dialog.tsx +159 -0
- package/template/ui/src/components/dropdown-menu.tsx +265 -0
- package/template/ui/src/components/field.tsx +238 -0
- package/template/ui/src/components/input-group.tsx +158 -0
- package/template/ui/src/components/input.tsx +19 -0
- package/template/ui/src/components/label.tsx +19 -0
- package/template/ui/src/components/pagination.tsx +127 -0
- package/template/ui/src/components/popover.tsx +89 -0
- package/template/ui/src/components/radio-group.tsx +37 -0
- package/template/ui/src/components/select.tsx +200 -0
- package/template/ui/src/components/separator.tsx +24 -0
- package/template/ui/src/components/sheet.tsx +138 -0
- package/template/ui/src/components/sidebar.tsx +723 -0
- package/template/ui/src/components/skeleton.tsx +13 -0
- package/template/ui/src/components/switch.tsx +31 -0
- package/template/ui/src/components/table.tsx +115 -0
- package/template/ui/src/components/tabs.tsx +81 -0
- package/template/ui/src/components/textarea.tsx +17 -0
- package/template/ui/src/components/toggle.tsx +44 -0
- package/template/ui/src/components/tooltip.tsx +65 -0
- package/template/ui/src/hooks/use-mobile.ts +21 -0
- package/template/ui/src/lib/utils.ts +2 -0
- package/template/ui/src/styles/globals.css +145 -0
|
@@ -0,0 +1,1693 @@
|
|
|
1
|
+
import Image from 'next/image'
|
|
2
|
+
import Link from 'next/link'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import type { Config, Fields } from '@puckeditor/core'
|
|
5
|
+
import { withPadding } from './padding'
|
|
6
|
+
import { withPluginBlocks } from './plugin-blocks'
|
|
7
|
+
import pluginBlocks from '../../pet-adopt.blocks'
|
|
8
|
+
import { classToken } from './sanitize'
|
|
9
|
+
|
|
10
|
+
import { PetCard } from '@/components/site/PetCard'
|
|
11
|
+
import { CopyButton } from '@/components/site/CopyButton'
|
|
12
|
+
import { ImageCarousel } from '@/components/site/ImageCarousel'
|
|
13
|
+
import { PetCatalog } from '@/components/site/PetCatalog'
|
|
14
|
+
import { SmartLink } from '@/components/site/SmartLink'
|
|
15
|
+
import { SocialLinks } from '@/components/site/SocialIcons'
|
|
16
|
+
import { RichText } from '@/components/site/RichText'
|
|
17
|
+
import { WhatsAppButton } from '@/components/site/WhatsAppButton'
|
|
18
|
+
import { safeMapEmbed, safeVideoEmbed } from '@/lib/links'
|
|
19
|
+
import { isPetStatus, labelFor, normalizeSpecies, PetStatus, SPECIES, STATUSES } from '@/lib/options'
|
|
20
|
+
import type { CatalogData, PetCardData, PetSpotlightData } from '@/lib/queries'
|
|
21
|
+
import { fillMessage } from '@/lib/whatsapp'
|
|
22
|
+
|
|
23
|
+
import { BLOCK_ICON_OPTIONS, BlockIcon } from './icons'
|
|
24
|
+
import { MediaPicker } from './media-picker'
|
|
25
|
+
import { PetPicker } from './pet-picker'
|
|
26
|
+
import type { MediaValue, PuckSiteMetadata } from './types'
|
|
27
|
+
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Shared helpers
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
type Background = 'none' | 'tint' | 'dark'
|
|
33
|
+
type Spacing = 'sm' | 'md' | 'lg'
|
|
34
|
+
|
|
35
|
+
const backgroundField = {
|
|
36
|
+
type: 'radio',
|
|
37
|
+
label: 'Background',
|
|
38
|
+
options: [
|
|
39
|
+
{ label: 'Plain', value: 'none' },
|
|
40
|
+
{ label: 'Tinted', value: 'tint' },
|
|
41
|
+
{ label: 'Dark', value: 'dark' },
|
|
42
|
+
],
|
|
43
|
+
} as const
|
|
44
|
+
|
|
45
|
+
const spacingField = {
|
|
46
|
+
type: 'radio',
|
|
47
|
+
label: 'Spacing',
|
|
48
|
+
options: [
|
|
49
|
+
{ label: 'Compact', value: 'sm' },
|
|
50
|
+
{ label: 'Normal', value: 'md' },
|
|
51
|
+
{ label: 'Roomy', value: 'lg' },
|
|
52
|
+
],
|
|
53
|
+
} as const
|
|
54
|
+
|
|
55
|
+
const alignField = {
|
|
56
|
+
type: 'radio',
|
|
57
|
+
label: 'Alignment',
|
|
58
|
+
options: [
|
|
59
|
+
{ label: 'Left', value: 'left' },
|
|
60
|
+
{ label: 'Center', value: 'center' },
|
|
61
|
+
],
|
|
62
|
+
} as const
|
|
63
|
+
|
|
64
|
+
export type HeadingStyle = 'normal' | 'display'
|
|
65
|
+
|
|
66
|
+
export const headingStyleField = {
|
|
67
|
+
type: 'radio',
|
|
68
|
+
label: 'Heading size',
|
|
69
|
+
options: [
|
|
70
|
+
{ label: 'Normal', value: 'normal' },
|
|
71
|
+
{ label: 'Display (very large)', value: 'display' },
|
|
72
|
+
],
|
|
73
|
+
} as const
|
|
74
|
+
|
|
75
|
+
/** The class for a block heading: the usual size, or the very large display size. */
|
|
76
|
+
export const headingClass = (style: HeadingStyle | undefined, base = '') => [base, style === 'display' ? 'heading-display' : ''].filter(Boolean).join(' ') || undefined
|
|
77
|
+
|
|
78
|
+
type ButtonStyle = 'primary' | 'outline' | 'dark'
|
|
79
|
+
|
|
80
|
+
const buttonStyleField = {
|
|
81
|
+
type: 'radio',
|
|
82
|
+
label: 'Button style',
|
|
83
|
+
options: [
|
|
84
|
+
{ label: 'Solid', value: 'primary' },
|
|
85
|
+
{ label: 'Outline', value: 'outline' },
|
|
86
|
+
{ label: 'Dark', value: 'dark' },
|
|
87
|
+
],
|
|
88
|
+
} as const
|
|
89
|
+
|
|
90
|
+
const buttonWidthField = {
|
|
91
|
+
type: 'radio',
|
|
92
|
+
label: 'Button width',
|
|
93
|
+
options: [
|
|
94
|
+
{ label: 'Fit the text', value: 'auto' },
|
|
95
|
+
{ label: 'Full width', value: 'full' },
|
|
96
|
+
],
|
|
97
|
+
} as const
|
|
98
|
+
|
|
99
|
+
/** Button classes from the style and width options (unset means a solid, fitted button). */
|
|
100
|
+
const buttonClass = (style?: ButtonStyle, width?: 'auto' | 'full') =>
|
|
101
|
+
['btn', style === 'outline' ? 'btn-outline' : style === 'dark' ? 'btn-dark' : 'btn-primary', width === 'full' ? 'btn-block' : '']
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.join(' ')
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Heading levels. On the live page every block gets `headingLevel` (see assignHeadingLevels): 1 for
|
|
107
|
+
* the first block with a heading (the page's only <h1>), 2 for the rest. In the editor it is unset,
|
|
108
|
+
* which reads as 2 (a Hero, as 1). The tag follows the level; the size follows the class
|
|
109
|
+
* (hero-title, block-heading, item-heading, minor-heading), so structure never changes the look.
|
|
110
|
+
*/
|
|
111
|
+
export type Level = { headingLevel?: 1 | 2 }
|
|
112
|
+
|
|
113
|
+
/** A Hero's heading: <h1>, or <h2> when another heading is already the page's <h1>. */
|
|
114
|
+
function HeroTitle({ level, style, children }: { level?: 1 | 2; style?: HeadingStyle; children: React.ReactNode }) {
|
|
115
|
+
const Tag = level === 2 ? 'h2' : 'h1'
|
|
116
|
+
return <Tag className={headingClass(style, 'hero-title')}>{children}</Tag>
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** A block's main heading: <h1> for the page's first heading, otherwise <h2>. */
|
|
120
|
+
function Title({ level, style, children }: { level?: 1 | 2; style?: HeadingStyle; children: React.ReactNode }) {
|
|
121
|
+
const Tag = level === 1 ? 'h1' : 'h2'
|
|
122
|
+
return <Tag className={headingClass(style, 'block-heading')}>{children}</Tag>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** A card or item title inside a block: one level below the block's heading. */
|
|
126
|
+
function ItemTitle({ level, className, children }: { level?: 1 | 2; className?: string; children: React.ReactNode }) {
|
|
127
|
+
const Tag = level === 1 ? 'h2' : 'h3'
|
|
128
|
+
return <Tag className={['item-heading', className].filter(Boolean).join(' ')}>{children}</Tag>
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const mediaField = (label: string) =>
|
|
132
|
+
({
|
|
133
|
+
type: 'custom',
|
|
134
|
+
label,
|
|
135
|
+
render: ({ value, onChange, readOnly }: { value: MediaValue; onChange: (v: MediaValue) => void; readOnly?: boolean }) => (
|
|
136
|
+
<MediaPicker value={value} onChange={onChange} readOnly={readOnly} />
|
|
137
|
+
),
|
|
138
|
+
}) as const
|
|
139
|
+
|
|
140
|
+
export function Section({
|
|
141
|
+
background = 'none',
|
|
142
|
+
spacing = 'md',
|
|
143
|
+
align = 'left',
|
|
144
|
+
children,
|
|
145
|
+
}: {
|
|
146
|
+
background?: Background
|
|
147
|
+
spacing?: Spacing
|
|
148
|
+
align?: 'left' | 'center'
|
|
149
|
+
children: React.ReactNode
|
|
150
|
+
}) {
|
|
151
|
+
return (
|
|
152
|
+
<section className={`section section-${classToken(background)} spacing-${classToken(spacing)} align-${classToken(align)}`}>
|
|
153
|
+
<div className="container">{children}</div>
|
|
154
|
+
</section>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const paragraphs = (text?: string) =>
|
|
159
|
+
(text ?? '')
|
|
160
|
+
.split(/\n{2,}/)
|
|
161
|
+
.map((p) => p.trim())
|
|
162
|
+
.filter(Boolean)
|
|
163
|
+
|
|
164
|
+
const siteOf = (puck: { metadata: Record<string, unknown> }) => (puck.metadata as Partial<PuckSiteMetadata>).site
|
|
165
|
+
|
|
166
|
+
type PetButtonAction = 'page' | 'whatsapp'
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* One pet as a full profile: the name over the photo, then the button, two short fact lines and the
|
|
170
|
+
* pet's own lists (health, personality, good with) and texts. Built from the pet's saved details,
|
|
171
|
+
* so it changes when the pet does. Used by the Pet spotlight and the Pet grid's profile layout.
|
|
172
|
+
*/
|
|
173
|
+
function PetProfile({
|
|
174
|
+
pet,
|
|
175
|
+
site,
|
|
176
|
+
buttonLabel,
|
|
177
|
+
buttonAction,
|
|
178
|
+
headingStyle,
|
|
179
|
+
level = 2,
|
|
180
|
+
}: {
|
|
181
|
+
pet: PetSpotlightData
|
|
182
|
+
site: PuckSiteMetadata['site'] | undefined
|
|
183
|
+
buttonLabel?: string
|
|
184
|
+
buttonAction?: PetButtonAction
|
|
185
|
+
headingStyle?: HeadingStyle
|
|
186
|
+
/** The name's heading level: 1 or 2 for a spotlight (it is the block's heading), 3 in a grid. */
|
|
187
|
+
level?: 1 | 2 | 3
|
|
188
|
+
}) {
|
|
189
|
+
const facts = [[pet.ageDescription, pet.sexLabel], [pet.breed || pet.speciesLabel, pet.color, pet.neutered ? 'Neutered' : null]]
|
|
190
|
+
// The same separator as the pet cards and pet pages.
|
|
191
|
+
.map((line) => line.filter(Boolean).join(' · '))
|
|
192
|
+
.filter(Boolean)
|
|
193
|
+
const label = buttonLabel || `Meet ${pet.name}`
|
|
194
|
+
// Section titles sit one level below the pet's name, so no heading level is skipped.
|
|
195
|
+
const Heading = (['h1', 'h2', 'h3'] as const)[level - 1]
|
|
196
|
+
const Sub = (['h2', 'h3', 'h4'] as const)[level - 1]
|
|
197
|
+
const lists: Array<[string, string[]]> = [
|
|
198
|
+
['Medical history', pet.healthChecks],
|
|
199
|
+
['Personality', pet.temperament],
|
|
200
|
+
['Good with', pet.goodWith],
|
|
201
|
+
]
|
|
202
|
+
return (
|
|
203
|
+
<article className="pet-profile" aria-labelledby={`pet-profile-${pet.id}`}>
|
|
204
|
+
{/* Square by default; stretches to the text column's height when the text is longer. */}
|
|
205
|
+
<div className="pet-profile-media">
|
|
206
|
+
<div className="pet-profile-photo">
|
|
207
|
+
{pet.image ? (
|
|
208
|
+
<Image src={pet.image.url} alt={pet.image.alt || pet.name} fill sizes="(max-width: 800px) 100vw, 40vw" />
|
|
209
|
+
) : (
|
|
210
|
+
<div className="image-text-placeholder" aria-hidden="true" />
|
|
211
|
+
)}
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
<div className="pet-profile-body">
|
|
215
|
+
<Heading
|
|
216
|
+
id={`pet-profile-${pet.id}`}
|
|
217
|
+
className={headingClass(headingStyle ?? 'display', `pet-profile-name ${level === 3 ? 'item-heading' : 'block-heading'}`)}
|
|
218
|
+
>
|
|
219
|
+
{pet.name}
|
|
220
|
+
</Heading>
|
|
221
|
+
{buttonAction === 'whatsapp' ? (
|
|
222
|
+
<WhatsAppButton phone={site?.whatsappNumber} message={fillMessage(site?.whatsappMessage, pet.name)} label={label} className="btn-block" />
|
|
223
|
+
) : (
|
|
224
|
+
<Link href={`/pets/${pet.slug}`} className="btn btn-primary btn-block">
|
|
225
|
+
{label}
|
|
226
|
+
</Link>
|
|
227
|
+
)}
|
|
228
|
+
{facts.length > 0 && (
|
|
229
|
+
<p className="pet-profile-facts">
|
|
230
|
+
{facts.map((line, i) => (
|
|
231
|
+
<span key={i}>{line}</span>
|
|
232
|
+
))}
|
|
233
|
+
</p>
|
|
234
|
+
)}
|
|
235
|
+
{lists.map(([title, items]) =>
|
|
236
|
+
items.length ? (
|
|
237
|
+
<section key={title} className="pet-profile-list">
|
|
238
|
+
<Sub className="minor-heading">{title}</Sub>
|
|
239
|
+
<ul>
|
|
240
|
+
{items.map((item) => (
|
|
241
|
+
<li key={item}>{item}</li>
|
|
242
|
+
))}
|
|
243
|
+
</ul>
|
|
244
|
+
</section>
|
|
245
|
+
) : null,
|
|
246
|
+
)}
|
|
247
|
+
{pet.healthNotes && (
|
|
248
|
+
<section className="pet-profile-list">
|
|
249
|
+
<Sub className="minor-heading">Health notes</Sub>
|
|
250
|
+
<RichText doc={pet.healthNotes} />
|
|
251
|
+
</section>
|
|
252
|
+
)}
|
|
253
|
+
{pet.description && (
|
|
254
|
+
<section className="pet-profile-list">
|
|
255
|
+
<Sub className="minor-heading">About {pet.name}</Sub>
|
|
256
|
+
<RichText doc={pet.description} />
|
|
257
|
+
</section>
|
|
258
|
+
)}
|
|
259
|
+
</div>
|
|
260
|
+
</article>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
// Block prop types
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
|
|
268
|
+
type HeroProps = {
|
|
269
|
+
heading: string
|
|
270
|
+
subheading: string
|
|
271
|
+
image: MediaValue
|
|
272
|
+
ctaLabel: string
|
|
273
|
+
ctaHref: string
|
|
274
|
+
showWhatsApp: boolean
|
|
275
|
+
align: 'left' | 'center'
|
|
276
|
+
height: 'md' | 'lg'
|
|
277
|
+
layout?: 'overlay' | 'stacked'
|
|
278
|
+
headingStyle?: HeadingStyle
|
|
279
|
+
buttonStyle?: ButtonStyle
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
type TextSectionProps = { heading: string; body: string; align: 'left' | 'center'; background: Background; spacing: Spacing }
|
|
283
|
+
|
|
284
|
+
type ImageGalleryProps = {
|
|
285
|
+
heading: string
|
|
286
|
+
columns: 2 | 3 | 4
|
|
287
|
+
items: { image: MediaValue; caption: string }[]
|
|
288
|
+
background: Background
|
|
289
|
+
spacing: Spacing
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
type PetGridProps = {
|
|
293
|
+
heading: string
|
|
294
|
+
headingStyle?: HeadingStyle
|
|
295
|
+
display?: 'cards' | 'profiles'
|
|
296
|
+
species: string
|
|
297
|
+
status: string
|
|
298
|
+
featuredOnly: boolean
|
|
299
|
+
limit: number
|
|
300
|
+
showViewAll: boolean
|
|
301
|
+
buttonLabel?: string
|
|
302
|
+
buttonAction?: PetButtonAction
|
|
303
|
+
background: Background
|
|
304
|
+
pets?: PetCardData[]
|
|
305
|
+
/** Filled in at render time for the profile layout, never saved. */
|
|
306
|
+
profiles?: PetSpotlightData[]
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
type CallToActionProps = {
|
|
310
|
+
heading: string
|
|
311
|
+
text: string
|
|
312
|
+
action: 'whatsapp' | 'link'
|
|
313
|
+
buttonLabel: string
|
|
314
|
+
href: string
|
|
315
|
+
background: Background
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
type TestimonialsProps = {
|
|
319
|
+
heading: string
|
|
320
|
+
items: { quote: string; name: string; detail: string }[]
|
|
321
|
+
background: Background
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
type FaqProps = { heading: string; items: { question: string; answer: string }[]; background: Background }
|
|
325
|
+
|
|
326
|
+
type ContactInfoProps = {
|
|
327
|
+
heading: string
|
|
328
|
+
showAddress: boolean
|
|
329
|
+
showHours: boolean
|
|
330
|
+
showWhatsApp: boolean
|
|
331
|
+
mapEmbedUrl: string
|
|
332
|
+
background: Background
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
type SocialLinksBlockProps = { heading: string; align: 'left' | 'center'; background: Background }
|
|
336
|
+
|
|
337
|
+
type ImageTextProps = {
|
|
338
|
+
image: MediaValue
|
|
339
|
+
imageSide: 'left' | 'right'
|
|
340
|
+
heading: string
|
|
341
|
+
headingStyle?: HeadingStyle
|
|
342
|
+
subheading?: string
|
|
343
|
+
body: string
|
|
344
|
+
ctaLabel: string
|
|
345
|
+
ctaHref: string
|
|
346
|
+
buttonStyle?: ButtonStyle
|
|
347
|
+
buttonWidth?: 'auto' | 'full'
|
|
348
|
+
imageWidth?: 'half' | 'wide'
|
|
349
|
+
photoMode?: 'single' | 'pair'
|
|
350
|
+
imageLabel?: string
|
|
351
|
+
secondImage?: MediaValue
|
|
352
|
+
secondImageLabel?: string
|
|
353
|
+
background: Background
|
|
354
|
+
spacing: Spacing
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
type AdoptionStepsProps = { heading: string; intro: string; items: { title: string; text: string }[]; background: Background }
|
|
358
|
+
|
|
359
|
+
type StatsProps = { heading: string; items: { value: string; label: string }[]; background: Background }
|
|
360
|
+
|
|
361
|
+
type VideoProps = { heading: string; url: string; caption: string; background: Background }
|
|
362
|
+
|
|
363
|
+
type ImageCarouselProps = { heading: string; items: { image: MediaValue; caption: string }[]; background: Background; spacing: Spacing }
|
|
364
|
+
|
|
365
|
+
type SpacerProps = { size: 'sm' | 'md' | 'lg' | 'xl' }
|
|
366
|
+
|
|
367
|
+
type DividerProps = { width: 'container' | 'narrow'; spacing: Spacing }
|
|
368
|
+
|
|
369
|
+
type PetCatalogProps = {
|
|
370
|
+
heading: string
|
|
371
|
+
headingStyle?: HeadingStyle
|
|
372
|
+
intro: string
|
|
373
|
+
showFilters: boolean
|
|
374
|
+
background: Background
|
|
375
|
+
/** Filled in at render time from the page's query string, never saved. */
|
|
376
|
+
catalog?: CatalogData
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
type CostTableProps = {
|
|
380
|
+
heading: string
|
|
381
|
+
headingStyle: HeadingStyle
|
|
382
|
+
intro: string
|
|
383
|
+
image: MediaValue
|
|
384
|
+
imageSide: 'left' | 'right'
|
|
385
|
+
itemLabel: string
|
|
386
|
+
valueLabel: string
|
|
387
|
+
rows: { label: string; value: string; highlight: 'none' | 'total' | 'strong' }[]
|
|
388
|
+
note: string
|
|
389
|
+
background: Background
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
type PetSpotlightProps = {
|
|
393
|
+
eyebrow: string
|
|
394
|
+
petId: number | null
|
|
395
|
+
layout?: 'spotlight' | 'profile'
|
|
396
|
+
headingStyle?: HeadingStyle
|
|
397
|
+
imageSide: 'left' | 'right'
|
|
398
|
+
buttonLabel: string
|
|
399
|
+
buttonAction?: PetButtonAction
|
|
400
|
+
showWhatsApp: boolean
|
|
401
|
+
background: Background
|
|
402
|
+
/** Filled in at render time (resolveData), never saved. */
|
|
403
|
+
spotlight?: PetSpotlightData | null
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
type TeamProps = {
|
|
407
|
+
heading: string
|
|
408
|
+
intro: string
|
|
409
|
+
members: { photo: MediaValue; name: string; role: string; bio: string }[]
|
|
410
|
+
background: Background
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
type FeaturesProps = {
|
|
414
|
+
heading: string
|
|
415
|
+
headingStyle?: HeadingStyle
|
|
416
|
+
intro: string
|
|
417
|
+
layout?: 'grid' | 'list'
|
|
418
|
+
columns: 2 | 3 | 4
|
|
419
|
+
items: { icon: string; title: string; text: string }[]
|
|
420
|
+
align: 'left' | 'center'
|
|
421
|
+
background: Background
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
type WaysToHelpProps = {
|
|
425
|
+
heading: string
|
|
426
|
+
intro: string
|
|
427
|
+
items: { icon: string; title: string; text: string; action: 'none' | 'link' | 'whatsapp'; label: string; href: string }[]
|
|
428
|
+
paymentTitle: string
|
|
429
|
+
paymentDetails: string
|
|
430
|
+
background: Background
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export type PuckComponents = {
|
|
434
|
+
Hero: HeroProps & Level
|
|
435
|
+
TextSection: TextSectionProps & Level
|
|
436
|
+
ImageGallery: ImageGalleryProps & Level
|
|
437
|
+
PetGrid: PetGridProps & Level
|
|
438
|
+
CallToAction: CallToActionProps & Level
|
|
439
|
+
Testimonials: TestimonialsProps & Level
|
|
440
|
+
Faq: FaqProps & Level
|
|
441
|
+
ContactInfo: ContactInfoProps & Level
|
|
442
|
+
SocialLinksBlock: SocialLinksBlockProps & Level
|
|
443
|
+
ImageText: ImageTextProps & Level
|
|
444
|
+
AdoptionSteps: AdoptionStepsProps & Level
|
|
445
|
+
Stats: StatsProps & Level
|
|
446
|
+
Video: VideoProps & Level
|
|
447
|
+
ImageCarousel: ImageCarouselProps & Level
|
|
448
|
+
Spacer: SpacerProps & Level
|
|
449
|
+
Divider: DividerProps & Level
|
|
450
|
+
PetSpotlight: PetSpotlightProps & Level
|
|
451
|
+
Team: TeamProps & Level
|
|
452
|
+
Features: FeaturesProps & Level
|
|
453
|
+
WaysToHelp: WaysToHelpProps & Level
|
|
454
|
+
CostTable: CostTableProps & Level
|
|
455
|
+
PetCatalog: PetCatalogProps & Level
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ---------------------------------------------------------------------------
|
|
459
|
+
// Config. Shared by the editor (client) and the public site (server).
|
|
460
|
+
// Blocks are plain presentational components, with no hooks or client-only code.
|
|
461
|
+
// ---------------------------------------------------------------------------
|
|
462
|
+
|
|
463
|
+
const blocks: Config<PuckComponents> = {
|
|
464
|
+
// No page fields: Puck's default "title" was never used (the title is on Page settings), and the
|
|
465
|
+
// page builder shows its preview controls there instead (PageEditor's FieldsPanel).
|
|
466
|
+
root: { fields: {} },
|
|
467
|
+
categories: {
|
|
468
|
+
layout: { title: 'Sections', components: ['Hero', 'TextSection', 'ImageText', 'Features', 'CallToAction'] },
|
|
469
|
+
media: { title: 'Media', components: ['ImageGallery', 'ImageCarousel', 'Video'] },
|
|
470
|
+
pets: { title: 'Pets', components: ['PetCatalog', 'PetSpotlight', 'PetGrid', 'AdoptionSteps', 'Stats'] },
|
|
471
|
+
trust: { title: 'Trust & contact', components: ['Testimonials', 'Team', 'WaysToHelp', 'CostTable', 'Faq', 'ContactInfo', 'SocialLinksBlock'] },
|
|
472
|
+
helpers: { title: 'Layout helpers', components: ['Spacer', 'Divider'] },
|
|
473
|
+
},
|
|
474
|
+
components: {
|
|
475
|
+
Hero: {
|
|
476
|
+
label: 'Hero banner',
|
|
477
|
+
defaultProps: {
|
|
478
|
+
heading: 'Welcome',
|
|
479
|
+
subheading: 'Tell visitors what makes your adoption service special.',
|
|
480
|
+
image: null,
|
|
481
|
+
ctaLabel: 'Meet the pets',
|
|
482
|
+
ctaHref: '/pets',
|
|
483
|
+
showWhatsApp: true,
|
|
484
|
+
align: 'center',
|
|
485
|
+
height: 'md',
|
|
486
|
+
},
|
|
487
|
+
fields: {
|
|
488
|
+
heading: { type: 'text', label: 'Heading' },
|
|
489
|
+
subheading: { type: 'textarea', label: 'Subheading' },
|
|
490
|
+
image: mediaField('Background image'),
|
|
491
|
+
ctaLabel: { type: 'text', label: 'Button text' },
|
|
492
|
+
ctaHref: { type: 'text', label: 'Button link (e.g. /pets)' },
|
|
493
|
+
showWhatsApp: {
|
|
494
|
+
type: 'radio',
|
|
495
|
+
label: 'WhatsApp button',
|
|
496
|
+
options: [
|
|
497
|
+
{ label: 'Show', value: true },
|
|
498
|
+
{ label: 'Hide', value: false },
|
|
499
|
+
],
|
|
500
|
+
},
|
|
501
|
+
align: alignField,
|
|
502
|
+
height: {
|
|
503
|
+
type: 'radio',
|
|
504
|
+
label: 'Height',
|
|
505
|
+
options: [
|
|
506
|
+
{ label: 'Medium', value: 'md' },
|
|
507
|
+
{ label: 'Tall', value: 'lg' },
|
|
508
|
+
],
|
|
509
|
+
},
|
|
510
|
+
layout: {
|
|
511
|
+
type: 'radio',
|
|
512
|
+
label: 'Layout',
|
|
513
|
+
options: [
|
|
514
|
+
{ label: 'Text over the image', value: 'overlay' },
|
|
515
|
+
{ label: 'Image above the text', value: 'stacked' },
|
|
516
|
+
],
|
|
517
|
+
},
|
|
518
|
+
headingStyle: headingStyleField,
|
|
519
|
+
buttonStyle: buttonStyleField,
|
|
520
|
+
} as Fields<HeroProps>,
|
|
521
|
+
render: ({ headingLevel, heading, subheading, image, ctaLabel, ctaHref, showWhatsApp, align, height, layout, headingStyle, buttonStyle, puck }) => {
|
|
522
|
+
const site = siteOf(puck)
|
|
523
|
+
if (layout === 'stacked') {
|
|
524
|
+
// A rounded photo with the heading, text and buttons under it, on the page's own colours.
|
|
525
|
+
return (
|
|
526
|
+
<section className={`hero-stacked align-${classToken(align)}`}>
|
|
527
|
+
<div className="container">
|
|
528
|
+
{image && (
|
|
529
|
+
<div className={`hero-stacked-image hero-stacked-${classToken(height)}`}>
|
|
530
|
+
<Image src={image.url} alt={image.alt || ''} fill priority sizes="100vw" />
|
|
531
|
+
</div>
|
|
532
|
+
)}
|
|
533
|
+
{heading && <HeroTitle level={headingLevel} style={headingStyle}>{heading}</HeroTitle>}
|
|
534
|
+
{subheading && <p className="hero-sub">{subheading}</p>}
|
|
535
|
+
<div className="hero-actions">
|
|
536
|
+
{ctaLabel && (
|
|
537
|
+
<SmartLink href={ctaHref} className={buttonClass(buttonStyle)}>
|
|
538
|
+
{ctaLabel}
|
|
539
|
+
</SmartLink>
|
|
540
|
+
)}
|
|
541
|
+
{showWhatsApp && <WhatsAppButton phone={site?.whatsappNumber} message={fillMessage(site?.whatsappMessage, null)} variant="outline" />}
|
|
542
|
+
</div>
|
|
543
|
+
</div>
|
|
544
|
+
</section>
|
|
545
|
+
)
|
|
546
|
+
}
|
|
547
|
+
return (
|
|
548
|
+
<section className={`hero hero-${classToken(height)} align-${classToken(align)}${image ? ' hero-has-image' : ''}`}>
|
|
549
|
+
{image && <Image src={image.url} alt={image.alt || ''} fill priority sizes="100vw" className="hero-image" />}
|
|
550
|
+
<div className="container hero-content">
|
|
551
|
+
{heading && <HeroTitle level={headingLevel} style={headingStyle}>{heading}</HeroTitle>}
|
|
552
|
+
{subheading && <p className="hero-sub">{subheading}</p>}
|
|
553
|
+
<div className="hero-actions">
|
|
554
|
+
{ctaLabel && (
|
|
555
|
+
<SmartLink href={ctaHref} className={buttonClass(buttonStyle)}>
|
|
556
|
+
{ctaLabel}
|
|
557
|
+
</SmartLink>
|
|
558
|
+
)}
|
|
559
|
+
{showWhatsApp && (
|
|
560
|
+
<WhatsAppButton
|
|
561
|
+
phone={site?.whatsappNumber}
|
|
562
|
+
message={fillMessage(site?.whatsappMessage, null)}
|
|
563
|
+
variant="outline"
|
|
564
|
+
className="btn-on-hero"
|
|
565
|
+
/>
|
|
566
|
+
)}
|
|
567
|
+
</div>
|
|
568
|
+
</div>
|
|
569
|
+
</section>
|
|
570
|
+
)
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
|
|
574
|
+
TextSection: {
|
|
575
|
+
label: 'Text',
|
|
576
|
+
defaultProps: { heading: 'About us', body: 'Write a few paragraphs here.\n\nLeave a blank line to start a new paragraph.', align: 'left', background: 'none', spacing: 'md' },
|
|
577
|
+
fields: {
|
|
578
|
+
heading: { type: 'text' },
|
|
579
|
+
body: { type: 'textarea', label: 'Text (blank line = new paragraph)' },
|
|
580
|
+
align: alignField,
|
|
581
|
+
background: backgroundField,
|
|
582
|
+
spacing: spacingField,
|
|
583
|
+
} as Fields<TextSectionProps>,
|
|
584
|
+
render: ({ headingLevel, heading, body, align, background, spacing }) => (
|
|
585
|
+
<Section background={background} spacing={spacing} align={align}>
|
|
586
|
+
<div className="prose">
|
|
587
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
588
|
+
{paragraphs(body).map((p, i) => (
|
|
589
|
+
<p key={i}>{p}</p>
|
|
590
|
+
))}
|
|
591
|
+
</div>
|
|
592
|
+
</Section>
|
|
593
|
+
),
|
|
594
|
+
},
|
|
595
|
+
|
|
596
|
+
ImageGallery: {
|
|
597
|
+
// Shown to owners as "Image grid". The type key stays ImageGallery: saved pages refer to it.
|
|
598
|
+
label: 'Image grid',
|
|
599
|
+
defaultProps: { heading: '', columns: 3, items: [], background: 'none', spacing: 'md' },
|
|
600
|
+
fields: {
|
|
601
|
+
heading: { type: 'text' },
|
|
602
|
+
columns: {
|
|
603
|
+
type: 'radio',
|
|
604
|
+
label: 'Columns',
|
|
605
|
+
options: [
|
|
606
|
+
{ label: '2', value: 2 },
|
|
607
|
+
{ label: '3', value: 3 },
|
|
608
|
+
{ label: '4', value: 4 },
|
|
609
|
+
],
|
|
610
|
+
},
|
|
611
|
+
items: {
|
|
612
|
+
type: 'array',
|
|
613
|
+
label: 'Images',
|
|
614
|
+
getItemSummary: (item) => item.caption || 'Image',
|
|
615
|
+
defaultItemProps: { image: null, caption: '' },
|
|
616
|
+
arrayFields: { image: mediaField('Image'), caption: { type: 'text' } },
|
|
617
|
+
},
|
|
618
|
+
background: backgroundField,
|
|
619
|
+
spacing: spacingField,
|
|
620
|
+
} as Fields<ImageGalleryProps>,
|
|
621
|
+
render: ({ headingLevel, heading, columns, items, background, spacing }) => (
|
|
622
|
+
<Section background={background} spacing={spacing}>
|
|
623
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
624
|
+
<div className={`gallery gallery-${classToken(columns)}`}>
|
|
625
|
+
{items
|
|
626
|
+
.filter((item) => item.image)
|
|
627
|
+
.map((item, i) => (
|
|
628
|
+
<figure key={i}>
|
|
629
|
+
<div className="gallery-image">
|
|
630
|
+
<Image src={item.image!.url} alt={item.image!.alt || item.caption || ''} fill sizes="(max-width: 640px) 100vw, 33vw" />
|
|
631
|
+
</div>
|
|
632
|
+
{item.caption && <figcaption>{item.caption}</figcaption>}
|
|
633
|
+
</figure>
|
|
634
|
+
))}
|
|
635
|
+
</div>
|
|
636
|
+
</Section>
|
|
637
|
+
),
|
|
638
|
+
},
|
|
639
|
+
|
|
640
|
+
PetGrid: {
|
|
641
|
+
label: 'Pet grid',
|
|
642
|
+
defaultProps: { heading: 'Ready for adoption', species: '', status: PetStatus.Available, featuredOnly: false, limit: 8, showViewAll: true, background: 'none' },
|
|
643
|
+
fields: {
|
|
644
|
+
heading: { type: 'text' },
|
|
645
|
+
headingStyle: headingStyleField,
|
|
646
|
+
display: {
|
|
647
|
+
type: 'radio',
|
|
648
|
+
label: 'Show pets as',
|
|
649
|
+
options: [
|
|
650
|
+
{ label: 'Cards in a grid', value: 'cards' },
|
|
651
|
+
{ label: 'Full profiles, one after another (up to 12)', value: 'profiles' },
|
|
652
|
+
],
|
|
653
|
+
},
|
|
654
|
+
// Free text, because species is too: "cat", "guinea pig"... Leave empty for every species.
|
|
655
|
+
species: { type: 'text', label: 'Species (empty for all)' },
|
|
656
|
+
status: { type: 'select', label: 'Status', options: [{ label: 'Any status', value: '' }, ...STATUSES] },
|
|
657
|
+
featuredOnly: {
|
|
658
|
+
type: 'radio',
|
|
659
|
+
label: 'Which pets',
|
|
660
|
+
options: [
|
|
661
|
+
{ label: 'Latest', value: false },
|
|
662
|
+
{ label: 'Featured only', value: true },
|
|
663
|
+
],
|
|
664
|
+
},
|
|
665
|
+
limit: { type: 'number', label: 'How many (1-24)', min: 1, max: 24 },
|
|
666
|
+
showViewAll: {
|
|
667
|
+
type: 'radio',
|
|
668
|
+
label: '"View all" link',
|
|
669
|
+
options: [
|
|
670
|
+
{ label: 'Show', value: true },
|
|
671
|
+
{ label: 'Hide', value: false },
|
|
672
|
+
],
|
|
673
|
+
},
|
|
674
|
+
buttonLabel: { type: 'text', label: 'Profile button text (default: Meet <name>)' },
|
|
675
|
+
buttonAction: {
|
|
676
|
+
type: 'radio',
|
|
677
|
+
label: 'Profile button opens',
|
|
678
|
+
options: [
|
|
679
|
+
{ label: "The pet's page", value: 'page' },
|
|
680
|
+
{ label: 'WhatsApp', value: 'whatsapp' },
|
|
681
|
+
],
|
|
682
|
+
},
|
|
683
|
+
background: backgroundField,
|
|
684
|
+
} as Fields<PetGridProps>,
|
|
685
|
+
// Live data. Runs in the editor (via a server action) and on the server when rendering.
|
|
686
|
+
// The result is never saved into the page JSON (see stripTransient).
|
|
687
|
+
resolveData: async ({ props }, { metadata }) => {
|
|
688
|
+
const meta = metadata as Partial<PuckSiteMetadata>
|
|
689
|
+
const filters = {
|
|
690
|
+
species: normalizeSpecies(props.species) || undefined,
|
|
691
|
+
status: isPetStatus(props.status) ? props.status : undefined,
|
|
692
|
+
featuredOnly: props.featuredOnly,
|
|
693
|
+
}
|
|
694
|
+
// Only the layout that is shown is fetched.
|
|
695
|
+
if (props.display === 'profiles') {
|
|
696
|
+
if (!meta.fetchPetProfiles) return { props }
|
|
697
|
+
const profiles = await meta.fetchPetProfiles({ ...filters, limit: Math.min(Math.max(Number(props.limit) || 6, 1), 12) })
|
|
698
|
+
return { props: { ...props, profiles, pets: undefined } }
|
|
699
|
+
}
|
|
700
|
+
if (!meta.fetchPets) return { props }
|
|
701
|
+
const pets = await meta.fetchPets({ ...filters, limit: Math.min(Math.max(Number(props.limit) || 8, 1), 24) })
|
|
702
|
+
return { props: { ...props, pets, profiles: undefined } }
|
|
703
|
+
},
|
|
704
|
+
render: ({ headingLevel, heading, headingStyle, display, pets, profiles, showViewAll, buttonLabel, buttonAction, background, puck }) => (
|
|
705
|
+
<Section background={background}>
|
|
706
|
+
<div className="section-head">
|
|
707
|
+
{heading && <Title level={headingLevel} style={headingStyle}>{heading}</Title>}
|
|
708
|
+
{showViewAll && (
|
|
709
|
+
<Link href="/pets" className="link-more">
|
|
710
|
+
View all pets
|
|
711
|
+
</Link>
|
|
712
|
+
)}
|
|
713
|
+
</div>
|
|
714
|
+
{display === 'profiles' ? (
|
|
715
|
+
profiles?.length ? (
|
|
716
|
+
<div className="pet-profiles">
|
|
717
|
+
{profiles.map((pet) => (
|
|
718
|
+
<PetProfile
|
|
719
|
+
key={pet.id}
|
|
720
|
+
pet={pet}
|
|
721
|
+
site={siteOf(puck)}
|
|
722
|
+
buttonLabel={buttonLabel}
|
|
723
|
+
buttonAction={buttonAction}
|
|
724
|
+
level={headingLevel === 1 ? 2 : 3}
|
|
725
|
+
/>
|
|
726
|
+
))}
|
|
727
|
+
</div>
|
|
728
|
+
) : (
|
|
729
|
+
<p className="muted">No pets to show yet.</p>
|
|
730
|
+
)
|
|
731
|
+
) : pets?.length ? (
|
|
732
|
+
<div className="pet-grid">
|
|
733
|
+
{pets.map((pet) => (
|
|
734
|
+
<PetCard key={pet.id} pet={pet} headingLevel={headingLevel === 1 ? 'h2' : 'h3'} />
|
|
735
|
+
))}
|
|
736
|
+
</div>
|
|
737
|
+
) : (
|
|
738
|
+
<p className="muted">No pets to show yet.</p>
|
|
739
|
+
)}
|
|
740
|
+
</Section>
|
|
741
|
+
),
|
|
742
|
+
},
|
|
743
|
+
|
|
744
|
+
CallToAction: {
|
|
745
|
+
label: 'Call to action',
|
|
746
|
+
defaultProps: { heading: 'Ready to meet them?', text: 'Send us a message and we will arrange a visit.', action: 'whatsapp', buttonLabel: 'Chat on WhatsApp', href: '', background: 'tint' },
|
|
747
|
+
fields: {
|
|
748
|
+
heading: { type: 'text' },
|
|
749
|
+
text: { type: 'textarea' },
|
|
750
|
+
action: {
|
|
751
|
+
type: 'radio',
|
|
752
|
+
label: 'Button opens',
|
|
753
|
+
options: [
|
|
754
|
+
{ label: 'WhatsApp', value: 'whatsapp' },
|
|
755
|
+
{ label: 'A link', value: 'link' },
|
|
756
|
+
],
|
|
757
|
+
},
|
|
758
|
+
buttonLabel: { type: 'text', label: 'Button text' },
|
|
759
|
+
href: { type: 'text', label: 'Link (only for "A link")' },
|
|
760
|
+
background: backgroundField,
|
|
761
|
+
} as Fields<CallToActionProps>,
|
|
762
|
+
render: ({ headingLevel, heading, text, action, buttonLabel, href, background, puck }) => {
|
|
763
|
+
const site = siteOf(puck)
|
|
764
|
+
return (
|
|
765
|
+
<Section background={background} align="center" spacing="lg">
|
|
766
|
+
<div className="prose">
|
|
767
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
768
|
+
{text && <p>{text}</p>}
|
|
769
|
+
{action === 'whatsapp' ? (
|
|
770
|
+
<WhatsAppButton phone={site?.whatsappNumber} message={fillMessage(site?.whatsappMessage, null)} label={buttonLabel || 'Chat on WhatsApp'} />
|
|
771
|
+
) : (
|
|
772
|
+
<SmartLink href={href} className="btn btn-primary">
|
|
773
|
+
{buttonLabel || 'Learn more'}
|
|
774
|
+
</SmartLink>
|
|
775
|
+
)}
|
|
776
|
+
</div>
|
|
777
|
+
</Section>
|
|
778
|
+
)
|
|
779
|
+
},
|
|
780
|
+
},
|
|
781
|
+
|
|
782
|
+
Testimonials: {
|
|
783
|
+
label: 'Adopter stories',
|
|
784
|
+
defaultProps: { heading: 'Happy tails', items: [{ quote: 'Adopting Mochi was the best decision we ever made.', name: 'The Tan family', detail: 'Adopted Mochi' }], background: 'tint' },
|
|
785
|
+
fields: {
|
|
786
|
+
heading: { type: 'text' },
|
|
787
|
+
items: {
|
|
788
|
+
type: 'array',
|
|
789
|
+
label: 'Stories',
|
|
790
|
+
getItemSummary: (item) => item.name || 'Story',
|
|
791
|
+
defaultItemProps: { quote: '', name: '', detail: '' },
|
|
792
|
+
arrayFields: { quote: { type: 'textarea' }, name: { type: 'text' }, detail: { type: 'text' } },
|
|
793
|
+
},
|
|
794
|
+
background: backgroundField,
|
|
795
|
+
} as Fields<TestimonialsProps>,
|
|
796
|
+
render: ({ headingLevel, heading, items, background }) => (
|
|
797
|
+
<Section background={background}>
|
|
798
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
799
|
+
<div className="testimonials">
|
|
800
|
+
{items.map((item, i) => (
|
|
801
|
+
<blockquote key={i}>
|
|
802
|
+
<p>{item.quote}</p>
|
|
803
|
+
<footer>
|
|
804
|
+
<strong>{item.name}</strong>
|
|
805
|
+
{item.detail && <span> · {item.detail}</span>}
|
|
806
|
+
</footer>
|
|
807
|
+
</blockquote>
|
|
808
|
+
))}
|
|
809
|
+
</div>
|
|
810
|
+
</Section>
|
|
811
|
+
),
|
|
812
|
+
},
|
|
813
|
+
|
|
814
|
+
Faq: {
|
|
815
|
+
label: 'FAQ',
|
|
816
|
+
defaultProps: { heading: 'Frequently asked questions', items: [{ question: 'How does adoption work?', answer: 'Message us, meet the pet, and we will guide you through the next steps.' }], background: 'none' },
|
|
817
|
+
fields: {
|
|
818
|
+
heading: { type: 'text' },
|
|
819
|
+
items: {
|
|
820
|
+
type: 'array',
|
|
821
|
+
label: 'Questions',
|
|
822
|
+
getItemSummary: (item) => item.question || 'Question',
|
|
823
|
+
defaultItemProps: { question: '', answer: '' },
|
|
824
|
+
arrayFields: { question: { type: 'text' }, answer: { type: 'textarea' } },
|
|
825
|
+
},
|
|
826
|
+
background: backgroundField,
|
|
827
|
+
} as Fields<FaqProps>,
|
|
828
|
+
render: ({ headingLevel, heading, items, background }) => (
|
|
829
|
+
<Section background={background}>
|
|
830
|
+
<div className="prose">
|
|
831
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
832
|
+
<div className="faq">
|
|
833
|
+
{items.map((item, i) => (
|
|
834
|
+
<details key={i}>
|
|
835
|
+
<summary>{item.question}</summary>
|
|
836
|
+
{paragraphs(item.answer).map((p, j) => (
|
|
837
|
+
<p key={j}>{p}</p>
|
|
838
|
+
))}
|
|
839
|
+
</details>
|
|
840
|
+
))}
|
|
841
|
+
</div>
|
|
842
|
+
</div>
|
|
843
|
+
</Section>
|
|
844
|
+
),
|
|
845
|
+
},
|
|
846
|
+
|
|
847
|
+
ContactInfo: {
|
|
848
|
+
label: 'Contact & map',
|
|
849
|
+
defaultProps: { heading: 'Visit us', showAddress: true, showHours: true, showWhatsApp: true, mapEmbedUrl: '', background: 'none' },
|
|
850
|
+
fields: {
|
|
851
|
+
heading: { type: 'text' },
|
|
852
|
+
showAddress: { type: 'radio', label: 'Address', options: [{ label: 'Show', value: true }, { label: 'Hide', value: false }] },
|
|
853
|
+
showHours: { type: 'radio', label: 'Opening hours', options: [{ label: 'Show', value: true }, { label: 'Hide', value: false }] },
|
|
854
|
+
showWhatsApp: { type: 'radio', label: 'WhatsApp button', options: [{ label: 'Show', value: true }, { label: 'Hide', value: false }] },
|
|
855
|
+
mapEmbedUrl: { type: 'text', label: 'Google Maps embed link (Share > Embed a map > copy src)' },
|
|
856
|
+
background: backgroundField,
|
|
857
|
+
} as Fields<ContactInfoProps>,
|
|
858
|
+
render: ({ headingLevel, heading, showAddress, showHours, showWhatsApp, mapEmbedUrl, background, puck }) => {
|
|
859
|
+
const site = siteOf(puck)
|
|
860
|
+
const map = safeMapEmbed(mapEmbedUrl)
|
|
861
|
+
return (
|
|
862
|
+
<Section background={background}>
|
|
863
|
+
<div className="contact-grid">
|
|
864
|
+
<div className="prose">
|
|
865
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
866
|
+
{showAddress && site?.address && <p className="pre-line">{site.address}</p>}
|
|
867
|
+
{showHours && site?.openingHours && <p className="pre-line">{site.openingHours}</p>}
|
|
868
|
+
{showWhatsApp && <WhatsAppButton phone={site?.whatsappNumber} message={fillMessage(site?.whatsappMessage, null)} />}
|
|
869
|
+
</div>
|
|
870
|
+
{map && <iframe className="map" src={map} title="Map" loading="lazy" referrerPolicy="no-referrer-when-downgrade" />}
|
|
871
|
+
</div>
|
|
872
|
+
</Section>
|
|
873
|
+
)
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
|
|
877
|
+
SocialLinksBlock: {
|
|
878
|
+
label: 'Social links',
|
|
879
|
+
defaultProps: { heading: 'Follow our rescues', align: 'center', background: 'none' },
|
|
880
|
+
fields: { heading: { type: 'text' }, align: alignField, background: backgroundField } as Fields<SocialLinksBlockProps>,
|
|
881
|
+
render: ({ headingLevel, heading, align, background, puck }) => (
|
|
882
|
+
<Section background={background} align={align}>
|
|
883
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
884
|
+
<SocialLinks items={siteOf(puck)?.socials} className="social-links-large" />
|
|
885
|
+
</Section>
|
|
886
|
+
),
|
|
887
|
+
},
|
|
888
|
+
|
|
889
|
+
ImageText: {
|
|
890
|
+
label: 'Image + text',
|
|
891
|
+
defaultProps: {
|
|
892
|
+
image: null,
|
|
893
|
+
imageSide: 'left',
|
|
894
|
+
heading: 'Our shelter',
|
|
895
|
+
body: 'Tell visitors about your rescue, your volunteers or how you care for the animals.\n\nLeave a blank line to start a new paragraph.',
|
|
896
|
+
ctaLabel: '',
|
|
897
|
+
ctaHref: '',
|
|
898
|
+
background: 'none',
|
|
899
|
+
spacing: 'md',
|
|
900
|
+
},
|
|
901
|
+
fields: {
|
|
902
|
+
image: mediaField('Image'),
|
|
903
|
+
imageSide: {
|
|
904
|
+
type: 'radio',
|
|
905
|
+
label: 'Image side',
|
|
906
|
+
options: [
|
|
907
|
+
{ label: 'Left', value: 'left' },
|
|
908
|
+
{ label: 'Right', value: 'right' },
|
|
909
|
+
],
|
|
910
|
+
},
|
|
911
|
+
heading: { type: 'text' },
|
|
912
|
+
headingStyle: headingStyleField,
|
|
913
|
+
subheading: { type: 'text', label: 'Bold line under the heading (optional)' },
|
|
914
|
+
body: { type: 'textarea', label: 'Text (blank line = new paragraph)' },
|
|
915
|
+
ctaLabel: { type: 'text', label: 'Button text (optional)' },
|
|
916
|
+
ctaHref: { type: 'text', label: 'Button link (e.g. /pets)' },
|
|
917
|
+
buttonStyle: buttonStyleField,
|
|
918
|
+
buttonWidth: buttonWidthField,
|
|
919
|
+
imageWidth: {
|
|
920
|
+
type: 'radio',
|
|
921
|
+
label: 'Photo width',
|
|
922
|
+
options: [
|
|
923
|
+
{ label: 'Half', value: 'half' },
|
|
924
|
+
{ label: 'Wide', value: 'wide' },
|
|
925
|
+
],
|
|
926
|
+
},
|
|
927
|
+
photoMode: {
|
|
928
|
+
type: 'radio',
|
|
929
|
+
label: 'Photos',
|
|
930
|
+
options: [
|
|
931
|
+
{ label: 'One photo', value: 'single' },
|
|
932
|
+
{ label: 'Two stacked (e.g. before / after)', value: 'pair' },
|
|
933
|
+
],
|
|
934
|
+
},
|
|
935
|
+
imageLabel: { type: 'text', label: 'Label on the photo (optional, e.g. Before)' },
|
|
936
|
+
secondImage: mediaField('Second photo (two stacked only)'),
|
|
937
|
+
secondImageLabel: { type: 'text', label: 'Label on the second photo (e.g. After)' },
|
|
938
|
+
background: backgroundField,
|
|
939
|
+
spacing: spacingField,
|
|
940
|
+
} as Fields<ImageTextProps>,
|
|
941
|
+
render: ({
|
|
942
|
+
headingLevel,
|
|
943
|
+
image,
|
|
944
|
+
imageSide,
|
|
945
|
+
heading,
|
|
946
|
+
headingStyle,
|
|
947
|
+
subheading,
|
|
948
|
+
body,
|
|
949
|
+
ctaLabel,
|
|
950
|
+
ctaHref,
|
|
951
|
+
buttonStyle,
|
|
952
|
+
buttonWidth,
|
|
953
|
+
imageWidth,
|
|
954
|
+
photoMode,
|
|
955
|
+
imageLabel,
|
|
956
|
+
secondImage,
|
|
957
|
+
secondImageLabel,
|
|
958
|
+
background,
|
|
959
|
+
spacing,
|
|
960
|
+
}) => {
|
|
961
|
+
const photo = (value: MediaValue, label?: string) => (
|
|
962
|
+
<figure className="image-text-media">
|
|
963
|
+
{value ? (
|
|
964
|
+
<Image src={value.url} alt={value.alt || ''} fill sizes="(max-width: 800px) 100vw, 50vw" />
|
|
965
|
+
) : (
|
|
966
|
+
<div className="image-text-placeholder" aria-hidden="true" />
|
|
967
|
+
)}
|
|
968
|
+
{/* The label is part of the picture's meaning ("Before"), so it is real text, on a dark chip
|
|
969
|
+
that keeps it readable over any photo. */}
|
|
970
|
+
{label && <figcaption className="photo-label">{label}</figcaption>}
|
|
971
|
+
</figure>
|
|
972
|
+
)
|
|
973
|
+
return (
|
|
974
|
+
<Section background={background} spacing={spacing}>
|
|
975
|
+
<div className={`image-text image-text-${classToken(imageSide)}${imageWidth === 'wide' ? ' image-text-wide' : ''}`}>
|
|
976
|
+
{photoMode === 'pair' ? (
|
|
977
|
+
<div className="image-text-pair">
|
|
978
|
+
{photo(image, imageLabel)}
|
|
979
|
+
{photo(secondImage ?? null, secondImageLabel)}
|
|
980
|
+
</div>
|
|
981
|
+
) : (
|
|
982
|
+
photo(image, imageLabel)
|
|
983
|
+
)}
|
|
984
|
+
<div className="prose">
|
|
985
|
+
{heading && <Title level={headingLevel} style={headingStyle}>{heading}</Title>}
|
|
986
|
+
{subheading && <p className="image-text-subheading">{subheading}</p>}
|
|
987
|
+
{paragraphs(body).map((p, i) => (
|
|
988
|
+
<p key={i}>{p}</p>
|
|
989
|
+
))}
|
|
990
|
+
{ctaLabel && (
|
|
991
|
+
<SmartLink href={ctaHref} className={buttonClass(buttonStyle, buttonWidth)}>
|
|
992
|
+
{ctaLabel}
|
|
993
|
+
</SmartLink>
|
|
994
|
+
)}
|
|
995
|
+
</div>
|
|
996
|
+
</div>
|
|
997
|
+
</Section>
|
|
998
|
+
)
|
|
999
|
+
},
|
|
1000
|
+
},
|
|
1001
|
+
|
|
1002
|
+
AdoptionSteps: {
|
|
1003
|
+
label: 'Adoption steps',
|
|
1004
|
+
defaultProps: {
|
|
1005
|
+
heading: 'How adoption works',
|
|
1006
|
+
intro: '',
|
|
1007
|
+
items: [
|
|
1008
|
+
{ title: 'Browse', text: 'Look through the pets and find one you would love to meet.' },
|
|
1009
|
+
{ title: 'Message us', text: 'Send us a WhatsApp message and we will answer your questions.' },
|
|
1010
|
+
{ title: 'Meet', text: 'Visit the pet and see if you are a good match for each other.' },
|
|
1011
|
+
{ title: 'Take them home', text: 'We help with the paperwork and the first days together.' },
|
|
1012
|
+
],
|
|
1013
|
+
background: 'none',
|
|
1014
|
+
},
|
|
1015
|
+
fields: {
|
|
1016
|
+
heading: { type: 'text' },
|
|
1017
|
+
intro: { type: 'textarea', label: 'Intro (optional)' },
|
|
1018
|
+
items: {
|
|
1019
|
+
type: 'array',
|
|
1020
|
+
label: 'Steps',
|
|
1021
|
+
getItemSummary: (item) => item.title || 'Step',
|
|
1022
|
+
defaultItemProps: { title: '', text: '' },
|
|
1023
|
+
arrayFields: { title: { type: 'text' }, text: { type: 'textarea' } },
|
|
1024
|
+
},
|
|
1025
|
+
background: backgroundField,
|
|
1026
|
+
} as Fields<AdoptionStepsProps>,
|
|
1027
|
+
render: ({ headingLevel, heading, intro, items, background }) => (
|
|
1028
|
+
<Section background={background}>
|
|
1029
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
1030
|
+
{intro && <p className="section-intro">{intro}</p>}
|
|
1031
|
+
{/* An ordered list: the order is the point, and screen readers announce "1 of 4". */}
|
|
1032
|
+
<ol className="steps">
|
|
1033
|
+
{items.map((item, i) => (
|
|
1034
|
+
<li key={i}>
|
|
1035
|
+
<span className="step-number" aria-hidden="true">
|
|
1036
|
+
{i + 1}
|
|
1037
|
+
</span>
|
|
1038
|
+
<div>
|
|
1039
|
+
{item.title && <ItemTitle level={headingLevel}>{item.title}</ItemTitle>}
|
|
1040
|
+
{item.text && <p>{item.text}</p>}
|
|
1041
|
+
</div>
|
|
1042
|
+
</li>
|
|
1043
|
+
))}
|
|
1044
|
+
</ol>
|
|
1045
|
+
</Section>
|
|
1046
|
+
),
|
|
1047
|
+
},
|
|
1048
|
+
|
|
1049
|
+
Stats: {
|
|
1050
|
+
label: 'Numbers',
|
|
1051
|
+
defaultProps: {
|
|
1052
|
+
heading: '',
|
|
1053
|
+
items: [
|
|
1054
|
+
{ value: '120+', label: 'Pets adopted' },
|
|
1055
|
+
{ value: '8', label: 'Years rescuing' },
|
|
1056
|
+
{ value: '30', label: 'Volunteers' },
|
|
1057
|
+
],
|
|
1058
|
+
background: 'tint',
|
|
1059
|
+
},
|
|
1060
|
+
fields: {
|
|
1061
|
+
heading: { type: 'text', label: 'Heading (optional)' },
|
|
1062
|
+
items: {
|
|
1063
|
+
type: 'array',
|
|
1064
|
+
label: 'Numbers',
|
|
1065
|
+
getItemSummary: (item) => [item.value, item.label].filter(Boolean).join(' ') || 'Number',
|
|
1066
|
+
defaultItemProps: { value: '', label: '' },
|
|
1067
|
+
arrayFields: { value: { type: 'text', label: 'Number (e.g. 120+)' }, label: { type: 'text', label: 'What it counts' } },
|
|
1068
|
+
},
|
|
1069
|
+
background: backgroundField,
|
|
1070
|
+
} as Fields<StatsProps>,
|
|
1071
|
+
render: ({ headingLevel, heading, items, background }) => (
|
|
1072
|
+
<Section background={background} align="center">
|
|
1073
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
1074
|
+
{/* A description list keeps each number with its label for screen readers. */}
|
|
1075
|
+
<dl className="stats">
|
|
1076
|
+
{items.map((item, i) => (
|
|
1077
|
+
<div key={i} className="stat">
|
|
1078
|
+
<dt>{item.label}</dt>
|
|
1079
|
+
<dd>{item.value}</dd>
|
|
1080
|
+
</div>
|
|
1081
|
+
))}
|
|
1082
|
+
</dl>
|
|
1083
|
+
</Section>
|
|
1084
|
+
),
|
|
1085
|
+
},
|
|
1086
|
+
|
|
1087
|
+
Video: {
|
|
1088
|
+
label: 'Video',
|
|
1089
|
+
defaultProps: { heading: '', url: '', caption: '', background: 'none' },
|
|
1090
|
+
fields: {
|
|
1091
|
+
heading: { type: 'text', label: 'Heading (optional)' },
|
|
1092
|
+
url: { type: 'text', label: 'YouTube or Vimeo link (https://...)' },
|
|
1093
|
+
caption: { type: 'text', label: 'Caption (optional)' },
|
|
1094
|
+
background: backgroundField,
|
|
1095
|
+
} as Fields<VideoProps>,
|
|
1096
|
+
render: ({ headingLevel, heading, url, caption, background }) => {
|
|
1097
|
+
const embed = safeVideoEmbed(url)
|
|
1098
|
+
return (
|
|
1099
|
+
<Section background={background}>
|
|
1100
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
1101
|
+
{embed ? (
|
|
1102
|
+
<figure className="video-block">
|
|
1103
|
+
<div className="video-frame">
|
|
1104
|
+
<iframe
|
|
1105
|
+
src={embed}
|
|
1106
|
+
title={caption || heading || 'Video'}
|
|
1107
|
+
loading="lazy"
|
|
1108
|
+
allow="accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen"
|
|
1109
|
+
allowFullScreen
|
|
1110
|
+
referrerPolicy="strict-origin-when-cross-origin"
|
|
1111
|
+
/>
|
|
1112
|
+
</div>
|
|
1113
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
1114
|
+
</figure>
|
|
1115
|
+
) : (
|
|
1116
|
+
<p className="muted">{url ? 'Use a YouTube or Vimeo link that starts with https://' : 'Paste a YouTube or Vimeo link.'}</p>
|
|
1117
|
+
)}
|
|
1118
|
+
</Section>
|
|
1119
|
+
)
|
|
1120
|
+
},
|
|
1121
|
+
},
|
|
1122
|
+
|
|
1123
|
+
ImageCarousel: {
|
|
1124
|
+
label: 'Image carousel',
|
|
1125
|
+
defaultProps: { heading: '', items: [], background: 'none', spacing: 'md' },
|
|
1126
|
+
fields: {
|
|
1127
|
+
heading: { type: 'text', label: 'Heading (optional)' },
|
|
1128
|
+
items: {
|
|
1129
|
+
type: 'array',
|
|
1130
|
+
label: 'Slides',
|
|
1131
|
+
getItemSummary: (item) => item.caption || item.image?.alt || 'Slide',
|
|
1132
|
+
defaultItemProps: { image: null, caption: '' },
|
|
1133
|
+
arrayFields: { image: mediaField('Image'), caption: { type: 'text', label: 'Caption (optional)' } },
|
|
1134
|
+
},
|
|
1135
|
+
background: backgroundField,
|
|
1136
|
+
spacing: spacingField,
|
|
1137
|
+
} as Fields<ImageCarouselProps>,
|
|
1138
|
+
render: ({ headingLevel, heading, items, background, spacing }) => {
|
|
1139
|
+
// Only plain strings cross to the client component.
|
|
1140
|
+
const slides = items
|
|
1141
|
+
.filter((item) => item.image)
|
|
1142
|
+
.map((item) => ({ url: item.image!.url, alt: item.image!.alt || '', caption: item.caption || '' }))
|
|
1143
|
+
return (
|
|
1144
|
+
<Section background={background} spacing={spacing}>
|
|
1145
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
1146
|
+
{slides.length ? <ImageCarousel items={slides} label={heading} /> : <p className="muted">Add images to the carousel.</p>}
|
|
1147
|
+
</Section>
|
|
1148
|
+
)
|
|
1149
|
+
},
|
|
1150
|
+
},
|
|
1151
|
+
|
|
1152
|
+
PetSpotlight: {
|
|
1153
|
+
label: 'Pet spotlight',
|
|
1154
|
+
defaultProps: { eyebrow: 'Pet of the week', petId: null, imageSide: 'left', buttonLabel: '', showWhatsApp: true, background: 'tint' },
|
|
1155
|
+
fields: {
|
|
1156
|
+
eyebrow: { type: 'text', label: 'Small heading (e.g. Pet of the week)' },
|
|
1157
|
+
petId: {
|
|
1158
|
+
type: 'custom',
|
|
1159
|
+
label: 'Pet',
|
|
1160
|
+
render: ({ id, value, onChange, readOnly }: { id: string; value: number | null; onChange: (value: number | null) => void; readOnly?: boolean }) => (
|
|
1161
|
+
<PetPicker id={id} value={value} onChange={onChange} readOnly={readOnly} />
|
|
1162
|
+
),
|
|
1163
|
+
},
|
|
1164
|
+
layout: {
|
|
1165
|
+
type: 'radio',
|
|
1166
|
+
label: 'Layout',
|
|
1167
|
+
options: [
|
|
1168
|
+
{ label: 'Spotlight (photo and short story)', value: 'spotlight' },
|
|
1169
|
+
{ label: 'Full profile (facts and lists)', value: 'profile' },
|
|
1170
|
+
],
|
|
1171
|
+
},
|
|
1172
|
+
headingStyle: headingStyleField,
|
|
1173
|
+
imageSide: {
|
|
1174
|
+
type: 'radio',
|
|
1175
|
+
label: 'Photo side',
|
|
1176
|
+
options: [
|
|
1177
|
+
{ label: 'Left', value: 'left' },
|
|
1178
|
+
{ label: 'Right', value: 'right' },
|
|
1179
|
+
],
|
|
1180
|
+
},
|
|
1181
|
+
buttonLabel: { type: 'text', label: 'Button text (default: Meet <name>)' },
|
|
1182
|
+
buttonAction: {
|
|
1183
|
+
type: 'radio',
|
|
1184
|
+
label: 'Button opens',
|
|
1185
|
+
options: [
|
|
1186
|
+
{ label: "The pet's page", value: 'page' },
|
|
1187
|
+
{ label: 'WhatsApp', value: 'whatsapp' },
|
|
1188
|
+
],
|
|
1189
|
+
},
|
|
1190
|
+
showWhatsApp: {
|
|
1191
|
+
type: 'radio',
|
|
1192
|
+
label: 'WhatsApp button',
|
|
1193
|
+
options: [
|
|
1194
|
+
{ label: 'Show', value: true },
|
|
1195
|
+
{ label: 'Hide', value: false },
|
|
1196
|
+
],
|
|
1197
|
+
},
|
|
1198
|
+
background: backgroundField,
|
|
1199
|
+
} as Fields<PetSpotlightProps>,
|
|
1200
|
+
// Live data, like the pet grid: the pet is looked up when the page renders, so its photo,
|
|
1201
|
+
// age and status are always current. Never saved into the page JSON (see stripTransient).
|
|
1202
|
+
resolveData: async ({ props }, { metadata }) => {
|
|
1203
|
+
const fetchPet = (metadata as Partial<PuckSiteMetadata>).fetchPet
|
|
1204
|
+
const id = Number(props.petId)
|
|
1205
|
+
if (!fetchPet || !Number.isSafeInteger(id) || id < 1) return { props: { ...props, spotlight: null } }
|
|
1206
|
+
return { props: { ...props, spotlight: await fetchPet(id) } }
|
|
1207
|
+
},
|
|
1208
|
+
render: ({ headingLevel, eyebrow, spotlight, petId, layout, headingStyle, imageSide, buttonLabel, buttonAction, showWhatsApp, background, puck }) => {
|
|
1209
|
+
// A pet that is adopted, link-only or gone hides the block on the live site.
|
|
1210
|
+
if (!spotlight) {
|
|
1211
|
+
return puck.isEditing ? (
|
|
1212
|
+
<Section background={background}>
|
|
1213
|
+
<p className="muted">
|
|
1214
|
+
{petId ? 'This pet is adopted, link-only or deleted, so the spotlight is hidden on the site.' : 'Choose a pet for the spotlight.'}
|
|
1215
|
+
</p>
|
|
1216
|
+
</Section>
|
|
1217
|
+
) : (
|
|
1218
|
+
<></>
|
|
1219
|
+
)
|
|
1220
|
+
}
|
|
1221
|
+
const site = siteOf(puck)
|
|
1222
|
+
const pet = spotlight
|
|
1223
|
+
if (layout === 'profile') {
|
|
1224
|
+
return (
|
|
1225
|
+
<Section background={background}>
|
|
1226
|
+
{eyebrow && <p className="spotlight-eyebrow">{eyebrow}</p>}
|
|
1227
|
+
<PetProfile pet={pet} site={site} buttonLabel={buttonLabel} buttonAction={buttonAction} headingStyle={headingStyle} level={headingLevel ?? 2} />
|
|
1228
|
+
</Section>
|
|
1229
|
+
)
|
|
1230
|
+
}
|
|
1231
|
+
const details = [labelFor(SPECIES, pet.species), pet.ageDescription, pet.location].filter(Boolean).join(' · ')
|
|
1232
|
+
return (
|
|
1233
|
+
<Section background={background}>
|
|
1234
|
+
<div className={`spotlight image-text image-text-${classToken(imageSide)}`}>
|
|
1235
|
+
<div className="image-text-media">
|
|
1236
|
+
{pet.image ? (
|
|
1237
|
+
<Image src={pet.image.url} alt={pet.image.alt || pet.name} fill sizes="(max-width: 800px) 100vw, 50vw" />
|
|
1238
|
+
) : (
|
|
1239
|
+
<div className="image-text-placeholder" aria-hidden="true" />
|
|
1240
|
+
)}
|
|
1241
|
+
</div>
|
|
1242
|
+
<div className="prose">
|
|
1243
|
+
{eyebrow && <p className="spotlight-eyebrow">{eyebrow}</p>}
|
|
1244
|
+
<Title level={headingLevel} style={headingStyle}>
|
|
1245
|
+
{pet.name}
|
|
1246
|
+
</Title>
|
|
1247
|
+
{details && <p className="muted">{details}</p>}
|
|
1248
|
+
{pet.story && <p>{pet.story}</p>}
|
|
1249
|
+
<div className="hero-actions">
|
|
1250
|
+
{buttonAction === 'whatsapp' ? (
|
|
1251
|
+
<WhatsAppButton phone={site?.whatsappNumber} message={fillMessage(site?.whatsappMessage, pet.name)} label={buttonLabel || `Ask about ${pet.name}`} />
|
|
1252
|
+
) : (
|
|
1253
|
+
<Link href={`/pets/${pet.slug}`} className="btn btn-primary">
|
|
1254
|
+
{buttonLabel || `Meet ${pet.name}`}
|
|
1255
|
+
</Link>
|
|
1256
|
+
)}
|
|
1257
|
+
{showWhatsApp && buttonAction !== 'whatsapp' && (
|
|
1258
|
+
<WhatsAppButton phone={site?.whatsappNumber} message={fillMessage(site?.whatsappMessage, pet.name)} variant="outline" />
|
|
1259
|
+
)}
|
|
1260
|
+
</div>
|
|
1261
|
+
</div>
|
|
1262
|
+
</div>
|
|
1263
|
+
</Section>
|
|
1264
|
+
)
|
|
1265
|
+
},
|
|
1266
|
+
},
|
|
1267
|
+
|
|
1268
|
+
Team: {
|
|
1269
|
+
label: 'Team',
|
|
1270
|
+
defaultProps: {
|
|
1271
|
+
heading: 'Meet the team',
|
|
1272
|
+
intro: '',
|
|
1273
|
+
members: [{ photo: null, name: 'Your name', role: 'Founder', bio: 'A line about what they do for the animals.' }],
|
|
1274
|
+
background: 'none',
|
|
1275
|
+
},
|
|
1276
|
+
fields: {
|
|
1277
|
+
heading: { type: 'text' },
|
|
1278
|
+
intro: { type: 'textarea', label: 'Intro (optional)' },
|
|
1279
|
+
members: {
|
|
1280
|
+
type: 'array',
|
|
1281
|
+
label: 'People',
|
|
1282
|
+
getItemSummary: (item) => item.name || 'Person',
|
|
1283
|
+
defaultItemProps: { photo: null, name: '', role: '', bio: '' },
|
|
1284
|
+
arrayFields: {
|
|
1285
|
+
photo: mediaField('Photo'),
|
|
1286
|
+
name: { type: 'text' },
|
|
1287
|
+
role: { type: 'text', label: 'Role (e.g. Volunteer vet)' },
|
|
1288
|
+
bio: { type: 'textarea', label: 'Short line (optional)' },
|
|
1289
|
+
},
|
|
1290
|
+
},
|
|
1291
|
+
background: backgroundField,
|
|
1292
|
+
} as Fields<TeamProps>,
|
|
1293
|
+
render: ({ headingLevel, heading, intro, members, background }) => (
|
|
1294
|
+
<Section background={background}>
|
|
1295
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
1296
|
+
{intro && <p className="section-intro">{intro}</p>}
|
|
1297
|
+
<ul className="team">
|
|
1298
|
+
{members.map((member, i) => (
|
|
1299
|
+
<li key={i} className="team-member">
|
|
1300
|
+
<div className="team-photo">
|
|
1301
|
+
{member.photo ? (
|
|
1302
|
+
<Image src={member.photo.url} alt={member.photo.alt || member.name} fill sizes="160px" />
|
|
1303
|
+
) : (
|
|
1304
|
+
<div className="image-text-placeholder" aria-hidden="true" />
|
|
1305
|
+
)}
|
|
1306
|
+
</div>
|
|
1307
|
+
{member.name && <ItemTitle level={headingLevel}>{member.name}</ItemTitle>}
|
|
1308
|
+
{member.role && <p className="team-role">{member.role}</p>}
|
|
1309
|
+
{member.bio && <p className="muted">{member.bio}</p>}
|
|
1310
|
+
</li>
|
|
1311
|
+
))}
|
|
1312
|
+
</ul>
|
|
1313
|
+
</Section>
|
|
1314
|
+
),
|
|
1315
|
+
},
|
|
1316
|
+
|
|
1317
|
+
Features: {
|
|
1318
|
+
label: 'Features with icons',
|
|
1319
|
+
defaultProps: {
|
|
1320
|
+
heading: 'Every pet comes',
|
|
1321
|
+
intro: '',
|
|
1322
|
+
columns: 3,
|
|
1323
|
+
items: [
|
|
1324
|
+
{ icon: 'shield', title: 'Vaccinated', text: 'Up to date on vaccinations before going home.' },
|
|
1325
|
+
{ icon: 'health', title: 'Vet checked', text: 'Seen by our vet, with health notes you can read.' },
|
|
1326
|
+
{ icon: 'heart', title: 'Lifetime support', text: 'Questions after adoption? We are a message away.' },
|
|
1327
|
+
],
|
|
1328
|
+
align: 'center',
|
|
1329
|
+
background: 'none',
|
|
1330
|
+
},
|
|
1331
|
+
fields: {
|
|
1332
|
+
heading: { type: 'text' },
|
|
1333
|
+
headingStyle: headingStyleField,
|
|
1334
|
+
intro: { type: 'textarea', label: 'Intro (optional)' },
|
|
1335
|
+
layout: {
|
|
1336
|
+
type: 'radio',
|
|
1337
|
+
label: 'Layout',
|
|
1338
|
+
options: [
|
|
1339
|
+
{ label: 'Columns', value: 'grid' },
|
|
1340
|
+
{ label: 'Heading beside a list', value: 'list' },
|
|
1341
|
+
],
|
|
1342
|
+
},
|
|
1343
|
+
columns: {
|
|
1344
|
+
type: 'radio',
|
|
1345
|
+
label: 'Columns (Columns layout)',
|
|
1346
|
+
options: [
|
|
1347
|
+
{ label: '2', value: 2 },
|
|
1348
|
+
{ label: '3', value: 3 },
|
|
1349
|
+
{ label: '4', value: 4 },
|
|
1350
|
+
],
|
|
1351
|
+
},
|
|
1352
|
+
items: {
|
|
1353
|
+
type: 'array',
|
|
1354
|
+
label: 'Points',
|
|
1355
|
+
getItemSummary: (item) => item.title || 'Point',
|
|
1356
|
+
defaultItemProps: { icon: 'check', title: '', text: '' },
|
|
1357
|
+
arrayFields: {
|
|
1358
|
+
icon: { type: 'select', label: 'Icon', options: BLOCK_ICON_OPTIONS },
|
|
1359
|
+
title: { type: 'text' },
|
|
1360
|
+
text: { type: 'textarea' },
|
|
1361
|
+
},
|
|
1362
|
+
},
|
|
1363
|
+
align: alignField,
|
|
1364
|
+
background: backgroundField,
|
|
1365
|
+
} as Fields<FeaturesProps>,
|
|
1366
|
+
render: ({ headingLevel, heading, headingStyle, intro, layout, columns, items, align, background }) => {
|
|
1367
|
+
if (layout === 'list') {
|
|
1368
|
+
// The heading (and intro) on one side, the points stacked on the other: bold title, then text.
|
|
1369
|
+
return (
|
|
1370
|
+
<Section background={background}>
|
|
1371
|
+
<div className="features-split">
|
|
1372
|
+
<div>
|
|
1373
|
+
{heading && <Title level={headingLevel} style={headingStyle}>{heading}</Title>}
|
|
1374
|
+
{intro && <p className="section-intro">{intro}</p>}
|
|
1375
|
+
</div>
|
|
1376
|
+
<ul className="features-list">
|
|
1377
|
+
{items.map((item, i) => (
|
|
1378
|
+
<li key={i}>
|
|
1379
|
+
{item.title && (
|
|
1380
|
+
<ItemTitle level={headingLevel}>
|
|
1381
|
+
{item.icon ? <BlockIcon name={item.icon} className="features-list-icon" /> : null}
|
|
1382
|
+
{item.title}
|
|
1383
|
+
</ItemTitle>
|
|
1384
|
+
)}
|
|
1385
|
+
{item.text && <p>{item.text}</p>}
|
|
1386
|
+
</li>
|
|
1387
|
+
))}
|
|
1388
|
+
</ul>
|
|
1389
|
+
</div>
|
|
1390
|
+
</Section>
|
|
1391
|
+
)
|
|
1392
|
+
}
|
|
1393
|
+
return (
|
|
1394
|
+
<Section background={background} align={align}>
|
|
1395
|
+
{heading && <Title level={headingLevel} style={headingStyle}>{heading}</Title>}
|
|
1396
|
+
{intro && <p className="section-intro">{intro}</p>}
|
|
1397
|
+
<ul className={`features features-${classToken(columns)}`}>
|
|
1398
|
+
{items.map((item, i) => (
|
|
1399
|
+
<li key={i}>
|
|
1400
|
+
{item.icon ? (
|
|
1401
|
+
<span className="feature-icon">
|
|
1402
|
+
<BlockIcon name={item.icon} />
|
|
1403
|
+
</span>
|
|
1404
|
+
) : null}
|
|
1405
|
+
{item.title && <ItemTitle level={headingLevel}>{item.title}</ItemTitle>}
|
|
1406
|
+
{item.text && <p>{item.text}</p>}
|
|
1407
|
+
</li>
|
|
1408
|
+
))}
|
|
1409
|
+
</ul>
|
|
1410
|
+
</Section>
|
|
1411
|
+
)
|
|
1412
|
+
},
|
|
1413
|
+
},
|
|
1414
|
+
|
|
1415
|
+
WaysToHelp: {
|
|
1416
|
+
label: 'Ways to help',
|
|
1417
|
+
defaultProps: {
|
|
1418
|
+
heading: 'Ways to help',
|
|
1419
|
+
intro: 'Not ready to adopt? There are other ways to make a difference.',
|
|
1420
|
+
items: [
|
|
1421
|
+
{ icon: 'money', title: 'Donate', text: 'Every bit helps with food, vaccines and vet bills.', action: 'none', label: '', href: '' },
|
|
1422
|
+
{ icon: 'home', title: 'Foster', text: 'Give a pet a temporary home while they wait for a family.', action: 'whatsapp', label: 'Ask about fostering', href: '' },
|
|
1423
|
+
{ icon: 'users', title: 'Volunteer', text: 'Help at adoption days, with transport or on social media.', action: 'whatsapp', label: 'Volunteer with us', href: '' },
|
|
1424
|
+
],
|
|
1425
|
+
paymentTitle: 'Bank details',
|
|
1426
|
+
paymentDetails: '',
|
|
1427
|
+
background: 'none',
|
|
1428
|
+
},
|
|
1429
|
+
fields: {
|
|
1430
|
+
heading: { type: 'text' },
|
|
1431
|
+
intro: { type: 'textarea', label: 'Intro (optional)' },
|
|
1432
|
+
items: {
|
|
1433
|
+
type: 'array',
|
|
1434
|
+
label: 'Ways',
|
|
1435
|
+
getItemSummary: (item) => item.title || 'Way to help',
|
|
1436
|
+
defaultItemProps: { icon: 'heart', title: '', text: '', action: 'none', label: '', href: '' },
|
|
1437
|
+
arrayFields: {
|
|
1438
|
+
icon: { type: 'select', label: 'Icon', options: BLOCK_ICON_OPTIONS },
|
|
1439
|
+
title: { type: 'text' },
|
|
1440
|
+
text: { type: 'textarea' },
|
|
1441
|
+
action: {
|
|
1442
|
+
type: 'radio',
|
|
1443
|
+
label: 'Button',
|
|
1444
|
+
options: [
|
|
1445
|
+
{ label: 'None', value: 'none' },
|
|
1446
|
+
{ label: 'WhatsApp', value: 'whatsapp' },
|
|
1447
|
+
{ label: 'A link', value: 'link' },
|
|
1448
|
+
],
|
|
1449
|
+
},
|
|
1450
|
+
label: { type: 'text', label: 'Button text' },
|
|
1451
|
+
href: { type: 'text', label: 'Link (only for "A link")' },
|
|
1452
|
+
},
|
|
1453
|
+
},
|
|
1454
|
+
paymentTitle: { type: 'text', label: 'Payment heading (e.g. Bank details)' },
|
|
1455
|
+
paymentDetails: { type: 'textarea', label: 'Payment details, shown with a Copy button (optional)' },
|
|
1456
|
+
background: backgroundField,
|
|
1457
|
+
} as Fields<WaysToHelpProps>,
|
|
1458
|
+
render: ({ headingLevel, heading, intro, items, paymentTitle, paymentDetails, background, puck }) => {
|
|
1459
|
+
const site = siteOf(puck)
|
|
1460
|
+
const details = paymentDetails?.trim()
|
|
1461
|
+
return (
|
|
1462
|
+
<Section background={background}>
|
|
1463
|
+
{heading && <Title level={headingLevel}>{heading}</Title>}
|
|
1464
|
+
{intro && <p className="section-intro">{intro}</p>}
|
|
1465
|
+
<ul className="features features-3 help-ways">
|
|
1466
|
+
{items.map((item, i) => (
|
|
1467
|
+
<li key={i}>
|
|
1468
|
+
{item.icon ? (
|
|
1469
|
+
<span className="feature-icon">
|
|
1470
|
+
<BlockIcon name={item.icon} />
|
|
1471
|
+
</span>
|
|
1472
|
+
) : null}
|
|
1473
|
+
{item.title && <ItemTitle level={headingLevel}>{item.title}</ItemTitle>}
|
|
1474
|
+
{item.text && <p>{item.text}</p>}
|
|
1475
|
+
{item.action === 'whatsapp' ? (
|
|
1476
|
+
<WhatsAppButton
|
|
1477
|
+
phone={site?.whatsappNumber}
|
|
1478
|
+
message={item.title ? `Hi! I'd like to help: ${item.title}.` : fillMessage(site?.whatsappMessage, null)}
|
|
1479
|
+
label={item.label || 'Chat on WhatsApp'}
|
|
1480
|
+
variant="outline"
|
|
1481
|
+
/>
|
|
1482
|
+
) : item.action === 'link' && item.href ? (
|
|
1483
|
+
<SmartLink href={item.href} className="btn btn-outline">
|
|
1484
|
+
{item.label || 'Learn more'}
|
|
1485
|
+
</SmartLink>
|
|
1486
|
+
) : null}
|
|
1487
|
+
</li>
|
|
1488
|
+
))}
|
|
1489
|
+
</ul>
|
|
1490
|
+
{details ? (
|
|
1491
|
+
<div className="payment-details">
|
|
1492
|
+
{paymentTitle && <ItemTitle level={headingLevel}>{paymentTitle}</ItemTitle>}
|
|
1493
|
+
<p className="pre-line">{details}</p>
|
|
1494
|
+
<CopyButton text={details} label={`Copy ${paymentTitle ? paymentTitle.toLowerCase() : 'details'}`} />
|
|
1495
|
+
</div>
|
|
1496
|
+
) : null}
|
|
1497
|
+
</Section>
|
|
1498
|
+
)
|
|
1499
|
+
},
|
|
1500
|
+
},
|
|
1501
|
+
|
|
1502
|
+
PetCatalog: {
|
|
1503
|
+
label: 'Pet catalogue',
|
|
1504
|
+
defaultProps: { heading: 'Adoptable pets', headingStyle: 'normal', intro: '', showFilters: true, background: 'none' },
|
|
1505
|
+
fields: {
|
|
1506
|
+
heading: { type: 'text' },
|
|
1507
|
+
headingStyle: headingStyleField,
|
|
1508
|
+
intro: { type: 'textarea', label: 'Intro (optional)' },
|
|
1509
|
+
showFilters: {
|
|
1510
|
+
type: 'radio',
|
|
1511
|
+
label: 'Filters (they always search the Pets page)',
|
|
1512
|
+
options: [
|
|
1513
|
+
{ label: 'Show', value: true },
|
|
1514
|
+
{ label: 'Hide', value: false },
|
|
1515
|
+
],
|
|
1516
|
+
},
|
|
1517
|
+
background: backgroundField,
|
|
1518
|
+
} as Fields<PetCatalogProps>,
|
|
1519
|
+
// Live data: the filters and page come from the address (/pets?species=cat&page=2). In the
|
|
1520
|
+
// editor there is no address to read, so it shows the first page with no filters.
|
|
1521
|
+
resolveData: async ({ props }, { metadata }) => {
|
|
1522
|
+
const meta = metadata as Partial<PuckSiteMetadata>
|
|
1523
|
+
if (!meta.fetchCatalog) return { props }
|
|
1524
|
+
return { props: { ...props, catalog: await meta.fetchCatalog(meta.searchParams ?? {}) } }
|
|
1525
|
+
},
|
|
1526
|
+
render: ({ headingLevel, heading, headingStyle, intro, showFilters, background, catalog }) => (
|
|
1527
|
+
<Section background={background}>
|
|
1528
|
+
{heading && (
|
|
1529
|
+
<Title level={headingLevel} style={headingStyle}>
|
|
1530
|
+
{heading}
|
|
1531
|
+
</Title>
|
|
1532
|
+
)}
|
|
1533
|
+
{intro && <p className="section-intro">{intro}</p>}
|
|
1534
|
+
{catalog ? (
|
|
1535
|
+
<PetCatalog catalog={catalog} showFilters={showFilters} cardHeading={headingLevel === 1 ? 'h2' : 'h3'} />
|
|
1536
|
+
) : (
|
|
1537
|
+
<p className="muted">Loading pets…</p>
|
|
1538
|
+
)}
|
|
1539
|
+
</Section>
|
|
1540
|
+
),
|
|
1541
|
+
},
|
|
1542
|
+
|
|
1543
|
+
CostTable: {
|
|
1544
|
+
label: 'Cost table',
|
|
1545
|
+
defaultProps: {
|
|
1546
|
+
heading: 'What does it cost?',
|
|
1547
|
+
headingStyle: 'display',
|
|
1548
|
+
intro: 'Every rescue is different, but this is roughly what it takes to get one pet ready for a home.',
|
|
1549
|
+
image: null,
|
|
1550
|
+
imageSide: 'left',
|
|
1551
|
+
itemLabel: 'Care',
|
|
1552
|
+
valueLabel: 'Average cost',
|
|
1553
|
+
rows: [
|
|
1554
|
+
{ label: 'Deworming and flea treatment', value: 'RM 40 – 60', highlight: 'none' },
|
|
1555
|
+
{ label: 'Vaccinations', value: 'RM 100 – 140', highlight: 'none' },
|
|
1556
|
+
{ label: 'Spay or neuter', value: 'RM 180 – 250', highlight: 'none' },
|
|
1557
|
+
{ label: 'Total for a healthy rescue', value: 'RM 320 – 450', highlight: 'total' },
|
|
1558
|
+
{ label: 'Emergency and medical cases', value: 'RM 600 – 1,200+', highlight: 'strong' },
|
|
1559
|
+
],
|
|
1560
|
+
note: '',
|
|
1561
|
+
background: 'none',
|
|
1562
|
+
},
|
|
1563
|
+
fields: {
|
|
1564
|
+
heading: { type: 'text' },
|
|
1565
|
+
headingStyle: headingStyleField,
|
|
1566
|
+
intro: { type: 'textarea', label: 'Intro (optional)' },
|
|
1567
|
+
image: mediaField('Photo (optional)'),
|
|
1568
|
+
imageSide: {
|
|
1569
|
+
type: 'radio',
|
|
1570
|
+
label: 'Heading and photo side',
|
|
1571
|
+
options: [
|
|
1572
|
+
{ label: 'Left', value: 'left' },
|
|
1573
|
+
{ label: 'Right', value: 'right' },
|
|
1574
|
+
],
|
|
1575
|
+
},
|
|
1576
|
+
itemLabel: { type: 'text', label: 'First column title' },
|
|
1577
|
+
valueLabel: { type: 'text', label: 'Second column title' },
|
|
1578
|
+
rows: {
|
|
1579
|
+
type: 'array',
|
|
1580
|
+
label: 'Rows',
|
|
1581
|
+
getItemSummary: (item) => [item.label, item.value].filter(Boolean).join(': ') || 'Row',
|
|
1582
|
+
defaultItemProps: { label: '', value: '', highlight: 'none' },
|
|
1583
|
+
arrayFields: {
|
|
1584
|
+
label: { type: 'text', label: 'Item' },
|
|
1585
|
+
value: { type: 'text', label: 'Cost (e.g. RM 40 – 60)' },
|
|
1586
|
+
highlight: {
|
|
1587
|
+
type: 'radio',
|
|
1588
|
+
label: 'Highlight',
|
|
1589
|
+
options: [
|
|
1590
|
+
{ label: 'None', value: 'none' },
|
|
1591
|
+
{ label: 'Total', value: 'total' },
|
|
1592
|
+
{ label: 'Strong', value: 'strong' },
|
|
1593
|
+
],
|
|
1594
|
+
},
|
|
1595
|
+
},
|
|
1596
|
+
},
|
|
1597
|
+
note: { type: 'textarea', label: 'Note under the table (optional)' },
|
|
1598
|
+
background: backgroundField,
|
|
1599
|
+
} as Fields<CostTableProps>,
|
|
1600
|
+
render: ({ headingLevel, heading, headingStyle, intro, image, imageSide, itemLabel, valueLabel, rows, note, background }) => (
|
|
1601
|
+
<Section background={background}>
|
|
1602
|
+
<div className={`cost-table cost-table-${classToken(imageSide)}`}>
|
|
1603
|
+
<div className="cost-table-intro">
|
|
1604
|
+
{heading && <Title level={headingLevel} style={headingStyle}>{heading}</Title>}
|
|
1605
|
+
{paragraphs(intro).map((p, i) => (
|
|
1606
|
+
<p key={i}>{p}</p>
|
|
1607
|
+
))}
|
|
1608
|
+
{image && (
|
|
1609
|
+
<div className="cost-table-image">
|
|
1610
|
+
<Image src={image.url} alt={image.alt || ''} fill sizes="(max-width: 800px) 100vw, 50vw" />
|
|
1611
|
+
</div>
|
|
1612
|
+
)}
|
|
1613
|
+
</div>
|
|
1614
|
+
<div>
|
|
1615
|
+
{/* A data table: column headers, a header cell per row, and a caption for screen
|
|
1616
|
+
readers. It scrolls sideways on a narrow screen instead of squashing (WCAG 1.4.10), and
|
|
1617
|
+
the scroller is focusable and named so a keyboard can scroll it in every browser (2.1.1). */}
|
|
1618
|
+
<div className="table-scroll" tabIndex={0} role="region" aria-label={heading || 'Costs'}>
|
|
1619
|
+
<table className="price-table">
|
|
1620
|
+
{heading && <caption className="sr-only">{heading}</caption>}
|
|
1621
|
+
<thead>
|
|
1622
|
+
<tr>
|
|
1623
|
+
<th scope="col">{itemLabel || 'Item'}</th>
|
|
1624
|
+
<th scope="col">{valueLabel || 'Cost'}</th>
|
|
1625
|
+
</tr>
|
|
1626
|
+
</thead>
|
|
1627
|
+
<tbody>
|
|
1628
|
+
{rows.map((row, i) => (
|
|
1629
|
+
<tr key={i} className={row.highlight !== 'none' ? `price-row-${classToken(row.highlight)}` : undefined}>
|
|
1630
|
+
<th scope="row">{row.label}</th>
|
|
1631
|
+
<td>{row.value}</td>
|
|
1632
|
+
</tr>
|
|
1633
|
+
))}
|
|
1634
|
+
</tbody>
|
|
1635
|
+
</table>
|
|
1636
|
+
</div>
|
|
1637
|
+
{note && <p className="muted price-note">{note}</p>}
|
|
1638
|
+
</div>
|
|
1639
|
+
</div>
|
|
1640
|
+
</Section>
|
|
1641
|
+
),
|
|
1642
|
+
},
|
|
1643
|
+
|
|
1644
|
+
Spacer: {
|
|
1645
|
+
label: 'Spacer',
|
|
1646
|
+
defaultProps: { size: 'md' },
|
|
1647
|
+
fields: {
|
|
1648
|
+
size: {
|
|
1649
|
+
type: 'radio',
|
|
1650
|
+
label: 'Height',
|
|
1651
|
+
options: [
|
|
1652
|
+
{ label: 'Small', value: 'sm' },
|
|
1653
|
+
{ label: 'Medium', value: 'md' },
|
|
1654
|
+
{ label: 'Large', value: 'lg' },
|
|
1655
|
+
{ label: 'Extra large', value: 'xl' },
|
|
1656
|
+
],
|
|
1657
|
+
},
|
|
1658
|
+
} as Fields<SpacerProps>,
|
|
1659
|
+
render: ({ size }) => <div className={`spacer spacer-${classToken(size)}`} aria-hidden="true" />,
|
|
1660
|
+
},
|
|
1661
|
+
|
|
1662
|
+
Divider: {
|
|
1663
|
+
label: 'Divider',
|
|
1664
|
+
defaultProps: { width: 'container', spacing: 'sm' },
|
|
1665
|
+
fields: {
|
|
1666
|
+
width: {
|
|
1667
|
+
type: 'radio',
|
|
1668
|
+
label: 'Width',
|
|
1669
|
+
options: [
|
|
1670
|
+
{ label: 'Full', value: 'container' },
|
|
1671
|
+
{ label: 'Short', value: 'narrow' },
|
|
1672
|
+
],
|
|
1673
|
+
},
|
|
1674
|
+
spacing: spacingField,
|
|
1675
|
+
} as Fields<DividerProps>,
|
|
1676
|
+
render: ({ width, spacing }) => (
|
|
1677
|
+
<div className={`divider-block spacing-${classToken(spacing)}`}>
|
|
1678
|
+
<div className="container">
|
|
1679
|
+
<hr className={`divider divider-${classToken(width)}`} />
|
|
1680
|
+
</div>
|
|
1681
|
+
</div>
|
|
1682
|
+
),
|
|
1683
|
+
},
|
|
1684
|
+
},
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* Every block, with the Padding option added to each (src/puck/padding.tsx). Blocks that plugins
|
|
1689
|
+
* add (pet-adopt.blocks.ts) join first, under "Plugins", so they get the Padding option too (the
|
|
1690
|
+
* Form block comes from the form builder plugin this way). The Pet page template offers the ones
|
|
1691
|
+
* that set `petPage`; the email builder offers none.
|
|
1692
|
+
*/
|
|
1693
|
+
export const config: Config<PuckComponents> = withPadding(withPluginBlocks(blocks, pluginBlocks))
|