MCPcopy Create free account
hub / github.com/adobe/react-spectrum / OptimisticToc

Function OptimisticToc

packages/dev/s2-docs/src/OptimisticToc.tsx:62–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60}
61
62export function OptimisticToc() {
63 let {currentPage} = useRouter();
64 let section = currentPage.exports?.section;
65 let hasToC =
66 (!currentPage.exports?.hideNav || section === 'Blog' || section === 'Releases') &&
67 currentPage.tableOfContents?.[0]?.children &&
68 currentPage.tableOfContents?.[0]?.children?.length > 0;
69 if (!hasToC) {
70 return null;
71 }
72
73 return (
74 <aside
75 className={style({
76 position: 'sticky',
77 top: 0,
78 paddingTop: 32,
79 marginBottom: -40,
80 boxSizing: 'border-box',
81 width: 180,
82 flexShrink: 0,
83 display: {
84 default: 'none',
85 lg: 'flex'
86 },
87 flexDirection: 'column'
88 })}>
89 <div
90 className={style({
91 font: 'title',
92 minHeight: 32,
93 paddingX: 12,
94 display: 'flex',
95 alignItems: 'center',
96 marginBottom: 4,
97 flexShrink: 0
98 })}>
99 On this page
100 </div>
101 <ScrollableToc>
102 <Toc toc={currentPage.tableOfContents?.[0]?.children ?? []} key={currentPage.url} />
103 {currentPage.exports?.relatedPages && (
104 <RelatedPages pages={currentPage.exports.relatedPages} />
105 )}
106 </ScrollableToc>
107 <div className={style({flexShrink: 0})}>
108 <Divider size="S" styles={style({marginY: 12})} />
109 <MarkdownMenu name={currentPage.name} url={currentPage.url} />
110 </div>
111 </aside>
112 );
113}
114
115function isExternalUrl(url: string): boolean {
116 return url.startsWith('http://') || url.startsWith('https://');

Callers

nothing calls this directly

Calls 1

useRouterFunction · 0.90

Tested by

no test coverage detected