@openpeepshq/react 0.7.1 → 0.8.1

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.
Files changed (91) hide show
  1. package/dist/components/markdown/compileMarkdown.js +1 -0
  2. package/dist/components/navigation/FooterMobile.js +4 -3
  3. package/dist/components/navigation/HeaderMobile.js +5 -2
  4. package/dist/components/navigation/MobileMenuItem.d.ts +3 -1
  5. package/dist/components/navigation/MobileMenuItem.js +7 -2
  6. package/dist/components/navigation/NavWithTooltip.d.ts +9 -0
  7. package/dist/components/navigation/NavWithTooltip.js +4 -0
  8. package/dist/components/navigation/index.d.ts +2 -0
  9. package/dist/components/navigation/index.js +1 -0
  10. package/dist/components/navigation/sideBarNavLinkClass.d.ts +6 -4
  11. package/dist/components/navigation/sideBarNavLinkClass.js +6 -2
  12. package/dist/components/post/CompactReplyParent.js +5 -6
  13. package/dist/components/post/TruncatedMarkdown.d.ts +27 -0
  14. package/dist/components/post/TruncatedMarkdown.js +37 -0
  15. package/dist/components/post/helpers.d.ts +2 -2
  16. package/dist/components/post/helpers.js +3 -16
  17. package/dist/components/post/index.d.ts +2 -0
  18. package/dist/components/post/index.js +1 -0
  19. package/dist/components/post/pieces/EventLocation.js +14 -0
  20. package/dist/components/post/pieces/EventRsvpButton.js +3 -1
  21. package/dist/components/post/pieces/PollContent.js +8 -2
  22. package/dist/components/post/post-form/ArticleForm.js +1 -1
  23. package/dist/components/post/post-form/ComposeAttachments.d.ts +5 -1
  24. package/dist/components/post/post-form/ComposeAttachments.js +20 -6
  25. package/dist/components/post/post-form/ComposeAttachments.test.d.ts +1 -0
  26. package/dist/components/post/post-form/ComposeAttachments.test.js +131 -0
  27. package/dist/components/post/post-form/EventForm.js +23 -3
  28. package/dist/components/post/post-form/ResourceForm.d.ts +3 -1
  29. package/dist/components/post/post-form/ResourceForm.js +51 -7
  30. package/dist/components/post/post-form/VisibilitySelector.js +9 -3
  31. package/dist/components/post/types/Article.js +2 -3
  32. package/dist/components/post/types/Event.js +10 -1
  33. package/dist/components/post/types/resource/FullResource.js +3 -3
  34. package/dist/components/preview-link/local/WelcomePreview.js +4 -2
  35. package/dist/components/resources/ResourceCard.d.ts +5 -1
  36. package/dist/components/resources/ResourceCard.js +94 -37
  37. package/dist/components/resources/ResourceCard.test.d.ts +1 -0
  38. package/dist/components/resources/ResourceCard.test.js +75 -0
  39. package/dist/components/resources/ResourceLibrary.js +1 -1
  40. package/dist/hooks/events/useEventRsvp.d.ts +1 -0
  41. package/dist/hooks/events/useEventRsvp.js +15 -7
  42. package/dist/hooks/posts/useResourceComposer.d.ts +2 -0
  43. package/dist/hooks/posts/useResourceComposer.js +131 -25
  44. package/dist/hooks/resources/useResourceLibrary.d.ts +1 -1
  45. package/dist/hooks/resources/useResourceLibrary.js +6 -2
  46. package/dist/hooks/useWelcomePreview.d.ts +3 -0
  47. package/dist/hooks/useWelcomePreview.js +1 -0
  48. package/dist/navigation/menuItems.js +15 -0
  49. package/dist/navigation/targets.d.ts +2 -0
  50. package/dist/pages/admin/community/CommunityMarkdownPage.js +2 -1
  51. package/dist/pages/auth/Register.js +3 -1
  52. package/dist/pages/resources/Edit.js +3 -3
  53. package/dist/pages/resources/New.js +2 -2
  54. package/dist/pages/settings/Account.js +30 -2
  55. package/package.json +2 -2
  56. package/src/components/markdown/compileMarkdown.ts +1 -0
  57. package/src/components/navigation/FooterMobile.tsx +41 -33
  58. package/src/components/navigation/HeaderMobile.tsx +55 -41
  59. package/src/components/navigation/MobileMenuItem.tsx +15 -2
  60. package/src/components/navigation/NavWithTooltip.tsx +26 -0
  61. package/src/components/navigation/index.ts +2 -0
  62. package/src/components/navigation/sideBarNavLinkClass.ts +9 -6
  63. package/src/components/post/CompactReplyParent.tsx +17 -10
  64. package/src/components/post/TruncatedMarkdown.tsx +91 -0
  65. package/src/components/post/helpers.ts +4 -18
  66. package/src/components/post/index.ts +2 -0
  67. package/src/components/post/pieces/EventLocation.tsx +27 -0
  68. package/src/components/post/pieces/EventRsvpButton.tsx +3 -0
  69. package/src/components/post/pieces/PollContent.tsx +8 -2
  70. package/src/components/post/post-form/ArticleForm.tsx +1 -1
  71. package/src/components/post/post-form/ComposeAttachments.tsx +24 -3
  72. package/src/components/post/post-form/EventForm.tsx +43 -15
  73. package/src/components/post/post-form/ResourceForm.tsx +135 -4
  74. package/src/components/post/post-form/VisibilitySelector.tsx +11 -3
  75. package/src/components/post/types/Article.tsx +5 -5
  76. package/src/components/post/types/Event.tsx +68 -7
  77. package/src/components/post/types/resource/FullResource.tsx +9 -1
  78. package/src/components/preview-link/local/WelcomePreview.tsx +11 -2
  79. package/src/components/resources/ResourceCard.tsx +184 -62
  80. package/src/components/resources/ResourceLibrary.tsx +2 -2
  81. package/src/hooks/events/useEventRsvp.ts +19 -7
  82. package/src/hooks/posts/useResourceComposer.ts +157 -33
  83. package/src/hooks/resources/useResourceLibrary.ts +6 -2
  84. package/src/hooks/useWelcomePreview.ts +4 -0
  85. package/src/navigation/menuItems.ts +16 -0
  86. package/src/navigation/targets.ts +2 -0
  87. package/src/pages/admin/community/CommunityMarkdownPage.tsx +5 -1
  88. package/src/pages/auth/Register.tsx +12 -0
  89. package/src/pages/resources/Edit.tsx +3 -2
  90. package/src/pages/resources/New.tsx +6 -1
  91. package/src/pages/settings/Account.tsx +51 -1
@@ -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
- <nav
20
- aria-label={t('navigation.primaryMobile', {
21
- defaultValue: 'Primary',
22
- })}
23
- className="bg-surface flex h-20 w-full items-center justify-evenly md:hidden"
24
- >
25
- <MobileMenuItem
26
- title={t('navigation.home')}
27
- icon={Home}
28
- action={hrefOf({ type: 'feed', feed: 'local' })}
29
- />
30
- <MobileMenuItem
31
- title={t('navigation.myFeed')}
32
- icon={Newspaper}
33
- action={hrefOf({ type: 'feed', feed: 'my' })}
34
- />
35
- <MobileMenuItem
36
- title={t('navigation.newPost')}
37
- icon={PlusSquare}
38
- action={onNewPost ?? hrefOf({ type: 'postNew' })}
39
- />
40
- <MobileMenuItem
41
- title={t('navigation.groups')}
42
- icon={Users}
43
- action={hrefOf({ type: 'groups' })}
44
- />
45
- <MobileMenuItem
46
- title={t('navigation.openNotifications')}
47
- icon={Bell}
48
- action={hrefOf({ type: 'notifications' })}
49
- badge={notificationStats.data?.unseen}
50
- />
51
- </nav>
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
- <div className="flex w-full items-center justify-between">
62
- <Dialog open={open} onOpenChange={setOpen}>
63
- <DialogTrigger asChild>
64
- <button type="button" title={menuLabel} aria-label={menuLabel}>
65
- {trigger}
66
- <span className="sr-only">{menuLabel}</span>
67
- </button>
68
- </DialogTrigger>
69
- <DialogPortal>
70
- <DialogOverlay />
71
- <DialogContent
72
- showCloseButton={false}
73
- className="left-0 top-0 h-screen w-[380px] translate-x-0 translate-y-0 rounded-none border-r p-0"
74
- >
75
- <SidebarNavCloseContext.Provider value={() => setOpen(false)}>
76
- <SideBar
77
- onClose={() => setOpen(false)}
78
- mainMenu={sideBar?.mainMenu?.()}
79
- profileMenu={sideBar?.profileMenu?.()}
80
- />
81
- </SidebarNavCloseContext.Provider>
82
- </DialogContent>
83
- </DialogPortal>
84
- </Dialog>
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
- <div>
87
- {logoSmall && (
88
- <a href="/">
89
- <img src={logoSmall} alt="logo" className="h-6 px-4" />
90
- </a>
91
- )}
92
- </div>
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
- <button
95
- type="button"
96
- title={messagesLabel}
97
- aria-label={messagesLabel}
98
- onClick={() => router.navigate({ type: 'conversation' })}
99
- >
100
- <MessageSquareText aria-hidden="true" />
101
- <span className="sr-only">{messagesLabel}</span>
102
- </button>
103
- </div>
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
- return (
29
+ const button = (
25
30
  <button
26
31
  type="button"
27
- title={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
- /** Active/inactive classes for sidebar nav links (parity with Svelte `MenuItem.svelte`). */
4
- export const sideBarNavLinkClass = ({ isActive }: { isActive: boolean }) =>
5
- cn(
6
- 'flex items-center gap-2 rounded-md px-3 py-2 hover:bg-surface',
7
- isActive ? 'text-primary font-bold' : 'text-foreground/70',
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
+ );
@@ -8,16 +8,13 @@ import type {
8
8
  PublicReplyPost,
9
9
  Question,
10
10
  } from '@openpeepshq/common/types';
11
- import {
12
- formatEventWhen,
13
- isHiddenPost,
14
- markdownPlainText,
15
- } from '@openpeepshq/common/lib';
11
+ import { formatEventWhen, isHiddenPost } from '@openpeepshq/common/lib';
16
12
  import { AudioLines, Calendar, CirclePlay, Paperclip } from 'lucide-react';
17
13
  import { cn } from '@openpeepshq/react-ui';
18
14
  import { useT } from '../../i18n';
19
15
  import { Avatar } from '../profile';
20
16
  import { isAudioAttachment } from './pieces/AudioAttachment';
17
+ import { TruncatedMarkdown } from './TruncatedMarkdown';
21
18
 
22
19
  export type CompactPost = Pick<
23
20
  PublicReplyPost,
@@ -119,7 +116,6 @@ const compactThumb = (post: CompactPost, t: TFunction): ReactNode => {
119
116
  const CompactNoteBody = ({ post, t }: { post: CompactPost; t: TFunction }) => {
120
117
  if (post.data?.type !== 'note') return null;
121
118
  const attachments = attachmentsOf(post);
122
- const text = markdownPlainText(post.data.content);
123
119
  const hasVisual = !!visualAttachment(attachments);
124
120
  const file = !hasVisual ? attachments[0] : undefined;
125
121
  const audio = !!file && isAudioAttachment(file);
@@ -129,10 +125,16 @@ const CompactNoteBody = ({ post, t }: { post: CompactPost; t: TFunction }) => {
129
125
  ? t('posts.compact.audio', { defaultValue: 'Audio' })
130
126
  : t('posts.compact.document', { defaultValue: 'Document' }))
131
127
  : undefined;
132
- if (!text && !docName) return null;
128
+ if (!post.data.content && !docName) return null;
133
129
  return (
134
130
  <>
135
- {text ? <p className="line-clamp-2 break-words text-sm">{text}</p> : null}
131
+ <TruncatedMarkdown
132
+ source={post.data.content ?? ''}
133
+ maxBlocks={1}
134
+ maxChars={80}
135
+ maxLines={1}
136
+ className="break-words text-sm text-muted-foreground"
137
+ />
136
138
  {docName ? (
137
139
  <p className="text-muted-foreground flex items-center gap-1 text-xs">
138
140
  {audio ? (
@@ -156,11 +158,16 @@ const CompactQuestionBody = ({
156
158
  }) => {
157
159
  if (post.data?.type !== 'question') return null;
158
160
  const data = post.data as Question;
159
- const text = markdownPlainText(data.content);
160
161
  const optionCount = data.options?.length ?? 0;
161
162
  return (
162
163
  <>
163
- {text ? <p className="line-clamp-2 break-words text-sm">{text}</p> : null}
164
+ <TruncatedMarkdown
165
+ source={data.content ?? ''}
166
+ maxBlocks={1}
167
+ maxChars={80}
168
+ maxLines={1}
169
+ className="break-words text-sm text-muted-foreground"
170
+ />
164
171
  {optionCount > 0 ? (
165
172
  <p className="text-muted-foreground truncate text-xs">
166
173
  {t('posts.compact.pollOptions', {
@@ -0,0 +1,91 @@
1
+ import { type ReactNode } from 'react';
2
+ import { truncateMarkdown } from '@openpeepshq/common/lib';
3
+ import { Popover, PopoverContent, PopoverTrigger } from '@openpeepshq/react-ui';
4
+ import { useT } from '../../i18n';
5
+ import { PostMarkdown } from './Markdown';
6
+ import { OPENPEEPS_POST_CAPTION_CLASS } from '../markdown/classes';
7
+
8
+ export interface TruncatedMarkdownProps {
9
+ /** Full markdown content; rendered in the popover when `interactive`. */
10
+ source: string;
11
+ /** Pre-truncated excerpt. When omitted, computed via `truncateMarkdown`. */
12
+ snippet?: string;
13
+ maxBlocks?: number;
14
+ maxChars?: number;
15
+ /** Lines the excerpt is clamped to (only when `interactive`). */
16
+ maxLines?: number;
17
+ /**
18
+ * When true, the excerpt is clamped and a "Show more" control reveals the
19
+ * full content in a popover (click/tap; hover on desktop via the popover).
20
+ * When false, the excerpt renders as-is — callers that own their own
21
+ * navigation keep it plain.
22
+ */
23
+ interactive?: boolean;
24
+ className?: string;
25
+ }
26
+
27
+ const clampClass = (n: number) => `line-clamp-${n as 1 | 2 | 3 | 4 | 5 | 6}`;
28
+
29
+ /**
30
+ * Single rendering surface for abbreviated markdown. The excerpt is always
31
+ * produced by the markdown-aware `truncateMarkdown` (links, images and
32
+ * emphasis are never severed), so every abbreviated preview renders as real
33
+ * markdown instead of raw text. Call sites with their own read-more navigation
34
+ * (e.g. Article) keep `interactive` off and render the link themselves.
35
+ */
36
+ export const TruncatedMarkdown = ({
37
+ source,
38
+ snippet: snippetProp,
39
+ maxBlocks = 2,
40
+ maxChars = 240,
41
+ maxLines = 2,
42
+ interactive = true,
43
+ className,
44
+ }: TruncatedMarkdownProps): ReactNode => {
45
+ const t = useT();
46
+ const excerpt = snippetProp ?? truncateMarkdown(source, maxBlocks, maxChars);
47
+ if (!excerpt) return null;
48
+
49
+ const excerptClass = [
50
+ OPENPEEPS_POST_CAPTION_CLASS,
51
+ interactive && maxLines > 0 ? clampClass(maxLines) : '',
52
+ className ?? '',
53
+ ]
54
+ .join(' ')
55
+ .trim();
56
+
57
+ const body = <PostMarkdown source={excerpt} className={excerptClass} />;
58
+
59
+ if (!interactive) return body;
60
+
61
+ return (
62
+ <div className="inline-block max-w-full align-baseline">
63
+ {body}
64
+ <Popover>
65
+ <PopoverTrigger asChild>
66
+ <button
67
+ type="button"
68
+ onClick={(e) => {
69
+ e.stopPropagation();
70
+ e.preventDefault();
71
+ }}
72
+ aria-label={t('posts.truncatedMarkdown.showHint', {
73
+ defaultValue: 'Show more',
74
+ })}
75
+ className="text-primary inline-flex items-center gap-1 text-xs font-medium underline decoration-transparent underline-offset-2 hover:decoration-inherit"
76
+ >
77
+ {t('posts.truncatedMarkdown.show', { defaultValue: 'Show more' })}
78
+ </button>
79
+ </PopoverTrigger>
80
+ <PopoverContent
81
+ side="top"
82
+ align="start"
83
+ sideOffset={8}
84
+ className="bg-popover text-popover-foreground z-50 max-w-xs rounded-md border p-3 shadow-md"
85
+ >
86
+ <PostMarkdown source={source} />
87
+ </PopoverContent>
88
+ </Popover>
89
+ </div>
90
+ );
91
+ };
@@ -1,4 +1,8 @@
1
1
  import type { PublicPost } from '@openpeepshq/common/types';
2
+ import { firstNWords as _firstNWords } from '@openpeepshq/common/lib';
3
+
4
+ /** @deprecated Use `firstNWords` from `@openpeepshq/common/lib` directly. */
5
+ export const firstNWords = _firstNWords;
2
6
 
3
7
  /** Splits a string into user-visible grapheme clusters (so emojis don't get chopped). */
4
8
  export const stringToSegments = (text: string) =>
@@ -12,21 +16,3 @@ export const postReactionStats = (post: PublicPost): string => {
12
16
  ].join('');
13
17
  return `${uniqueEmojis} ${post.reactions?.length ?? 0}`;
14
18
  };
15
-
16
- /** Truncates markdown to roughly the first N words, preserving links. */
17
- export const firstNWords = (
18
- markdown: string | undefined,
19
- n: number,
20
- ): string => {
21
- if (!markdown) return '';
22
- const regex = /\[.*?\]\(.*?\)|(\w+)/g;
23
- let wordCount = 0;
24
- const out: string[] = [];
25
- let match: RegExpExecArray | null;
26
- while ((match = regex.exec(markdown)) !== null) {
27
- if (wordCount >= n) break;
28
- out.push(match[0]);
29
- wordCount++;
30
- }
31
- return out.join(' ');
32
- };
@@ -6,6 +6,8 @@ export { FeedPostContent } from './FeedPostContent';
6
6
  export { PostDetail } from './PostDetail';
7
7
  export type { PostDetailProps } from './PostDetail';
8
8
  export { PostMarkdown, OpenpeepsMarkdown } from './Markdown';
9
+ export { TruncatedMarkdown } from './TruncatedMarkdown';
10
+ export type { TruncatedMarkdownProps } from './TruncatedMarkdown';
9
11
  export { PostMenu } from './pieces/PostMenu';
10
12
  export type { PostMenuProps } from './pieces/PostMenu';
11
13
  export { ShareMenu } from './pieces/ShareMenu';
@@ -44,6 +44,33 @@ export function EventLocation({
44
44
  : undefined;
45
45
  const jamLink = getJamUrl(post.id, origin, occurrence);
46
46
 
47
+ if (preview && staticRender) {
48
+ if (physicalLocation) {
49
+ return (
50
+ <span className="text-sm">
51
+ {truncate
52
+ ? truncateText(physicalLocation.text)
53
+ : physicalLocation.text}
54
+ </span>
55
+ );
56
+ }
57
+ if (event.jam) {
58
+ return (
59
+ <a href={jamLink} className="text-primary text-sm underline">
60
+ {t('events.location.jam', { defaultValue: 'Jam Event' })}
61
+ </a>
62
+ );
63
+ }
64
+ if (event.url) {
65
+ return (
66
+ <a href={event.url} className="text-primary text-sm underline">
67
+ {t('events.location.online', { defaultValue: 'Online' })}
68
+ </a>
69
+ );
70
+ }
71
+ return null;
72
+ }
73
+
47
74
  if (preview) {
48
75
  return (
49
76
  <div className="flex items-center gap-1 text-sm">
@@ -23,6 +23,7 @@ export const EventRsvpButton = ({
23
23
  myRsvp,
24
24
  canRsvp,
25
25
  rsvpClosed,
26
+ hideRsvpButton,
26
27
  recurring,
27
28
  defaultId,
28
29
  occurrences,
@@ -83,6 +84,8 @@ export const EventRsvpButton = ({
83
84
  );
84
85
  }
85
86
 
87
+ if (hideRsvpButton) return null;
88
+
86
89
  const scopeDialog =
87
90
  pending && recurring && !lockToOccurrence ? (
88
91
  <EventRsvpScopeDialog
@@ -247,13 +247,19 @@ export function PollContent({ post }: PollContentProps) {
247
247
 
248
248
  <div className="text-muted-foreground mt-4 flex flex-wrap items-center gap-3 text-sm">
249
249
  <span>
250
- {votes.length || 0} {t('posts.vote.count', { defaultValue: 'votes' })}
250
+ {t('posts.vote.count', {
251
+ count: votes.length || 0,
252
+ defaultValue: 'votes',
253
+ })}
251
254
  </span>
252
255
  {pollData.expiresAt ? (
253
256
  <span>
254
257
  {hasPollEnded
255
258
  ? t('posts.poll.ended', { defaultValue: 'Poll ended' })
256
- : `${formatDistanceToNow(pollData.expiresAt)} ${t('posts.poll.timeLeft', { defaultValue: 'left' })}`}
259
+ : t('posts.poll.timeLeft', {
260
+ time: formatDistanceToNow(pollData.expiresAt),
261
+ defaultValue: '{{time}} left',
262
+ })}
257
263
  </span>
258
264
  ) : null}
259
265
  {hasVoted && !hasPollEnded ? (
@@ -62,7 +62,7 @@ export function ArticleForm({
62
62
  </h2>
63
63
 
64
64
  <Label
65
- title={t('articles.form.title', { defaultValue: 'New Article' })}
65
+ title={t('articles.form.titleInput', { defaultValue: 'Title' })}
66
66
  htmlFor="article-title"
67
67
  >
68
68
  <Input
@@ -10,6 +10,10 @@ import { isBlobUrl, revokeBlobUrl } from '../attachmentPreview';
10
10
  export interface ComposeAttachmentsProps {
11
11
  attachments: MediaAttachmentData[];
12
12
  onChange: (attachments: MediaAttachmentData[]) => void;
13
+ /** Image picker may select several files at once (resource galleries). */
14
+ multipleImages?: boolean;
15
+ /** Audio picker may select several files at once (default: yes). */
16
+ multipleAudio?: boolean;
13
17
  }
14
18
 
15
19
  const AUDIO_NAME = /\.(mp3|wav|ogg|oga|m4a|aac|flac|opus|weba)$/i;
@@ -59,6 +63,8 @@ export interface ComposeAttachmentsApi {
59
63
  export function useComposeAttachments({
60
64
  attachments,
61
65
  onChange,
66
+ multipleImages = false,
67
+ multipleAudio = true,
62
68
  }: ComposeAttachmentsProps): ComposeAttachmentsApi {
63
69
  const imageInputRef = useRef<HTMLInputElement>(null);
64
70
  const audioInputRef = useRef<HTMLInputElement>(null);
@@ -130,6 +136,20 @@ export function useComposeAttachments({
130
136
  enqueueFile(processed);
131
137
  };
132
138
 
139
+ // A single pick keeps the crop/alt-text flow; a bulk pick is enqueued
140
+ // directly, since per-file cropping isn't practical for a gallery batch.
141
+ const handleImageFilesSelected = async (files: File[]) => {
142
+ const first = files[0];
143
+ if (!first) return;
144
+ if (files.length === 1) {
145
+ await handleImageSelected(first);
146
+ return;
147
+ }
148
+ for (const file of files) {
149
+ enqueueFile(await convertToWebpIfHeic(file));
150
+ }
151
+ };
152
+
133
153
  const onUploaded = (key: string, attachment: MediaAttachment) =>
134
154
  setItems((prev) =>
135
155
  prev.map((i) => {
@@ -204,10 +224,11 @@ export function useComposeAttachments({
204
224
  ref={imageInputRef}
205
225
  type="file"
206
226
  accept="image/*,video/*,.mkv"
227
+ multiple={multipleImages}
207
228
  className="hidden"
208
229
  onChange={(e) => {
209
- const file = e.target.files?.[0];
210
- if (file) void handleImageSelected(file);
230
+ const files = e.target.files;
231
+ if (files?.length) void handleImageFilesSelected(Array.from(files));
211
232
  e.target.value = '';
212
233
  }}
213
234
  />
@@ -215,7 +236,7 @@ export function useComposeAttachments({
215
236
  ref={audioInputRef}
216
237
  type="file"
217
238
  accept="audio/*,.mp3,.wav,.ogg,.m4a,.aac,.flac,.opus,.weba"
218
- multiple
239
+ multiple={multipleAudio}
219
240
  className="hidden"
220
241
  onChange={(e) => {
221
242
  const files = e.target.files;