@openpeepshq/react 0.7.1 → 0.8.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/dist/components/markdown/compileMarkdown.js +1 -0
- package/dist/components/navigation/FooterMobile.js +4 -3
- package/dist/components/navigation/HeaderMobile.js +5 -2
- package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
- package/dist/components/navigation/MobileMenuItem.js +7 -2
- package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
- package/dist/components/navigation/NavWithTooltip.js +4 -0
- package/dist/components/navigation/index.d.ts +2 -0
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
- package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
- package/dist/components/post/CompactReplyParent.js +5 -6
- package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
- package/dist/components/post/TruncatedMarkdown.js +37 -0
- package/dist/components/post/helpers.d.ts +2 -2
- package/dist/components/post/helpers.js +3 -16
- package/dist/components/post/index.d.ts +2 -0
- package/dist/components/post/index.js +1 -0
- package/dist/components/post/pieces/EventLocation.js +14 -0
- package/dist/components/post/pieces/EventRsvpButton.js +3 -1
- package/dist/components/post/pieces/PollContent.js +8 -2
- package/dist/components/post/post-form/ArticleForm.js +1 -1
- package/dist/components/post/post-form/EventForm.js +23 -3
- package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
- package/dist/components/post/post-form/ResourceForm.js +48 -7
- package/dist/components/post/post-form/VisibilitySelector.js +9 -3
- package/dist/components/post/types/Article.js +2 -3
- package/dist/components/post/types/Event.js +10 -1
- package/dist/components/post/types/resource/FullResource.js +3 -3
- package/dist/components/preview-link/local/WelcomePreview.js +4 -2
- package/dist/components/resources/ResourceCard.d.ts +5 -1
- package/dist/components/resources/ResourceCard.js +29 -5
- package/dist/components/resources/ResourceCard.test.d.ts +1 -0
- package/dist/components/resources/ResourceCard.test.js +75 -0
- package/dist/components/resources/ResourceLibrary.js +1 -1
- package/dist/hooks/events/useEventRsvp.d.ts +1 -0
- package/dist/hooks/events/useEventRsvp.js +15 -7
- package/dist/hooks/posts/useResourceComposer.d.ts +2 -0
- package/dist/hooks/posts/useResourceComposer.js +131 -25
- package/dist/hooks/resources/useResourceLibrary.d.ts +1 -1
- package/dist/hooks/resources/useResourceLibrary.js +6 -2
- package/dist/hooks/useWelcomePreview.d.ts +3 -0
- package/dist/hooks/useWelcomePreview.js +1 -0
- package/dist/navigation/menuItems.js +15 -0
- package/dist/navigation/targets.d.ts +2 -0
- package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
- package/dist/pages/auth/Register.js +3 -1
- package/dist/pages/resources/Edit.js +3 -3
- package/dist/pages/resources/New.js +2 -2
- package/dist/pages/settings/Account.js +30 -2
- package/package.json +2 -2
- package/src/components/markdown/compileMarkdown.ts +1 -0
- package/src/components/navigation/FooterMobile.tsx +41 -33
- package/src/components/navigation/HeaderMobile.tsx +55 -41
- package/src/components/navigation/MobileMenuItem.tsx +15 -2
- package/src/components/navigation/NavWithTooltip.tsx +26 -0
- package/src/components/navigation/index.ts +2 -0
- package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
- package/src/components/post/CompactReplyParent.tsx +17 -10
- package/src/components/post/TruncatedMarkdown.tsx +91 -0
- package/src/components/post/helpers.ts +4 -18
- package/src/components/post/index.ts +2 -0
- package/src/components/post/pieces/EventLocation.tsx +27 -0
- package/src/components/post/pieces/EventRsvpButton.tsx +3 -0
- package/src/components/post/pieces/PollContent.tsx +8 -2
- package/src/components/post/post-form/ArticleForm.tsx +1 -1
- package/src/components/post/post-form/EventForm.tsx +43 -15
- package/src/components/post/post-form/ResourceForm.tsx +132 -4
- package/src/components/post/post-form/VisibilitySelector.tsx +11 -3
- package/src/components/post/types/Article.tsx +5 -5
- package/src/components/post/types/Event.tsx +68 -7
- package/src/components/post/types/resource/FullResource.tsx +9 -1
- package/src/components/preview-link/local/WelcomePreview.tsx +11 -2
- package/src/components/resources/ResourceCard.tsx +68 -10
- package/src/components/resources/ResourceLibrary.tsx +2 -2
- package/src/hooks/events/useEventRsvp.ts +19 -7
- package/src/hooks/posts/useResourceComposer.ts +157 -33
- package/src/hooks/resources/useResourceLibrary.ts +6 -2
- package/src/hooks/useWelcomePreview.ts +4 -0
- package/src/navigation/menuItems.ts +16 -0
- package/src/navigation/targets.ts +2 -0
- package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
- package/src/pages/auth/Register.tsx +12 -0
- package/src/pages/resources/Edit.tsx +3 -2
- package/src/pages/resources/New.tsx +6 -1
- package/src/pages/settings/Account.tsx +51 -1
|
@@ -2,12 +2,16 @@ import { useMemo, useState } from 'react';
|
|
|
2
2
|
import { categoryTreeFromPaths, normalizeResourceTags, pathStartsWith, } from '@openpeepshq/common/lib';
|
|
3
3
|
import { useOpenpeeps } from '../../contexts/openpeeps/index.js';
|
|
4
4
|
import { useFeedListParams } from '../useResolvedFeedFormat.js';
|
|
5
|
-
export const useResourceLibrary = (groupId) => {
|
|
5
|
+
export const useResourceLibrary = (groupId, ungrouped) => {
|
|
6
6
|
const { openpeepsApi } = useOpenpeeps();
|
|
7
7
|
const params = useFeedListParams({ format: 'linear' });
|
|
8
8
|
const query = openpeepsApi.usePostsByType('resource', {
|
|
9
9
|
...params,
|
|
10
|
-
...(groupId
|
|
10
|
+
...(groupId
|
|
11
|
+
? { groupId }
|
|
12
|
+
: ungrouped
|
|
13
|
+
? { ungrouped: 'true' }
|
|
14
|
+
: {}),
|
|
11
15
|
});
|
|
12
16
|
const bookmarkedIds = openpeepsApi.useCurrentProfileBookmarkedIds();
|
|
13
17
|
const [search, setSearch] = useState('');
|
|
@@ -2,7 +2,10 @@ export type WelcomePreviewContent = {
|
|
|
2
2
|
/** Short label above the title. Omitted when it would repeat the title. */
|
|
3
3
|
eyebrow?: string;
|
|
4
4
|
title: string;
|
|
5
|
+
/** Plain-text excerpt (image-stripped) for non-markdown consumers / fallback. */
|
|
5
6
|
description: string;
|
|
7
|
+
/** Raw welcome markdown (image-bearing) for markdown rendering + overlays. */
|
|
8
|
+
markdown: string;
|
|
6
9
|
imageUrl?: string;
|
|
7
10
|
imageFit: 'cover' | 'contain';
|
|
8
11
|
};
|
|
@@ -33,6 +33,7 @@ export const useWelcomePreview = (systemScheme) => {
|
|
|
33
33
|
: t('welcome.defaultIntro', {
|
|
34
34
|
defaultValue: 'Welcome to this community, hosted on AllPeep.',
|
|
35
35
|
}),
|
|
36
|
+
markdown: configured,
|
|
36
37
|
imageUrl: markdownImage || logo || undefined,
|
|
37
38
|
imageFit: markdownImage ? 'cover' : 'contain',
|
|
38
39
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const navTooltip = (id) => `navigation.tooltips.${id}`;
|
|
1
2
|
/** Default main-menu targets for hosts to render with their own icons/labels. */
|
|
2
3
|
export const buildMainNavItems = (caps) => {
|
|
3
4
|
const items = [
|
|
@@ -5,24 +6,28 @@ export const buildMainNavItems = (caps) => {
|
|
|
5
6
|
id: 'community',
|
|
6
7
|
target: { type: 'feed', feed: 'local' },
|
|
7
8
|
labelKey: 'navigation.community',
|
|
9
|
+
tooltipKey: navTooltip('community'),
|
|
8
10
|
icon: 'Home',
|
|
9
11
|
},
|
|
10
12
|
{
|
|
11
13
|
id: 'welcome',
|
|
12
14
|
target: { type: 'welcome' },
|
|
13
15
|
labelKey: 'navigation.goToWelcomePage',
|
|
16
|
+
tooltipKey: navTooltip('welcome'),
|
|
14
17
|
icon: 'BookCheck',
|
|
15
18
|
},
|
|
16
19
|
{
|
|
17
20
|
id: 'explore',
|
|
18
21
|
target: { type: 'explore' },
|
|
19
22
|
labelKey: 'navigation.explore',
|
|
23
|
+
tooltipKey: navTooltip('explore'),
|
|
20
24
|
icon: 'Search',
|
|
21
25
|
},
|
|
22
26
|
{
|
|
23
27
|
id: 'myFeed',
|
|
24
28
|
target: { type: 'feed', feed: 'my' },
|
|
25
29
|
labelKey: 'navigation.myFeed',
|
|
30
|
+
tooltipKey: navTooltip('myFeed'),
|
|
26
31
|
icon: 'Newspaper',
|
|
27
32
|
},
|
|
28
33
|
];
|
|
@@ -31,6 +36,7 @@ export const buildMainNavItems = (caps) => {
|
|
|
31
36
|
id: 'jams',
|
|
32
37
|
target: { type: 'jams' },
|
|
33
38
|
labelKey: 'navigation.jams',
|
|
39
|
+
tooltipKey: navTooltip('jams'),
|
|
34
40
|
icon: 'PhoneCall',
|
|
35
41
|
});
|
|
36
42
|
}
|
|
@@ -38,41 +44,49 @@ export const buildMainNavItems = (caps) => {
|
|
|
38
44
|
id: 'groups',
|
|
39
45
|
target: { type: 'groups' },
|
|
40
46
|
labelKey: 'navigation.groups',
|
|
47
|
+
tooltipKey: navTooltip('groups'),
|
|
41
48
|
icon: 'Users',
|
|
42
49
|
}, {
|
|
43
50
|
id: 'events',
|
|
44
51
|
target: { type: 'events' },
|
|
45
52
|
labelKey: 'navigation.events',
|
|
53
|
+
tooltipKey: navTooltip('events'),
|
|
46
54
|
icon: 'CalendarDays',
|
|
47
55
|
}, {
|
|
48
56
|
id: 'articles',
|
|
49
57
|
target: { type: 'articles' },
|
|
50
58
|
labelKey: 'navigation.articles',
|
|
59
|
+
tooltipKey: navTooltip('articles'),
|
|
51
60
|
icon: 'ScrollText',
|
|
52
61
|
}, {
|
|
53
62
|
id: 'resources',
|
|
54
63
|
target: { type: 'resources' },
|
|
55
64
|
labelKey: 'navigation.resources',
|
|
65
|
+
tooltipKey: navTooltip('resources'),
|
|
56
66
|
icon: 'Library',
|
|
57
67
|
}, {
|
|
58
68
|
id: 'messages',
|
|
59
69
|
target: { type: 'conversation' },
|
|
60
70
|
labelKey: 'navigation.messages',
|
|
71
|
+
tooltipKey: navTooltip('messages'),
|
|
61
72
|
icon: 'MessageSquareText',
|
|
62
73
|
}, {
|
|
63
74
|
id: 'members',
|
|
64
75
|
target: { type: 'members' },
|
|
65
76
|
labelKey: 'navigation.members',
|
|
77
|
+
tooltipKey: navTooltip('members'),
|
|
66
78
|
icon: 'BookUser',
|
|
67
79
|
}, {
|
|
68
80
|
id: 'bookmarks',
|
|
69
81
|
target: { type: 'feed', feed: 'bookmarks' },
|
|
70
82
|
labelKey: 'navigation.bookmarks',
|
|
83
|
+
tooltipKey: navTooltip('bookmarks'),
|
|
71
84
|
icon: 'Bookmark',
|
|
72
85
|
}, {
|
|
73
86
|
id: 'settings',
|
|
74
87
|
target: { type: 'settings' },
|
|
75
88
|
labelKey: 'navigation.settings',
|
|
89
|
+
tooltipKey: navTooltip('settings'),
|
|
76
90
|
icon: 'Settings',
|
|
77
91
|
});
|
|
78
92
|
if (caps.showAdmin) {
|
|
@@ -80,6 +94,7 @@ export const buildMainNavItems = (caps) => {
|
|
|
80
94
|
id: 'admin',
|
|
81
95
|
target: { type: 'admin' },
|
|
82
96
|
labelKey: 'navigation.administration',
|
|
97
|
+
tooltipKey: navTooltip('administration'),
|
|
83
98
|
icon: 'Bolt',
|
|
84
99
|
});
|
|
85
100
|
}
|
|
@@ -89,6 +89,8 @@ export type NavItemDef = {
|
|
|
89
89
|
id: string;
|
|
90
90
|
target: NavTarget;
|
|
91
91
|
labelKey: string;
|
|
92
|
+
/** i18n key describing what happens when the item is activated. */
|
|
93
|
+
tooltipKey?: string;
|
|
92
94
|
/** Lucide (or similar) icon component name — host maps to actual icon. */
|
|
93
95
|
icon?: string;
|
|
94
96
|
end?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useT, useSetPageHeader } from '../../../index.js';
|
|
4
|
+
import { Markdown } from '../../../lib/Markdown.js';
|
|
4
5
|
import { OpenpeepsMarkdownInput } from '../../../components/index.js';
|
|
5
6
|
import { Button, Toast, deepGet, deepSet } from '@openpeepshq/react-ui';
|
|
6
7
|
import { useCommunityConfig } from './useCommunityConfig.js';
|
|
@@ -31,5 +32,5 @@ export function CommunityMarkdownPage({ path, titleKey, descriptionKey, }) {
|
|
|
31
32
|
if (isLoading || !draft) {
|
|
32
33
|
return (_jsx("div", { className: "text-muted-foreground flex h-32 items-center justify-center text-sm", children: t('common.form.loading', { defaultValue: 'Loading…' }) }));
|
|
33
34
|
}
|
|
34
|
-
return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsx(
|
|
35
|
+
return (_jsxs("div", { className: "flex flex-col gap-4 p-4", children: [_jsx(Markdown, { source: t(descriptionKey), className: "pb-2 pt-4 text-sm text-muted-foreground" }), _jsx(OpenpeepsMarkdownInput, { value: value, maxLength: 10000, rows: 18, className: "min-h-[30rem]", onChange: setContent }), _jsx(Button, { variant: "default", action: handleSubmit, title: t('configuration.community.save'), children: t('configuration.community.save') }), status ? (_jsx(Toast, { variant: status.type, onDismiss: () => setStatus(null), children: status.message })) : null] }));
|
|
35
36
|
}
|
|
@@ -147,7 +147,9 @@ export function Register({ invite = false }) {
|
|
|
147
147
|
defaultValue: 'Show password',
|
|
148
148
|
}) })] })] }) }), _jsx(FormMessage, {})] })) }), _jsx(FormField, { control: form.control, name: "confirmPassword", render: ({ field }) => (_jsxs(FormItem, { children: [_jsx(FormLabel, { children: t('auth.register.confirmPassword', {
|
|
149
149
|
defaultValue: 'Confirm Password',
|
|
150
|
-
}) }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "password", "data-testid": "auth-register-confirm-password" }) }), _jsx(FormMessage, { "data-testid": "auth-register-confirm-password-error" })] })) }),
|
|
150
|
+
}) }), _jsx(FormControl, { children: _jsx(Input, { ...field, type: "password", "data-testid": "auth-register-confirm-password" }) }), _jsx(FormMessage, { "data-testid": "auth-register-confirm-password-error" })] })) }), password && password.length > 0 && (_jsx("p", { "data-testid": "auth-register-password-rules", className: "text-xs text-muted-foreground", children: t('auth.register.passwordRules', {
|
|
151
|
+
defaultValue: '8+ characters, with an uppercase letter, lowercase letter, number, and symbol',
|
|
152
|
+
}) })), (password ?? '').length > 0 &&
|
|
151
153
|
(confirmPassword ?? '').length === 0 && (_jsx("div", { className: "bg-surface border-border flex w-full justify-center rounded py-2", children: _jsx("p", { children: getStrengthMessage(calculatePasswordStrength(password)) }) })), _jsx(FormField, { control: form.control, name: "privacyPolicyAccepted", render: ({ field }) => (_jsxs(FormItem, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(FormControl, { children: _jsx(Input, { type: "checkbox", checked: field.value, onChange: (e) => field.onChange(e.target.checked), "data-testid": "auth-register-privacy-checkbox" }) }), _jsxs("p", { children: [t('auth.register.privacyPolicyAgreement', {
|
|
152
154
|
defaultValue: 'I have read and agree to the',
|
|
153
155
|
}), ' ', _jsx("a", { href: privacyPolicyLink, target: "_blank", rel: "noopener noreferrer", className: "anchor text-sm", children: t('auth.register.privacyPolicy', {
|
|
@@ -9,10 +9,10 @@ import { Button, LoadingSpinner, Toast } from '@openpeepshq/react-ui';
|
|
|
9
9
|
export const EditResource = () => {
|
|
10
10
|
const t = useT();
|
|
11
11
|
const { resourceId = '' } = useParams();
|
|
12
|
-
const { postQuery, postData, setPostData, resourceTitle, submitting, error, clearError, submit, } = useEditResource(resourceId);
|
|
13
|
-
const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.update.title', { defaultValue: 'Update resource' }), variant: "default", action: submit, disabled: submitting, children: submitting
|
|
12
|
+
const { postQuery, postData, setPostData, resourceTitle, canSubmit, submitting, error, clearError, submit, } = useEditResource(resourceId);
|
|
13
|
+
const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.update.title', { defaultValue: 'Update resource' }), variant: "default", action: submit, disabled: submitting || !canSubmit, children: submitting
|
|
14
14
|
? t('common.saving', { defaultValue: 'Saving…' })
|
|
15
|
-
: t('resources.update.title', { defaultValue: 'Update resource' }) })), [submit, submitting, t]);
|
|
15
|
+
: t('resources.update.title', { defaultValue: 'Update resource' }) })), [canSubmit, submit, submitting, t]);
|
|
16
16
|
useSetPageHeader(resourceTitle
|
|
17
17
|
? `${t('resources.edit', { defaultValue: 'Edit resource' })} ${truncateText(resourceTitle)}`
|
|
18
18
|
: t('resources.edit', { defaultValue: 'Edit resource' }), headerActions);
|
|
@@ -6,10 +6,10 @@ import { useNewResource } from '../../hooks/index.js';
|
|
|
6
6
|
import { Button, Toast } from '@openpeepshq/react-ui';
|
|
7
7
|
export const NewResource = () => {
|
|
8
8
|
const t = useT();
|
|
9
|
-
const { postData, setPostData, canSubmit, submitting, error, clearError, submit, } = useNewResource();
|
|
9
|
+
const { postData, setPostData, canSubmit, groupOnly, submitting, error, clearError, submit, } = useNewResource();
|
|
10
10
|
const headerActions = useMemo(() => (_jsx(Button, { title: t('resources.create.title', { defaultValue: 'Create resource' }), variant: "default", action: submit, disabled: submitting || !canSubmit, "data-testid": "resources-submit", children: submitting
|
|
11
11
|
? t('common.submitting', { defaultValue: 'Publishing…' })
|
|
12
12
|
: t('resources.create.title', { defaultValue: 'Create resource' }) })), [canSubmit, submit, submitting, t]);
|
|
13
13
|
useSetPageHeader(t('resources.new', { defaultValue: 'New resource' }), headerActions);
|
|
14
|
-
return (_jsxs("div", { className: "pb-12", children: [_jsx(ResourceForm, { postData: postData, onChange: setPostData }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
14
|
+
return (_jsxs("div", { className: "pb-12", children: [_jsx(ResourceForm, { postData: postData, onChange: setPostData, groupOnly: groupOnly }), error ? (_jsx("div", { className: "px-3", children: _jsx(Toast, { variant: "error", onDismiss: clearError, children: error }) })) : null] }));
|
|
15
15
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useT, useOpenpeeps, useSetPageHeader } from '../../index.js';
|
|
4
|
-
import { useCurrentAccount } from '../../components/index.js';
|
|
4
|
+
import { useCurrentAccount, useToast } from '../../components/index.js';
|
|
5
5
|
import { Button, Input, Label, Toast } from '@openpeepshq/react-ui';
|
|
6
6
|
export function AccountSettings() {
|
|
7
7
|
const t = useT();
|
|
8
8
|
const { openpeepsApi, client } = useOpenpeeps();
|
|
9
|
+
const { success, error: toastError } = useToast();
|
|
9
10
|
const account = useCurrentAccount();
|
|
10
11
|
const updateAccount = openpeepsApi.updateCurrentAccountAction();
|
|
11
12
|
useSetPageHeader(t('settings.account.title', { defaultValue: 'Account' }));
|
|
@@ -60,6 +61,25 @@ export function AccountSettings() {
|
|
|
60
61
|
setSubmitting(false);
|
|
61
62
|
}
|
|
62
63
|
};
|
|
64
|
+
const validateEmail = openpeepsApi.validationEmailAction();
|
|
65
|
+
const [verifying, setVerifying] = useState(false);
|
|
66
|
+
const handleVerifyEmail = async () => {
|
|
67
|
+
setVerifying(true);
|
|
68
|
+
try {
|
|
69
|
+
await validateEmail();
|
|
70
|
+
success(t('settings.account.verifyEmailSent', {
|
|
71
|
+
defaultValue: 'Verification email sent',
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
toastError(t('settings.account.verifyEmailError', {
|
|
76
|
+
defaultValue: 'Failed to send verification email',
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
setVerifying(false);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
63
83
|
const exportAccount = async () => {
|
|
64
84
|
setExporting(true);
|
|
65
85
|
try {
|
|
@@ -98,7 +118,15 @@ export function AccountSettings() {
|
|
|
98
118
|
defaultValue: 'Required to change your email or password.',
|
|
99
119
|
}) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "email", children: t('settings.account.email', { defaultValue: 'Email' }) }), _jsx(Input, { id: "email", type: "email", value: email, placeholder: t('settings.account.emailPlaceholder', {
|
|
100
120
|
defaultValue: 'Enter your email',
|
|
101
|
-
}), onChange: (e) => setEmail(e.target.value), "data-testid": "settings-email-input" })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(
|
|
121
|
+
}), onChange: (e) => setEmail(e.target.value), "data-testid": "settings-email-input" })] }), !account?.emailValidated ? (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-muted-foreground text-sm", children: t('settings.account.verifyEmailDescription', {
|
|
122
|
+
defaultValue: 'Your email is not verified. Resend a verification email.',
|
|
123
|
+
}) }), _jsx(Button, { title: t('settings.account.verifyEmailButton', {
|
|
124
|
+
defaultValue: 'Verify email',
|
|
125
|
+
}), variant: "outline", action: handleVerifyEmail, loading: verifying, "data-testid": "settings-verify-email-button", children: verifying
|
|
126
|
+
? t('common.submitting', { defaultValue: 'Sending...' })
|
|
127
|
+
: t('settings.account.verifyEmailButton', {
|
|
128
|
+
defaultValue: 'Verify email',
|
|
129
|
+
}) })] })) : null, _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "newPassword", children: t('settings.account.newPassword', {
|
|
102
130
|
defaultValue: 'New password',
|
|
103
131
|
}) }), _jsx(Input, { id: "newPassword", type: "password", autoComplete: "new-password", value: newPassword, placeholder: t('settings.account.newPasswordPlaceholder', {
|
|
104
132
|
defaultValue: 'Enter your new password',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"simple-icons": "^16.31.0",
|
|
53
53
|
"uuidv7": "^1.0.2",
|
|
54
54
|
"@openpeepshq/client": "^0.2.1",
|
|
55
|
-
"@openpeepshq/greenscreen": "^0.2.1",
|
|
56
55
|
"@openpeepshq/common": "^0.4.0",
|
|
56
|
+
"@openpeepshq/greenscreen": "^0.2.1",
|
|
57
57
|
"@openpeepshq/react-ui": "^0.4.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bell, Home, Newspaper, PlusSquare, Users } from 'lucide-react';
|
|
2
|
+
import { TooltipProvider } from '@openpeepshq/react-ui';
|
|
2
3
|
import { MobileMenuItem } from './MobileMenuItem';
|
|
3
4
|
import { useHrefOf } from '../../contexts/router';
|
|
4
5
|
import { useOpenpeeps } from '../../contexts/openpeeps';
|
|
@@ -16,38 +17,45 @@ export function FooterMobile({ onNewPost }: FooterMobileProps = {}) {
|
|
|
16
17
|
const notificationStats = openpeepsApi.useCurrentProfileNotificationStats();
|
|
17
18
|
|
|
18
19
|
return (
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
20
|
+
<TooltipProvider delayDuration={300}>
|
|
21
|
+
<nav
|
|
22
|
+
aria-label={t('navigation.primaryMobile', {
|
|
23
|
+
defaultValue: 'Primary',
|
|
24
|
+
})}
|
|
25
|
+
className="bg-surface flex h-20 w-full items-center justify-evenly md:hidden"
|
|
26
|
+
>
|
|
27
|
+
<MobileMenuItem
|
|
28
|
+
title={t('navigation.home')}
|
|
29
|
+
tooltip={t('navigation.tooltips.community')}
|
|
30
|
+
icon={Home}
|
|
31
|
+
action={hrefOf({ type: 'feed', feed: 'local' })}
|
|
32
|
+
/>
|
|
33
|
+
<MobileMenuItem
|
|
34
|
+
title={t('navigation.myFeed')}
|
|
35
|
+
tooltip={t('navigation.tooltips.myFeed')}
|
|
36
|
+
icon={Newspaper}
|
|
37
|
+
action={hrefOf({ type: 'feed', feed: 'my' })}
|
|
38
|
+
/>
|
|
39
|
+
<MobileMenuItem
|
|
40
|
+
title={t('navigation.newPost')}
|
|
41
|
+
tooltip={t('navigation.tooltips.newPost')}
|
|
42
|
+
icon={PlusSquare}
|
|
43
|
+
action={onNewPost ?? hrefOf({ type: 'postNew' })}
|
|
44
|
+
/>
|
|
45
|
+
<MobileMenuItem
|
|
46
|
+
title={t('navigation.groups')}
|
|
47
|
+
tooltip={t('navigation.tooltips.groups')}
|
|
48
|
+
icon={Users}
|
|
49
|
+
action={hrefOf({ type: 'groups' })}
|
|
50
|
+
/>
|
|
51
|
+
<MobileMenuItem
|
|
52
|
+
title={t('navigation.openNotifications')}
|
|
53
|
+
tooltip={t('navigation.tooltips.notifications')}
|
|
54
|
+
icon={Bell}
|
|
55
|
+
action={hrefOf({ type: 'notifications' })}
|
|
56
|
+
badge={notificationStats.data?.unseen}
|
|
57
|
+
/>
|
|
58
|
+
</nav>
|
|
59
|
+
</TooltipProvider>
|
|
52
60
|
);
|
|
53
61
|
}
|
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
DialogPortal,
|
|
7
7
|
DialogOverlay,
|
|
8
8
|
DialogTrigger,
|
|
9
|
+
TooltipProvider,
|
|
9
10
|
} from '@openpeepshq/react-ui';
|
|
11
|
+
import { NavWithTooltip } from './NavWithTooltip';
|
|
10
12
|
import { getTheme } from '@openpeepshq/common';
|
|
11
13
|
import { useServerInfo } from '../server-data';
|
|
12
14
|
import {
|
|
@@ -37,9 +39,11 @@ export function HeaderMobile({ avatar, sideBar }: HeaderMobileProps = {}) {
|
|
|
37
39
|
const t = useT();
|
|
38
40
|
const [open, setOpen] = useState(false);
|
|
39
41
|
const menuLabel = t('navigation.openMenu', { defaultValue: 'Open menu' });
|
|
42
|
+
const menuTooltip = t('navigation.tooltips.openMenu');
|
|
40
43
|
const messagesLabel = t('navigation.openMessages', {
|
|
41
44
|
defaultValue: 'Open messages',
|
|
42
45
|
});
|
|
46
|
+
const messagesTooltip = t('navigation.tooltips.openMessages');
|
|
43
47
|
|
|
44
48
|
const logoSmall = getTheme(
|
|
45
49
|
serverInfo.communityConfig,
|
|
@@ -58,49 +62,59 @@ export function HeaderMobile({ avatar, sideBar }: HeaderMobileProps = {}) {
|
|
|
58
62
|
|
|
59
63
|
return (
|
|
60
64
|
<header className="bg-background sticky top-0 z-10 flex px-4 py-2 md:hidden">
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
<TooltipProvider delayDuration={300}>
|
|
66
|
+
<div className="flex w-full items-center justify-between">
|
|
67
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
68
|
+
<NavWithTooltip label={menuTooltip} side="bottom">
|
|
69
|
+
<DialogTrigger asChild>
|
|
70
|
+
<button
|
|
71
|
+
type="button"
|
|
72
|
+
title={menuTooltip}
|
|
73
|
+
aria-label={menuLabel}
|
|
74
|
+
>
|
|
75
|
+
{trigger}
|
|
76
|
+
<span className="sr-only">{menuLabel}</span>
|
|
77
|
+
</button>
|
|
78
|
+
</DialogTrigger>
|
|
79
|
+
</NavWithTooltip>
|
|
80
|
+
<DialogPortal>
|
|
81
|
+
<DialogOverlay />
|
|
82
|
+
<DialogContent
|
|
83
|
+
showCloseButton={false}
|
|
84
|
+
className="left-0 top-0 h-screen w-[380px] translate-x-0 translate-y-0 rounded-none border-r p-0"
|
|
85
|
+
>
|
|
86
|
+
<SidebarNavCloseContext.Provider value={() => setOpen(false)}>
|
|
87
|
+
<SideBar
|
|
88
|
+
onClose={() => setOpen(false)}
|
|
89
|
+
mainMenu={sideBar?.mainMenu?.()}
|
|
90
|
+
profileMenu={sideBar?.profileMenu?.()}
|
|
91
|
+
/>
|
|
92
|
+
</SidebarNavCloseContext.Provider>
|
|
93
|
+
</DialogContent>
|
|
94
|
+
</DialogPortal>
|
|
95
|
+
</Dialog>
|
|
85
96
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
<div>
|
|
98
|
+
{logoSmall && (
|
|
99
|
+
<a href="/">
|
|
100
|
+
<img src={logoSmall} alt="logo" className="h-6 px-4" />
|
|
101
|
+
</a>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
93
104
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
<NavWithTooltip label={messagesTooltip} side="bottom">
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
title={messagesTooltip}
|
|
109
|
+
aria-label={messagesLabel}
|
|
110
|
+
onClick={() => router.navigate({ type: 'conversation' })}
|
|
111
|
+
>
|
|
112
|
+
<MessageSquareText aria-hidden="true" />
|
|
113
|
+
<span className="sr-only">{messagesLabel}</span>
|
|
114
|
+
</button>
|
|
115
|
+
</NavWithTooltip>
|
|
116
|
+
</div>
|
|
117
|
+
</TooltipProvider>
|
|
104
118
|
</header>
|
|
105
119
|
);
|
|
106
120
|
}
|
|
@@ -2,11 +2,14 @@ import { formatBadgeCount } from '@openpeepshq/common';
|
|
|
2
2
|
import { cn } from '@openpeepshq/react-ui';
|
|
3
3
|
import type { IconType } from '@openpeepshq/react-ui';
|
|
4
4
|
import { useRouter } from '../../contexts/router';
|
|
5
|
+
import { NavWithTooltip } from './NavWithTooltip';
|
|
5
6
|
|
|
6
7
|
export interface MobileMenuItemProps {
|
|
7
8
|
action: string | (() => unknown);
|
|
8
9
|
icon: IconType;
|
|
9
10
|
title?: string;
|
|
11
|
+
/** Describes the action on hover (icon-only mobile footer). */
|
|
12
|
+
tooltip?: string;
|
|
10
13
|
/** Unread/unseen count shown as a badge on the icon. */
|
|
11
14
|
badge?: number;
|
|
12
15
|
}
|
|
@@ -15,16 +18,18 @@ export function MobileMenuItem({
|
|
|
15
18
|
action,
|
|
16
19
|
icon: Icon,
|
|
17
20
|
title,
|
|
21
|
+
tooltip,
|
|
18
22
|
badge,
|
|
19
23
|
}: MobileMenuItemProps) {
|
|
20
24
|
const router = useRouter();
|
|
21
25
|
const active = typeof action === 'string' && router.pathname === action;
|
|
22
26
|
const showBadge = (badge ?? 0) > 0;
|
|
27
|
+
const hint = tooltip ?? title;
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
const button = (
|
|
25
30
|
<button
|
|
26
31
|
type="button"
|
|
27
|
-
title={
|
|
32
|
+
title={hint}
|
|
28
33
|
aria-label={title}
|
|
29
34
|
className="relative"
|
|
30
35
|
onClick={() => {
|
|
@@ -53,4 +58,12 @@ export function MobileMenuItem({
|
|
|
53
58
|
</span>
|
|
54
59
|
</button>
|
|
55
60
|
);
|
|
61
|
+
|
|
62
|
+
if (!hint) return button;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<NavWithTooltip label={hint} side="top">
|
|
66
|
+
{button}
|
|
67
|
+
</NavWithTooltip>
|
|
68
|
+
);
|
|
56
69
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TooltipContent,
|
|
4
|
+
TooltipRoot,
|
|
5
|
+
TooltipTrigger,
|
|
6
|
+
} from '@openpeepshq/react-ui';
|
|
7
|
+
|
|
8
|
+
export type NavTooltipSide = 'top' | 'bottom' | 'left' | 'right';
|
|
9
|
+
|
|
10
|
+
export type NavWithTooltipProps = {
|
|
11
|
+
label: string;
|
|
12
|
+
side?: NavTooltipSide;
|
|
13
|
+
children: ReactElement;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Hover tooltip for a single nav control; wrap the list in `TooltipProvider`. */
|
|
17
|
+
export const NavWithTooltip = ({
|
|
18
|
+
label,
|
|
19
|
+
side = 'right',
|
|
20
|
+
children,
|
|
21
|
+
}: NavWithTooltipProps) => (
|
|
22
|
+
<TooltipRoot>
|
|
23
|
+
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
|
24
|
+
<TooltipContent side={side}>{label}</TooltipContent>
|
|
25
|
+
</TooltipRoot>
|
|
26
|
+
);
|
|
@@ -11,6 +11,8 @@ export { FooterMobile } from './FooterMobile';
|
|
|
11
11
|
export type { FooterMobileProps } from './FooterMobile';
|
|
12
12
|
export { MobileMenuItem } from './MobileMenuItem';
|
|
13
13
|
export type { MobileMenuItemProps } from './MobileMenuItem';
|
|
14
|
+
export { NavWithTooltip } from './NavWithTooltip';
|
|
15
|
+
export type { NavWithTooltipProps, NavTooltipSide } from './NavWithTooltip';
|
|
14
16
|
export { ContentHeader } from './ContentHeader';
|
|
15
17
|
export { PageHeaderAction } from './PageHeaderAction';
|
|
16
18
|
export type { PageHeaderActionProps } from './PageHeaderAction';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { cn } from '@openpeepshq/react-ui';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Sidebar nav link classes. A string so Radix Tooltip's Slot can merge
|
|
5
|
+
* `className` — a NavLink callback gets stringified and the flex row is lost.
|
|
6
|
+
* Active state uses `aria-current="page"`, which NavLink sets itself.
|
|
7
|
+
*/
|
|
8
|
+
export const sideBarNavLinkClass = cn(
|
|
9
|
+
'flex items-center gap-2 rounded-md px-3 py-2 text-foreground/70 hover:bg-surface',
|
|
10
|
+
'aria-[current=page]:font-bold aria-[current=page]:text-primary',
|
|
11
|
+
);
|