@stainless-api/docs 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +1 -0
- package/CHANGELOG.md +13 -0
- package/README.md +11 -0
- package/components/variables.css +139 -0
- package/eslint.config.js +10 -0
- package/package.json +74 -0
- package/plugin/assets/fonts/geist/OFL.txt +93 -0
- package/plugin/assets/fonts/geist/geist-italic-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-italic-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-italic-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-italic-latin.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-latin-ext.woff2 +0 -0
- package/plugin/assets/fonts/geist/geist-mono-latin.woff2 +0 -0
- package/plugin/assets/languages/curl.svg +10 -0
- package/plugin/assets/languages/go.svg +4 -0
- package/plugin/assets/languages/java.svg +7 -0
- package/plugin/assets/languages/kotlin.svg +10 -0
- package/plugin/assets/languages/powershell.svg +3 -0
- package/plugin/assets/languages/python.svg +19 -0
- package/plugin/assets/languages/ruby.svg +125 -0
- package/plugin/assets/languages/terraform.svg +5 -0
- package/plugin/assets/languages/typescript.svg +11 -0
- package/plugin/assets/stainless-logo-dark.png +0 -0
- package/plugin/assets/stainless-logo.png +0 -0
- package/plugin/buildAlgoliaIndex.ts +72 -0
- package/plugin/cms/client.ts +62 -0
- package/plugin/cms/server.ts +268 -0
- package/plugin/cms/sidebar-builder.ts +420 -0
- package/plugin/cms/worker.ts +122 -0
- package/plugin/components/SDKSelect.astro +154 -0
- package/plugin/components/SnippetCode.tsx +212 -0
- package/plugin/components/search/Search.astro +6 -0
- package/plugin/components/search/SearchAlgolia.astro +87 -0
- package/plugin/components/search/SearchIsland.tsx +100 -0
- package/plugin/generateAPIReferenceLink.ts +71 -0
- package/plugin/globalJs/ai-dropdown.ts +57 -0
- package/plugin/globalJs/code-snippets.ts +87 -0
- package/plugin/globalJs/copy.ts +37 -0
- package/plugin/globalJs/navigation.ts +81 -0
- package/plugin/globalJs/tooltip.ts +32 -0
- package/plugin/helpers/getPageLoadEvent.ts +8 -0
- package/plugin/index.ts +308 -0
- package/plugin/languages.ts +67 -0
- package/plugin/loadPluginConfig.ts +273 -0
- package/plugin/middlewareBuilder/stainlessMiddleware.d.ts +5 -0
- package/plugin/middlewareBuilder/stlStarlightMiddleware.ts +5 -0
- package/plugin/react/Routing.tsx +435 -0
- package/plugin/referencePlaceholderUtils.ts +82 -0
- package/plugin/replaceSidebarPlaceholderMiddleware.ts +50 -0
- package/plugin/routes/Docs.astro +171 -0
- package/plugin/routes/DocsStatic.astro +14 -0
- package/plugin/routes/Overview.astro +67 -0
- package/plugin/routes/markdown.ts +58 -0
- package/plugin/vendor/preview.worker.docs.js +21657 -0
- package/plugin/vendor/templates/go.md +314 -0
- package/plugin/vendor/templates/java.md +87 -0
- package/plugin/vendor/templates/kotlin.md +87 -0
- package/plugin/vendor/templates/node.md +233 -0
- package/plugin/vendor/templates/python.md +249 -0
- package/plugin/vendor/templates/ruby.md +145 -0
- package/plugin/vendor/templates/terraform.md +60 -0
- package/plugin/vendor/templates/typescript.md +317 -0
- package/scripts/vendor_deps.ts +50 -0
- package/shared/virtualModule.ts +7 -0
- package/stl-docs/components/APIReferenceAIDropdown.tsx +86 -0
- package/stl-docs/components/ClientRouterHead.astro +41 -0
- package/stl-docs/components/Header.astro +91 -0
- package/stl-docs/components/Sidebar.astro +11 -0
- package/stl-docs/components/ThemeSelect.astro +225 -0
- package/stl-docs/components/content-panel/ContentBreadcrumbs.tsx +84 -0
- package/stl-docs/components/content-panel/ContentPanel.astro +72 -0
- package/stl-docs/components/content-panel/ProseAIDropdown.tsx +64 -0
- package/stl-docs/components/headers/DefaultHeader.astro +36 -0
- package/stl-docs/components/headers/HeaderLinks.astro +16 -0
- package/stl-docs/components/headers/SplashMobileMenuToggle.astro +49 -0
- package/stl-docs/components/headers/StackedHeader.astro +75 -0
- package/stl-docs/components/mintlify-compat/Accordion.astro +46 -0
- package/stl-docs/components/mintlify-compat/AccordionGroup.astro +25 -0
- package/stl-docs/components/mintlify-compat/Card.tsx +32 -0
- package/stl-docs/components/mintlify-compat/Columns.astro +66 -0
- package/stl-docs/components/mintlify-compat/Frame.astro +37 -0
- package/stl-docs/components/mintlify-compat/Step.astro +58 -0
- package/stl-docs/components/mintlify-compat/Steps.astro +17 -0
- package/stl-docs/components/mintlify-compat/Tab.astro +13 -0
- package/stl-docs/components/mintlify-compat/Tabs.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Callout.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Check.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Danger.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Info.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Note.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Tip.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/Warning.astro +7 -0
- package/stl-docs/components/mintlify-compat/callouts/index.ts +9 -0
- package/stl-docs/components/mintlify-compat/card.css +44 -0
- package/stl-docs/components/mintlify-compat/index.ts +15 -0
- package/stl-docs/components/nav-tabs/NavDropdown.astro +106 -0
- package/stl-docs/components/nav-tabs/NavTabs.astro +165 -0
- package/stl-docs/components/nav-tabs/SecondaryNavTabs.astro +62 -0
- package/stl-docs/components/nav-tabs/buildNavLinks.ts +14 -0
- package/stl-docs/index.ts +174 -0
- package/stl-docs/loadStlDocsConfig.ts +160 -0
- package/stl-docs/redirects.ts +33 -0
- package/stl-docs/tabsMiddleware.ts +183 -0
- package/styles/code.css +189 -0
- package/styles/fonts.css +68 -0
- package/styles/links.css +51 -0
- package/styles/mintlify-compat.css +1 -0
- package/styles/overrides.css +79 -0
- package/styles/page.css +76 -0
- package/styles/sdk_select.css +11 -0
- package/styles/search.css +85 -0
- package/styles/sidebar.css +168 -0
- package/styles/toc.css +42 -0
- package/styles/variables.css +18 -0
- package/theme.css +15 -0
- package/tsconfig.json +18 -0
- package/virtual-module.d.ts +43 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div class="stl-ui-mintlify-compat-accordion-group">
|
|
2
|
+
<slot />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<style>
|
|
6
|
+
@layer stl-ui-mintlify-compat {
|
|
7
|
+
.stl-ui-mintlify-compat-accordion-group {
|
|
8
|
+
border-radius: 12px;
|
|
9
|
+
border: 1px solid var(--sl-color-hairline);
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
padding-inline-start: -5rem;
|
|
12
|
+
|
|
13
|
+
.stl-ui-mintlify-compat-accordion {
|
|
14
|
+
margin: 0;
|
|
15
|
+
border-inline-start: none;
|
|
16
|
+
border: none;
|
|
17
|
+
border-radius: 0;
|
|
18
|
+
|
|
19
|
+
&:not(:last-child) {
|
|
20
|
+
border-bottom: 1px solid var(--sl-color-hairline);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
|
|
3
|
+
type CardProps = {
|
|
4
|
+
icon?: LucideIcon;
|
|
5
|
+
title: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
href?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function CardGroup({ children }: { children: React.ReactNode }) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="stl-ui-mintlify-compat-card-group" data-stl-ui-element>
|
|
13
|
+
{children}
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function Card({ icon: Icon, title, children, href, ...rest }: CardProps) {
|
|
19
|
+
const Slot = href ? 'a' : 'div';
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Slot className="stl-ui-mintlify-compat-card" href={href} {...rest} data-stl-ui-element>
|
|
23
|
+
{Icon && (
|
|
24
|
+
<span className="stl-ui-mintlify-compat-card-icon">
|
|
25
|
+
<Icon size={22} />
|
|
26
|
+
</span>
|
|
27
|
+
)}
|
|
28
|
+
<h2 className="stl-ui-mintlify-compat-card-title">{title}</h2>
|
|
29
|
+
<div className="stl-ui-mintlify-compat-card-content">{children}</div>
|
|
30
|
+
</Slot>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
|
|
4
|
+
export interface Props {
|
|
5
|
+
cols: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { cols } = Astro.props;
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<div
|
|
12
|
+
class={clsx('stl-ui-mintlify-compat-columns', `stl-ui-mintlify-compat-columns--${cols}`)}
|
|
13
|
+
data-stl-ui-element
|
|
14
|
+
>
|
|
15
|
+
<slot />
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
@layer stl-ui-mintlify-compat {
|
|
20
|
+
.stl-ui-mintlify-compat-columns {
|
|
21
|
+
display: grid;
|
|
22
|
+
gap: 1rem;
|
|
23
|
+
grid-template-columns: 1fr;
|
|
24
|
+
|
|
25
|
+
> [data-stl-ui-element] {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@media (min-width: 50rem) {
|
|
31
|
+
.stl-ui-mintlify-compat-columns--2 {
|
|
32
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
33
|
+
}
|
|
34
|
+
.stl-ui-mintlify-compat-columns--3 {
|
|
35
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
36
|
+
}
|
|
37
|
+
.stl-ui-mintlify-compat-columns--4 {
|
|
38
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
39
|
+
}
|
|
40
|
+
.stl-ui-mintlify-compat-columns--5 {
|
|
41
|
+
grid-template-columns: repeat(5, minmax(0, 1fr));
|
|
42
|
+
}
|
|
43
|
+
.stl-ui-mintlify-compat-columns--6 {
|
|
44
|
+
grid-template-columns: repeat(6, minmax(0, 1fr));
|
|
45
|
+
}
|
|
46
|
+
.stl-ui-mintlify-compat-columns--7 {
|
|
47
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
48
|
+
}
|
|
49
|
+
.stl-ui-mintlify-compat-columns--8 {
|
|
50
|
+
grid-template-columns: repeat(8, minmax(0, 1fr));
|
|
51
|
+
}
|
|
52
|
+
.stl-ui-mintlify-compat-columns--9 {
|
|
53
|
+
grid-template-columns: repeat(9, minmax(0, 1fr));
|
|
54
|
+
}
|
|
55
|
+
.stl-ui-mintlify-compat-columns--10 {
|
|
56
|
+
grid-template-columns: repeat(10, minmax(0, 1fr));
|
|
57
|
+
}
|
|
58
|
+
.stl-ui-mintlify-compat-columns--11 {
|
|
59
|
+
grid-template-columns: repeat(11, minmax(0, 1fr));
|
|
60
|
+
}
|
|
61
|
+
.stl-ui-mintlify-compat-columns--12 {
|
|
62
|
+
grid-template-columns: repeat(12, minmax(0, 1fr));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
export interface Props {
|
|
3
|
+
caption?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const { caption } = Astro.props;
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<div class="stl-ui-mintlify-compat-frame" data-stl-ui-element>
|
|
10
|
+
<div class="stl-ui-mintlify-compat-frame-content"><slot /></div>
|
|
11
|
+
{caption && <div class="stl-ui-mintlify-compat-frame-caption">{caption}</div>}
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
@layer stl-ui-mintlify-compat {
|
|
16
|
+
.stl-ui-mintlify-compat-frame {
|
|
17
|
+
padding: 6px;
|
|
18
|
+
border-radius: 10px;
|
|
19
|
+
background-color: var(--sl-color-gray-7);
|
|
20
|
+
border: 1px solid var(--sl-color-gray-6);
|
|
21
|
+
|
|
22
|
+
.stl-ui-mintlify-compat-frame-content {
|
|
23
|
+
border-radius: 8px;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.stl-ui-mintlify-compat-frame-caption {
|
|
28
|
+
text-align: center;
|
|
29
|
+
padding-top: 12px;
|
|
30
|
+
padding-bottom: 6px;
|
|
31
|
+
font-size: var(--sl-text-body);
|
|
32
|
+
color: var(--sl-color-gray-3);
|
|
33
|
+
line-height: 100%;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
export interface Props {
|
|
3
|
+
title?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const { title } = Astro.props;
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
<li class="stl-ui-mintlify-compat-step" data-stl-ui-element>
|
|
10
|
+
<div class="stl-ui-mintlify-compat-step-step-number"></div>
|
|
11
|
+
<div>
|
|
12
|
+
<p class="stl-ui-mintlify-compat-step-title">{title}</p>
|
|
13
|
+
<div class="stl-ui-mintlify-compat-step-content"><slot /></div>
|
|
14
|
+
</div>
|
|
15
|
+
</li>
|
|
16
|
+
|
|
17
|
+
<style>
|
|
18
|
+
@layer stl-ui-mintlify-compat {
|
|
19
|
+
.stl-ui-mintlify-compat-step {
|
|
20
|
+
display: flex;
|
|
21
|
+
|
|
22
|
+
&:not(:first-child) {
|
|
23
|
+
margin-top: 1rem;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.stl-ui-mintlify-compat-step-step-number {
|
|
28
|
+
margin-right: 1rem;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: top;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
margin-top: 4px;
|
|
33
|
+
|
|
34
|
+
&::before {
|
|
35
|
+
counter-increment: ui-steps;
|
|
36
|
+
content: counter(ui-steps);
|
|
37
|
+
border-radius: 50%;
|
|
38
|
+
height: 1.5rem;
|
|
39
|
+
width: 1.5rem;
|
|
40
|
+
font-size: 0.8rem;
|
|
41
|
+
color: var(--sl-color-text);
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
background-color: var(--sl-color-gray-5);
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.stl-ui-mintlify-compat-step-title {
|
|
51
|
+
font-weight: 600;
|
|
52
|
+
color: var(--sl-color-text);
|
|
53
|
+
}
|
|
54
|
+
.stl-ui-mintlify-compat-step-content {
|
|
55
|
+
margin-top: 0.5rem;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<ol class="stl-ui-mintlify-compat-steps"><slot /></ol>
|
|
2
|
+
|
|
3
|
+
<style>
|
|
4
|
+
@layer stl-ui-mintlify-compat {
|
|
5
|
+
.stl-ui-mintlify-compat-steps {
|
|
6
|
+
counter-reset: ui-steps;
|
|
7
|
+
list-style: none;
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
margin-top: 1rem;
|
|
11
|
+
|
|
12
|
+
* {
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Callout from './Callout.astro';
|
|
2
|
+
import Check from './Check.astro';
|
|
3
|
+
import Danger from './Danger.astro';
|
|
4
|
+
import Info from './Info.astro';
|
|
5
|
+
import Note from './Note.astro';
|
|
6
|
+
import Tip from './Tip.astro';
|
|
7
|
+
import Warning from './Warning.astro';
|
|
8
|
+
|
|
9
|
+
export { Check, Danger, Info, Note, Tip, Warning, Callout };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@layer stl-ui-mintlify-compat {
|
|
2
|
+
.stl-ui-mintlify-compat-card {
|
|
3
|
+
border-radius: 12px;
|
|
4
|
+
padding: 16px;
|
|
5
|
+
font-size: var(--sl-text-body);
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 8px;
|
|
8
|
+
border: 1px solid var(--sl-color-hairline);
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
|
|
11
|
+
.stl-ui-mintlify-compat-card-icon svg {
|
|
12
|
+
color: var(--sl-color-accent);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.stl-ui-mintlify-compat-card-title {
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
font-size: 1.125rem;
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
margin-top: 8px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.stl-ui-mintlify-compat-card-content {
|
|
25
|
+
margin-top: 0;
|
|
26
|
+
color: var(--sl-color-text-secondary);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
a.stl-ui-mintlify-compat-card {
|
|
31
|
+
text-decoration: none;
|
|
32
|
+
color: var(--sl-color-text-secondary);
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
border-color: var(--sl-color-accent);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.stl-ui-mintlify-compat-card-group {
|
|
40
|
+
display: grid;
|
|
41
|
+
gap: 1rem;
|
|
42
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/components/index.ts
|
|
2
|
+
import Tab from './Tab.astro';
|
|
3
|
+
import Tabs from './Tabs.astro';
|
|
4
|
+
import Frame from './Frame.astro';
|
|
5
|
+
import Columns from './Columns.astro';
|
|
6
|
+
import Steps from './Steps.astro';
|
|
7
|
+
import Step from './Step.astro';
|
|
8
|
+
import Accordion from './Accordion.astro';
|
|
9
|
+
import AccordionGroup from './AccordionGroup.astro';
|
|
10
|
+
|
|
11
|
+
export * from './callouts';
|
|
12
|
+
export * from './Card';
|
|
13
|
+
|
|
14
|
+
export { Tab, Tabs, Frame, Columns, Steps, Step, AccordionGroup, Accordion };
|
|
15
|
+
export { Button } from '@stainless-api/ui-primitives';
|
|
@@ -0,0 +1,106 @@
|
|
|
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';
|
|
9
|
+
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';
|
|
17
|
+
|
|
18
|
+
const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
19
|
+
|
|
20
|
+
const buttonText = (navLinks.find((item) => item.active) ?? navLinks[0]).label;
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
<div class="stldocs-root nav-dropdown-root">
|
|
24
|
+
<Dropdown id="nav-dropdown">
|
|
25
|
+
<DropdownTrigger
|
|
26
|
+
className={`dropdown-toggle stldocs-button-tertiary nav-dropdown-button`}
|
|
27
|
+
type="button"
|
|
28
|
+
id={BUTTON_ID}
|
|
29
|
+
aria-expanded="false"
|
|
30
|
+
withChevron={!useHamburgerIcon}
|
|
31
|
+
isIcon
|
|
32
|
+
>
|
|
33
|
+
{useHamburgerIcon ? <Icon name="bars" size="16px" /> : buttonText}
|
|
34
|
+
</DropdownTrigger>
|
|
35
|
+
<DropdownMenu className="dropdown-menu" position="below" aria-labelledby={BUTTON_ID}>
|
|
36
|
+
{
|
|
37
|
+
navLinks.map((item) => (
|
|
38
|
+
<DropdownItem key={item.link} href={item.link} className="dropdown-item">
|
|
39
|
+
{item.label}
|
|
40
|
+
</DropdownItem>
|
|
41
|
+
))
|
|
42
|
+
}
|
|
43
|
+
</DropdownMenu>
|
|
44
|
+
</Dropdown>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
import { initDropdown } from '@stainless-api/docs-ui/src/components/scripts/dropdown';
|
|
49
|
+
import { getPageLoadEvent } from '../../../plugin/helpers/getPageLoadEvent';
|
|
50
|
+
|
|
51
|
+
document.addEventListener(getPageLoadEvent(), () => {
|
|
52
|
+
initDropdown({
|
|
53
|
+
dropdownId: 'nav-dropdown',
|
|
54
|
+
isFixed: true,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
</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
|
+
|
|
76
|
+
<style>
|
|
77
|
+
:root {
|
|
78
|
+
--menu-font-size: calc(var(--sl-text-body) * 0.9);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.dropdown {
|
|
82
|
+
position: relative;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.dropdown-item {
|
|
86
|
+
clear: both;
|
|
87
|
+
color: var(--sl-color-text);
|
|
88
|
+
text-align: inherit;
|
|
89
|
+
text-decoration: none;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
}
|
|
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
|
+
</style>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Button } from '@stainless-api/ui-primitives';
|
|
3
|
+
import { buildNavLinks } from './buildNavLinks';
|
|
4
|
+
import NavDropdown from './NavDropdown.astro';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
|
|
7
|
+
const navLinks = buildNavLinks(Astro.locals.starlightRoute);
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<div id="nav-links-container">
|
|
11
|
+
<ul class="nav-links" id="nav-links-list">
|
|
12
|
+
<li class="mobile-menu-item" data-mobile-only>
|
|
13
|
+
<NavDropdown />
|
|
14
|
+
</li>
|
|
15
|
+
{
|
|
16
|
+
navLinks.map((item) => (
|
|
17
|
+
<li data-desktop-only>
|
|
18
|
+
<Button
|
|
19
|
+
href={item.link}
|
|
20
|
+
className={clsx('nav-link')}
|
|
21
|
+
variant={item.active ? 'accent-muted' : 'ghost'}
|
|
22
|
+
>
|
|
23
|
+
<span>{item.label}</span>
|
|
24
|
+
</Button>
|
|
25
|
+
</li>
|
|
26
|
+
))
|
|
27
|
+
}
|
|
28
|
+
</ul>
|
|
29
|
+
<!-- The test container is used to measure the width of the nav links and see if they fit -->
|
|
30
|
+
<!-- TODO: probably want to clean this up bc it's duplicated code -->
|
|
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>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { getPageLoadEvent } from '../../../plugin/helpers/getPageLoadEvent';
|
|
46
|
+
|
|
47
|
+
function getRequiredWidth() {
|
|
48
|
+
const navLinksTestContainer = document.getElementById('nav-links-test-container');
|
|
49
|
+
if (!navLinksTestContainer) return 1000000; // fallback to a large number
|
|
50
|
+
|
|
51
|
+
const rw = navLinksTestContainer.scrollWidth;
|
|
52
|
+
navLinksTestContainer.remove();
|
|
53
|
+
return rw;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function initNavbar() {
|
|
57
|
+
const masterContainer = document.getElementById('nav-links-container');
|
|
58
|
+
if (!masterContainer) return;
|
|
59
|
+
|
|
60
|
+
const navLinksContainer = document.getElementById('nav-links-list');
|
|
61
|
+
if (!navLinksContainer) return;
|
|
62
|
+
|
|
63
|
+
const requiredWidth = getRequiredWidth();
|
|
64
|
+
|
|
65
|
+
function checkIfFits() {
|
|
66
|
+
if (!masterContainer) return;
|
|
67
|
+
if (!navLinksContainer) return;
|
|
68
|
+
const availableWidth = masterContainer.clientWidth;
|
|
69
|
+
const canFit = availableWidth >= requiredWidth;
|
|
70
|
+
|
|
71
|
+
const mode = canFit ? 'desktop' : 'mobile';
|
|
72
|
+
|
|
73
|
+
localStorage.setItem('stl-nav-links-mode', mode);
|
|
74
|
+
|
|
75
|
+
document.documentElement.classList.remove('stl-nav-links-mode-desktop');
|
|
76
|
+
document.documentElement.classList.remove('stl-nav-links-mode-mobile');
|
|
77
|
+
|
|
78
|
+
document.documentElement.classList.add('stl-nav-links-mode-' + mode);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
window.addEventListener('resize', () => {
|
|
82
|
+
checkIfFits();
|
|
83
|
+
});
|
|
84
|
+
checkIfFits();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Initialize all dropdowns on the page
|
|
88
|
+
document.addEventListener(getPageLoadEvent(), () => {
|
|
89
|
+
initNavbar();
|
|
90
|
+
});
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<style is:global>
|
|
94
|
+
.stl-nav-links-mode-desktop [data-desktop-only] {
|
|
95
|
+
display: block;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.stl-nav-links-mode-desktop [data-mobile-only] {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.stl-nav-links-mode-mobile [data-mobile-only] {
|
|
103
|
+
display: block;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.stl-nav-links-mode-mobile [data-desktop-only] {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
</style>
|
|
110
|
+
|
|
111
|
+
<style>
|
|
112
|
+
/* :root {
|
|
113
|
+
--menu-font-size: calc(var(--sl-text-body));
|
|
114
|
+
} */
|
|
115
|
+
|
|
116
|
+
#nav-links-container {
|
|
117
|
+
visibility: hidden;
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-grow: 1;
|
|
120
|
+
justify-content: flex-start;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
margin-left: 1rem;
|
|
123
|
+
margin-right: 1rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.nav-links {
|
|
127
|
+
display: flex;
|
|
128
|
+
list-style: none;
|
|
129
|
+
gap: 0;
|
|
130
|
+
padding: 0;
|
|
131
|
+
margin: 0;
|
|
132
|
+
white-space: nowrap;
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
#nav-links-test-container {
|
|
137
|
+
position: absolute;
|
|
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
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@media (min-width: 50rem) {
|
|
160
|
+
#nav-links-container {
|
|
161
|
+
display: flex;
|
|
162
|
+
visibility: visible;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
</style>
|