@meith/web 0.16.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.md +165 -0
- package/app/(auth)/layout.tsx +6 -0
- package/app/(auth)/login/page.tsx +106 -0
- package/app/(auth)/login/verify/page.tsx +55 -0
- package/app/(auth)/register/page.tsx +83 -0
- package/app/(auth)/reset/confirm/page.tsx +45 -0
- package/app/(auth)/reset/page.tsx +22 -0
- package/app/(auth)/verify/page.tsx +44 -0
- package/app/(auth)/verify/resend/page.tsx +51 -0
- package/app/(board)/[slug]/feed.xml/route.ts +48 -0
- package/app/(board)/[slug]/new/page.tsx +112 -0
- package/app/(board)/[slug]/page.tsx +403 -0
- package/app/(board)/discover/[view]/page.tsx +115 -0
- package/app/(board)/discover/page.tsx +5 -0
- package/app/(board)/layout.tsx +22 -0
- package/app/(board)/member/[id]/page.tsx +187 -0
- package/app/(board)/member/[id]/reputation/page.tsx +195 -0
- package/app/(board)/member/by-name/[name]/page.tsx +32 -0
- package/app/(board)/messages/[id]/page.tsx +103 -0
- package/app/(board)/messages/compose/page.tsx +60 -0
- package/app/(board)/messages/layout.tsx +5 -0
- package/app/(board)/messages/page.tsx +179 -0
- package/app/(board)/modcp/forums/page.tsx +59 -0
- package/app/(board)/modcp/ip/page.tsx +158 -0
- package/app/(board)/modcp/layout.tsx +5 -0
- package/app/(board)/modcp/log/page.tsx +98 -0
- package/app/(board)/modcp/page.tsx +112 -0
- package/app/(board)/moderation/layout.tsx +5 -0
- package/app/(board)/moderation/page.tsx +111 -0
- package/app/(board)/moderation/reports/page.tsx +193 -0
- package/app/(board)/moderation/warn/page.tsx +158 -0
- package/app/(board)/notifications/layout.tsx +5 -0
- package/app/(board)/notifications/page.tsx +144 -0
- package/app/(board)/notifications/preferences/page.tsx +65 -0
- package/app/(board)/online/page.tsx +119 -0
- package/app/(board)/page.tsx +195 -0
- package/app/(board)/plugins/[key]/[[...path]]/page.tsx +72 -0
- package/app/(board)/privacy/page.tsx +12 -0
- package/app/(board)/report/page.tsx +71 -0
- package/app/(board)/rules/page.tsx +12 -0
- package/app/(board)/search/[token]/page.tsx +130 -0
- package/app/(board)/search/page.tsx +289 -0
- package/app/(board)/stats/page.tsx +202 -0
- package/app/(board)/subscriptions/layout.tsx +5 -0
- package/app/(board)/subscriptions/page.tsx +142 -0
- package/app/(board)/terms/page.tsx +12 -0
- package/app/(board)/thread/[slug]/edit/page.tsx +107 -0
- package/app/(board)/thread/[slug]/feed.xml/route.ts +42 -0
- package/app/(board)/thread/[slug]/page.tsx +707 -0
- package/app/(board)/thread/[slug]/poll/page.tsx +41 -0
- package/app/(board)/thread/[slug]/post/[postId]/history/page.tsx +160 -0
- package/app/(board)/thread/[slug]/reply/page.tsx +136 -0
- package/app/(board)/unsubscribe/page.tsx +73 -0
- package/app/(board)/usercp/avatar/page.tsx +56 -0
- package/app/(board)/usercp/contacts/page.tsx +141 -0
- package/app/(board)/usercp/email/confirm/page.tsx +52 -0
- package/app/(board)/usercp/layout.tsx +23 -0
- package/app/(board)/usercp/options/page.tsx +56 -0
- package/app/(board)/usercp/page.tsx +71 -0
- package/app/(board)/usercp/profile/page.tsx +81 -0
- package/app/(board)/usercp/security/page.tsx +238 -0
- package/app/(board)/usercp/security/verify/page.tsx +92 -0
- package/app/(board)/usercp/signature/page.tsx +67 -0
- package/app/admin/antispam/page.tsx +155 -0
- package/app/admin/api/marketplace/screenshot/route.ts +68 -0
- package/app/admin/api/plugins/[key]/[...path]/route.ts +27 -0
- package/app/admin/api-tokens/page.tsx +129 -0
- package/app/admin/content/announcements/page.tsx +110 -0
- package/app/admin/content/attachments/page.tsx +199 -0
- package/app/admin/content/navigation/page.tsx +123 -0
- package/app/admin/content/page.tsx +170 -0
- package/app/admin/forums/[id]/page.tsx +96 -0
- package/app/admin/forums/[id]/permissions/page.tsx +108 -0
- package/app/admin/forums/page.tsx +45 -0
- package/app/admin/groups/[id]/page.tsx +133 -0
- package/app/admin/groups/memberships/page.tsx +56 -0
- package/app/admin/groups/page.tsx +104 -0
- package/app/admin/groups/promotions/page.tsx +143 -0
- package/app/admin/layout.tsx +86 -0
- package/app/admin/log/page.tsx +116 -0
- package/app/admin/page.tsx +206 -0
- package/app/admin/plugins/[key]/[[...path]]/page.tsx +276 -0
- package/app/admin/plugins/browse/page.tsx +70 -0
- package/app/admin/plugins/page.tsx +165 -0
- package/app/admin/security/page.tsx +124 -0
- package/app/admin/settings/page.tsx +190 -0
- package/app/admin/system/page.tsx +303 -0
- package/app/admin/themes/[key]/page.tsx +110 -0
- package/app/admin/themes/browse/page.tsx +70 -0
- package/app/admin/themes/page.tsx +163 -0
- package/app/admin/users/[id]/merge/page.tsx +136 -0
- package/app/admin/users/[id]/page.tsx +208 -0
- package/app/admin/users/mail/page.tsx +68 -0
- package/app/admin/users/page.tsx +260 -0
- package/app/admin/users/prune/page.tsx +186 -0
- package/app/api/health/route.ts +11 -0
- package/app/api/metrics/route.ts +66 -0
- package/app/api/plugins/[key]/[...path]/route.ts +27 -0
- package/app/api/read/all/route.ts +15 -0
- package/app/api/read/forum/[id]/route.ts +29 -0
- package/app/api/read/thread/[id]/route.ts +40 -0
- package/app/api/ready/route.ts +63 -0
- package/app/api/system/tick/route.ts +77 -0
- package/app/api/v1/[...path]/route.ts +208 -0
- package/app/api/v1/openapi.json/route.ts +12 -0
- package/app/apple-icon.ts +11 -0
- package/app/atom.xml/route.ts +7 -0
- package/app/attachment/[id]/route.ts +10 -0
- package/app/attachment/[id]/thumb/route.ts +10 -0
- package/app/auth/passkey/options/route.ts +145 -0
- package/app/auth/passkey/verify/route.ts +241 -0
- package/app/auth/resume/route.ts +55 -0
- package/app/auth/sso/[provider]/callback/route.ts +173 -0
- package/app/auth/sso/[provider]/go/route.ts +57 -0
- package/app/auth/sso/[provider]/route.ts +105 -0
- package/app/avatar/[id]/route.ts +31 -0
- package/app/brand/icon-192.png/route.ts +7 -0
- package/app/brand/icon-512.png/route.ts +7 -0
- package/app/brand/icon-maskable.png/route.ts +7 -0
- package/app/demo/stripe/[[...path]]/route.ts +27 -0
- package/app/error.tsx +15 -0
- package/app/feed.xml/route.ts +7 -0
- package/app/forumdisplay.php/page.tsx +11 -0
- package/app/group/[id]/badge/[scheme]/route.ts +26 -0
- package/app/icon.ts +13 -0
- package/app/install/page.tsx +221 -0
- package/app/jump/page.tsx +28 -0
- package/app/layout.tsx +124 -0
- package/app/logo/[scheme]/route.ts +24 -0
- package/app/manifest.ts +43 -0
- package/app/member.php/page.tsx +11 -0
- package/app/memberlist.php/page.tsx +11 -0
- package/app/not-found.tsx +14 -0
- package/app/opengraph-image.ts +11 -0
- package/app/redirect/page.tsx +44 -0
- package/app/robots.txt/route.ts +35 -0
- package/app/showthread.php/page.tsx +11 -0
- package/app/sitemap/[page]/route.ts +64 -0
- package/app/sitemap.xml/route.ts +31 -0
- package/app/twitter-image.ts +11 -0
- package/app/viewforum.php/page.tsx +11 -0
- package/app/viewtopic.php/page.tsx +11 -0
- package/bin/forum-web.mjs +241 -0
- package/components.json +21 -0
- package/instrumentation.ts +18 -0
- package/next.config.mjs +182 -0
- package/package.json +99 -0
- package/postcss.config.mjs +7 -0
- package/proxy.ts +160 -0
- package/src/components/account/active-sessions.tsx +87 -0
- package/src/components/account/avatar-form.tsx +119 -0
- package/src/components/account/credential-proof-form.tsx +76 -0
- package/src/components/account/logout-form.tsx +14 -0
- package/src/components/account/notification-forms.tsx +157 -0
- package/src/components/account/passkey-enrol.tsx +81 -0
- package/src/components/account/passkey-proof-button.tsx +47 -0
- package/src/components/account/push-device-form.tsx +193 -0
- package/src/components/account/relation-forms.tsx +69 -0
- package/src/components/account/reputation-forms.tsx +124 -0
- package/src/components/account/security-activity.tsx +46 -0
- package/src/components/account/sign-in-methods.tsx +166 -0
- package/src/components/account/subscription-forms.tsx +151 -0
- package/src/components/account/two-factor-forms.tsx +226 -0
- package/src/components/account/usercp-forms.tsx +387 -0
- package/src/components/account/usercp-nav.tsx +14 -0
- package/src/components/account/usercp-shell.tsx +34 -0
- package/src/components/admin/admin-forms.tsx +92 -0
- package/src/components/admin/admin-nav.tsx +52 -0
- package/src/components/admin/admin-undo.tsx +32 -0
- package/src/components/admin/api-token-forms.tsx +89 -0
- package/src/components/admin/badge-forms.tsx +97 -0
- package/src/components/admin/branding-forms.tsx +102 -0
- package/src/components/admin/content-forms.tsx +712 -0
- package/src/components/admin/form-bits.tsx +11 -0
- package/src/components/admin/forum-forms.tsx +524 -0
- package/src/components/admin/forum-tree.tsx +454 -0
- package/src/components/admin/group-forms.tsx +646 -0
- package/src/components/admin/mail-test-card.tsx +90 -0
- package/src/components/admin/marketplace-forms.tsx +30 -0
- package/src/components/admin/marketplace-listing.tsx +123 -0
- package/src/components/admin/navigation-forms.tsx +229 -0
- package/src/components/admin/navigation-tree.tsx +442 -0
- package/src/components/admin/oklch-picker.tsx +180 -0
- package/src/components/admin/plugin-forms.tsx +225 -0
- package/src/components/admin/settings-form.tsx +148 -0
- package/src/components/admin/system-forms.tsx +169 -0
- package/src/components/admin/theme-changes.tsx +354 -0
- package/src/components/admin/theme-forms.tsx +636 -0
- package/src/components/admin/theme-palette.tsx +119 -0
- package/src/components/admin/theme-preview.tsx +461 -0
- package/src/components/admin/user-bulk-toolbar.tsx +99 -0
- package/src/components/admin/user-forms.tsx +488 -0
- package/src/components/auth/auth-page.tsx +45 -0
- package/src/components/auth/form-controls.tsx +117 -0
- package/src/components/auth/login-form.tsx +47 -0
- package/src/components/auth/passkey-client.ts +171 -0
- package/src/components/auth/passkey-second-factor.tsx +69 -0
- package/src/components/auth/passkey-sign-in.tsx +61 -0
- package/src/components/auth/register-form.tsx +136 -0
- package/src/components/auth/resend-verification-form.tsx +34 -0
- package/src/components/auth/reset-confirm-form.tsx +43 -0
- package/src/components/auth/reset-request-form.tsx +35 -0
- package/src/components/auth/second-factor-form.tsx +51 -0
- package/src/components/auth/sso-buttons.tsx +47 -0
- package/src/components/board/live-region.tsx +74 -0
- package/src/components/board/search-off-notice.tsx +18 -0
- package/src/components/board/section-page.tsx +114 -0
- package/src/components/content/attachment-field.tsx +51 -0
- package/src/components/content/composer-field.ts +31 -0
- package/src/components/content/composer-ids.ts +6 -0
- package/src/components/content/composer-intents.tsx +27 -0
- package/src/components/content/composer-recovery.tsx +215 -0
- package/src/components/content/edit-post-form.tsx +121 -0
- package/src/components/content/markdown-editor.tsx +590 -0
- package/src/components/content/markdown-syntax.ts +53 -0
- package/src/components/content/mention-token.ts +23 -0
- package/src/components/content/multiquote-button.tsx +32 -0
- package/src/components/content/multiquote-selection.tsx +105 -0
- package/src/components/content/multiquote.ts +125 -0
- package/src/components/content/new-thread-form.tsx +169 -0
- package/src/components/content/poll-edit-form.tsx +96 -0
- package/src/components/content/poll.tsx +89 -0
- package/src/components/content/quote-in-place.tsx +51 -0
- package/src/components/content/reply-form.tsx +113 -0
- package/src/components/content/thanks-button.tsx +65 -0
- package/src/components/content/thread-rating.tsx +143 -0
- package/src/components/install/install-form.tsx +497 -0
- package/src/components/legal/legal-document.tsx +22 -0
- package/src/components/messages/message-forms.tsx +152 -0
- package/src/components/moderation/inline-moderation-form.tsx +158 -0
- package/src/components/moderation/modcp-nav.tsx +15 -0
- package/src/components/moderation/modcp-shell.tsx +41 -0
- package/src/components/moderation/queue-form.tsx +96 -0
- package/src/components/moderation/report-forms.tsx +120 -0
- package/src/components/moderation/signature-lock-form.tsx +83 -0
- package/src/components/moderation/thread-surgery-form.tsx +96 -0
- package/src/components/moderation/thread-tools-form.tsx +137 -0
- package/src/components/moderation/warning-forms.tsx +125 -0
- package/src/components/profile/custom-field.tsx +79 -0
- package/src/components/shell/appearance-icons.tsx +35 -0
- package/src/components/shell/board-notice.tsx +21 -0
- package/src/components/shell/copy-record.ts +20 -0
- package/src/components/shell/copy.tsx +17 -0
- package/src/components/shell/crash-notice.tsx +86 -0
- package/src/components/shell/demo-banner.tsx +49 -0
- package/src/components/shell/group-name-style.tsx +6 -0
- package/src/components/shell/measure.ts +1 -0
- package/src/components/shell/notification-menu.tsx +361 -0
- package/src/components/shell/offline-notice.tsx +29 -0
- package/src/components/shell/onboarding-banner.tsx +39 -0
- package/src/components/shell/page-shell.tsx +167 -0
- package/src/components/shell/panel-list.tsx +95 -0
- package/src/components/shell/panel-nav.tsx +40 -0
- package/src/components/shell/panel-overview.tsx +81 -0
- package/src/components/shell/panel-page.tsx +96 -0
- package/src/components/shell/panel-pagination.tsx +28 -0
- package/src/components/shell/panel-shell.tsx +31 -0
- package/src/components/shell/theme-runtime-style.tsx +6 -0
- package/src/components/shell/theme-switcher.tsx +97 -0
- package/src/components/shell/timezone-probe.tsx +45 -0
- package/src/components/shell/view-tabs.tsx +60 -0
- package/src/config.ts +13 -0
- package/src/server/absent-services.ts +29 -0
- package/src/server/admin-actions.ts +171 -0
- package/src/server/admin-settings-actions.ts +83 -0
- package/src/server/admin-undo-actions.ts +70 -0
- package/src/server/admin-undo.ts +75 -0
- package/src/server/admin.ts +112 -0
- package/src/server/announcements.ts +82 -0
- package/src/server/antispam.ts +310 -0
- package/src/server/api/content.ts +486 -0
- package/src/server/api/http.ts +119 -0
- package/src/server/api/members.ts +109 -0
- package/src/server/api/messages.ts +113 -0
- package/src/server/api/registry.ts +30 -0
- package/src/server/api/search.ts +98 -0
- package/src/server/api/subscriptions.ts +106 -0
- package/src/server/api-auth.ts +66 -0
- package/src/server/api-token-actions.ts +85 -0
- package/src/server/api-tokens-admin.ts +95 -0
- package/src/server/appearance-actions.ts +39 -0
- package/src/server/attachment-download.ts +43 -0
- package/src/server/attachment-embed.ts +63 -0
- package/src/server/attachment-upload-actions.ts +92 -0
- package/src/server/attachments.ts +257 -0
- package/src/server/auth-actions.ts +479 -0
- package/src/server/auth-config.ts +61 -0
- package/src/server/auth-events.ts +92 -0
- package/src/server/auth-form-state.ts +14 -0
- package/src/server/auth-mail.ts +104 -0
- package/src/server/avatars.ts +83 -0
- package/src/server/board-latest-actions.ts +7 -0
- package/src/server/board-latest.tsx +103 -0
- package/src/server/board-offline.ts +23 -0
- package/src/server/board-url.ts +14 -0
- package/src/server/brand-assets.ts +151 -0
- package/src/server/brand-mark.tsx +110 -0
- package/src/server/branding-actions.ts +53 -0
- package/src/server/branding.ts +101 -0
- package/src/server/cache-targets.ts +13 -0
- package/src/server/code-highlighting.ts +33 -0
- package/src/server/container.ts +402 -0
- package/src/server/content-actions.ts +459 -0
- package/src/server/content-admin-actions.ts +492 -0
- package/src/server/content-admin.ts +95 -0
- package/src/server/content-security-policy.ts +35 -0
- package/src/server/context.ts +32 -0
- package/src/server/cookies.ts +139 -0
- package/src/server/credential-proof-actions.ts +42 -0
- package/src/server/credential-proof.ts +35 -0
- package/src/server/current-location.ts +19 -0
- package/src/server/demo-stripe.ts +104 -0
- package/src/server/demo-uploads.ts +28 -0
- package/src/server/demo.ts +80 -0
- package/src/server/discovery.ts +104 -0
- package/src/server/embeds.ts +113 -0
- package/src/server/error-notice.tsx +41 -0
- package/src/server/federation-actions.ts +113 -0
- package/src/server/federation.ts +138 -0
- package/src/server/feed-builder.ts +72 -0
- package/src/server/feed-routes.ts +122 -0
- package/src/server/fixture-actor-source.ts +62 -0
- package/src/server/fixture-forum-repo.ts +59 -0
- package/src/server/fixture-member-profile-repo.ts +30 -0
- package/src/server/fixture-post-repo.ts +108 -0
- package/src/server/fixture-thread-repo.ts +98 -0
- package/src/server/form-state-reporter.ts +34 -0
- package/src/server/form-values.ts +23 -0
- package/src/server/forum-admin-actions.ts +353 -0
- package/src/server/forum-admin.ts +98 -0
- package/src/server/group-admin-actions.ts +341 -0
- package/src/server/group-admin.ts +98 -0
- package/src/server/group-badge-actions.ts +61 -0
- package/src/server/group-badge.ts +62 -0
- package/src/server/group-identity.ts +104 -0
- package/src/server/i18n-catalogs.ts +42 -0
- package/src/server/i18n.ts +69 -0
- package/src/server/image-upload.ts +109 -0
- package/src/server/inline-moderation-actions.ts +129 -0
- package/src/server/install-actions.ts +124 -0
- package/src/server/install.ts +281 -0
- package/src/server/legacy-redirect.ts +83 -0
- package/src/server/legal.ts +43 -0
- package/src/server/location-header.ts +37 -0
- package/src/server/mail-brand.ts +43 -0
- package/src/server/mail-health.ts +41 -0
- package/src/server/mail-send.ts +44 -0
- package/src/server/mail-test-actions.ts +67 -0
- package/src/server/mail-test.ts +56 -0
- package/src/server/markdown-pipeline.ts +31 -0
- package/src/server/marketplace-actions.ts +47 -0
- package/src/server/marketplace-admin.ts +260 -0
- package/src/server/mention-actions.ts +21 -0
- package/src/server/mention-search.ts +35 -0
- package/src/server/message-actions.ts +110 -0
- package/src/server/messages.ts +141 -0
- package/src/server/modcp.ts +125 -0
- package/src/server/moderation-actions.ts +165 -0
- package/src/server/navigation-admin-actions.ts +217 -0
- package/src/server/navigation.ts +112 -0
- package/src/server/nonce.ts +13 -0
- package/src/server/notification-actions.ts +84 -0
- package/src/server/notification-audience.ts +10 -0
- package/src/server/notification-menu-actions.ts +82 -0
- package/src/server/notification-menu.ts +96 -0
- package/src/server/notifications.ts +93 -0
- package/src/server/onboarding-actions.ts +27 -0
- package/src/server/onboarding.ts +89 -0
- package/src/server/page-metadata.ts +14 -0
- package/src/server/passkey-challenge.ts +42 -0
- package/src/server/plugin-admin-actions.ts +232 -0
- package/src/server/plugin-admin.ts +276 -0
- package/src/server/plugin-host.ts +143 -0
- package/src/server/plugin-pages.ts +192 -0
- package/src/server/plugin-panel.ts +49 -0
- package/src/server/plugin-routes.ts +298 -0
- package/src/server/plugin-view.tsx +58 -0
- package/src/server/poll-actions.ts +104 -0
- package/src/server/poll-scope.ts +52 -0
- package/src/server/post-notifications.ts +71 -0
- package/src/server/post-scope.ts +86 -0
- package/src/server/presence.ts +177 -0
- package/src/server/profile-fields.ts +112 -0
- package/src/server/push-actions.ts +113 -0
- package/src/server/push.ts +40 -0
- package/src/server/redirect-back.ts +15 -0
- package/src/server/registration.ts +7 -0
- package/src/server/relation-actions.ts +89 -0
- package/src/server/relations.ts +45 -0
- package/src/server/reply-core.ts +173 -0
- package/src/server/report-actions.ts +165 -0
- package/src/server/report-scope.ts +21 -0
- package/src/server/reputation-actions.ts +146 -0
- package/src/server/reputation-target.ts +49 -0
- package/src/server/reputation.ts +70 -0
- package/src/server/request-fingerprint.ts +65 -0
- package/src/server/safe-path.ts +16 -0
- package/src/server/same-origin.ts +45 -0
- package/src/server/search-page.ts +313 -0
- package/src/server/search.ts +45 -0
- package/src/server/secret-auth.ts +20 -0
- package/src/server/see-other.ts +11 -0
- package/src/server/seed-board.ts +417 -0
- package/src/server/session-actions.ts +78 -0
- package/src/server/session-cookies.ts +124 -0
- package/src/server/session-key.ts +17 -0
- package/src/server/settings.ts +47 -0
- package/src/server/signatures.ts +62 -0
- package/src/server/sso-handshake.ts +79 -0
- package/src/server/stats.ts +63 -0
- package/src/server/subscription-actions.ts +161 -0
- package/src/server/surgery-actions.ts +180 -0
- package/src/server/syndication.ts +77 -0
- package/src/server/system-admin-actions.ts +134 -0
- package/src/server/system-admin.ts +90 -0
- package/src/server/test-container.ts +114 -0
- package/src/server/theme-admin-actions.ts +242 -0
- package/src/server/theme-admin.ts +203 -0
- package/src/server/theme-runtime.ts +89 -0
- package/src/server/theme-style.ts +279 -0
- package/src/server/theme.ts +52 -0
- package/src/server/thread-core.ts +207 -0
- package/src/server/thread-rating-actions.ts +55 -0
- package/src/server/thread-tool-actions.ts +154 -0
- package/src/server/two-factor-actions.ts +178 -0
- package/src/server/two-factor.ts +86 -0
- package/src/server/upgrade-notice.ts +41 -0
- package/src/server/user-admin-actions.ts +572 -0
- package/src/server/user-admin.ts +165 -0
- package/src/server/usercp-actions.ts +263 -0
- package/src/server/usercp-mail.ts +120 -0
- package/src/server/viewer-preferences.ts +64 -0
- package/src/server/warning-actions.ts +122 -0
- package/src/styles/globals.css +969 -0
- package/src/theme/contract.fixture.ts +793 -0
- package/src/view/account-copy.ts +351 -0
- package/src/view/admin-content-copy.ts +66 -0
- package/src/view/admin-copy.ts +106 -0
- package/src/view/admin-forum-tree-copy.ts +40 -0
- package/src/view/admin-group-copy.ts +80 -0
- package/src/view/admin-log.ts +58 -0
- package/src/view/admin-nav.ts +164 -0
- package/src/view/admin-navigation-copy.ts +58 -0
- package/src/view/admin-panel-copy.ts +194 -0
- package/src/view/admin-settings.ts +173 -0
- package/src/view/admin-theme-copy.ts +229 -0
- package/src/view/admin-user-copy.ts +96 -0
- package/src/view/attachments.ts +51 -0
- package/src/view/auth-copy.ts +147 -0
- package/src/view/board-index.ts +167 -0
- package/src/view/board-latest.ts +101 -0
- package/src/view/breadcrumb.ts +50 -0
- package/src/view/contacts.ts +85 -0
- package/src/view/content-copy.ts +118 -0
- package/src/view/contrast.ts +286 -0
- package/src/view/copy.ts +101 -0
- package/src/view/count.ts +8 -0
- package/src/view/discovery-view.ts +74 -0
- package/src/view/editor-toolbar.ts +84 -0
- package/src/view/error-notice.ts +52 -0
- package/src/view/feed.ts +130 -0
- package/src/view/forum-cursor.ts +54 -0
- package/src/view/forum-display.ts +152 -0
- package/src/view/forum-jump.ts +60 -0
- package/src/view/forum-notice.ts +24 -0
- package/src/view/inline-moderation.ts +87 -0
- package/src/view/install-copy.ts +95 -0
- package/src/view/legal.ts +58 -0
- package/src/view/locale.ts +40 -0
- package/src/view/marketplace-panel.ts +51 -0
- package/src/view/member-identity.ts +23 -0
- package/src/view/member-profile.ts +65 -0
- package/src/view/messages.ts +222 -0
- package/src/view/metadata.ts +75 -0
- package/src/view/modcp-nav.ts +76 -0
- package/src/view/moderation-copy.ts +84 -0
- package/src/view/moderation-queue.ts +67 -0
- package/src/view/navigation-arrange.ts +188 -0
- package/src/view/navigation.ts +173 -0
- package/src/view/notification-menu.ts +202 -0
- package/src/view/notifications.ts +84 -0
- package/src/view/onboarding.ts +26 -0
- package/src/view/pager.ts +191 -0
- package/src/view/panel-nav.ts +203 -0
- package/src/view/plugin-panel.ts +42 -0
- package/src/view/post-form.ts +61 -0
- package/src/view/post-link.ts +29 -0
- package/src/view/presence.ts +99 -0
- package/src/view/promotion-rules.ts +52 -0
- package/src/view/redirect-notice.ts +21 -0
- package/src/view/reputation.ts +107 -0
- package/src/view/search-controls.ts +103 -0
- package/src/view/search-results.ts +291 -0
- package/src/view/security-activity.ts +73 -0
- package/src/view/setting-groups.ts +43 -0
- package/src/view/shell.ts +164 -0
- package/src/view/slug-id.ts +12 -0
- package/src/view/sso-hand-off.ts +44 -0
- package/src/view/sso-notices.ts +48 -0
- package/src/view/subscriptions.ts +76 -0
- package/src/view/theme-draft.ts +167 -0
- package/src/view/theme-preference.ts +30 -0
- package/src/view/theme-tokens.ts +333 -0
- package/src/view/thread-view.ts +280 -0
- package/src/view/time.ts +31 -0
- package/src/view/timezone.ts +35 -0
- package/src/view/two-factor.ts +6 -0
- package/src/view/usercp-nav.ts +103 -0
- package/src/view/usercp.ts +196 -0
- package/src/view/warnings.ts +128 -0
- package/src/view/word-filter.ts +5 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Translator } from '@meith/i18n'
|
|
2
|
+
import { type CompiledWordFilter, summarise } from '@meith/markdown'
|
|
3
|
+
import type {
|
|
4
|
+
LatestPostModel,
|
|
5
|
+
LatestPostsModel,
|
|
6
|
+
LatestThreadModel,
|
|
7
|
+
LatestThreadsModel,
|
|
8
|
+
} from '@meith/theme-kit'
|
|
9
|
+
|
|
10
|
+
import { forumHref } from './board-index'
|
|
11
|
+
import { count } from './count'
|
|
12
|
+
import { type MemberIdentity, nameClassOf } from './member-identity'
|
|
13
|
+
import { memberHref } from './member-profile'
|
|
14
|
+
import { postLink } from './post-link'
|
|
15
|
+
import { formatTime } from './time'
|
|
16
|
+
import { filterWords } from './word-filter'
|
|
17
|
+
|
|
18
|
+
export interface LatestThreadRow {
|
|
19
|
+
readonly threadId: number
|
|
20
|
+
readonly title: string
|
|
21
|
+
readonly slug: string
|
|
22
|
+
readonly forumId: number
|
|
23
|
+
readonly forumTitle: string
|
|
24
|
+
readonly forumSlug: string
|
|
25
|
+
readonly authorUserId: number | null
|
|
26
|
+
readonly authorUsername: string
|
|
27
|
+
readonly replyCount: number
|
|
28
|
+
readonly createdAt: Date
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface LatestPostRow {
|
|
32
|
+
readonly postId: number
|
|
33
|
+
readonly threadId: number
|
|
34
|
+
readonly threadTitle: string
|
|
35
|
+
readonly threadSlug: string
|
|
36
|
+
readonly forumId: number
|
|
37
|
+
readonly forumTitle: string
|
|
38
|
+
readonly forumSlug: string
|
|
39
|
+
readonly authorUserId: number | null
|
|
40
|
+
readonly authorUsername: string
|
|
41
|
+
readonly createdAt: Date
|
|
42
|
+
readonly messageSource: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface LatestInput<Row> {
|
|
46
|
+
readonly rows: readonly Row[]
|
|
47
|
+
readonly now: Date
|
|
48
|
+
readonly t?: Translator | undefined
|
|
49
|
+
readonly identities?: ReadonlyMap<number, MemberIdentity>
|
|
50
|
+
readonly wordFilter?: CompiledWordFilter | undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const EXCERPT_CHARS = 140
|
|
54
|
+
|
|
55
|
+
function postHref(row: LatestPostRow): string {
|
|
56
|
+
return postLink(`/thread/${row.threadId}-${row.threadSlug}`, row.postId)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function authorOf(
|
|
60
|
+
row: { authorUserId: number | null; authorUsername: string },
|
|
61
|
+
identities: ReadonlyMap<number, MemberIdentity> | undefined,
|
|
62
|
+
) {
|
|
63
|
+
return {
|
|
64
|
+
userId: row.authorUserId,
|
|
65
|
+
username: row.authorUsername,
|
|
66
|
+
profileHref: row.authorUserId === null ? null : memberHref(row.authorUserId),
|
|
67
|
+
nameClass: nameClassOf(identities, row.authorUserId),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function buildLatestThreadsModel(input: LatestInput<LatestThreadRow>): LatestThreadsModel {
|
|
72
|
+
const threads: LatestThreadModel[] = input.rows.map((row) => ({
|
|
73
|
+
title: row.title,
|
|
74
|
+
href: `/thread/${row.threadId}-${row.slug}`,
|
|
75
|
+
forum: {
|
|
76
|
+
label: row.forumTitle,
|
|
77
|
+
href: forumHref({ id: row.forumId, slug: row.forumSlug }),
|
|
78
|
+
},
|
|
79
|
+
author: authorOf(row, input.identities),
|
|
80
|
+
replyCount: count(row.replyCount, input.t),
|
|
81
|
+
startedAt: formatTime(row.createdAt, input.now, input.t),
|
|
82
|
+
}))
|
|
83
|
+
|
|
84
|
+
return { threads, capturedAt: formatTime(input.now, input.now, input.t) }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function buildLatestPostsModel(input: LatestInput<LatestPostRow>): LatestPostsModel {
|
|
88
|
+
const posts: LatestPostModel[] = input.rows.map((row) => ({
|
|
89
|
+
threadTitle: row.threadTitle,
|
|
90
|
+
href: postHref(row),
|
|
91
|
+
forum: {
|
|
92
|
+
label: row.forumTitle,
|
|
93
|
+
href: forumHref({ id: row.forumId, slug: row.forumSlug }),
|
|
94
|
+
},
|
|
95
|
+
author: authorOf(row, input.identities),
|
|
96
|
+
excerpt: filterWords(summarise(row.messageSource, EXCERPT_CHARS), input.wordFilter),
|
|
97
|
+
postedAt: formatTime(row.createdAt, input.now, input.t),
|
|
98
|
+
}))
|
|
99
|
+
|
|
100
|
+
return { posts, capturedAt: formatTime(input.now, input.now, input.t) }
|
|
101
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ancestorIds } from '@meith/forums'
|
|
2
|
+
import type { LinkModel } from '@meith/theme-kit'
|
|
3
|
+
|
|
4
|
+
import { forumHref } from './board-index'
|
|
5
|
+
|
|
6
|
+
export interface CrumbForum {
|
|
7
|
+
readonly id: number
|
|
8
|
+
readonly slug: string
|
|
9
|
+
readonly title: string
|
|
10
|
+
readonly path: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BreadcrumbInput {
|
|
14
|
+
readonly forums: readonly CrumbForum[]
|
|
15
|
+
readonly forumId: number
|
|
16
|
+
readonly visibleForumIds?: ReadonlySet<number>
|
|
17
|
+
readonly leaf?: string
|
|
18
|
+
readonly homeLabel?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function buildBreadcrumb({
|
|
22
|
+
forums,
|
|
23
|
+
forumId,
|
|
24
|
+
visibleForumIds,
|
|
25
|
+
leaf,
|
|
26
|
+
homeLabel = 'Home',
|
|
27
|
+
}: BreadcrumbInput): readonly LinkModel[] {
|
|
28
|
+
const byId = new Map(forums.map((forum) => [forum.id, forum]))
|
|
29
|
+
const self = byId.get(forumId)
|
|
30
|
+
|
|
31
|
+
const items: LinkModel[] = [{ label: homeLabel, href: '/' }]
|
|
32
|
+
if (self === undefined) {
|
|
33
|
+
if (leaf !== undefined) items.push({ label: leaf, href: '' })
|
|
34
|
+
return items
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const visible = (id: number) => visibleForumIds === undefined || visibleForumIds.has(id)
|
|
38
|
+
|
|
39
|
+
for (const ancestorId of ancestorIds(self.path)) {
|
|
40
|
+
const ancestor = byId.get(ancestorId)
|
|
41
|
+
if (ancestor === undefined || !visible(ancestor.id)) continue
|
|
42
|
+
items.push({ label: ancestor.title, href: forumHref(ancestor) })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
items.push({ label: self.title, href: forumHref(self) })
|
|
46
|
+
|
|
47
|
+
if (leaf !== undefined) items.push({ label: leaf, href: '' })
|
|
48
|
+
|
|
49
|
+
return items
|
|
50
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Translator } from '@meith/i18n'
|
|
2
|
+
import { isOnline, type RelationKind, type RelationRow } from '@meith/relations'
|
|
3
|
+
import type { TimeModel } from '@meith/theme-kit'
|
|
4
|
+
|
|
5
|
+
import { memberHref } from './member-profile'
|
|
6
|
+
import { formatTime, untranslated } from './time'
|
|
7
|
+
|
|
8
|
+
export interface ContactRowView {
|
|
9
|
+
readonly userId: number
|
|
10
|
+
readonly username: string
|
|
11
|
+
readonly profileHref: string
|
|
12
|
+
readonly isOnline: boolean
|
|
13
|
+
readonly lastSeenLabel: string | null
|
|
14
|
+
readonly addedAt: TimeModel
|
|
15
|
+
readonly messageHref: string | null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ContactsView {
|
|
19
|
+
readonly kind: RelationKind
|
|
20
|
+
readonly buddies: readonly ContactRowView[]
|
|
21
|
+
readonly ignored: readonly ContactRowView[]
|
|
22
|
+
readonly onlineCount: number
|
|
23
|
+
readonly total: number
|
|
24
|
+
readonly limit: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function buildContactsView(input: {
|
|
28
|
+
readonly kind: RelationKind
|
|
29
|
+
readonly buddies: readonly RelationRow[]
|
|
30
|
+
readonly ignored: readonly RelationRow[]
|
|
31
|
+
readonly limit: number
|
|
32
|
+
readonly now: Date
|
|
33
|
+
readonly t?: Translator
|
|
34
|
+
}): ContactsView {
|
|
35
|
+
const row = (entry: RelationRow): ContactRowView => ({
|
|
36
|
+
userId: entry.userId,
|
|
37
|
+
username: entry.username,
|
|
38
|
+
profileHref: memberHref(entry.userId),
|
|
39
|
+
isOnline: isOnline(entry.lastActiveAt, input.now),
|
|
40
|
+
lastSeenLabel:
|
|
41
|
+
entry.lastActiveAt === null
|
|
42
|
+
? null
|
|
43
|
+
: `Last seen ${formatTime(entry.lastActiveAt, input.now, input.t).label}`,
|
|
44
|
+
addedAt: formatTime(entry.createdAt, input.now, input.t),
|
|
45
|
+
messageHref:
|
|
46
|
+
entry.kind === 'buddy' ? `/messages/compose?to=${encodeURIComponent(entry.username)}` : null,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const buddies = input.buddies.map(row)
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
kind: input.kind,
|
|
53
|
+
buddies,
|
|
54
|
+
ignored: input.ignored.map(row),
|
|
55
|
+
onlineCount: buddies.filter((entry) => entry.isOnline).length,
|
|
56
|
+
total: input.buddies.length + input.ignored.length,
|
|
57
|
+
limit: input.limit,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function contactsNotice(
|
|
62
|
+
query: {
|
|
63
|
+
readonly added?: string | undefined
|
|
64
|
+
readonly ignored?: string | undefined
|
|
65
|
+
readonly removed?: string | undefined
|
|
66
|
+
},
|
|
67
|
+
t: Translator = untranslated(),
|
|
68
|
+
): { kind: 'info'; message: string } | null {
|
|
69
|
+
if (query.added !== undefined) {
|
|
70
|
+
return { kind: 'info', message: t.t('contacts.added', { name: nameOf(query.added, t) }) }
|
|
71
|
+
}
|
|
72
|
+
if (query.ignored !== undefined) {
|
|
73
|
+
return { kind: 'info', message: t.t('contacts.ignored', { name: nameOf(query.ignored, t) }) }
|
|
74
|
+
}
|
|
75
|
+
if (query.removed !== undefined) {
|
|
76
|
+
return { kind: 'info', message: t.t('contacts.removed', { name: nameOf(query.removed, t) }) }
|
|
77
|
+
}
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function nameOf(raw: string, t: Translator): string {
|
|
82
|
+
const trimmed = raw.trim()
|
|
83
|
+
if (trimmed === '') return t.t('contacts.someMember')
|
|
84
|
+
return trimmed.length > 30 ? `${trimmed.slice(0, 30)}…` : trimmed
|
|
85
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Translator } from '@meith/i18n'
|
|
2
|
+
|
|
3
|
+
import { copyFor, patternCopy, splitAround } from './copy'
|
|
4
|
+
import { untranslated } from './time'
|
|
5
|
+
|
|
6
|
+
export function replyFormCopy(t: Translator = untranslated()): Readonly<Record<string, string>> {
|
|
7
|
+
return copyFor(
|
|
8
|
+
[
|
|
9
|
+
'composer.draftSaved',
|
|
10
|
+
'composer.autosave.failed',
|
|
11
|
+
'composer.autosave.saved',
|
|
12
|
+
'composer.autosave.saving',
|
|
13
|
+
'composer.recovery.available',
|
|
14
|
+
'composer.recovery.discard',
|
|
15
|
+
'composer.recovery.restore',
|
|
16
|
+
'composer.notifyReplies',
|
|
17
|
+
'composer.reply.submit',
|
|
18
|
+
'composer.reply.write',
|
|
19
|
+
'composer.reply.quick',
|
|
20
|
+
'composer.reply.draftSaved',
|
|
21
|
+
],
|
|
22
|
+
t,
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function editPostFormCopy(t: Translator = untranslated()): Readonly<Record<string, string>> {
|
|
27
|
+
return copyFor(
|
|
28
|
+
[
|
|
29
|
+
'composer.edit.reason',
|
|
30
|
+
'composer.edit.submit',
|
|
31
|
+
'composer.edit.delete',
|
|
32
|
+
'composer.edit.deleteBlurb',
|
|
33
|
+
'composer.edit.restore',
|
|
34
|
+
'composer.edit.restoreBlurb',
|
|
35
|
+
'composer.preview',
|
|
36
|
+
],
|
|
37
|
+
t,
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function newThreadFormCopy(
|
|
42
|
+
t: Translator = untranslated(),
|
|
43
|
+
): Readonly<Record<string, string>> {
|
|
44
|
+
return {
|
|
45
|
+
...copyFor(
|
|
46
|
+
[
|
|
47
|
+
'composer.draftSaved',
|
|
48
|
+
'composer.notifyReplies',
|
|
49
|
+
'composer.newThread.subject',
|
|
50
|
+
'composer.newThread.prefix',
|
|
51
|
+
'composer.newThread.prefixOptional',
|
|
52
|
+
'composer.newThread.choosePrefix',
|
|
53
|
+
'composer.newThread.noPrefix',
|
|
54
|
+
'composer.newThread.addPoll',
|
|
55
|
+
'composer.newThread.optional',
|
|
56
|
+
'composer.newThread.question',
|
|
57
|
+
'composer.newThread.pollChoices',
|
|
58
|
+
'composer.newThread.pollChoicesHint',
|
|
59
|
+
'composer.newThread.pollRevote',
|
|
60
|
+
'composer.newThread.pollPublic',
|
|
61
|
+
'composer.newThread.submit',
|
|
62
|
+
],
|
|
63
|
+
t,
|
|
64
|
+
),
|
|
65
|
+
...patternCopy(['composer.newThread.option'], t),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function messageFormsCopy(t: Translator = untranslated()): Readonly<Record<string, string>> {
|
|
70
|
+
return copyFor(
|
|
71
|
+
[
|
|
72
|
+
'messageForm.to',
|
|
73
|
+
'messageForm.toHint',
|
|
74
|
+
'messageForm.bcc',
|
|
75
|
+
'messageForm.bccHint',
|
|
76
|
+
'messageForm.subject',
|
|
77
|
+
'messageForm.bodyHint',
|
|
78
|
+
'messageForm.receipt',
|
|
79
|
+
'messageForm.send',
|
|
80
|
+
'messageForm.withSelected',
|
|
81
|
+
'messageForm.markRead',
|
|
82
|
+
'messageForm.markUnread',
|
|
83
|
+
'messageForm.restore',
|
|
84
|
+
'messageForm.deleteForever',
|
|
85
|
+
'messageForm.emptyTrash',
|
|
86
|
+
'messageForm.moveToTrash',
|
|
87
|
+
],
|
|
88
|
+
t,
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function threadRatingCopy(
|
|
93
|
+
rating: { readonly count: number; readonly average: number; readonly mine: number | null },
|
|
94
|
+
t: Translator = untranslated(),
|
|
95
|
+
): Readonly<Record<string, string>> {
|
|
96
|
+
const [outOfLead, outOfTail] = splitAround(t, 'thread.rating.outOf', 'average')
|
|
97
|
+
return {
|
|
98
|
+
...copyFor(
|
|
99
|
+
[
|
|
100
|
+
'thread.rating.section',
|
|
101
|
+
'thread.rating.none',
|
|
102
|
+
'thread.rating.rateIt',
|
|
103
|
+
'thread.rating.yours',
|
|
104
|
+
],
|
|
105
|
+
t,
|
|
106
|
+
),
|
|
107
|
+
...patternCopy(['thread.rating.rateValue', 'thread.rating.currentValue'], t),
|
|
108
|
+
'thread.rating.outOfLead': outOfLead,
|
|
109
|
+
'thread.rating.outOfTail': outOfTail,
|
|
110
|
+
'thread.rating.average': t.number(rating.average, {
|
|
111
|
+
minimumFractionDigits: 1,
|
|
112
|
+
maximumFractionDigits: 1,
|
|
113
|
+
}),
|
|
114
|
+
'thread.rating.from': t.t('thread.rating.from', { count: rating.count }),
|
|
115
|
+
'thread.rating.countLabel': t.t('thread.rating.countLabel', { count: rating.count }),
|
|
116
|
+
'thread.rating.mine': t.t('thread.rating.mine', { value: rating.mine ?? 0 }),
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { Translator } from '@meith/i18n'
|
|
2
|
+
import { oklchToRgb, parseColour, relativeLuminance } from '@meith/theme-kit'
|
|
3
|
+
|
|
4
|
+
import { untranslated } from './time'
|
|
5
|
+
|
|
6
|
+
export type ContrastNeed = 'text' | 'large-text' | 'non-text'
|
|
7
|
+
|
|
8
|
+
export const REQUIRED_RATIO: Readonly<Record<ContrastNeed, number>> = {
|
|
9
|
+
text: 4.5,
|
|
10
|
+
'large-text': 3,
|
|
11
|
+
'non-text': 3,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ContrastPair {
|
|
15
|
+
readonly foreground: string
|
|
16
|
+
readonly background: string
|
|
17
|
+
readonly labelKey: string
|
|
18
|
+
readonly need: ContrastNeed
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const CONTRAST_PAIRS: readonly ContrastPair[] = [
|
|
22
|
+
{
|
|
23
|
+
foreground: 'foreground',
|
|
24
|
+
background: 'background',
|
|
25
|
+
labelKey: 'contrast.foreground-on-background',
|
|
26
|
+
need: 'text',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
foreground: 'foreground',
|
|
30
|
+
background: 'surface',
|
|
31
|
+
labelKey: 'contrast.foreground-on-surface',
|
|
32
|
+
need: 'text',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
foreground: 'card-foreground',
|
|
36
|
+
background: 'card',
|
|
37
|
+
labelKey: 'contrast.card-foreground-on-card',
|
|
38
|
+
need: 'text',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
foreground: 'muted-foreground',
|
|
42
|
+
background: 'card',
|
|
43
|
+
labelKey: 'contrast.muted-foreground-on-card',
|
|
44
|
+
need: 'text',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
foreground: 'muted-foreground',
|
|
48
|
+
background: 'background',
|
|
49
|
+
labelKey: 'contrast.muted-foreground-on-background',
|
|
50
|
+
need: 'text',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
foreground: 'primary-foreground',
|
|
54
|
+
background: 'primary',
|
|
55
|
+
labelKey: 'contrast.primary-foreground-on-primary',
|
|
56
|
+
need: 'text',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
foreground: 'primary-foreground',
|
|
60
|
+
background: 'primary-hover',
|
|
61
|
+
labelKey: 'contrast.primary-foreground-on-primary-hover',
|
|
62
|
+
need: 'text',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
foreground: 'secondary-foreground',
|
|
66
|
+
background: 'secondary',
|
|
67
|
+
labelKey: 'contrast.secondary-foreground-on-secondary',
|
|
68
|
+
need: 'text',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
foreground: 'destructive-foreground',
|
|
72
|
+
background: 'destructive',
|
|
73
|
+
labelKey: 'contrast.destructive-foreground-on-destructive',
|
|
74
|
+
need: 'text',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
foreground: 'accent-foreground',
|
|
78
|
+
background: 'accent',
|
|
79
|
+
labelKey: 'contrast.accent-foreground-on-accent',
|
|
80
|
+
need: 'text',
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
{
|
|
84
|
+
foreground: 'card-foreground',
|
|
85
|
+
background: 'post-highlight',
|
|
86
|
+
labelKey: 'contrast.card-foreground-on-post-highlight',
|
|
87
|
+
need: 'text',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
foreground: 'card-foreground',
|
|
91
|
+
background: 'post-own',
|
|
92
|
+
labelKey: 'contrast.card-foreground-on-post-own',
|
|
93
|
+
need: 'text',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
foreground: 'card-foreground',
|
|
97
|
+
background: 'post-unapproved',
|
|
98
|
+
labelKey: 'contrast.card-foreground-on-post-unapproved',
|
|
99
|
+
need: 'text',
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
{
|
|
103
|
+
foreground: 'forum-unread',
|
|
104
|
+
background: 'card',
|
|
105
|
+
labelKey: 'contrast.forum-unread-on-card',
|
|
106
|
+
need: 'text',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
foreground: 'forum-read',
|
|
110
|
+
background: 'card',
|
|
111
|
+
labelKey: 'contrast.forum-read-on-card',
|
|
112
|
+
need: 'text',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
foreground: 'forum-locked',
|
|
116
|
+
background: 'card',
|
|
117
|
+
labelKey: 'contrast.forum-locked-on-card',
|
|
118
|
+
need: 'text',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
foreground: 'thread-pinned',
|
|
122
|
+
background: 'card',
|
|
123
|
+
labelKey: 'contrast.thread-pinned-on-card',
|
|
124
|
+
need: 'text',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
foreground: 'thread-locked',
|
|
128
|
+
background: 'card',
|
|
129
|
+
labelKey: 'contrast.thread-locked-on-card',
|
|
130
|
+
need: 'text',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
foreground: 'thread-moved',
|
|
134
|
+
background: 'card',
|
|
135
|
+
labelKey: 'contrast.thread-moved-on-card',
|
|
136
|
+
need: 'text',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
foreground: 'thread-unapproved',
|
|
140
|
+
background: 'card',
|
|
141
|
+
labelKey: 'contrast.thread-unapproved-on-card',
|
|
142
|
+
need: 'text',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
foreground: 'thread-deleted',
|
|
146
|
+
background: 'card',
|
|
147
|
+
labelKey: 'contrast.thread-deleted-on-card',
|
|
148
|
+
need: 'text',
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
{
|
|
152
|
+
foreground: 'moderation-pending',
|
|
153
|
+
background: 'card',
|
|
154
|
+
labelKey: 'contrast.moderation-pending-on-card',
|
|
155
|
+
need: 'text',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
foreground: 'moderation-approved',
|
|
159
|
+
background: 'card',
|
|
160
|
+
labelKey: 'contrast.moderation-approved-on-card',
|
|
161
|
+
need: 'text',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
foreground: 'moderation-rejected',
|
|
165
|
+
background: 'card',
|
|
166
|
+
labelKey: 'contrast.moderation-rejected-on-card',
|
|
167
|
+
need: 'text',
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
{
|
|
171
|
+
foreground: 'group-admin',
|
|
172
|
+
background: 'card',
|
|
173
|
+
labelKey: 'contrast.group-admin-on-card',
|
|
174
|
+
need: 'text',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
foreground: 'group-supermod',
|
|
178
|
+
background: 'card',
|
|
179
|
+
labelKey: 'contrast.group-supermod-on-card',
|
|
180
|
+
need: 'text',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
foreground: 'group-mod',
|
|
184
|
+
background: 'card',
|
|
185
|
+
labelKey: 'contrast.group-mod-on-card',
|
|
186
|
+
need: 'text',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
foreground: 'group-banned',
|
|
190
|
+
background: 'card',
|
|
191
|
+
labelKey: 'contrast.group-banned-on-card',
|
|
192
|
+
need: 'text',
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
{
|
|
196
|
+
foreground: 'ring',
|
|
197
|
+
background: 'background',
|
|
198
|
+
labelKey: 'contrast.ring-on-background',
|
|
199
|
+
need: 'non-text',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
foreground: 'ring',
|
|
203
|
+
background: 'card',
|
|
204
|
+
labelKey: 'contrast.ring-on-card',
|
|
205
|
+
need: 'non-text',
|
|
206
|
+
},
|
|
207
|
+
{ foreground: 'input', background: 'card', labelKey: 'contrast.input-on-card', need: 'non-text' },
|
|
208
|
+
]
|
|
209
|
+
|
|
210
|
+
export type ContrastState = 'pass' | 'fail' | 'unknown'
|
|
211
|
+
|
|
212
|
+
export interface ContrastCheck {
|
|
213
|
+
readonly pair: ContrastPair
|
|
214
|
+
readonly required: number
|
|
215
|
+
readonly ratio: number | null
|
|
216
|
+
readonly state: ContrastState
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function contrastRatio(a: string, b: string): number | null {
|
|
220
|
+
const first = parseColour(a)
|
|
221
|
+
const second = parseColour(b)
|
|
222
|
+
if (first === null || second === null) return null
|
|
223
|
+
|
|
224
|
+
const lighter = Math.max(
|
|
225
|
+
relativeLuminance(oklchToRgb(first).rgb),
|
|
226
|
+
relativeLuminance(oklchToRgb(second).rgb),
|
|
227
|
+
)
|
|
228
|
+
const darker = Math.min(
|
|
229
|
+
relativeLuminance(oklchToRgb(first).rgb),
|
|
230
|
+
relativeLuminance(oklchToRgb(second).rgb),
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
return (lighter + 0.05) / (darker + 0.05)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function check(pair: ContrastPair, values: Readonly<Record<string, string>>): ContrastCheck {
|
|
237
|
+
const foreground = values[pair.foreground]
|
|
238
|
+
const background = values[pair.background]
|
|
239
|
+
const required = REQUIRED_RATIO[pair.need]
|
|
240
|
+
|
|
241
|
+
if (foreground === undefined || background === undefined) {
|
|
242
|
+
return { pair, required, ratio: null, state: 'unknown' }
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const ratio = contrastRatio(foreground, background)
|
|
246
|
+
return {
|
|
247
|
+
pair,
|
|
248
|
+
required,
|
|
249
|
+
ratio,
|
|
250
|
+
state: ratio === null ? 'unknown' : ratio >= required ? 'pass' : 'fail',
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function checkContrast(
|
|
255
|
+
values: Readonly<Record<string, string>>,
|
|
256
|
+
pairs: readonly ContrastPair[] = CONTRAST_PAIRS,
|
|
257
|
+
): readonly ContrastCheck[] {
|
|
258
|
+
return pairs.map((pair) => check(pair, values))
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export function contrastChecksFor(
|
|
262
|
+
token: string,
|
|
263
|
+
values: Readonly<Record<string, string>>,
|
|
264
|
+
): readonly ContrastCheck[] {
|
|
265
|
+
return checkContrast(
|
|
266
|
+
values,
|
|
267
|
+
CONTRAST_PAIRS.filter((pair) => pair.foreground === token || pair.background === token),
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function contrastCopy(t: Translator = untranslated()): Readonly<Record<string, string>> {
|
|
272
|
+
const copy: Record<string, string> = {}
|
|
273
|
+
for (const pair of CONTRAST_PAIRS) copy[pair.labelKey] = t.t(pair.labelKey)
|
|
274
|
+
return copy
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function formatRatio(ratio: number): string {
|
|
278
|
+
return `${ratio.toFixed(2).replace(/\.?0+$/, '')}:1`
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export function contrastGrade(ratio: number, need: ContrastNeed): 'AAA' | 'AA' | 'Fails' {
|
|
282
|
+
if (need === 'non-text') return ratio >= 3 ? 'AA' : 'Fails'
|
|
283
|
+
const enhanced = need === 'text' ? 7 : 4.5
|
|
284
|
+
if (ratio >= enhanced) return 'AAA'
|
|
285
|
+
return ratio >= REQUIRED_RATIO[need] ? 'AA' : 'Fails'
|
|
286
|
+
}
|