@tribe-nest/forge 3.60.0 → 3.61.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/package.json +2 -1
- package/src/contexts/CartContext.tsx +34 -1
- package/src/contexts/PublicAuthContext.tsx +15 -3
- package/src/data/queries/_tests/metaSignals.spec.tsx +130 -0
- package/src/data/queries/useAccount.ts +33 -2
- package/src/data/queries/useAnalytics.ts +6 -6
- package/src/data/queries/useCallChat.ts +2 -2
- package/src/data/queries/useChat.ts +10 -1
- package/src/data/queries/useCheckouts.ts +2 -1
- package/src/data/queries/useCoachingAvailability.ts +10 -1
- package/src/data/queries/useCommunities.ts +2 -0
- package/src/data/queries/useCommunity.ts +362 -18
- package/src/data/queries/useCommunityAgent.ts +247 -0
- package/src/data/queries/useCommunityCalendar.ts +150 -0
- package/src/data/queries/useCommunityClassroom.ts +75 -0
- package/src/data/queries/useCommunityMembers.ts +108 -0
- package/src/data/queries/useCommunityModeration.ts +327 -0
- package/src/data/queries/useCommunityWiki.ts +137 -0
- package/src/data/queries/useCourses.ts +2 -0
- package/src/data/queries/useEmailSignIn.ts +79 -0
- package/src/data/queries/useEvents.ts +6 -1
- package/src/data/queries/useForms.ts +5 -1
- package/src/data/queries/useLeadMagnet.ts +6 -2
- package/src/data/queries/useMyBookings.ts +24 -1
- package/src/data/queries/useMyTickets.ts +24 -1
- package/src/data/queries/useNotifications.ts +6 -2
- package/src/data/queries/useOrders.ts +2 -1
- package/src/data/queries/usePWA.ts +111 -35
- package/src/data/queries/useSiteApp.ts +130 -0
- package/src/data/queries/useSubscriptions.ts +6 -1
- package/src/i18n/de.json +746 -1
- package/src/i18n/en.json +746 -1
- package/src/index.ts +17 -0
- package/src/runtime/pages.spec.ts +5 -0
- package/src/runtime/pages.ts +32 -6
- package/src/types/models.ts +11 -0
- package/src/ui/analytics/ForgeAnalytics.tsx +64 -34
- package/src/ui/analytics/PageMetaPixel.tsx +23 -8
- package/src/ui/analytics/_tests/ForgeAnalytics.meta.spec.tsx +129 -0
- package/src/ui/analytics/_tests/metaCommerceEvents.spec.tsx +159 -0
- package/src/ui/analytics/useMetaEvents.ts +78 -0
- package/src/ui/headless/_tests/communityAgent.spec.tsx +519 -0
- package/src/ui/headless/_tests/communityCalendar.spec.tsx +195 -0
- package/src/ui/headless/_tests/communityClassroom.spec.tsx +120 -0
- package/src/ui/headless/_tests/communityHarness.tsx +10 -3
- package/src/ui/headless/_tests/communityMembers.spec.tsx +316 -0
- package/src/ui/headless/_tests/communityPoll.spec.tsx +389 -0
- package/src/ui/headless/_tests/memberHomeBar.spec.ts +84 -0
- package/src/ui/headless/_tests/siteAppBar.spec.ts +83 -0
- package/src/ui/headless/_tests/siteAppHarness.ts +19 -0
- package/src/ui/headless/_tests/siteAppHome.spec.ts +226 -0
- package/src/ui/headless/_tests/siteAppPrompts.spec.ts +185 -0
- package/src/ui/headless/_tests/useCommunityJoin.spec.tsx +228 -14
- package/src/ui/headless/_tests/useCommunityMembership.spec.tsx +29 -1
- package/src/ui/headless/_tests/useCommunityModeration.spec.tsx +420 -0
- package/src/ui/headless/_tests/useCommunityReads.spec.tsx +11 -2
- package/src/ui/headless/_tests/useCommunityWiki.spec.tsx +224 -0
- package/src/ui/headless/_tests/useSiteApp.spec.tsx +52 -0
- package/src/ui/headless/_tests/wikiMediaImage.spec.tsx +132 -0
- package/src/ui/headless/auth/useEmailCodeSignIn.ts +186 -0
- package/src/ui/headless/auth/useSignupForm.ts +20 -1
- package/src/ui/headless/chat/useChatAttachmentUpload.ts +9 -6
- package/src/ui/headless/chat/useChatRoom.ts +35 -1
- package/src/ui/headless/communities/index.ts +41 -0
- package/src/ui/headless/communities/useCommunityCalendar.ts +156 -0
- package/src/ui/headless/communities/useCommunityClassroom.ts +84 -0
- package/src/ui/headless/communities/useCommunityHome.ts +3 -0
- package/src/ui/headless/communities/useCommunityJoin.ts +73 -23
- package/src/ui/headless/communities/useCommunityMembership.ts +48 -2
- package/src/ui/headless/communities/useCommunityWiki.ts +266 -0
- package/src/ui/headless/community/communityPoll.ts +297 -0
- package/src/ui/headless/community/countries.ts +123 -0
- package/src/ui/headless/community/index.ts +81 -1
- package/src/ui/headless/community/linkPreview.ts +71 -0
- package/src/ui/headless/community/richLexical.ts +27 -2
- package/src/ui/headless/community/useCommunityAgent.ts +285 -0
- package/src/ui/headless/community/useCommunityMembers.ts +175 -0
- package/src/ui/headless/community/useCommunityModeration.ts +300 -0
- package/src/ui/headless/community/useCommunitySpaceFeed.ts +22 -4
- package/src/ui/headless/community/useCommunityThread.ts +16 -3
- package/src/ui/headless/community/useMentionComposer.ts +17 -9
- package/src/ui/headless/community/useRichMentionComposer.ts +21 -5
- package/src/ui/headless/downloads/index.ts +8 -0
- package/src/ui/headless/downloads/useDownloadPage.ts +134 -0
- package/src/ui/headless/index.ts +13 -0
- package/src/ui/headless/memberHome/index.ts +10 -0
- package/src/ui/headless/memberHome/memberHomeBar.ts +91 -0
- package/src/ui/headless/memberHome/useMemberHomeNav.ts +56 -18
- package/src/ui/headless/portal/index.ts +57 -0
- package/src/ui/headless/portal/usePortal.ts +274 -0
- package/src/ui/headless/portal/usePortalFiles.ts +68 -0
- package/src/ui/headless/portal/usePortalMessages.ts +189 -0
- package/src/ui/headless/portal/usePortalPreview.ts +142 -0
- package/src/ui/headless/siteApp/appBar.ts +102 -0
- package/src/ui/headless/siteApp/appHome.ts +344 -0
- package/src/ui/headless/siteApp/appPrompts.ts +229 -0
- package/src/ui/headless/siteApp/index.ts +58 -0
- package/src/ui/headless/siteApp/useAppHome.ts +210 -0
- package/src/ui/headless/siteApp/useAppInstallRequest.ts +16 -0
- package/src/ui/headless/work/index.ts +2 -0
- package/src/ui/headless/work/useWorkPortal.ts +37 -26
- package/src/ui/index.ts +11 -0
- package/src/ui/styled/AccountDashboard.tsx +712 -352
- package/src/ui/styled/AiAgentWidget.tsx +13 -1
- package/src/ui/styled/ChatRoom.tsx +126 -16
- package/src/ui/styled/Checkout.tsx +8 -0
- package/src/ui/styled/CheckoutConfirmation.tsx +8 -0
- package/src/ui/styled/CoachingConfirmation.tsx +8 -0
- package/src/ui/styled/CoachingDetail.tsx +2 -0
- package/src/ui/styled/CourseConfirmation.tsx +5 -0
- package/src/ui/styled/CourseDetail.tsx +2 -0
- package/src/ui/styled/DownloadPage.tsx +263 -0
- package/src/ui/styled/EventConfirmation.tsx +10 -0
- package/src/ui/styled/EventDetail.tsx +10 -0
- package/src/ui/styled/FilmLibrary.tsx +22 -9
- package/src/ui/styled/MusicLinkPage.tsx +5 -5
- package/src/ui/styled/ProductDetail.tsx +12 -0
- package/src/ui/styled/PwaRegistration.tsx +5 -1
- package/src/ui/styled/SignupForm.tsx +18 -3
- package/src/ui/styled/_tests/AccountDashboardBookingCall.spec.tsx +5 -5
- package/src/ui/styled/_tests/AccountNotifications.spec.tsx +135 -0
- package/src/ui/styled/_tests/DownloadPage.spec.tsx +68 -0
- package/src/ui/styled/app/AppBar.tsx +298 -0
- package/src/ui/styled/app/AppHome.tsx +1139 -0
- package/src/ui/styled/app/AppHomeMark.tsx +66 -0
- package/src/ui/styled/app/AppPrompts.tsx +464 -0
- package/src/ui/styled/app/_tests/AppBar.spec.tsx +96 -0
- package/src/ui/styled/app/_tests/AppHome.spec.tsx +209 -0
- package/src/ui/styled/app/_tests/AppPrompts.spec.tsx +232 -0
- package/src/ui/styled/app/index.ts +7 -0
- package/src/ui/styled/chat/ChatThreadPanel.tsx +29 -4
- package/src/ui/styled/chat/MessageBubble.tsx +43 -6
- package/src/ui/styled/communities/CommunityAbout.tsx +6 -1
- package/src/ui/styled/communities/CommunityCalendar.tsx +484 -0
- package/src/ui/styled/communities/CommunityClassroom.tsx +302 -0
- package/src/ui/styled/communities/CommunityHome.tsx +134 -11
- package/src/ui/styled/communities/CommunityJoinSheet.tsx +119 -19
- package/src/ui/styled/communities/CommunityMembershipMenu.tsx +168 -52
- package/src/ui/styled/communities/CommunityPublicWiki.tsx +75 -0
- package/src/ui/styled/communities/CommunityWiki.tsx +289 -0
- package/src/ui/styled/communities/MyMembershipsList.tsx +31 -5
- package/src/ui/styled/communities/_tests/CommunityAppHome.spec.tsx +92 -0
- package/src/ui/styled/communities/_tests/CommunityClassroomCalendar.spec.tsx +453 -0
- package/src/ui/styled/communities/_tests/CommunityMobile.spec.tsx +399 -0
- package/src/ui/styled/communities/_tests/CommunityWiki.spec.tsx +223 -0
- package/src/ui/styled/communities/index.ts +9 -0
- package/src/ui/styled/communities/shared.tsx +39 -11
- package/src/ui/styled/community/CommunityAgent.tsx +286 -0
- package/src/ui/styled/community/CommunityComposer.tsx +266 -15
- package/src/ui/styled/community/CommunityFeed.tsx +50 -1
- package/src/ui/styled/community/CommunityLinkPreview.tsx +159 -0
- package/src/ui/styled/community/CommunityMemberGlobe.tsx +171 -0
- package/src/ui/styled/community/CommunityMemberProfile.tsx +137 -4
- package/src/ui/styled/community/CommunityMembers.tsx +387 -0
- package/src/ui/styled/community/CommunityModeration.tsx +587 -0
- package/src/ui/styled/community/CommunityModerationState.tsx +127 -0
- package/src/ui/styled/community/CommunityModeratorMenu.tsx +317 -0
- package/src/ui/styled/community/CommunityNotifications.tsx +52 -6
- package/src/ui/styled/community/CommunityPollCard.tsx +250 -0
- package/src/ui/styled/community/CommunityPostCard.tsx +110 -34
- package/src/ui/styled/community/CommunityPostDetail.tsx +157 -71
- package/src/ui/styled/community/CommunityRichText.tsx +177 -32
- package/src/ui/styled/community/CommunitySpaces.tsx +49 -14
- package/src/ui/styled/community/_tests/CommunityAgent.spec.tsx +571 -0
- package/src/ui/styled/community/_tests/CommunityLinkPreview.spec.tsx +167 -0
- package/src/ui/styled/community/_tests/CommunityMembers.spec.tsx +137 -0
- package/src/ui/styled/community/_tests/CommunityModeration.spec.tsx +291 -0
- package/src/ui/styled/community/_tests/CommunityPoll.spec.tsx +386 -0
- package/src/ui/styled/community/index.ts +37 -2
- package/src/ui/styled/forge-utilities.css +234 -0
- package/src/ui/styled/members/CallRecordingActions.tsx +182 -0
- package/src/ui/styled/members/MemberCallsCalendar.tsx +13 -158
- package/src/ui/styled/members/MemberHomeLayout.tsx +295 -15
- package/src/ui/styled/members/MemberPostsFeed.tsx +3 -2
- package/src/ui/styled/members/index.ts +8 -0
- package/src/ui/styled/portal/PortalAccountSection.tsx +61 -0
- package/src/ui/styled/portal/PortalActivity.tsx +167 -0
- package/src/ui/styled/portal/PortalBilling.tsx +197 -0
- package/src/ui/styled/portal/PortalFiles.tsx +279 -0
- package/src/ui/styled/portal/PortalHome.tsx +401 -0
- package/src/ui/styled/portal/PortalMessages.tsx +300 -0
- package/src/ui/styled/portal/PortalPreviewBanner.tsx +75 -0
- package/src/ui/styled/portal/PortalProjects.tsx +407 -0
- package/src/ui/styled/portal/PortalShell.tsx +397 -0
- package/src/ui/styled/portal/_tests/PortalAppHome.spec.tsx +90 -0
- package/src/ui/styled/portal/_tests/PortalFiles.spec.tsx +159 -0
- package/src/ui/styled/portal/_tests/PortalHome.spec.tsx +148 -0
- package/src/ui/styled/portal/_tests/PortalMessages.spec.tsx +168 -0
- package/src/ui/styled/portal/_tests/PortalPreviewBanner.spec.tsx +132 -0
- package/src/ui/styled/portal/_tests/portalNav.spec.ts +123 -0
- package/src/ui/styled/portal/index.ts +13 -0
- package/src/ui/styled/portal/portalNav.ts +260 -0
- package/src/ui/styled/portal/shared.tsx +206 -0
- package/src/ui/styled/work/WorkInviteAccept.tsx +228 -168
- package/src/ui/styled/work/WorkPortalProjects.tsx +68 -120
- package/src/ui/styled/work/WorkProjectDocuments.tsx +99 -128
- package/src/ui/styled/work/WorkProjectInvoices.tsx +91 -86
- package/src/ui/styled/work/WorkProjectReport.tsx +11 -17
- package/src/ui/styled/work/WorkReportBody.tsx +223 -248
- package/src/ui/styled/work/WorkTaskAttachments.tsx +23 -29
- package/src/ui/styled/work/WorkTaskComments.tsx +75 -102
- package/src/ui/styled/work/WorkTaskDetail.tsx +48 -59
- package/src/ui/styled/work/WorkTokenReport.tsx +8 -16
- package/src/ui/styled/work/index.ts +1 -1
- package/src/utils/_tests/metaEvents.spec.ts +264 -0
- package/src/utils/landing.ts +19 -6
- package/src/utils/metaEvents.ts +302 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { useContext, useEffect, useState, type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import {
|
|
3
|
+
BookOpen,
|
|
4
|
+
Briefcase,
|
|
5
|
+
CalendarDays,
|
|
6
|
+
ChevronRight,
|
|
7
|
+
Home,
|
|
8
|
+
Menu,
|
|
9
|
+
MessageSquare,
|
|
10
|
+
ShoppingBag,
|
|
11
|
+
Users,
|
|
12
|
+
type LucideIcon,
|
|
13
|
+
} from "lucide-react";
|
|
14
|
+
import { useThemeTokens } from "../../theme/ForgeThemeProvider";
|
|
15
|
+
import { useForgeT } from "../../../i18n";
|
|
16
|
+
import { PublicAuthContext } from "../../../contexts/PublicAuthContext";
|
|
17
|
+
import { resolveAppHomeHref, useSiteApp } from "../../../data/queries/useSiteApp";
|
|
18
|
+
import { useNotificationUnreadCount } from "../../../data/queries/useNotifications";
|
|
19
|
+
import { buildAppBar, type AppBarItem, type AppBarKey } from "../../headless/siteApp/appBar";
|
|
20
|
+
import { CommunitySheet } from "../communities/shared";
|
|
21
|
+
import { AppPrompts } from "./AppPrompts";
|
|
22
|
+
|
|
23
|
+
/** Literal keys, so the translation spec can see every one of them. */
|
|
24
|
+
const LABEL_KEYS: Record<AppBarKey, string> = {
|
|
25
|
+
home: "forge.app_bar.home",
|
|
26
|
+
communities: "forge.app_bar.communities",
|
|
27
|
+
portal: "forge.app_bar.portal",
|
|
28
|
+
inbox: "forge.app_bar.inbox",
|
|
29
|
+
events: "forge.app_bar.events",
|
|
30
|
+
courses: "forge.app_bar.courses",
|
|
31
|
+
shop: "forge.app_bar.shop",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const ICONS: Record<AppBarKey, LucideIcon> = {
|
|
35
|
+
home: Home,
|
|
36
|
+
communities: Users,
|
|
37
|
+
portal: Briefcase,
|
|
38
|
+
inbox: MessageSquare,
|
|
39
|
+
events: CalendarDays,
|
|
40
|
+
courses: BookOpen,
|
|
41
|
+
shop: ShoppingBag,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Tailwind's `lg`: from here up the site's own navigation is enough, and the bar hides. */
|
|
45
|
+
const BAR_BREAKPOINT = 1024;
|
|
46
|
+
/** The bar's height above the safe area. */
|
|
47
|
+
export const APP_BAR_HEIGHT = 56;
|
|
48
|
+
|
|
49
|
+
export interface AppBarProps {
|
|
50
|
+
/** Current location pathname (drives the active tab). Read from the window when not given. */
|
|
51
|
+
currentPath?: string;
|
|
52
|
+
/**
|
|
53
|
+
* SPA navigation adapter. Defaults to a full-page `window.location` visit.
|
|
54
|
+
* Pass your router's navigate for client-side transitions.
|
|
55
|
+
*/
|
|
56
|
+
navigate?: (href: string) => void;
|
|
57
|
+
/** Also host the app's install and notification prompts. Default true. */
|
|
58
|
+
prompts?: boolean;
|
|
59
|
+
className?: string;
|
|
60
|
+
style?: CSSProperties;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The site app's bottom bar: Home, the creator's chosen items (at most three),
|
|
65
|
+
* then More, a bottom sheet with every other destination. Below `lg` only,
|
|
66
|
+
* fixed to the bottom, 56px plus the phone's safe area, and it leaves a spacer
|
|
67
|
+
* of the same height so the page's last line is never under it.
|
|
68
|
+
*
|
|
69
|
+
* Home follows the Home rule (`useAppHomeHref`): the creator's start page when
|
|
70
|
+
* they chose one. Drop `<AppBar />` onto a custom start page and it behaves
|
|
71
|
+
* exactly as it does on `/i/app`. The bar publishes its height as
|
|
72
|
+
* `--forge-bottom-bar-height` on the root, so the site's chat bubble sits above
|
|
73
|
+
* it, the same contract `MemberHomeLayout` keeps inside a community.
|
|
74
|
+
*/
|
|
75
|
+
export function AppBar({ currentPath, navigate, prompts = true, className, style }: AppBarProps) {
|
|
76
|
+
const t = useThemeTokens();
|
|
77
|
+
const tr = useForgeT();
|
|
78
|
+
const auth = useContext(PublicAuthContext);
|
|
79
|
+
const signedIn = !!auth?.user;
|
|
80
|
+
const { data } = useSiteApp();
|
|
81
|
+
const [path, setPath] = useState<string | null>(currentPath ?? null);
|
|
82
|
+
const [moreOpen, setMoreOpen] = useState(false);
|
|
83
|
+
const go = navigate ?? ((href: string) => window.location.assign(href));
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (currentPath !== undefined) setPath(currentPath);
|
|
87
|
+
else if (typeof window !== "undefined") setPath(window.location.pathname);
|
|
88
|
+
}, [currentPath]);
|
|
89
|
+
|
|
90
|
+
const model = buildAppBar({ barItems: data?.barItems, homeHref: resolveAppHomeHref(data), currentPath: path });
|
|
91
|
+
const inboxShown = model.bar.some((item) => item.key === "inbox");
|
|
92
|
+
const { data: unread } = useNotificationUnreadCount(signedIn && inboxShown);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
96
|
+
const root = document.documentElement;
|
|
97
|
+
const narrow = window.matchMedia(`(max-width: ${BAR_BREAKPOINT - 1}px)`);
|
|
98
|
+
const apply = () =>
|
|
99
|
+
narrow.matches
|
|
100
|
+
? root.style.setProperty("--forge-bottom-bar-height", `${APP_BAR_HEIGHT}px`)
|
|
101
|
+
: root.style.removeProperty("--forge-bottom-bar-height");
|
|
102
|
+
apply();
|
|
103
|
+
narrow.addEventListener?.("change", apply);
|
|
104
|
+
return () => {
|
|
105
|
+
narrow.removeEventListener?.("change", apply);
|
|
106
|
+
root.style.removeProperty("--forge-bottom-bar-height");
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
const label = (item: AppBarItem) => tr(LABEL_KEYS[item.key]);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
{/* The page ends above the bar, not under it. */}
|
|
115
|
+
<div
|
|
116
|
+
aria-hidden
|
|
117
|
+
data-testid="app-bar-spacer"
|
|
118
|
+
className="fg:lg:hidden"
|
|
119
|
+
style={{ height: `calc(${APP_BAR_HEIGHT}px + env(safe-area-inset-bottom))` }}
|
|
120
|
+
/>
|
|
121
|
+
<nav
|
|
122
|
+
aria-label={tr("forge.app_bar.nav_label")}
|
|
123
|
+
data-testid="app-bar"
|
|
124
|
+
className={`fg:fixed fg:inset-x-0 fg:bottom-0 fg:z-40 fg:flex fg:lg:hidden ${className ?? ""}`}
|
|
125
|
+
style={{
|
|
126
|
+
background: t.background,
|
|
127
|
+
borderTop: `1px solid ${t.border}`,
|
|
128
|
+
paddingBottom: "env(safe-area-inset-bottom)",
|
|
129
|
+
...style,
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{model.bar.map((item) => {
|
|
133
|
+
const Icon = ICONS[item.key];
|
|
134
|
+
return (
|
|
135
|
+
<BarButton
|
|
136
|
+
key={item.key}
|
|
137
|
+
icon={<Icon size={20} aria-hidden />}
|
|
138
|
+
label={label(item)}
|
|
139
|
+
active={item.active}
|
|
140
|
+
href={item.href}
|
|
141
|
+
onGo={go}
|
|
142
|
+
badge={item.key === "inbox" ? (unread ?? 0) : 0}
|
|
143
|
+
testId={`app-bar-${item.key}`}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
})}
|
|
147
|
+
<BarButton
|
|
148
|
+
icon={<Menu size={20} aria-hidden />}
|
|
149
|
+
label={tr("forge.app_bar.more")}
|
|
150
|
+
active={model.moreActive}
|
|
151
|
+
onPress={() => setMoreOpen(true)}
|
|
152
|
+
testId="app-bar-more"
|
|
153
|
+
/>
|
|
154
|
+
</nav>
|
|
155
|
+
|
|
156
|
+
<CommunitySheet
|
|
157
|
+
open={moreOpen}
|
|
158
|
+
onOpenChange={setMoreOpen}
|
|
159
|
+
testId="app-more-sheet"
|
|
160
|
+
title={tr("forge.app_bar.more_title")}
|
|
161
|
+
closeLabel={tr("forge.app_bar.aria_close")}
|
|
162
|
+
>
|
|
163
|
+
{model.more.map((item) => {
|
|
164
|
+
const Icon = ICONS[item.key];
|
|
165
|
+
return (
|
|
166
|
+
<a
|
|
167
|
+
key={item.key}
|
|
168
|
+
href={item.href}
|
|
169
|
+
data-testid={`app-more-${item.key}`}
|
|
170
|
+
aria-current={item.active ? "page" : undefined}
|
|
171
|
+
onClick={(event) => {
|
|
172
|
+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
setMoreOpen(false);
|
|
175
|
+
go(item.href);
|
|
176
|
+
}}
|
|
177
|
+
style={{
|
|
178
|
+
display: "flex",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
gap: 12,
|
|
181
|
+
width: "100%",
|
|
182
|
+
padding: "12px 4px",
|
|
183
|
+
borderBottom: `1px solid ${t.border}`,
|
|
184
|
+
color: item.active ? t.primary : t.text,
|
|
185
|
+
fontFamily: t.fontFamily,
|
|
186
|
+
fontSize: 16,
|
|
187
|
+
fontWeight: item.active ? 700 : 500,
|
|
188
|
+
textDecoration: "none",
|
|
189
|
+
boxSizing: "border-box",
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
<Icon size={18} aria-hidden style={{ flexShrink: 0 }} />
|
|
193
|
+
<span style={{ flex: 1 }}>{label(item)}</span>
|
|
194
|
+
<ChevronRight size={16} aria-hidden style={{ color: t.muted }} />
|
|
195
|
+
</a>
|
|
196
|
+
);
|
|
197
|
+
})}
|
|
198
|
+
</CommunitySheet>
|
|
199
|
+
|
|
200
|
+
{prompts ? <AppPrompts /> : null}
|
|
201
|
+
</>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function BarButton({
|
|
206
|
+
icon,
|
|
207
|
+
label,
|
|
208
|
+
active,
|
|
209
|
+
href,
|
|
210
|
+
onGo,
|
|
211
|
+
onPress,
|
|
212
|
+
badge = 0,
|
|
213
|
+
testId,
|
|
214
|
+
}: {
|
|
215
|
+
icon: ReactNode;
|
|
216
|
+
label: string;
|
|
217
|
+
active: boolean;
|
|
218
|
+
href?: string;
|
|
219
|
+
onGo?: (href: string) => void;
|
|
220
|
+
onPress?: () => void;
|
|
221
|
+
badge?: number;
|
|
222
|
+
testId: string;
|
|
223
|
+
}) {
|
|
224
|
+
const t = useThemeTokens();
|
|
225
|
+
const style: CSSProperties = {
|
|
226
|
+
flex: 1,
|
|
227
|
+
minWidth: 0,
|
|
228
|
+
display: "flex",
|
|
229
|
+
flexDirection: "column",
|
|
230
|
+
alignItems: "center",
|
|
231
|
+
justifyContent: "center",
|
|
232
|
+
gap: 3,
|
|
233
|
+
padding: "8px 2px 7px",
|
|
234
|
+
minHeight: APP_BAR_HEIGHT,
|
|
235
|
+
background: "transparent",
|
|
236
|
+
border: "none",
|
|
237
|
+
color: active ? t.primary : t.muted,
|
|
238
|
+
fontFamily: t.fontFamily,
|
|
239
|
+
fontSize: 11,
|
|
240
|
+
fontWeight: active ? 700 : 500,
|
|
241
|
+
textDecoration: "none",
|
|
242
|
+
cursor: "pointer",
|
|
243
|
+
boxSizing: "border-box",
|
|
244
|
+
};
|
|
245
|
+
const content = (
|
|
246
|
+
<>
|
|
247
|
+
<span style={{ position: "relative", display: "inline-flex" }}>
|
|
248
|
+
{icon}
|
|
249
|
+
{badge > 0 ? (
|
|
250
|
+
<span
|
|
251
|
+
data-testid={`${testId}-badge`}
|
|
252
|
+
style={{
|
|
253
|
+
position: "absolute",
|
|
254
|
+
top: -4,
|
|
255
|
+
right: -8,
|
|
256
|
+
minWidth: 16,
|
|
257
|
+
height: 16,
|
|
258
|
+
padding: "0 4px",
|
|
259
|
+
borderRadius: 8,
|
|
260
|
+
background: t.primary,
|
|
261
|
+
color: t.textPrimary,
|
|
262
|
+
fontSize: 10,
|
|
263
|
+
fontWeight: 700,
|
|
264
|
+
lineHeight: "16px",
|
|
265
|
+
textAlign: "center",
|
|
266
|
+
boxSizing: "border-box",
|
|
267
|
+
}}
|
|
268
|
+
>
|
|
269
|
+
{badge > 99 ? "99+" : badge}
|
|
270
|
+
</span>
|
|
271
|
+
) : null}
|
|
272
|
+
</span>
|
|
273
|
+
<span style={{ maxWidth: "100%", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>{label}</span>
|
|
274
|
+
</>
|
|
275
|
+
);
|
|
276
|
+
if (href && onGo) {
|
|
277
|
+
return (
|
|
278
|
+
<a
|
|
279
|
+
href={href}
|
|
280
|
+
data-testid={testId}
|
|
281
|
+
aria-current={active ? "page" : undefined}
|
|
282
|
+
onClick={(event) => {
|
|
283
|
+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
284
|
+
event.preventDefault();
|
|
285
|
+
onGo(href);
|
|
286
|
+
}}
|
|
287
|
+
style={style}
|
|
288
|
+
>
|
|
289
|
+
{content}
|
|
290
|
+
</a>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
return (
|
|
294
|
+
<button type="button" data-testid={testId} aria-haspopup="dialog" aria-pressed={active} onClick={onPress} style={style}>
|
|
295
|
+
{content}
|
|
296
|
+
</button>
|
|
297
|
+
);
|
|
298
|
+
}
|