Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 38 additions & 28 deletions js/documentation/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import MainContent from '@src/components/MainContent'
import PageFooter from '@src/components/PageFooter'
import {
ContentContainer,
MainColumn,
PageGrid,
SideCarContainer,
SideNavContainer,
Expand All @@ -56,6 +57,7 @@ import {
ROOT_TITLE,
} from '@src/consts'
import { NavDataProvider } from '@src/contexts/NavDataContext'
import { RestNavProvider } from '@src/contexts/RestNavContext'
import { collectHeadings } from '@src/markdoc/utils/parseHeadings'
import { getNavData } from '@src/NavData'

Expand Down Expand Up @@ -169,29 +171,35 @@ function App({ Component, pageProps = {}, swrConfig }: MyAppProps) {
<FullNav desktop />
)}
</SideNavContainer>
<ContentContainer>
<MainContent
Component={Component}
title={displayTitle}
description={displayDescription}
/>
<PageFooter />
</ContentContainer>
<SideCarContainer>
{isClient ? (
<Suspense fallback={<div>Loading table of contents...</div>}>
<TableOfContents
key={router.asPath}
toc={toc}
/>
</Suspense>
) : (
<TableOfContents
key={router.asPath}
toc={toc}
<MainColumn>
<ContentContainer>
<MainContent
Component={Component}
title={displayTitle}
description={displayDescription}
/>
<PageFooter />
</ContentContainer>
{toc?.length > 0 && (
<SideCarContainer>
{isClient ? (
<Suspense
fallback={<div>Loading table of contents...</div>}
>
<TableOfContents
key={router.asPath}
toc={toc}
/>
</Suspense>
) : (
<TableOfContents
key={router.asPath}
toc={toc}
/>
)}
</SideCarContainer>
)}
</SideCarContainer>
</MainColumn>
</PageGrid>
)}
</Page>
Expand All @@ -211,13 +219,15 @@ function App({ Component, pageProps = {}, swrConfig }: MyAppProps) {
<NavigationContextProvider value={navContextVal}>
<SWRConfig value={swrConfig}>
<NavDataProvider value={navData}>
<BreakpointProvider>
<StyledThemeProvider theme={docsStyledTheme}>
<HonorableThemeProvider>
<FillLevelProvider value={0}>{app}</FillLevelProvider>
</HonorableThemeProvider>
</StyledThemeProvider>
</BreakpointProvider>
<RestNavProvider>
<BreakpointProvider>
<StyledThemeProvider theme={docsStyledTheme}>
<HonorableThemeProvider>
<FillLevelProvider value={0}>{app}</FillLevelProvider>
</HonorableThemeProvider>
</StyledThemeProvider>
</BreakpointProvider>
</RestNavProvider>
</NavDataProvider>
</SWRConfig>
</NavigationContextProvider>
Expand Down
184 changes: 184 additions & 0 deletions js/documentation/src/components/DocsSearch.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import {
AiSparkleFilledIcon,
Button,
IconFrame,
SearchIcon,
} from '@pluralsh/design-system'

import styled from 'styled-components'

import { mqs } from './Breakpoints'

function SearchTrigger({ compact = false }: { compact?: boolean }) {
if (compact) {
return (
<IconFrame
clickable
size="large"
type="floating"
textValue="Search docs"
tooltip="Search docs"
icon={<SearchIcon size={16} />}
className="docs-search-trigger"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
/>
)
}

return (
<SearchBar
type="button"
className="docs-search-trigger"
aria-label="Search docs"
>
<SearchIcon
size={16}
className="searchIcon"
/>
<span className="placeholder">Search docs...</span>
<Kbd>⌘K</Kbd>
</SearchBar>
)
}

function AskAiTrigger({ compact = false }: { compact?: boolean }) {
if (compact) {
return (
<IconFrame
clickable
size="large"
type="secondary"
textValue="Ask AI"
tooltip="Ask AI"
icon={<AiSparkleFilledIcon size={16} />}
className="docs-ai-trigger"
/>
)
}

return (
<AskAiButton
className="docs-ai-trigger"
secondary
startIcon={<AiSparkleFilledIcon size={16} />}
>
Ask AI
</AskAiButton>
)
}

export function DocsSearch() {
return (
<>
<CenterCluster>
<SearchTrigger />
<WideAskAi>
<AskAiTrigger />
</WideAskAi>
<NarrowAskAi>
<AskAiTrigger compact />
</NarrowAskAi>
</CenterCluster>
<ToolbarCluster>
<SearchTrigger compact />
<AskAiTrigger compact />
</ToolbarCluster>
</>
)
}

const AskAiButton = styled(Button)({
height: 40,
minHeight: 40,
})

const SearchBar = styled.button(({ theme }) => ({
display: 'flex',
alignItems: 'center',
gap: theme.spacing.small,
width: 220,
[mqs.threeColumn]: {
width: 360,
maxWidth: '32vw',
},
height: 40,
padding: `0 ${theme.spacing.xsmall}px 0 ${theme.spacing.medium}px`,
border: theme.borders.input,
borderRadius: theme.borderRadiuses.medium,
background: theme.colors['fill-one'],
color: theme.colors['text-xlight'],
cursor: 'pointer',
...theme.partials.text.body2,
'.searchIcon': {
flexShrink: 0,
color: theme.colors['text-light'],
},
'.placeholder': {
flex: 1,
minWidth: 0,
textAlign: 'left',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
},
'&:hover': {
background: theme.colors['fill-one-hover'],
color: theme.colors['text-light'],
},
'&:focus, &:focus-visible': {
outline: 'none',
},
'&:focus-visible': {
...theme.partials.focus.default,
},
}))

const Kbd = styled.span(({ theme }) => ({
...theme.partials.text.caption,
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
minWidth: 28,
height: 22,
padding: `0 ${theme.spacing.xsmall}px`,
borderRadius: theme.borderRadiuses.medium,
background: theme.colors['fill-two'],
color: theme.colors['text-xlight'],
}))

const CenterCluster = styled.div(({ theme }) => ({
display: 'none',
[mqs.fullHeader]: {
display: 'flex',
alignItems: 'center',
gap: theme.spacing.small,
position: 'absolute',
left: '50%',
top: '50%',
transform: 'translate(-50%, -50%)',
zIndex: 1,
},
}))

const ToolbarCluster = styled.div(({ theme }) => ({
display: 'flex',
alignItems: 'center',
gap: theme.spacing.xsmall,
[mqs.fullHeader]: {
display: 'none',
},
}))

const WideAskAi = styled.div({
display: 'none',
[mqs.threeColumn]: {
display: 'block',
},
})

const NarrowAskAi = styled.div({
display: 'block',
[mqs.threeColumn]: {
display: 'none',
},
})
16 changes: 15 additions & 1 deletion js/documentation/src/components/ExternalScripts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,27 @@ function KapaWidget() {
src="https://widget.kapa.ai/kapa-widget.bundle.js"
data-website-id="8288b978-8aca-4409-9cbd-de12c446cf07"
data-project-name="Plural"
data-view-mode="sidebar"
data-view-mode="default"
data-button-hide="true"
data-launcher-button-hidden="true"
data-modal-open-on-command-k="true"
data-modal-command-k-search-mode-default="true"
data-search-mode-enabled="true"
data-modal-override-open-selector-search=".docs-search-trigger"
data-modal-override-open-selector=".docs-ai-trigger"
data-mcp-enabled="true"
data-mcp-server-url="https://plural.mcp.kapa.ai"
data-project-color="#5D63F4"
data-project-logo="https://docs.plural.sh/favicon-192.png"
data-kapa-branding-hidden="true"
data-color-scheme="dark"
data-surface-color-dark="#12151B"
data-surface-elevated-color-dark="#1B1F27"
data-surface-hover-color-dark="#252932"
data-text-color-dark="#EEF0F1"
data-text-muted-color-dark="#A1A5B0"
data-border-color-dark="#303540"
data-anchor-color-dark="#5D63F4"
/>
)
}
Expand Down
4 changes: 3 additions & 1 deletion js/documentation/src/components/FullNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export const NavButtons = styled(NavButtonsUnstyled)<{ desktop: boolean }>(
export const NavWrap = styled.div((_) => ({
position: 'relative',
flexGrow: 1,
flex: 1,
minHeight: 0,
}))

function NavButton({
Expand Down Expand Up @@ -102,7 +104,7 @@ export function FullNav({
const previousPath = usePrevious(thisPath)

useEffect(() => {
if (thisPath !== previousPath) {
if (previousPath && thisPath !== previousPath) {
if (setIsOpen) {
setIsOpen(false)
}
Expand Down
4 changes: 3 additions & 1 deletion js/documentation/src/components/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const GlobalStyles = createGlobalStyle(({ theme }) => ({
':root': {
'--top-nav-height': '72px',
'--menu-extra-bpad': '0px',
'--docs-sidenav-width': '306px',
'--docs-sidecar-width': '220px',
},
'a:any-link': {
color: 'unset',
Expand All @@ -39,7 +41,7 @@ const GlobalStyles = createGlobalStyle(({ theme }) => ({
},
body: {
margin: 0,
overflowX: 'hidden',
overflowX: 'clip',
color: theme.colors.text,
backgroundColor: theme.colors['fill-zero'],
...fillAvailable('minHeight'),
Expand Down
15 changes: 12 additions & 3 deletions js/documentation/src/components/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ import Breadcrumbs from './Breadcrumbs'
import { FooterLink } from './PageFooter'
import { PagePropsContext } from './PagePropsContext'

const ContentWrapper = styled.div(({ theme }) => ({
marginTop: theme.spacing.xlarge,
const ContentWrapper = styled.div((_) => ({
minWidth: 0,
}))

const BreadcrumbsWrapper = styled.div(({ theme }) => ({
marginTop: theme.spacing.xlarge,
display: 'flex',
alignItems: 'center',
width: '100%',
minWidth: 0,
minHeight: 40,
marginBottom: theme.spacing.large,
'& > *': {
minWidth: 0,
width: '100%',
},
}))

const Title = styled.h1(({ theme }) => ({
Expand Down
Loading
Loading