Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 47ad9dc

Browse files
authored
adds doc search (#366)
- adds the algolia docsearch component - gets rid of the community/github/tiwtter button on mobile
1 parent e83110d commit 47ad9dc

File tree

7 files changed

+302
-129
lines changed

7 files changed

+302
-129
lines changed

components/Docs/Docs.module.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.mainWrapper {
22
display: flex;
3+
border-top: 1px solid var(--color-divider-on-dark);
34
}
45

56
.docsCard {
@@ -45,7 +46,7 @@
4546
flex: 0 0 300px;
4647
position: sticky;
4748
height: calc(100vh - 54px);
48-
top: 54px;
49+
top: 0px;
4950
z-index: 5;
5051
max-width: 300px;
5152
}
@@ -409,17 +410,16 @@ h5:hover .headingCopyIcon {
409410
min-height: 54px;
410411
display: flex;
411412
align-items: stretch;
412-
border-bottom: 1px solid var(--color-divider-on-dark);
413413
border-top: 1px solid var(--color-divider-on-dark);
414414
background-color: var(--color-primary-background);
415415
z-index: 10;
416416
}
417417

418418
.leftInner {
419419
position: relative;
420-
padding: 0 var(--size-medium);
421-
flex: 0 0 300px;
420+
padding: var(--size-small) var(--size-medium);
422421
display: flex;
422+
border-bottom: 1px solid var(--color-divider-on-dark);
423423
align-items: center;
424424
}
425425

@@ -634,7 +634,7 @@ h5:hover .headingCopyIcon {
634634
flex-direction: column;
635635
position: sticky;
636636
padding: var(--size-xLarge) var(--size-large);
637-
top: 80px;
637+
top: 0px;
638638
height: calc(100vh - 80px);
639639
}
640640

components/common/Navbar/Navbar.tsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import ProductDropdown from './ProductDropdown';
1515
import { GithubPopup } from '../../GithubPopup/GithubPopup';
1616
import { AiFillGithub } from 'react-icons/ai';
1717
import { FaDiscord } from 'react-icons/fa';
18+
import { DocSearch } from '@docsearch/react';
19+
20+
import '@docsearch/css';
21+
import { useMediaQuery } from '../../MediaQuery/MediaQuery';
1822

1923
const Navbar = ({
2024
hideFreeTrialText,
@@ -89,7 +93,6 @@ const Navbar = ({
8993
<Link href={'/'} className={styles.urlStyle}>
9094
{isOpen ? <HighlightLogoWhite /> : <HighlightLogo />}
9195
</Link>
92-
9396
<Typography type="copy3" emphasis={true}>
9497
<p
9598
className={classNames(styles.navTitle, {
@@ -100,6 +103,11 @@ const Navbar = ({
100103
{title}
101104
</p>
102105
</Typography>
106+
<DocSearch
107+
appId="JGT9LI80J2"
108+
indexName="highlight"
109+
apiKey="ac336720d8f4f996abe3adee603a1c84"
110+
/>
103111
</div>
104112
<div className={styles.navMenu} onClick={() => setIsOpen(!isOpen)}>
105113
{isOpen ? (
@@ -108,6 +116,7 @@ const Navbar = ({
108116
<AiOutlineMenu />
109117
)}
110118
</div>
119+
111120
{isOpen && (
112121
<div className={styles.mobileMenu}>
113122
<ul className={classNames(styles.menuList, styles.header)}>
@@ -191,22 +200,6 @@ const Navbar = ({
191200
styles.headerRight
192201
)}
193202
>
194-
{isDocsPage && (
195-
<>
196-
<Link
197-
href="https://discord.gg/yxaXEAqgwN"
198-
className={styles.headerButton}
199-
>
200-
<Typography type="copy2">Community</Typography>
201-
</Link>
202-
<Link
203-
href="https://github.com/highlight/highlight"
204-
className={styles.headerButton}
205-
>
206-
<Typography type="copy2">Github</Typography>
207-
</Link>
208-
</>
209-
)}
210203
{!isDocsPage && (
211204
<Link href="/docs" className={classNames(styles.headerButton, styles.headerButtonRight)}>
212205
<Typography type="copy2">Docs</Typography>

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"styles": "yarn typed-scss-modules ./ --watch --ignore '**/node_modules'"
1313
},
1414
"dependencies": {
15+
"@docsearch/css": "3",
16+
"@docsearch/js": "3",
1517
"@graphcms/rich-text-react-renderer": "^0.6.1",
1618
"@headlessui/react": "^1.7.4",
1719
"@heroicons/react": "^2.0.13",

pages/_document.js

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
// pages/_document.js
22

3-
import Document, {Head, Html, Main, NextScript} from 'next/document'
4-
import Script from "next/script";
3+
import Document, { Head, Html, Main, NextScript } from 'next/document'
4+
import Script from 'next/script'
55

66
class HighlightDocument extends Document {
7-
render() {
8-
return (
9-
<Html>
10-
<Head>
11-
<link rel="preconnect" href="https://fonts.googleapis.com"></link>
12-
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin></link>
13-
<link
14-
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital@0;1&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
15-
rel="stylesheet"
16-
></link>
17-
<Script
18-
src="https://www.googletagmanager.com/gtag/js?id=AW-10833687189"
19-
strategy="afterInteractive"
20-
/>
21-
<Script id="google-analytics" strategy="afterInteractive">
22-
{`
7+
render() {
8+
return (
9+
<Html>
10+
<Head>
11+
<link rel="preconnect" href="https://JGT9LI80J2-dsn.algolia.net" crossorigin />
12+
<link rel="preconnect" href="https://fonts.googleapis.com"></link>
13+
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin></link>
14+
<link
15+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital@0;1&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
16+
rel="stylesheet"
17+
></link>
18+
<Script src="https://www.googletagmanager.com/gtag/js?id=AW-10833687189" strategy="afterInteractive" />
19+
<Script id="google-analytics" strategy="afterInteractive">
20+
{`
2321
function gtag() {
2422
(window.dataLayer || []).push(arguments);
2523
}
@@ -31,15 +29,15 @@ class HighlightDocument extends Document {
3129
gtag('config', 'AW-10833687189');
3230
window.gtag = gtag
3331
`}
34-
</Script>
35-
<NextScript/>
36-
</Head>
37-
<body style={{overflowX: 'hidden'}}>
38-
<Main/>
39-
</body>
40-
</Html>
41-
)
42-
}
32+
</Script>
33+
<NextScript />
34+
</Head>
35+
<body style={{ overflowX: 'hidden' }}>
36+
<Main />
37+
</body>
38+
</Html>
39+
)
40+
}
4341
}
4442

4543
export default HighlightDocument

pages/docs/[[...doc]].tsx

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Callout } from '../../components/Docs/Callout/Callout'
3030
import { CodeBlock } from '../../components/common/CodeBlock/CodeBlock'
3131
import { quickStartContent, QuickStartContent, QuickStartStep, QuickStartType } from '../../components/QuickstartContent/QuickstartContent'
3232
import Markdown from 'markdown-to-jsx'
33+
import { useMediaQuery } from '../../components/MediaQuery/MediaQuery'
3334

3435
const DOCS_CONTENT_PATH = path.join(process.cwd(), 'docs-content')
3536
const DOCS_GITUB_LINK = `https://github.com/highlight/highlight.io/blob/main/docs-content/`
@@ -640,6 +641,8 @@ const DocPage = ({
640641

641642
const currentToc = toc?.children.find((c) => c.tocSlug === relPath?.split("/").filter(r => r)[0])
642643

644+
const is400 = useMediaQuery(400);
645+
643646
return (
644647
<>
645648
<Meta
@@ -655,47 +658,11 @@ const DocPage = ({
655658
canonical={`/docs/${slug}`}
656659
/>
657660
<Navbar title="Docs" hideBanner isDocsPage fixed />
658-
<div className={styles.contentInnerBar}>
659-
<div className={styles.leftInner}>
660-
<DocSelect />
661-
</div>
662-
<div className={styles.centerInner}>
663-
<DocSearchbar docPaths={docOptions} />
664-
{isSdkDoc && (
665-
<div
666-
style={{
667-
display: 'flex',
668-
flexDirection: 'row',
669-
justifyContent: 'space-between',
670-
gap: 8,
671-
}}
672-
>
673-
<Link className={styles.sdkSocialItem} href={`${DOCS_GITUB_LINK}${relPath}`} target="_blank">
674-
<FaGithub
675-
style={{
676-
height: 20,
677-
width: 20,
678-
flexShrink: 0,
679-
}}
680-
></FaGithub>
681-
<Typography type="copy4">Suggest Edits?</Typography>
682-
</Link>
683-
<Link className={styles.sdkSocialItem} href="https://discord.gg/yxaXEAqgwN" target="_blank">
684-
<FaDiscord
685-
style={{
686-
height: 20,
687-
width: 20,
688-
flexShrink: 0,
689-
}}
690-
></FaDiscord>
691-
<Typography type="copy4">Community / Support</Typography>
692-
</Link>
693-
</div>
694-
)}
695-
</div>
696-
</div>
697661
<main ref={blogBody} className={styles.mainWrapper}>
698662
<div className={styles.leftSection}>
663+
<div className={styles.leftInner}>
664+
<DocSelect />
665+
</div>
699666
<div className={styles.tocMenuLarge}>
700667
{isSdkDoc ? (
701668
<SdkTableOfContents />
@@ -756,34 +723,6 @@ const DocPage = ({
756723
[styles.quickStartCenterSection]: isQuickstart,
757724
})}
758725
>
759-
{!isSdkDoc && !isQuickstart && (
760-
<div className={styles.resourcesMobile}>
761-
<Link
762-
className={styles.socialItem}
763-
href="https://discord.gg/yxaXEAqgwN"
764-
target="_blank"
765-
style={{
766-
borderBottom: '1px solid #30294E',
767-
}}
768-
>
769-
<FaDiscord style={{ height: 20, width: 20 }}></FaDiscord>
770-
<Typography type="copy3">Community / Support</Typography>
771-
</Link>
772-
<Link className={styles.socialItem} href={`${DOCS_GITUB_LINK}${relPath ?? ''}`} target="_blank">
773-
<FaGithub style={{ height: 20, width: 20 }}></FaGithub>
774-
<Typography type="copy3">Suggest Edits?</Typography>
775-
</Link>
776-
<Link
777-
style={{ borderTop: '1px solid #30294E' }}
778-
className={styles.socialItem}
779-
href="https://twitter.com/highlightio"
780-
target="_blank"
781-
>
782-
<FaTwitter style={{ height: 20, width: 20 }}></FaTwitter>
783-
<Typography type="copy3">Follow us!</Typography>
784-
</Link>
785-
</div>
786-
)}
787726
<div className={styles.breadcrumb}>
788727
{!isSdkDoc &&
789728
getBreadcrumbs(metadata, docOptions, docIndex).map((breadcrumb, i) =>

styles/globals.scss

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
scrollbar-width: none; /* Firefox */
1616
}
1717

18+
.DocSearch-Button {
19+
background-color: #0d0225 !important;
20+
border: 1px solid var(--divider-on-dark) !important;
21+
}
22+
.DocSearch-Button:hover {
23+
border: 1px solid var(--copy-on-dark) !important;
24+
box-shadow: none !important;
25+
border: 1px solid var(--copy-on-light) !important;
26+
color: var(--copy-on-light) !important;
27+
}
28+
29+
.DocSearch-Button .DocSearch-Search-Icon {
30+
color: var(--copy-on-light) !important;
31+
}
32+
1833
:root {
1934
--color-purple-100: #ede9fe;
2035
--color-purple-200: #ddd6fe;
@@ -141,22 +156,17 @@
141156

142157
--max-width: 1200px;
143158

144-
--box-shadow: 0px 0.9px 1.4px rgba(0, 0, 0, 0.012),
145-
0px 2.2px 3.6px rgba(0, 0, 0, 0.018), 0px 4.4px 7.4px rgba(0, 0, 0, 0.022),
146-
0px 9.1px 15.3px rgba(0, 0, 0, 0.028), 0px 25px 42px rgba(0, 0, 0, 0.04);
159+
--box-shadow: 0px 0.9px 1.4px rgba(0, 0, 0, 0.012), 0px 2.2px 3.6px rgba(0, 0, 0, 0.018),
160+
0px 4.4px 7.4px rgba(0, 0, 0, 0.022), 0px 9.1px 15.3px rgba(0, 0, 0, 0.028), 0px 25px 42px rgba(0, 0, 0, 0.04);
147161

148-
--box-shadow-2: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%),
149-
0 9px 28px 8px rgb(0 0 0 / 5%);
150-
--box-shadow-3: 0 2.8px 2.2px rgba(0, 0, 0, 0.02),
151-
0 6.7px 5.3px rgba(0, 0, 0, 0.028), 0 12.5px 10px rgba(0, 0, 0, 0.035),
152-
0 22.3px 17.9px rgba(0, 0, 0, 0.042), 0 41.8px 33.4px rgba(0, 0, 0, 0.05),
162+
--box-shadow-2: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
163+
--box-shadow-3: 0 2.8px 2.2px rgba(0, 0, 0, 0.02), 0 6.7px 5.3px rgba(0, 0, 0, 0.028),
164+
0 12.5px 10px rgba(0, 0, 0, 0.035), 0 22.3px 17.9px rgba(0, 0, 0, 0.042), 0 41.8px 33.4px rgba(0, 0, 0, 0.05),
153165
0 100px 80px rgba(0, 0, 0, 0.07);
154166

155-
--header-font-family: 'Poppins', 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
156-
'Noto Sans', sans-serif;
157-
--body-font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI',
158-
Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
159-
'Segoe UI Symbol';
167+
--header-font-family: 'Poppins', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
168+
--body-font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,
169+
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
160170
--monospace-font-family: 'Roboto Mono', monospace;
161171

162172
--button-border-radius: var(--size-xSmall);

0 commit comments

Comments
 (0)