@stainless-api/docs 0.1.0-beta.5 → 0.1.0-beta.51
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/CHANGELOG.md +390 -0
- package/eslint-suppressions.json +47 -0
- package/locals.d.ts +14 -0
- package/package.json +43 -39
- package/plugin/buildAlgoliaIndex.ts +31 -6
- package/plugin/cms/server.ts +98 -56
- package/plugin/cms/sidebar-builder.ts +7 -26
- package/plugin/cms/worker.ts +3 -3
- package/plugin/components/MethodDescription.tsx +54 -0
- package/plugin/components/SDKSelect.astro +7 -87
- package/plugin/components/SnippetCode.tsx +11 -7
- package/plugin/components/search/SearchAlgolia.astro +5 -33
- package/plugin/components/search/SearchIsland.tsx +37 -23
- package/plugin/generateAPIReferenceLink.ts +2 -2
- package/plugin/globalJs/ai-dropdown-options.ts +235 -0
- package/plugin/globalJs/method-descriptions.ts +33 -0
- package/plugin/globalJs/navigation.ts +7 -27
- package/plugin/helpers/getPageLoadEvent.ts +1 -1
- package/plugin/index.ts +54 -34
- package/plugin/languages.ts +2 -2
- package/plugin/loadPluginConfig.ts +112 -32
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +1 -1
- package/plugin/react/Routing.tsx +176 -80
- package/plugin/referencePlaceholderUtils.ts +1 -1
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +5 -1
- package/plugin/routes/Docs.astro +60 -85
- package/plugin/routes/Overview.astro +10 -16
- package/plugin/routes/markdown.ts +7 -7
- package/plugin/vendor/preview.worker.docs.js +17973 -16561
- package/plugin/vendor/templates/go.md +1 -1
- package/plugin/vendor/templates/python.md +1 -1
- package/resolveSrcFile.ts +10 -0
- package/scripts/vendor_deps.ts +1 -1
- package/shared/getSharedLogger.ts +15 -0
- package/shared/terminalUtils.ts +3 -0
- package/src/content.config.ts +9 -0
- package/stl-docs/components/AIDropdown.tsx +63 -0
- package/stl-docs/components/{content-panel/ContentBreadcrumbs.tsx → ContentBreadcrumbs.tsx} +2 -2
- package/stl-docs/components/Head.astro +16 -0
- package/stl-docs/components/Header.astro +6 -8
- package/stl-docs/components/PageTitle.astro +82 -0
- package/stl-docs/components/TableOfContents.astro +34 -0
- package/stl-docs/components/ThemeSelect.astro +118 -141
- package/stl-docs/components/content-panel/ContentPanel.astro +16 -46
- package/stl-docs/components/headers/DefaultHeader.astro +1 -1
- package/stl-docs/components/headers/HeaderLinks.astro +1 -1
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +17 -1
- package/stl-docs/components/headers/StackedHeader.astro +29 -24
- package/stl-docs/components/icons/chat-gpt.tsx +17 -0
- package/stl-docs/components/icons/claude.tsx +10 -0
- package/stl-docs/components/icons/cursor.tsx +10 -0
- package/stl-docs/components/icons/gemini.tsx +19 -0
- package/stl-docs/components/icons/markdown.tsx +10 -0
- package/stl-docs/components/index.ts +1 -0
- package/stl-docs/components/mintlify-compat/Accordion.astro +7 -38
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +9 -23
- package/stl-docs/components/mintlify-compat/Columns.astro +40 -42
- package/stl-docs/components/mintlify-compat/Frame.astro +16 -18
- package/stl-docs/components/mintlify-compat/Step.astro +30 -32
- package/stl-docs/components/mintlify-compat/Steps.astro +8 -10
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +10 -3
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +7 -3
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +7 -3
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +7 -3
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +7 -3
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +7 -3
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +7 -3
- package/stl-docs/components/mintlify-compat/card.css +33 -35
- package/stl-docs/components/nav-tabs/NavDropdown.astro +31 -75
- package/stl-docs/components/nav-tabs/NavTabs.astro +78 -80
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +15 -8
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +4 -3
- package/stl-docs/components/pagination/HomeLink.astro +10 -0
- package/stl-docs/components/pagination/Pagination.astro +174 -0
- package/stl-docs/components/pagination/PaginationLinkEmphasized.astro +22 -0
- package/stl-docs/components/pagination/PaginationLinkQuiet.astro +13 -0
- package/stl-docs/components/pagination/util.ts +71 -0
- package/stl-docs/components/scripts.ts +1 -0
- package/stl-docs/components/{Sidebar.astro → sidebars/BaseSidebar.astro} +2 -3
- package/stl-docs/components/sidebars/SDKSelectSidebar.astro +8 -0
- package/stl-docs/disableCalloutSyntax.ts +36 -0
- package/stl-docs/index.ts +98 -26
- package/stl-docs/loadStlDocsConfig.ts +37 -5
- package/stl-docs/proseMarkdown/proseMarkdownIntegration.ts +64 -0
- package/stl-docs/proseMarkdown/proseMarkdownMiddleware.ts +34 -0
- package/stl-docs/proseMarkdown/toMarkdown.ts +158 -0
- package/stl-docs/tabsMiddleware.ts +12 -4
- package/styles/code.css +104 -141
- package/styles/fonts.css +32 -17
- package/styles/links.css +11 -48
- package/styles/method-descriptions.css +36 -0
- package/styles/overrides.css +49 -57
- package/styles/page.css +90 -59
- package/styles/sdk_select.css +9 -7
- package/styles/search.css +58 -69
- package/styles/sidebar.css +211 -131
- package/styles/{variables.css → sl-variables.css} +3 -2
- package/styles/stldocs-variables.css +6 -0
- package/styles/toc.css +41 -34
- package/theme.css +12 -2
- package/tsconfig.json +2 -5
- package/virtual-module.d.ts +8 -4
- package/components/variables.css +0 -139
- package/plugin/globalJs/ai-dropdown.ts +0 -57
- package/stl-docs/components/APIReferenceAIDropdown.tsx +0 -86
- package/stl-docs/components/content-panel/ProseAIDropdown.tsx +0 -64
- /package/{plugin/assets → assets}/fonts/geist/OFL.txt +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- /package/{plugin/assets → assets}/fonts/geist/geist-mono-latin.woff2 +0 -0
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { Callout as StainlessCallout, type CalloutVariant } from '@stainless-api/ui-primitives';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
variant?: CalloutVariant;
|
|
6
|
+
children: astroHTML.JSX.Children;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { variant } = Astro.props;
|
|
3
10
|
---
|
|
4
11
|
|
|
5
|
-
<
|
|
12
|
+
<StainlessCallout variant={variant}>
|
|
6
13
|
<slot />
|
|
7
|
-
</
|
|
14
|
+
</StainlessCallout>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { Callout } from '@stainless-api/ui-primitives';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
children: astroHTML.JSX.Children;
|
|
6
|
+
}
|
|
3
7
|
---
|
|
4
8
|
|
|
5
|
-
<
|
|
9
|
+
<Callout variant="success">
|
|
6
10
|
<slot />
|
|
7
|
-
</
|
|
11
|
+
</Callout>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { Callout } from '@stainless-api/ui-primitives';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
children: astroHTML.JSX.Children;
|
|
6
|
+
}
|
|
3
7
|
---
|
|
4
8
|
|
|
5
|
-
<
|
|
9
|
+
<Callout variant="danger">
|
|
6
10
|
<slot />
|
|
7
|
-
</
|
|
11
|
+
</Callout>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { Callout } from '@stainless-api/ui-primitives';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
children: astroHTML.JSX.Children;
|
|
6
|
+
}
|
|
3
7
|
---
|
|
4
8
|
|
|
5
|
-
<
|
|
9
|
+
<Callout variant="info">
|
|
6
10
|
<slot />
|
|
7
|
-
</
|
|
11
|
+
</Callout>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { Callout } from '@stainless-api/ui-primitives';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
children: astroHTML.JSX.Children;
|
|
6
|
+
}
|
|
3
7
|
---
|
|
4
8
|
|
|
5
|
-
<
|
|
9
|
+
<Callout variant="note">
|
|
6
10
|
<slot />
|
|
7
|
-
</
|
|
11
|
+
</Callout>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { Callout } from '@stainless-api/ui-primitives';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
children: astroHTML.JSX.Children;
|
|
6
|
+
}
|
|
3
7
|
---
|
|
4
8
|
|
|
5
|
-
<
|
|
9
|
+
<Callout variant="tip">
|
|
6
10
|
<slot />
|
|
7
|
-
</
|
|
11
|
+
</Callout>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
2
|
+
import { Callout } from '@stainless-api/ui-primitives';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
children: astroHTML.JSX.Children;
|
|
6
|
+
}
|
|
3
7
|
---
|
|
4
8
|
|
|
5
|
-
<
|
|
9
|
+
<Callout variant="warning">
|
|
6
10
|
<slot />
|
|
7
|
-
</
|
|
11
|
+
</Callout>
|
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
flex-direction: column;
|
|
1
|
+
.stl-ui-mintlify-compat-card {
|
|
2
|
+
border-radius: 12px;
|
|
3
|
+
padding: 16px;
|
|
4
|
+
font-size: var(--stl-typography-scale-base);
|
|
5
|
+
display: flex;
|
|
6
|
+
gap: 8px;
|
|
7
|
+
border: 1px solid var(--stl-color-border);
|
|
8
|
+
flex-direction: column;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
.stl-ui-mintlify-compat-card-icon svg {
|
|
11
|
+
color: var(--sl-color-accent);
|
|
12
|
+
}
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
.stl-ui-mintlify-compat-card-title {
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
font-size: 1.125rem;
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
margin-top: 8px;
|
|
21
|
+
}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
23
|
+
.stl-ui-mintlify-compat-card-content {
|
|
24
|
+
margin-top: 0;
|
|
25
|
+
color: var(--stl-color-foreground-reduced);
|
|
28
26
|
}
|
|
27
|
+
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
a.stl-ui-mintlify-compat-card {
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
color: var(--stl-color-foreground-reduced);
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
33
|
+
&:hover {
|
|
34
|
+
border-color: var(--sl-color-accent);
|
|
37
35
|
}
|
|
36
|
+
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
38
|
+
.stl-ui-mintlify-compat-card-group {
|
|
39
|
+
display: grid;
|
|
40
|
+
gap: 1rem;
|
|
41
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
44
42
|
}
|
|
@@ -1,81 +1,52 @@
|
|
|
1
1
|
---
|
|
2
|
-
import {
|
|
3
|
-
Dropdown,
|
|
4
|
-
DropdownTrigger,
|
|
5
|
-
DropdownMenu,
|
|
6
|
-
DropdownItem,
|
|
7
|
-
} from '@stainless-api/docs-ui/src/components/dropdown';
|
|
8
|
-
import { Icon } from '@astrojs/starlight/components';
|
|
2
|
+
import { Dropdown } from '@stainless-api/docs/components';
|
|
9
3
|
import { buildNavLinks } from './buildNavLinks';
|
|
10
|
-
|
|
11
|
-
export interface Props {
|
|
12
|
-
useHamburgerIcon?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const { useHamburgerIcon = false } = Astro.props as Props;
|
|
16
|
-
const BUTTON_ID = 'nav-dropdown-button';
|
|
4
|
+
import { ChevronsUpDownIcon } from 'lucide-react';
|
|
17
5
|
|
|
18
6
|
const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
19
7
|
|
|
20
|
-
const buttonText = (navLinks.find((item) => item.active) ?? navLinks[0]).label;
|
|
8
|
+
const buttonText = (navLinks.find((item) => item.active) ?? navLinks[0]!).label;
|
|
21
9
|
---
|
|
22
10
|
|
|
23
|
-
<
|
|
24
|
-
<Dropdown
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</
|
|
11
|
+
<Dropdown id="nav-dropdown" className="nav-dropdown-root">
|
|
12
|
+
<Dropdown.Trigger>
|
|
13
|
+
<Dropdown.TriggerSelectedItem>{buttonText}</Dropdown.TriggerSelectedItem>
|
|
14
|
+
<Dropdown.TriggerIcon>
|
|
15
|
+
<ChevronsUpDownIcon size={16} />
|
|
16
|
+
</Dropdown.TriggerIcon>
|
|
17
|
+
</Dropdown.Trigger>
|
|
18
|
+
<Dropdown.Menu className="dropdown-menu">
|
|
19
|
+
{
|
|
20
|
+
navLinks.map((item) => (
|
|
21
|
+
<Dropdown.MenuItem
|
|
22
|
+
key={item.link}
|
|
23
|
+
href={item.link}
|
|
24
|
+
className="dropdown-item"
|
|
25
|
+
value={item.label}
|
|
26
|
+
isSelected={item.label === buttonText}
|
|
27
|
+
>
|
|
28
|
+
{item.label}
|
|
29
|
+
<Dropdown.MenuItemTemplate>{item.label}</Dropdown.MenuItemTemplate>
|
|
30
|
+
</Dropdown.MenuItem>
|
|
31
|
+
))
|
|
32
|
+
}
|
|
33
|
+
</Dropdown.Menu>
|
|
34
|
+
</Dropdown>
|
|
46
35
|
|
|
47
36
|
<script>
|
|
48
|
-
import { initDropdown } from '@stainless-api/docs
|
|
37
|
+
import { initDropdown } from '@stainless-api/docs/components/scripts';
|
|
49
38
|
import { getPageLoadEvent } from '../../../plugin/helpers/getPageLoadEvent';
|
|
50
39
|
|
|
51
40
|
document.addEventListener(getPageLoadEvent(), () => {
|
|
52
41
|
initDropdown({
|
|
53
|
-
|
|
54
|
-
isFixed: true,
|
|
42
|
+
root: document.getElementById('nav-dropdown'),
|
|
55
43
|
});
|
|
56
44
|
});
|
|
57
45
|
</script>
|
|
58
|
-
<style is:global>
|
|
59
|
-
.nav-dropdown-root .dropdown-menu.stldocs-dropdown-menu {
|
|
60
|
-
display: none;
|
|
61
|
-
position: fixed;
|
|
62
|
-
z-index: 1000;
|
|
63
|
-
width: 200px;
|
|
64
|
-
margin: 0.125rem 0 0;
|
|
65
|
-
font-size: 1rem;
|
|
66
|
-
text-align: left;
|
|
67
|
-
list-style: none;
|
|
68
|
-
background-clip: padding-box;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.nav-dropdown-root .dropdown-menu.open {
|
|
72
|
-
display: block;
|
|
73
|
-
}
|
|
74
|
-
</style>
|
|
75
46
|
|
|
76
47
|
<style>
|
|
77
48
|
:root {
|
|
78
|
-
--menu-font-size: calc(var(--
|
|
49
|
+
--menu-font-size: calc(var(--stl-typography-scale-base) * 0.9);
|
|
79
50
|
}
|
|
80
51
|
|
|
81
52
|
.dropdown {
|
|
@@ -83,24 +54,9 @@ const buttonText = (navLinks.find((item) => item.active) ?? navLinks[0]).label;
|
|
|
83
54
|
}
|
|
84
55
|
|
|
85
56
|
.dropdown-item {
|
|
86
|
-
|
|
87
|
-
color: var(--sl-color-text);
|
|
57
|
+
color: inherit;
|
|
88
58
|
text-align: inherit;
|
|
89
59
|
text-decoration: none;
|
|
90
60
|
white-space: nowrap;
|
|
91
61
|
}
|
|
92
|
-
|
|
93
|
-
.dropdown-item:focus {
|
|
94
|
-
color: #1e2125;
|
|
95
|
-
background-color: #e9ecef;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.nav-dropdown-root {
|
|
99
|
-
background-color: var(--sl-color-bg-nav);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.nav-dropdown-button {
|
|
103
|
-
color: var(--sl-color-text);
|
|
104
|
-
font-weight: 500;
|
|
105
|
-
}
|
|
106
62
|
</style>
|
|
@@ -7,80 +7,98 @@ import clsx from 'clsx';
|
|
|
7
7
|
const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
<div id="nav-links-container">
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<ul class="nav-links" id="nav-links-test-container">
|
|
32
|
-
{
|
|
33
|
-
navLinks.map((item) => (
|
|
34
|
-
<li>
|
|
35
|
-
<Button href={item.link} className={clsx('nav-link')} variant={item.active ? 'accent' : 'ghost'}>
|
|
36
|
-
<span>{item.label}</span>
|
|
37
|
-
</Button>
|
|
38
|
-
</li>
|
|
39
|
-
))
|
|
40
|
-
}
|
|
41
|
-
</ul>
|
|
10
|
+
<div id="nav-links-container" class="nav-links-container">
|
|
11
|
+
<div class="desktop-nav-links-container">
|
|
12
|
+
<ul class="nav-links" id="nav-links-list">
|
|
13
|
+
{
|
|
14
|
+
navLinks.map((item) => (
|
|
15
|
+
<li data-desktop-only>
|
|
16
|
+
<Button
|
|
17
|
+
href={item.link}
|
|
18
|
+
className={clsx('nav-link')}
|
|
19
|
+
variant={item.active ? 'accent-muted' : 'ghost'}
|
|
20
|
+
>
|
|
21
|
+
<span>{item.label}</span>
|
|
22
|
+
</Button>
|
|
23
|
+
</li>
|
|
24
|
+
))
|
|
25
|
+
}
|
|
26
|
+
</ul>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="mobile-nav-dropdown" data-mobile-only>
|
|
29
|
+
<NavDropdown />
|
|
30
|
+
</div>
|
|
42
31
|
</div>
|
|
43
32
|
|
|
44
33
|
<script>
|
|
45
34
|
import { getPageLoadEvent } from '../../../plugin/helpers/getPageLoadEvent';
|
|
46
35
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
// We need to measure the nav links to see if they fit. We create an offscreen hidden clone for measurement.
|
|
37
|
+
function createOffscreenClone(element: HTMLElement): HTMLElement {
|
|
38
|
+
const clone = element.cloneNode(true) as HTMLElement;
|
|
39
|
+
clone.removeAttribute('id');
|
|
40
|
+
clone.id = 'cloned-nav-links-measurement';
|
|
41
|
+
clone.style.position = 'absolute';
|
|
42
|
+
clone.style.visibility = 'hidden';
|
|
43
|
+
clone.style.top = '0';
|
|
44
|
+
clone.style.left = '0';
|
|
45
|
+
clone.style.width = 'auto';
|
|
46
|
+
clone.style.whiteSpace = 'nowrap';
|
|
47
|
+
clone.style.pointerEvents = 'none';
|
|
48
|
+
clone.style.zIndex = '-9999';
|
|
49
|
+
|
|
50
|
+
clone.querySelectorAll('[data-desktop-only], [data-mobile-only]').forEach((el) => {
|
|
51
|
+
el.removeAttribute('data-desktop-only');
|
|
52
|
+
});
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return rw;
|
|
54
|
+
document.body.appendChild(clone);
|
|
55
|
+
return clone;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
function initNavbar() {
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
59
|
+
const navLinksContainer = document.getElementById('nav-links-container');
|
|
60
|
+
if (!navLinksContainer) {
|
|
61
|
+
console.error(`NavTabs: #nav-links-container not found`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
59
64
|
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
65
|
+
const navLinksList = document.getElementById('nav-links-list');
|
|
66
|
+
if (!navLinksList) {
|
|
67
|
+
console.error(`NavTabs: #nav-links-list not found`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const measurementClone = createOffscreenClone(navLinksList);
|
|
72
|
+
const requiredWidth = measurementClone.clientWidth;
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
let currentMode: 'desktop' | 'mobile' | null = null;
|
|
64
75
|
|
|
65
76
|
function checkIfFits() {
|
|
66
|
-
if (!masterContainer) return;
|
|
67
77
|
if (!navLinksContainer) return;
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
|
|
79
|
+
// 16px buffer helps it feel less crowded before switching modes
|
|
80
|
+
const bufferSpace = 16;
|
|
81
|
+
const availableWidth = navLinksContainer.clientWidth;
|
|
82
|
+
const canFit = availableWidth - bufferSpace >= requiredWidth;
|
|
70
83
|
|
|
71
84
|
const mode = canFit ? 'desktop' : 'mobile';
|
|
72
85
|
|
|
73
|
-
|
|
86
|
+
// Only update if mode actually changed
|
|
87
|
+
if (mode === currentMode) return;
|
|
88
|
+
|
|
89
|
+
currentMode = mode;
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
document.documentElement.classList.remove('stl-nav-links-mode-mobile');
|
|
91
|
+
localStorage.setItem('stl-nav-links-mode', mode);
|
|
77
92
|
|
|
93
|
+
document.documentElement.classList.remove('stl-nav-links-mode-desktop', 'stl-nav-links-mode-mobile');
|
|
78
94
|
document.documentElement.classList.add('stl-nav-links-mode-' + mode);
|
|
79
95
|
}
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
82
98
|
checkIfFits();
|
|
83
99
|
});
|
|
100
|
+
|
|
101
|
+
resizeObserver.observe(navLinksContainer);
|
|
84
102
|
checkIfFits();
|
|
85
103
|
}
|
|
86
104
|
|
|
@@ -109,55 +127,35 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
109
127
|
</style>
|
|
110
128
|
|
|
111
129
|
<style>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
.nav-links-container {
|
|
131
|
+
flex-grow: 1;
|
|
132
|
+
margin-left: 1rem;
|
|
133
|
+
margin-right: 1rem;
|
|
134
|
+
}
|
|
115
135
|
|
|
116
|
-
|
|
117
|
-
visibility: hidden;
|
|
136
|
+
.desktop-nav-links-container {
|
|
118
137
|
display: flex;
|
|
119
138
|
flex-grow: 1;
|
|
120
139
|
justify-content: flex-start;
|
|
121
140
|
overflow: hidden;
|
|
122
|
-
margin-left: 1rem;
|
|
123
|
-
margin-right: 1rem;
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
.nav-links {
|
|
127
144
|
display: flex;
|
|
128
145
|
list-style: none;
|
|
129
|
-
gap:
|
|
146
|
+
gap: 4px;
|
|
130
147
|
padding: 0;
|
|
131
148
|
margin: 0;
|
|
132
149
|
white-space: nowrap;
|
|
133
150
|
overflow: hidden;
|
|
134
151
|
}
|
|
135
152
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
top: 0;
|
|
139
|
-
left: 0;
|
|
140
|
-
visibility: hidden;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.nav-links li {
|
|
144
|
-
display: flex;
|
|
145
|
-
align-items: center;
|
|
146
|
-
justify-content: center;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.nav-link {
|
|
150
|
-
text-decoration: none;
|
|
151
|
-
flex: 1;
|
|
152
|
-
|
|
153
|
-
&.stl-ui-button--ghost:hover {
|
|
154
|
-
color: var(--sl-color-text-accent);
|
|
155
|
-
background-color: transparent;
|
|
156
|
-
}
|
|
153
|
+
.mobile-nav-dropdown {
|
|
154
|
+
flex-grow: 1;
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
@media (min-width: 50rem) {
|
|
160
|
-
|
|
158
|
+
.desktop-nav-links-container {
|
|
161
159
|
display: flex;
|
|
162
160
|
visibility: visible;
|
|
163
161
|
}
|
|
@@ -34,13 +34,7 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
34
34
|
align-items: center;
|
|
35
35
|
padding: 0;
|
|
36
36
|
list-style: none;
|
|
37
|
-
overflow-x: auto;
|
|
38
37
|
margin-bottom: -1px;
|
|
39
|
-
gap: 0.29rem;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.stl-active-secondary-link:hover {
|
|
43
|
-
background-color: transparent;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
li {
|
|
@@ -48,7 +42,21 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
48
42
|
border-bottom: 2px solid transparent;
|
|
49
43
|
|
|
50
44
|
&.active {
|
|
51
|
-
border-color: var(--
|
|
45
|
+
border-color: var(--stl-color-accent-border-strong);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.stl-ui-button {
|
|
49
|
+
/* match sidebar. TODO: hoist sidebar variables to use those instead of hardcoding? */
|
|
50
|
+
border-width: 0;
|
|
51
|
+
padding: 8px 12px;
|
|
52
|
+
margin-inline: -12px;
|
|
53
|
+
}
|
|
54
|
+
/* cover for button’s negative margin */
|
|
55
|
+
&:not(:first-child) {
|
|
56
|
+
margin-inline-start: 12px;
|
|
57
|
+
}
|
|
58
|
+
&:not(:last-child) {
|
|
59
|
+
margin-inline-end: 12px;
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -56,7 +64,6 @@ const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
|
56
64
|
@media (min-width: 50rem) {
|
|
57
65
|
.stl-secondary-nav-tabs {
|
|
58
66
|
display: block;
|
|
59
|
-
padding-left: 0.55rem;
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
</style>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { StarlightRouteData } from '@astrojs/starlight/route-data';
|
|
2
|
-
import { TABS } from 'virtual:stl-
|
|
2
|
+
import { TABS } from 'virtual:stl-docs-virtual-module';
|
|
3
|
+
import type { StarlightRouteWithStlDocs } from '../../tabsMiddleware';
|
|
3
4
|
|
|
4
5
|
export function buildNavLinks(starlightRoute: StarlightRouteData) {
|
|
5
|
-
|
|
6
|
-
const activeTabIndex =
|
|
6
|
+
const routeData: StarlightRouteWithStlDocs = starlightRoute;
|
|
7
|
+
const activeTabIndex = routeData?._stlDocs?.activeTabIndex;
|
|
7
8
|
|
|
8
9
|
const navLinks = TABS.map((item, index) => ({
|
|
9
10
|
...item,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { base } from 'astro:config/client';
|
|
3
|
+
import { HomeIcon } from 'lucide-react';
|
|
4
|
+
import PaginationLinkQuiet from './PaginationLinkQuiet.astro';
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<PaginationLinkQuiet href={base}>
|
|
8
|
+
<HomeIcon slot="icon" />
|
|
9
|
+
Home
|
|
10
|
+
</PaginationLinkQuiet>
|