@flamingo-stack/openframe-frontend-core 0.0.296 → 0.0.297
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/README.md +9 -0
- package/dist/{chunk-7RIYT7ZH.js → chunk-2QG57XOJ.js} +1067 -205
- package/dist/chunk-2QG57XOJ.js.map +1 -0
- package/dist/{chunk-WHMATDVP.js → chunk-3JIQVE7T.js} +9 -15
- package/dist/{chunk-WHMATDVP.js.map → chunk-3JIQVE7T.js.map} +1 -1
- package/dist/{chunk-GLLDTKZK.cjs → chunk-4PSQS3SW.cjs} +7 -9
- package/dist/chunk-4PSQS3SW.cjs.map +1 -0
- package/dist/{chunk-OY7OF7E7.js → chunk-4TLE6VLU.js} +30 -24
- package/dist/chunk-4TLE6VLU.js.map +1 -0
- package/dist/{chunk-W6M2FLLT.cjs → chunk-53FUMSZ5.cjs} +40 -46
- package/dist/chunk-53FUMSZ5.cjs.map +1 -0
- package/dist/{chunk-D3LEFMOA.cjs → chunk-54KNMC2R.cjs} +3 -3
- package/dist/{chunk-D3LEFMOA.cjs.map → chunk-54KNMC2R.cjs.map} +1 -1
- package/dist/{chunk-EYEW6PTA.cjs → chunk-6C526VNN.cjs} +358 -118
- package/dist/chunk-6C526VNN.cjs.map +1 -0
- package/dist/{chunk-XREEV72C.cjs → chunk-7OVGB2DQ.cjs} +19 -25
- package/dist/chunk-7OVGB2DQ.cjs.map +1 -0
- package/dist/{chunk-6GCI7JOE.js → chunk-AD6C23QY.js} +8 -7
- package/dist/{chunk-6GCI7JOE.js.map → chunk-AD6C23QY.js.map} +1 -1
- package/dist/chunk-F5OB2YAL.cjs +144 -0
- package/dist/chunk-F5OB2YAL.cjs.map +1 -0
- package/dist/chunk-FBWXMMRB.cjs +2 -0
- package/dist/chunk-FBWXMMRB.cjs.map +1 -0
- package/dist/{chunk-YIGPRLQY.cjs → chunk-FCDQNTDG.cjs} +21 -20
- package/dist/chunk-FCDQNTDG.cjs.map +1 -0
- package/dist/{chunk-IE6OU3WQ.cjs → chunk-FQOTC3UU.cjs} +318 -16
- package/dist/chunk-FQOTC3UU.cjs.map +1 -0
- package/dist/{chunk-QHIXS3W2.cjs → chunk-GUTS7HGA.cjs} +11590 -2105
- package/dist/chunk-GUTS7HGA.cjs.map +1 -0
- package/dist/chunk-GZ4C3XW6.js +2 -0
- package/dist/chunk-GZ4C3XW6.js.map +1 -0
- package/dist/{chunk-5P3B2LZW.js → chunk-IL47XWV5.js} +8 -14
- package/dist/{chunk-5P3B2LZW.js.map → chunk-IL47XWV5.js.map} +1 -1
- package/dist/{chunk-LCNMR277.js → chunk-IZ7JSBFP.js} +1 -1
- package/dist/chunk-IZ7JSBFP.js.map +1 -0
- package/dist/{chunk-EL6QLAWX.js → chunk-JALO4TAZ.js} +357 -55
- package/dist/chunk-JALO4TAZ.js.map +1 -0
- package/dist/{chunk-AQOWFSMB.cjs → chunk-L6PSSIUQ.cjs} +1 -1
- package/dist/chunk-L6PSSIUQ.cjs.map +1 -0
- package/dist/{chunk-MBFWU2EM.js → chunk-L7ULJKG7.js} +6 -10
- package/dist/{chunk-MBFWU2EM.js.map → chunk-L7ULJKG7.js.map} +1 -1
- package/dist/{chunk-K2PFPBMF.js → chunk-PC746XCO.js} +15050 -5565
- package/dist/chunk-PC746XCO.js.map +1 -0
- package/dist/{chunk-3ZXUQQL4.js → chunk-PI4WSYQV.js} +2 -2
- package/dist/{chunk-E4XABBSU.js → chunk-PWQUAVA3.js} +338 -98
- package/dist/chunk-PWQUAVA3.js.map +1 -0
- package/dist/chunk-SA2WPJVO.js +144 -0
- package/dist/chunk-SA2WPJVO.js.map +1 -0
- package/dist/{chunk-X6BV7MB7.cjs → chunk-UNVE2SDJ.cjs} +37 -31
- package/dist/chunk-UNVE2SDJ.cjs.map +1 -0
- package/dist/{chunk-5E2HOSSH.cjs → chunk-WMSTJAZT.cjs} +913 -51
- package/dist/chunk-WMSTJAZT.cjs.map +1 -0
- package/dist/{chunk-ZP4AVIZP.js → chunk-X4DOXQRT.js} +4 -6
- package/dist/{chunk-ZP4AVIZP.js.map → chunk-X4DOXQRT.js.map} +1 -1
- package/dist/{chunk-X647HY3F.cjs → chunk-YBYI62OE.cjs} +33 -37
- package/dist/chunk-YBYI62OE.cjs.map +1 -0
- package/dist/components/case-studies/index.cjs +126 -0
- package/dist/components/case-studies/index.cjs.map +1 -0
- package/dist/components/case-studies/index.d.ts +2 -0
- package/dist/components/case-studies/index.d.ts.map +1 -0
- package/dist/components/case-studies/index.js +126 -0
- package/dist/components/case-studies/index.js.map +1 -0
- package/dist/components/case-studies/share-experience-section.d.ts +48 -0
- package/dist/components/case-studies/share-experience-section.d.ts.map +1 -0
- package/dist/components/chat/index.cjs +8 -18
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +75 -85
- package/dist/components/contact/index.cjs +8 -15
- package/dist/components/contact/index.cjs.map +1 -1
- package/dist/components/contact/index.js +7 -14
- package/dist/components/docs/doc-viewer.d.ts +39 -2
- package/dist/components/docs/doc-viewer.d.ts.map +1 -1
- package/dist/components/docs/docs-hub-page.d.ts +46 -0
- package/dist/components/docs/docs-hub-page.d.ts.map +1 -0
- package/dist/components/docs/index.cjs +17 -9
- package/dist/components/docs/index.cjs.map +1 -1
- package/dist/components/docs/index.d.ts +4 -0
- package/dist/components/docs/index.d.ts.map +1 -1
- package/dist/components/docs/index.js +16 -8
- package/dist/components/docs/skeletons.d.ts +32 -0
- package/dist/components/docs/skeletons.d.ts.map +1 -0
- package/dist/components/docs/use-docs-resolve-link.d.ts +20 -0
- package/dist/components/docs/use-docs-resolve-link.d.ts.map +1 -0
- package/dist/components/docs/use-document-tree.d.ts.map +1 -1
- package/dist/components/embeds/embed-container.d.ts +37 -0
- package/dist/components/embeds/embed-container.d.ts.map +1 -0
- package/dist/components/embeds/embed-iframe.d.ts.map +1 -1
- package/dist/components/embeds/file-download-card.d.ts +18 -0
- package/dist/components/embeds/file-download-card.d.ts.map +1 -0
- package/dist/components/embeds/index.cjs +38 -15
- package/dist/components/embeds/index.cjs.map +1 -1
- package/dist/components/embeds/index.d.ts +8 -0
- package/dist/components/embeds/index.d.ts.map +1 -1
- package/dist/components/embeds/index.js +40 -17
- package/dist/components/embeds/linkedin-embed-client.d.ts +8 -0
- package/dist/components/embeds/linkedin-embed-client.d.ts.map +1 -0
- package/dist/components/embeds/markdown-image.d.ts +5 -0
- package/dist/components/embeds/markdown-image.d.ts.map +1 -0
- package/dist/components/embeds/reddit-embed-client.d.ts +7 -0
- package/dist/components/embeds/reddit-embed-client.d.ts.map +1 -0
- package/dist/components/embeds/rich-markdown-runtime.d.ts +46 -0
- package/dist/components/embeds/rich-markdown-runtime.d.ts.map +1 -0
- package/dist/components/embeds/twitter-embed-client.d.ts +8 -0
- package/dist/components/embeds/twitter-embed-client.d.ts.map +1 -0
- package/dist/components/faq/index.cjs +9 -16
- package/dist/components/faq/index.cjs.map +1 -1
- package/dist/components/faq/index.js +8 -15
- package/dist/components/features/index.cjs +8 -16
- package/dist/components/features/index.cjs.map +1 -1
- package/dist/components/features/index.js +24 -32
- package/dist/components/index.cjs +257 -452
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +781 -976
- package/dist/components/index.js.map +1 -1
- package/dist/components/layout/page-header.d.ts +78 -0
- package/dist/components/layout/page-header.d.ts.map +1 -0
- package/dist/components/layout/page-layout.d.ts +10 -1
- package/dist/components/layout/page-layout.d.ts.map +1 -1
- package/dist/components/layout/page-with-header.d.ts +67 -0
- package/dist/components/layout/page-with-header.d.ts.map +1 -0
- package/dist/components/layout/title-block.d.ts +17 -1
- package/dist/components/layout/title-block.d.ts.map +1 -1
- package/dist/components/navigation/index.cjs +7 -15
- package/dist/components/navigation/index.cjs.map +1 -1
- package/dist/components/navigation/index.js +9 -17
- package/dist/components/onboarding-guides/index.cjs +35 -36
- package/dist/components/onboarding-guides/index.cjs.map +1 -1
- package/dist/components/onboarding-guides/index.js +13 -14
- package/dist/components/onboarding-guides/index.js.map +1 -1
- package/dist/components/onboarding-guides/onboarding-guide-detail-view.d.ts +1 -1
- package/dist/components/onboarding-guides/onboarding-guide-detail-view.d.ts.map +1 -1
- package/dist/components/related-content/index.cjs +9 -16
- package/dist/components/related-content/index.cjs.map +1 -1
- package/dist/components/related-content/index.js +8 -15
- package/dist/components/shared/dev-section/dev-section-page.d.ts +9 -0
- package/dist/components/shared/dev-section/dev-section-page.d.ts.map +1 -1
- package/dist/components/shared/dev-section/dev-section-view.d.ts.map +1 -1
- package/dist/components/shared/dev-section/index.d.ts +1 -1
- package/dist/components/shared/dev-section/index.d.ts.map +1 -1
- package/dist/components/shared/doc-search/use-doc-search.d.ts.map +1 -1
- package/dist/components/shared/legal-document/legal-document-page.d.ts.map +1 -1
- package/dist/components/shared/product-release/release-detail-page.d.ts.map +1 -1
- package/dist/components/tickets/index.cjs +100 -112
- package/dist/components/tickets/index.cjs.map +1 -1
- package/dist/components/tickets/index.js +20 -32
- package/dist/components/tickets/index.js.map +1 -1
- package/dist/components/ui/file-manager/index.cjs +50 -52
- package/dist/components/ui/file-manager/index.cjs.map +1 -1
- package/dist/components/ui/file-manager/index.js +4 -6
- package/dist/components/ui/file-manager/index.js.map +1 -1
- package/dist/components/ui/index.cjs +13 -19
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +133 -139
- package/dist/components/ui/release-changelog-section.d.ts +6 -2
- package/dist/components/ui/release-changelog-section.d.ts.map +1 -1
- package/dist/components/ui/rich-markdown-renderer.d.ts +34 -0
- package/dist/components/ui/rich-markdown-renderer.d.ts.map +1 -0
- package/dist/components/ui/simple-markdown-renderer.d.ts +2 -8
- package/dist/components/ui/simple-markdown-renderer.d.ts.map +1 -1
- package/dist/contexts/chat-runtime-context.d.ts +14 -0
- package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
- package/dist/contexts/index.cjs +3 -3
- package/dist/contexts/index.js +5 -5
- package/dist/embed-shims/index.cjs +3 -3
- package/dist/embed-shims/index.cjs.map +1 -1
- package/dist/embed-shims/index.js +4 -4
- package/dist/hooks/index.cjs +4 -9
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js +6 -11
- package/dist/index.cjs +14 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +362 -368
- package/dist/types/doc-source.d.ts +31 -1
- package/dist/types/doc-source.d.ts.map +1 -1
- package/dist/utils/index.cjs +4 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/page-header-constants.d.ts +15 -0
- package/dist/utils/page-header-constants.d.ts.map +1 -0
- package/dist/utils/social-embed-cache.d.ts +29 -0
- package/dist/utils/social-embed-cache.d.ts.map +1 -0
- package/package.json +7 -1
- package/src/components/case-studies/index.ts +4 -0
- package/src/components/case-studies/share-experience-section.tsx +185 -0
- package/src/components/chat/embeddable-chat.tsx +1 -1
- package/src/components/docs/doc-viewer.tsx +111 -19
- package/src/components/docs/docs-hub-page.tsx +149 -0
- package/src/components/docs/index.ts +17 -0
- package/src/components/docs/skeletons.tsx +138 -0
- package/src/components/docs/use-docs-resolve-link.ts +52 -0
- package/src/components/docs/use-document-tree.ts +21 -0
- package/src/components/embeds/embed-container.tsx +80 -0
- package/src/components/embeds/embed-iframe.tsx +7 -9
- package/src/components/embeds/file-download-card.tsx +54 -0
- package/src/components/embeds/index.ts +30 -0
- package/src/components/embeds/linkedin-embed-client.tsx +100 -0
- package/src/components/embeds/markdown-image.tsx +88 -0
- package/src/components/embeds/og-link-preview.tsx +13 -13
- package/src/components/embeds/reddit-embed-client.tsx +550 -0
- package/src/components/embeds/rich-markdown-runtime.tsx +79 -0
- package/src/components/embeds/twitter-embed-client.tsx +308 -0
- package/src/components/layout/page-header.tsx +182 -0
- package/src/components/layout/page-layout.tsx +14 -1
- package/src/components/layout/page-with-header.tsx +110 -0
- package/src/components/layout/title-block.tsx +40 -62
- package/src/components/onboarding-guides/onboarding-guide-detail-view.tsx +3 -3
- package/src/components/shared/dev-section/dev-section-page.tsx +9 -1
- package/src/components/shared/dev-section/dev-section-view.tsx +14 -9
- package/src/components/shared/dev-section/index.ts +1 -1
- package/src/components/shared/doc-search/use-doc-search.ts +7 -3
- package/src/components/shared/legal-document/legal-document-page.tsx +2 -2
- package/src/components/shared/product-release/release-detail-page.tsx +6 -4
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/release-changelog-section.tsx +7 -2
- package/src/components/ui/rich-markdown-renderer.tsx +1203 -0
- package/src/components/ui/simple-markdown-renderer.tsx +7 -11
- package/src/contexts/chat-runtime-context.tsx +14 -0
- package/src/types/doc-source.ts +33 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/page-header-constants.ts +15 -0
- package/src/utils/social-embed-cache.ts +391 -0
- package/dist/chunk-26PKDALD.js +0 -2379
- package/dist/chunk-26PKDALD.js.map +0 -1
- package/dist/chunk-3MCHAFHB.js +0 -89
- package/dist/chunk-3MCHAFHB.js.map +0 -1
- package/dist/chunk-5E2HOSSH.cjs.map +0 -1
- package/dist/chunk-66AANIOC.cjs +0 -619
- package/dist/chunk-66AANIOC.cjs.map +0 -1
- package/dist/chunk-6JINAOI7.cjs +0 -311
- package/dist/chunk-6JINAOI7.cjs.map +0 -1
- package/dist/chunk-7RIYT7ZH.js.map +0 -1
- package/dist/chunk-AQOWFSMB.cjs.map +0 -1
- package/dist/chunk-BOCFIKYS.cjs +0 -3009
- package/dist/chunk-BOCFIKYS.cjs.map +0 -1
- package/dist/chunk-D652TJBQ.js +0 -3009
- package/dist/chunk-D652TJBQ.js.map +0 -1
- package/dist/chunk-E4XABBSU.js.map +0 -1
- package/dist/chunk-EL6QLAWX.js.map +0 -1
- package/dist/chunk-EYEW6PTA.cjs.map +0 -1
- package/dist/chunk-FQJK446R.js +0 -1606
- package/dist/chunk-FQJK446R.js.map +0 -1
- package/dist/chunk-GLLDTKZK.cjs.map +0 -1
- package/dist/chunk-IE6OU3WQ.cjs.map +0 -1
- package/dist/chunk-J54Z3OCR.cjs +0 -1606
- package/dist/chunk-J54Z3OCR.cjs.map +0 -1
- package/dist/chunk-K2PFPBMF.js.map +0 -1
- package/dist/chunk-KXCRGTRN.cjs +0 -2379
- package/dist/chunk-KXCRGTRN.cjs.map +0 -1
- package/dist/chunk-LCNMR277.js.map +0 -1
- package/dist/chunk-LFGGF7OT.cjs +0 -449
- package/dist/chunk-LFGGF7OT.cjs.map +0 -1
- package/dist/chunk-M2OCXTNT.js +0 -311
- package/dist/chunk-M2OCXTNT.js.map +0 -1
- package/dist/chunk-ME4EVDFP.js +0 -619
- package/dist/chunk-ME4EVDFP.js.map +0 -1
- package/dist/chunk-OQ6X7ZOC.js +0 -449
- package/dist/chunk-OQ6X7ZOC.js.map +0 -1
- package/dist/chunk-OY7OF7E7.js.map +0 -1
- package/dist/chunk-POKKCWKF.js +0 -354
- package/dist/chunk-POKKCWKF.js.map +0 -1
- package/dist/chunk-QHIXS3W2.cjs.map +0 -1
- package/dist/chunk-TFSYSWPS.cjs +0 -89
- package/dist/chunk-TFSYSWPS.cjs.map +0 -1
- package/dist/chunk-W6M2FLLT.cjs.map +0 -1
- package/dist/chunk-X647HY3F.cjs.map +0 -1
- package/dist/chunk-X6BV7MB7.cjs.map +0 -1
- package/dist/chunk-XREEV72C.cjs.map +0 -1
- package/dist/chunk-YETA25JW.cjs +0 -354
- package/dist/chunk-YETA25JW.cjs.map +0 -1
- package/dist/chunk-YIGPRLQY.cjs.map +0 -1
- /package/dist/{chunk-3ZXUQQL4.js.map → chunk-PI4WSYQV.js.map} +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef } from 'react';
|
|
4
|
+
import { XLogo } from '../icons/x-logo';
|
|
5
|
+
import { socialCache } from '../../utils/social-embed-cache';
|
|
6
|
+
import { TwitterContainer } from './embed-container';
|
|
7
|
+
import { useRichMarkdownRuntime } from './rich-markdown-runtime';
|
|
8
|
+
|
|
9
|
+
// Using inline SVG icons to avoid dependency issues
|
|
10
|
+
const MessageCircleIcon = () => (
|
|
11
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
12
|
+
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/>
|
|
13
|
+
</svg>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const ExternalLinkIcon = () => (
|
|
17
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
18
|
+
<path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/>
|
|
19
|
+
<polyline points="15,3 21,3 21,9"/>
|
|
20
|
+
<line x1="10" y1="14" x2="21" y2="3"/>
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const HeartIcon = () => (
|
|
25
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
26
|
+
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
|
|
27
|
+
</svg>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const RepeatIcon = () => (
|
|
31
|
+
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
32
|
+
<polyline points="17,1 21,5 17,9"/>
|
|
33
|
+
<path d="M3 11V9a4 4 0 0 1 4-4h14"/>
|
|
34
|
+
<polyline points="7,23 3,19 7,15"/>
|
|
35
|
+
<path d="M21 13v2a4 4 0 0 1-4 4H3"/>
|
|
36
|
+
</svg>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const ClockIcon = () => (
|
|
40
|
+
<svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
41
|
+
<circle cx="12" cy="12" r="10"/>
|
|
42
|
+
<polyline points="12,6 12,12 16,14"/>
|
|
43
|
+
</svg>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const UserIcon = () => (
|
|
47
|
+
<svg width="12" height="12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
48
|
+
<path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/>
|
|
49
|
+
<circle cx="12" cy="7" r="4"/>
|
|
50
|
+
</svg>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// X glyph: the lib's standard XLogo (color follows the text context).
|
|
54
|
+
const XIcon = () => <XLogo className="w-5 h-5" color="currentColor" />;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
interface TwitterOEmbedResponse {
|
|
59
|
+
url: string;
|
|
60
|
+
author_name: string;
|
|
61
|
+
author_url: string;
|
|
62
|
+
html: string;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
type: string;
|
|
66
|
+
cache_age: string;
|
|
67
|
+
provider_name: string;
|
|
68
|
+
provider_url: string;
|
|
69
|
+
version: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface TwitterEmbedProps {
|
|
73
|
+
url: string;
|
|
74
|
+
tweetId?: string;
|
|
75
|
+
maxWidth?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function TwitterEmbedClient({ url, tweetId, maxWidth = 700 }: TwitterEmbedProps) {
|
|
79
|
+
const { twitterProxyUrl } = useRichMarkdownRuntime();
|
|
80
|
+
const [tweetData, setTweetData] = useState<TwitterOEmbedResponse | null>(null);
|
|
81
|
+
const [loading, setLoading] = useState(true);
|
|
82
|
+
const [error, setError] = useState<string | null>(null);
|
|
83
|
+
const initializationDone = useRef(false);
|
|
84
|
+
|
|
85
|
+
// Extract tweet ID from URL if not provided
|
|
86
|
+
const extractedTweetId = tweetId || url.match(/status\/(\d+)/)?.[1];
|
|
87
|
+
|
|
88
|
+
// Normalize the Twitter URL
|
|
89
|
+
const tweetUrl = url.includes('twitter.com') || url.includes('x.com')
|
|
90
|
+
? url
|
|
91
|
+
: `https://twitter.com/twitter/status/${extractedTweetId}`;
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
// Only run once
|
|
95
|
+
if (initializationDone.current) return;
|
|
96
|
+
initializationDone.current = true;
|
|
97
|
+
|
|
98
|
+
if (!extractedTweetId) {
|
|
99
|
+
setError('Invalid tweet URL or ID');
|
|
100
|
+
setLoading(false);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Use centralized cache hierarchy
|
|
105
|
+
socialCache.fetchWithHierarchy({
|
|
106
|
+
platform: 'twitter',
|
|
107
|
+
url: tweetUrl,
|
|
108
|
+
apiEndpoint: twitterProxyUrl,
|
|
109
|
+
dataValidator: (data) => data && data.html,
|
|
110
|
+
onDataUpdate: (data) => setTweetData(data),
|
|
111
|
+
onError: (errorMsg) => setError(errorMsg),
|
|
112
|
+
onLoading: (loading) => setLoading(loading)
|
|
113
|
+
});
|
|
114
|
+
}, []); // Empty dependency array - only run once
|
|
115
|
+
|
|
116
|
+
if (loading) {
|
|
117
|
+
return (
|
|
118
|
+
<TwitterContainer>
|
|
119
|
+
<div className="border border-ods-border rounded-lg p-6 bg-ods-card animate-pulse">
|
|
120
|
+
<div className="flex items-center space-x-3 mb-4">
|
|
121
|
+
<div className="w-12 h-12 bg-ods-border rounded-full"></div>
|
|
122
|
+
<div>
|
|
123
|
+
<div className="h-4 bg-ods-border rounded w-32 mb-2"></div>
|
|
124
|
+
<div className="h-3 bg-ods-border rounded w-24"></div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<div className="space-y-2 mb-4">
|
|
128
|
+
<div className="h-4 bg-ods-border rounded w-full"></div>
|
|
129
|
+
<div className="h-4 bg-ods-border rounded w-3/4"></div>
|
|
130
|
+
</div>
|
|
131
|
+
<div className="flex items-center space-x-4">
|
|
132
|
+
<div className="h-4 bg-ods-border rounded w-16"></div>
|
|
133
|
+
<div className="h-4 bg-ods-border rounded w-16"></div>
|
|
134
|
+
<div className="h-4 bg-ods-border rounded w-16"></div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</TwitterContainer>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (error || !tweetData) {
|
|
142
|
+
return (
|
|
143
|
+
<TwitterContainer>
|
|
144
|
+
<div className="border border-ods-border rounded-lg p-6 bg-ods-card">
|
|
145
|
+
<div className="flex items-center space-x-3 text-ods-text-secondary mb-4">
|
|
146
|
+
<XIcon />
|
|
147
|
+
<span>Tweet unavailable</span>
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<div className="text-center">
|
|
151
|
+
<p className="text-ods-text-secondary text-sm mb-4">
|
|
152
|
+
This tweet could not be loaded. It may have been deleted, made private, or the account may be suspended.
|
|
153
|
+
</p>
|
|
154
|
+
<a
|
|
155
|
+
href={url}
|
|
156
|
+
target="_blank"
|
|
157
|
+
rel="noopener noreferrer"
|
|
158
|
+
className="inline-flex items-center space-x-2 px-4 py-2 bg-ods-bg-secondary text-ods-text-primary rounded-md text-sm font-medium hover:bg-ods-bg-tertiary transition-colors"
|
|
159
|
+
>
|
|
160
|
+
<XIcon />
|
|
161
|
+
<span>View on X</span>
|
|
162
|
+
</a>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</TwitterContainer>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Parse the HTML to extract detailed tweet information and media
|
|
170
|
+
const parser = new DOMParser();
|
|
171
|
+
const doc = parser.parseFromString(tweetData.html, 'text/html');
|
|
172
|
+
const blockquote = doc.querySelector('blockquote');
|
|
173
|
+
|
|
174
|
+
// Extract tweet text (remove attribution line)
|
|
175
|
+
const fullText = blockquote?.textContent || '';
|
|
176
|
+
const tweetText = fullText.replace(/- .* \(@.*\).*$/, '').trim();
|
|
177
|
+
|
|
178
|
+
// Extract username from author_url (e.g., https://twitter.com/username)
|
|
179
|
+
const username = tweetData.author_url ? tweetData.author_url.split('/').pop() : '';
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
// Extract any links from the tweet
|
|
184
|
+
const links = Array.from(blockquote?.querySelectorAll('a') || [])
|
|
185
|
+
.map(link => ({
|
|
186
|
+
url: link.href,
|
|
187
|
+
text: link.textContent || link.href
|
|
188
|
+
}))
|
|
189
|
+
.filter(link => !link.url.includes('twitter.com') && !link.url.includes('x.com'));
|
|
190
|
+
|
|
191
|
+
// Format time (simulated - we don't have real timestamp from oEmbed)
|
|
192
|
+
const formatTime = () => {
|
|
193
|
+
return 'on X'; // Simplified since we don't have actual timestamp
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const truncateText = (text: string, maxLength: number = 600) => {
|
|
197
|
+
if (text.length <= maxLength) return text;
|
|
198
|
+
return text.slice(0, maxLength) + '...';
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// Profile picture URL using Unavatar service.
|
|
202
|
+
// The hub used to proxy this via `useProxiedImageUrl` (chat runtime), but
|
|
203
|
+
// docs / blog pages don't mount a chat runtime, so we fetch unavatar
|
|
204
|
+
// directly. Embedders that need a proxy can register a runtime later.
|
|
205
|
+
const getProfilePicUrl = (username: string | undefined) => {
|
|
206
|
+
if (!username) return '';
|
|
207
|
+
return `https://unavatar.io/twitter/${username}`;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<TwitterContainer>
|
|
212
|
+
<div className="border border-ods-border rounded-lg bg-ods-card overflow-hidden">
|
|
213
|
+
{/* Header with Profile Picture */}
|
|
214
|
+
<div className="p-4 border-b border-ods-border">
|
|
215
|
+
<div className="flex items-center justify-between">
|
|
216
|
+
<div className="flex items-center space-x-3">
|
|
217
|
+
{/* User Profile Picture */}
|
|
218
|
+
<div className="w-8 h-8 rounded-full overflow-hidden flex-shrink-0">
|
|
219
|
+
<img
|
|
220
|
+
src={getProfilePicUrl(username)}
|
|
221
|
+
alt={`${tweetData.author_name} profile picture`}
|
|
222
|
+
className="w-full h-full object-cover"
|
|
223
|
+
onError={(e) => {
|
|
224
|
+
// Simple fallback without state updates
|
|
225
|
+
const target = e.target as HTMLImageElement;
|
|
226
|
+
target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjxwYXRoIGQ9Ik0yMCAyMXYtMmE0IDQgMCAwIDAtNC00SDhhNCA0IDAgMCAwLTQgNHYyIi8+PGNpcmNsZSBjeD0iMTIiIGN5PSI3IiByPSI0Ii8+PC9zdmc+';
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
<div>
|
|
231
|
+
<p className="text-ods-text-primary font-medium">@{username}</p>
|
|
232
|
+
<div className="flex items-center space-x-2 text-ods-text-secondary text-sm">
|
|
233
|
+
<UserIcon />
|
|
234
|
+
<span>{tweetData.author_name}</span>
|
|
235
|
+
<ClockIcon />
|
|
236
|
+
<span>{formatTime()}</span>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
{/* Content */}
|
|
244
|
+
<div className="p-4">
|
|
245
|
+
{tweetText && (
|
|
246
|
+
<div
|
|
247
|
+
className="text-ods-text-secondary text-sm leading-relaxed mb-4 overflow-hidden"
|
|
248
|
+
style={{ maxHeight: `${maxWidth - 200}px` }}
|
|
249
|
+
>
|
|
250
|
+
<p className="whitespace-pre-wrap">
|
|
251
|
+
{truncateText(tweetText)}
|
|
252
|
+
</p>
|
|
253
|
+
</div>
|
|
254
|
+
)}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
{/* Links Section */}
|
|
259
|
+
{links.length > 0 && (
|
|
260
|
+
<div className="mb-4 space-y-2">
|
|
261
|
+
{links.map((link, index) => (
|
|
262
|
+
<a
|
|
263
|
+
key={index}
|
|
264
|
+
href={link.url}
|
|
265
|
+
target="_blank"
|
|
266
|
+
rel="noopener noreferrer"
|
|
267
|
+
className="inline-flex items-center space-x-2 text-[#1DA1F2] hover:text-ods-accent transition-colors text-sm"
|
|
268
|
+
>
|
|
269
|
+
<ExternalLinkIcon />
|
|
270
|
+
<span className="underline">{link.text}</span>
|
|
271
|
+
</a>
|
|
272
|
+
))}
|
|
273
|
+
</div>
|
|
274
|
+
)}
|
|
275
|
+
|
|
276
|
+
{/* Stats */}
|
|
277
|
+
<div className="flex items-center space-x-6 text-ods-text-secondary text-sm">
|
|
278
|
+
<div className="flex items-center space-x-1">
|
|
279
|
+
<HeartIcon />
|
|
280
|
+
<span>Likes</span>
|
|
281
|
+
</div>
|
|
282
|
+
<div className="flex items-center space-x-1">
|
|
283
|
+
<RepeatIcon />
|
|
284
|
+
<span>Retweets</span>
|
|
285
|
+
</div>
|
|
286
|
+
<div className="flex items-center space-x-1">
|
|
287
|
+
<MessageCircleIcon />
|
|
288
|
+
<span>Replies</span>
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
{/* Footer */}
|
|
294
|
+
<div className="px-4 py-3 bg-ods-bg-secondary border-t border-ods-border">
|
|
295
|
+
<a
|
|
296
|
+
href={url}
|
|
297
|
+
target="_blank"
|
|
298
|
+
rel="noopener noreferrer"
|
|
299
|
+
className="inline-flex items-center space-x-2 text-ods-accent hover:opacity-80 transition-colors text-sm font-medium"
|
|
300
|
+
>
|
|
301
|
+
<ExternalLinkIcon />
|
|
302
|
+
<span>View on X</span>
|
|
303
|
+
</a>
|
|
304
|
+
</div>
|
|
305
|
+
</div>
|
|
306
|
+
</TwitterContainer>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { cn } from '../../utils/cn'
|
|
5
|
+
import { EntityImage } from '../ui/entity-image'
|
|
6
|
+
import { BackButton } from './back-button'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Page-header primitive — the canonical "back-button + title + subtitle
|
|
10
|
+
* + (optional) image / actions" chrome every lib page uses.
|
|
11
|
+
*
|
|
12
|
+
* Owns the SSOT for the page-header DOM/CSS that the rest of the lib
|
|
13
|
+
* was duplicating: pre-`mb` top padding, h1 typography (`text-h2`), h6
|
|
14
|
+
* subtitle (`text-h6`), the gap between the back button and the title
|
|
15
|
+
* block, and the right-side actions slot. Consumers either render this
|
|
16
|
+
* directly (e.g. `<DocViewer>` / `<DocsHubPage>`) or compose it through
|
|
17
|
+
* the `<TitleBlock>` adapter which adds the `PageActions` /
|
|
18
|
+
* `ActionsMenu` / selector wiring on top.
|
|
19
|
+
*
|
|
20
|
+
* Why this exists: knowledge-hub vs releases sat at different vertical
|
|
21
|
+
* rhythms (px-perfect mismatch on title baseline + subtitle offset)
|
|
22
|
+
* because the docs surface hand-rolled its own chrome instead of going
|
|
23
|
+
* through `TitleBlock`. Centralizing the layout here means every
|
|
24
|
+
* embeddable lib page (DocViewer, DevSectionPage, LegalDocumentPage,
|
|
25
|
+
* OnboardingGuideDetailView) renders pixel-identical title/subtitle/
|
|
26
|
+
* back-button typography + spacing — and a future spacing/typography
|
|
27
|
+
* tweak is one file.
|
|
28
|
+
*/
|
|
29
|
+
export interface PageHeaderProps {
|
|
30
|
+
/** Page title (h1). Plain string — ReactNode is intentionally not
|
|
31
|
+
* supported here so every consumer renders the same typography. */
|
|
32
|
+
title?: string
|
|
33
|
+
/** Optional icon rendered inline before the title text (e.g. the
|
|
34
|
+
* rocket emoji on /releases, the docs icon on /knowledge-base).
|
|
35
|
+
* Same `flex items-center gap-3` row as `<DevSectionView>`'s hero. */
|
|
36
|
+
titleIcon?: React.ReactNode
|
|
37
|
+
/** Page subtitle (description paragraph). */
|
|
38
|
+
subtitle?: string
|
|
39
|
+
/**
|
|
40
|
+
* Render a yellow accent dot (`.`) after the title. Mirrors the
|
|
41
|
+
* hub's legacy `<AdminPageHeader accentDot>` flag — now lib-wide so
|
|
42
|
+
* surfaces like `/knowledge-base` keep their existing accent styling
|
|
43
|
+
* after the migration.
|
|
44
|
+
*/
|
|
45
|
+
accentDot?: boolean
|
|
46
|
+
/** Optional thumbnail / hero image rendered to the left of the
|
|
47
|
+
* title block. Used by entity-image-style headers (onboarding
|
|
48
|
+
* guides, knowledge-base entries). */
|
|
49
|
+
image?: { src: string; alt?: string }
|
|
50
|
+
/** Back-button shown above the title block. Hidden on mobile (matches
|
|
51
|
+
* the existing TitleBlock + DocViewer behavior). */
|
|
52
|
+
backButton?: { label?: string; onClick: () => void }
|
|
53
|
+
/** Right-side actions slot (action buttons / menu / tab selector).
|
|
54
|
+
* Composed externally (e.g. `<TitleBlock>` builds `PageActions` + menu
|
|
55
|
+
* + selector and passes the result here). */
|
|
56
|
+
actions?: React.ReactNode
|
|
57
|
+
/**
|
|
58
|
+
* Visual variant.
|
|
59
|
+
* - `plain` (default): transparent background, no border.
|
|
60
|
+
* - `card`: card background, border, and padding on mobile only —
|
|
61
|
+
* collapses to plain on md+ (legacy `TitleBlock` variant — kept so
|
|
62
|
+
* surfaces that depend on the card affordance don't regress).
|
|
63
|
+
*/
|
|
64
|
+
variant?: 'plain' | 'card'
|
|
65
|
+
/** When the consumer wraps `<PageHeader>` in its OWN spacing container
|
|
66
|
+
* (e.g. `<DevSectionView>`'s `gap-10 flex-col`), the default `mb-l`
|
|
67
|
+
* bottom margin doubles up. Pass `noBottomMargin` to opt out. */
|
|
68
|
+
noBottomMargin?: boolean
|
|
69
|
+
/** Same as `noBottomMargin` for the default `pt-l` top padding. Set
|
|
70
|
+
* this when PageHeader is nested INSIDE another layout that already
|
|
71
|
+
* provides top spacing (e.g. `<DevSectionView>`'s hero, which sits
|
|
72
|
+
* inside `<PageLayout>`'s children flow). */
|
|
73
|
+
noTopPadding?: boolean
|
|
74
|
+
className?: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Title typography — copied verbatim from <DevSectionView>'s hero h1
|
|
78
|
+
// (`src/components/shared/dev-section/dev-section-view.tsx`). The user-
|
|
79
|
+
// reported "header text not aligned" between /knowledge-base and
|
|
80
|
+
// /releases bottomed out here: DevSectionView rendered text-h1 with
|
|
81
|
+
// tracking-[-1.12px] while this component used text-h2 — visually huge
|
|
82
|
+
// gap. Now both render through the exact same class string. DevSectionView
|
|
83
|
+
// is being refactored in this commit to delegate to <PageHeader> so the
|
|
84
|
+
// shared-component claim is enforced at the code level too.
|
|
85
|
+
const TITLE_CLASS = 'text-h1 tracking-[-1.12px] text-ods-text-primary flex items-center gap-3'
|
|
86
|
+
// Subtitle ALWAYS occupies exactly 2 lines of vertical space.
|
|
87
|
+
// `min-h-[56px]` (= 2 × 28px leading) reserves the row height so a
|
|
88
|
+
// single-line subtitle doesn't shrink the header — page-to-page height
|
|
89
|
+
// stays consistent.
|
|
90
|
+
// `line-clamp-2` caps long copy at 2 lines + ellipsis so wrapping doesn't
|
|
91
|
+
// push the search bar down.
|
|
92
|
+
const SUBTITLE_CLASS = "font-['DM_Sans'] font-medium text-[18px] leading-[28px] text-ods-text-secondary max-w-3xl line-clamp-2 min-h-[56px]"
|
|
93
|
+
|
|
94
|
+
export function PageHeader({
|
|
95
|
+
title,
|
|
96
|
+
titleIcon,
|
|
97
|
+
subtitle,
|
|
98
|
+
accentDot,
|
|
99
|
+
image,
|
|
100
|
+
backButton,
|
|
101
|
+
actions,
|
|
102
|
+
variant = 'plain',
|
|
103
|
+
noBottomMargin = false,
|
|
104
|
+
noTopPadding = false,
|
|
105
|
+
className,
|
|
106
|
+
}: PageHeaderProps) {
|
|
107
|
+
return (
|
|
108
|
+
<div
|
|
109
|
+
className={cn(
|
|
110
|
+
'flex items-end justify-between gap-[var(--spacing-system-m)]',
|
|
111
|
+
'md:flex-col md:items-start md:justify-start lg:flex-row lg:items-end lg:justify-between',
|
|
112
|
+
!noTopPadding && 'pt-[var(--spacing-system-l)]',
|
|
113
|
+
variant === 'card'
|
|
114
|
+
? cn(
|
|
115
|
+
'bg-ods-card border-b border-ods-border',
|
|
116
|
+
'px-[var(--spacing-system-l)] pb-[var(--spacing-system-l)]',
|
|
117
|
+
'md:bg-transparent md:border-b-0',
|
|
118
|
+
'md:px-0 md:pb-0',
|
|
119
|
+
!noBottomMargin && 'md:mb-[var(--spacing-system-l)]',
|
|
120
|
+
)
|
|
121
|
+
: !noBottomMargin && 'mb-[var(--spacing-system-l)]',
|
|
122
|
+
className,
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
<div className="flex flex-col gap-[var(--spacing-system-xs)] flex-1 min-w-0">
|
|
126
|
+
{backButton && (
|
|
127
|
+
<BackButton
|
|
128
|
+
onClick={backButton.onClick}
|
|
129
|
+
label={backButton.label}
|
|
130
|
+
className="hidden md:inline-flex"
|
|
131
|
+
/>
|
|
132
|
+
)}
|
|
133
|
+
{/* Title + subtitle stack. Matches `<DevSectionView>`'s hero
|
|
134
|
+
* exactly: `space-y-4` between h1 and p, `flex items-center
|
|
135
|
+
* gap-3` for icon-inline title row, identical class strings.
|
|
136
|
+
* Image (entity-image-style) prefixes the title row, NOT a
|
|
137
|
+
* separate column with its own vertical rhythm — that's the
|
|
138
|
+
* legacy TitleBlock 2-col layout which broke the title-to-
|
|
139
|
+
* subtitle gap. */}
|
|
140
|
+
{(title || subtitle || image || titleIcon) && (
|
|
141
|
+
<div className="space-y-4">
|
|
142
|
+
{(title || image || titleIcon) && (
|
|
143
|
+
<h1 className={TITLE_CLASS}>
|
|
144
|
+
{image && (
|
|
145
|
+
<EntityImage
|
|
146
|
+
src={image.src}
|
|
147
|
+
alt={image.alt}
|
|
148
|
+
fallbackText={image.alt || title}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
{titleIcon}
|
|
152
|
+
{title && (
|
|
153
|
+
<span>
|
|
154
|
+
{title}
|
|
155
|
+
{accentDot && <span className="text-ods-accent">.</span>}
|
|
156
|
+
</span>
|
|
157
|
+
)}
|
|
158
|
+
</h1>
|
|
159
|
+
)}
|
|
160
|
+
{(title || titleIcon || image) && (
|
|
161
|
+
// Always render the subtitle <p> when the title block exists,
|
|
162
|
+
// even when `subtitle` is empty — `SUBTITLE_CLASS` reserves
|
|
163
|
+
// `min-h-[56px]` so headers WITH and WITHOUT subtitles share a
|
|
164
|
+
// baseline (the JSDoc on SUBTITLE_CLASS claims "ALWAYS occupies
|
|
165
|
+
// exactly 2 lines"; gating the <p> on truthy `subtitle` broke
|
|
166
|
+
// that contract — pages without subtitle were ~56px shorter).
|
|
167
|
+
// Falsy subtitles render an NBSP placeholder so the empty <p>
|
|
168
|
+
// still takes its reserved height.
|
|
169
|
+
<p className={SUBTITLE_CLASS}>{subtitle || ' '}</p>
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
{actions && (
|
|
176
|
+
<div className="flex gap-2 items-center shrink-0">{actions}</div>
|
|
177
|
+
)}
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export default PageHeader
|
|
@@ -10,6 +10,11 @@ export interface PageLayoutProps {
|
|
|
10
10
|
children: React.ReactNode
|
|
11
11
|
title?: string
|
|
12
12
|
subtitle?: string
|
|
13
|
+
/** Inline icon rendered before the title text — forwarded to
|
|
14
|
+
* TitleBlock/PageHeader. Same shape as DevSectionPage's hero icon. */
|
|
15
|
+
titleIcon?: React.ReactNode
|
|
16
|
+
/** Yellow accent dot after the title — forwarded to TitleBlock/PageHeader. */
|
|
17
|
+
accentDot?: boolean
|
|
13
18
|
image?: { src: string; alt?: string }
|
|
14
19
|
backButton?: { label?: string; onClick: () => void }
|
|
15
20
|
actions?: PageActionButton[]
|
|
@@ -33,6 +38,8 @@ export function PageLayout({
|
|
|
33
38
|
children,
|
|
34
39
|
title,
|
|
35
40
|
subtitle,
|
|
41
|
+
titleIcon,
|
|
42
|
+
accentDot,
|
|
36
43
|
image,
|
|
37
44
|
backButton,
|
|
38
45
|
actions,
|
|
@@ -46,14 +53,16 @@ export function PageLayout({
|
|
|
46
53
|
}: PageLayoutProps) {
|
|
47
54
|
const hasActions = actions && actions.length > 0
|
|
48
55
|
const needsBottomPadding = hasActions && actionsVariant === 'primary-buttons'
|
|
49
|
-
const hasHeader = showHeader && (title || subtitle || image || backButton || hasActions || selector)
|
|
56
|
+
const hasHeader = showHeader && (title || subtitle || titleIcon || image || backButton || hasActions || selector)
|
|
50
57
|
|
|
51
58
|
return (
|
|
52
59
|
<div className={cn('flex flex-col w-full', className)}>
|
|
53
60
|
{hasHeader && (
|
|
54
61
|
<TitleBlock
|
|
55
62
|
title={title}
|
|
63
|
+
titleIcon={titleIcon}
|
|
56
64
|
subtitle={subtitle}
|
|
65
|
+
accentDot={accentDot}
|
|
57
66
|
image={image}
|
|
58
67
|
backButton={backButton}
|
|
59
68
|
actions={actions}
|
|
@@ -74,4 +83,8 @@ export function PageLayout({
|
|
|
74
83
|
export type { PageActionButton } from '../ui/page-actions'
|
|
75
84
|
export { TitleBlock } from './title-block'
|
|
76
85
|
export type { TitleBlockProps } from './title-block'
|
|
86
|
+
export { PageHeader } from './page-header'
|
|
87
|
+
export type { PageHeaderProps } from './page-header'
|
|
88
|
+
export { PageWithHeader } from './page-with-header'
|
|
89
|
+
export type { PageWithHeaderProps } from './page-with-header'
|
|
77
90
|
export default PageLayout
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { useRouter } from '../../embed-shims/next-navigation'
|
|
5
|
+
import { PageShell } from './article-detail-layout'
|
|
6
|
+
import { PageLayout } from './page-layout'
|
|
7
|
+
import { PageHeader, type PageHeaderProps } from './page-header'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `<PageWithHeader>` — the canonical 4-layer unified-chrome wrapper that
|
|
11
|
+
* every public lib/hub page now uses (Knowledge Hub, Roadmap, FAQs,
|
|
12
|
+
* Authors, Blog, Vendors, Case Studies, Interviews, Investor Updates,
|
|
13
|
+
* /webinars-/podcasts-/events, hub admin-but-public pages, …).
|
|
14
|
+
*
|
|
15
|
+
* Renders the same JSX tree every consumer was hand-rolling individually
|
|
16
|
+
* before this helper landed:
|
|
17
|
+
*
|
|
18
|
+
* PageShell ← bg-ods-bg, min-h-screen, max-w-[1920px],
|
|
19
|
+
* page-shell-px/pt/pb gutters
|
|
20
|
+
* PageLayout backButton ← TitleBlock → PageHeader #1 (back-btn row
|
|
21
|
+
* only, pt-l + mb-l)
|
|
22
|
+
* div.w-full.flex-col.gap-10 ← matches DevSectionView's hero container
|
|
23
|
+
* PageHeader title/subtitle ← PageHeader #2 (noTopPadding +
|
|
24
|
+
* titleIcon accentDot noBottomMargin so PageLayout's gap-l owns
|
|
25
|
+
* noTopPadding the spacing between #1 and #2)
|
|
26
|
+
* noBottomMargin
|
|
27
|
+
* children ← page-specific body (search, lists, forms)
|
|
28
|
+
*
|
|
29
|
+
* Why this exists: 15+ pages copy-pasted the EXACT same nesting + the
|
|
30
|
+
* EXACT same `noTopPadding + noBottomMargin + accentDot` triplet on the
|
|
31
|
+
* inner `<PageHeader>`. Forgetting one of those flags collapsed the gap
|
|
32
|
+
* to ~8px (the FAQs-vs-Onboarding-Guides bug). Centralizing the chain
|
|
33
|
+
* here makes the spacing invariant compiler-enforced — consumers can't
|
|
34
|
+
* pick the wrong combination.
|
|
35
|
+
*
|
|
36
|
+
* **Back button is config-driven by default.** Consumers don't have to
|
|
37
|
+
* thread `useRouter()` + `() => router.push('/')` themselves anymore —
|
|
38
|
+
* the helper supplies a sane default (`{ label: 'Back to home', href: '/' }`).
|
|
39
|
+
* Hosts whose `/` lives elsewhere should pass their own `href`. Pass
|
|
40
|
+
* `backButton={false}` to suppress entirely (the lib's own
|
|
41
|
+
* `<DocsHubPage>` does this on the platform-home docs landing).
|
|
42
|
+
*/
|
|
43
|
+
export interface PageWithHeaderProps {
|
|
44
|
+
/** Title — passed straight to inner `<PageHeader>`. */
|
|
45
|
+
title?: string
|
|
46
|
+
/** Inline icon rendered before the title (lucide / SVG node). Wrap with
|
|
47
|
+
* `SECTION_HERO_ICON_CLASS` at the call site, or use the lib's
|
|
48
|
+
* `<PageHeader>`'s `titleIcon` ReactNode signature directly. */
|
|
49
|
+
titleIcon?: PageHeaderProps['titleIcon']
|
|
50
|
+
/** Subtitle (1-2 lines, auto-clamped to 2 + min-h-[56px]). */
|
|
51
|
+
subtitle?: string
|
|
52
|
+
/** Render yellow accent dot after the title (default true — matches every
|
|
53
|
+
* unified surface). Pass `false` to opt out. */
|
|
54
|
+
accentDot?: boolean
|
|
55
|
+
/** Back-button config. Defaults to `{ label: 'Back to home', href: '/' }`.
|
|
56
|
+
* Pass `false` to hide entirely (platform-home docs landings). */
|
|
57
|
+
backButton?: { label?: string; href?: string } | false
|
|
58
|
+
/** Optional image (entity-image-style — onboarding guides etc.). */
|
|
59
|
+
image?: PageHeaderProps['image']
|
|
60
|
+
/** Optional actions slot (right side of header). */
|
|
61
|
+
actions?: React.ReactNode
|
|
62
|
+
/** Page body — search bars, lists, forms, sections. Rendered INSIDE the
|
|
63
|
+
* gap-10 flex column so it shares gutters + vertical rhythm with the
|
|
64
|
+
* header. */
|
|
65
|
+
children: React.ReactNode
|
|
66
|
+
/** Extra class applied to the gap-10 content wrapper. */
|
|
67
|
+
contentClassName?: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function PageWithHeader({
|
|
71
|
+
title,
|
|
72
|
+
titleIcon,
|
|
73
|
+
subtitle,
|
|
74
|
+
accentDot = true,
|
|
75
|
+
backButton,
|
|
76
|
+
image,
|
|
77
|
+
actions,
|
|
78
|
+
children,
|
|
79
|
+
contentClassName,
|
|
80
|
+
}: PageWithHeaderProps) {
|
|
81
|
+
const router = useRouter()
|
|
82
|
+
|
|
83
|
+
const backCfg =
|
|
84
|
+
backButton === false
|
|
85
|
+
? undefined
|
|
86
|
+
: {
|
|
87
|
+
label: backButton?.label ?? 'Back to home',
|
|
88
|
+
onClick: () => router.push(backButton?.href ?? '/'),
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<PageShell>
|
|
93
|
+
<PageLayout backButton={backCfg}>
|
|
94
|
+
<div className={`w-full flex flex-col gap-10${contentClassName ? ` ${contentClassName}` : ''}`}>
|
|
95
|
+
<PageHeader
|
|
96
|
+
title={title}
|
|
97
|
+
titleIcon={titleIcon}
|
|
98
|
+
subtitle={subtitle}
|
|
99
|
+
accentDot={accentDot}
|
|
100
|
+
image={image}
|
|
101
|
+
actions={actions}
|
|
102
|
+
noTopPadding
|
|
103
|
+
noBottomMargin
|
|
104
|
+
/>
|
|
105
|
+
{children}
|
|
106
|
+
</div>
|
|
107
|
+
</PageLayout>
|
|
108
|
+
</PageShell>
|
|
109
|
+
)
|
|
110
|
+
}
|