Skip to content

Commit

Permalink
Merge branch 'main' into fix-colorScheme-button-themes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThangHuuVu authored Feb 2, 2025
2 parents 67eb381 + 63fdab1 commit 71b2b01
Show file tree
Hide file tree
Showing 19 changed files with 759 additions and 447 deletions.
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/2_bug_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ body:
- "EVE Online"
- "Facebook"
- "FACEIT"
- "Figma"
- "Foursquare"
- "Freshbooks"
- "FusionAuth"
Expand All @@ -63,6 +64,7 @@ body:
- "Kinde"
- "Line"
- "LinkedIn"
- "Logto"
- "Loops"
- "Mailchimp"
- "Mail.ru"
Expand Down
1 change: 1 addition & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exemptLabels:
- triage
- accepted
staleLabel: stale
only: issues
markComment: >
It looks like this issue did not receive any activity for 60 days.
It will be closed in 7 days if no further activity occurs. If you think your issue
Expand Down
62 changes: 0 additions & 62 deletions docs/components/DocSearch/hit.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions docs/components/DocSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ const DocSearch = dynamic(
() => import("./wrapper").then((mod) => mod.default),
{
ssr: false,
loading: () => (
<div className="relative h-8 w-48 appearance-none rounded-lg bg-black/[.05] px-3 py-1.5 pr-2 text-base leading-tight text-gray-500 transition-colors focus:!bg-transparent max-md:ml-6 md:text-sm dark:bg-gray-50/10 dark:text-gray-400">
Search...
<kbd className="pointer-events-none absolute right-0 top-0 my-1.5 flex h-5 select-none items-center gap-1 rounded border bg-white px-1.5 font-mono text-[10px] font-medium text-gray-500 transition-opacity contrast-more:border-current contrast-more:text-current max-sm:hidden ltr:right-1.5 rtl:left-1.5 dark:border-gray-100/20 dark:bg-black/50 contrast-more:dark:border-current">
CTRL K
</kbd>
</div>
),
}
)

Expand Down
105 changes: 0 additions & 105 deletions docs/components/DocSearch/searchInput.tsx

This file was deleted.

118 changes: 16 additions & 102 deletions docs/components/DocSearch/wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,112 +1,26 @@
import { useEffect, useRef, useState } from "react"
import algoliasearch from "algoliasearch/lite"
import { InstantSearch, Hits, useInstantSearch } from "react-instantsearch"
//import { InstantSearchNext } from "react-instantsearch-nextjs"
import { CustomSearchBox } from "./searchInput"
import Hit from "./hit"
import { DocSearch } from "@docsearch/react"
import { useTheme } from "nextra-theme-docs"
import { useEffect } from "react"

const algoliaClient = algoliasearch(
process.env.NEXT_PUBLIC_ALGOLIA_APP_ID!,
process.env.NEXT_PUBLIC_ALGOLIA_KEY!
)
import "@docsearch/css"

const searchClient = {
...algoliaClient,
search(requests: any) {
if (requests.every(({ params }) => !params.query)) {
return Promise.resolve({
results: requests.map(() => ({
hits: [],
nbHits: 0,
nbPages: 0,
page: 0,
processingTimeMS: 0,
hitsPerPage: 0,
exhaustiveNbHits: false,
query: "",
params: "",
})),
})
}
return algoliaClient.search(requests)
},
}

export default function Wrapper() {
const docSearchRef = useRef<HTMLDivElement>(null)
const [isSearchHitsVisible, setIsSearchHitsVisible] = useState(false)
function App() {
const { resolvedTheme } = useTheme()

useEffect(() => {
function ctrlKHandler(e: KeyboardEvent) {
if (e.repeat || e.target instanceof HTMLInputElement) return
if (e.ctrlKey && e.key === "k") {
e.preventDefault()
document
.querySelector<HTMLInputElement>('input[type="search"]')
?.focus()
}
}

function clickSearchBoxOutsideHandler(event: MouseEvent) {
setIsSearchHitsVisible(
Boolean(
event.target instanceof Node &&
docSearchRef.current?.contains(event.target)
)
)
}

window.addEventListener("keydown", ctrlKHandler)
window.addEventListener("mousedown", clickSearchBoxOutsideHandler)

return () => {
window.removeEventListener("keydown", ctrlKHandler)
window.removeEventListener("mousedown", clickSearchBoxOutsideHandler)
if (resolvedTheme) {
// hack to get DocSearch to use dark mode colors if applicable
document.documentElement.setAttribute("data-theme", resolvedTheme)
}
}, [])
}, [resolvedTheme])

return (
<div
ref={docSearchRef}
className="relative [aside_&]:w-full max-md:[nav_&]:hidden"
>
<InstantSearch
indexName="next-auth"
// @ts-expect-error
searchClient={searchClient}
>
<CustomSearchBox />
{isSearchHitsVisible && (
<NoResultsBoundary>
<Hits
hitComponent={Hit}
className="fixed left-2 top-28 z-50 mt-[50px] max-h-[calc(100dvh_-_120px)] w-[calc(100vw_-_16px)] overflow-y-auto rounded-md bg-neutral-100 shadow-lg md:absolute md:left-auto md:right-0 md:top-12 md:mt-auto md:w-96 dark:bg-neutral-800 [&>ol]:flex [&>ol]:flex-col [&>ol]:divide-y [&>ol]:divide-neutral-400/30 [&>ol]:dark:divide-neutral-900/50"
/>
</NoResultsBoundary>
)}
</InstantSearch>
</div>
<DocSearch
appId={process.env.NEXT_PUBLIC_ALGOLIA_APP_ID!}
indexName="next-auth"
apiKey={process.env.NEXT_PUBLIC_ALGOLIA_KEY!}
/>
)
}

function NoResultsBoundary({ children }) {
const { indexUiState, results } = useInstantSearch()

if (
indexUiState.query !== undefined &&
!results.__isArtificial &&
results.nbHits === 0
) {
return (
<div className="fixed left-2 top-28 z-50 mt-[50px] max-h-[calc(100dvh_-_120px)] w-[calc(100vw_-_16px)] overflow-y-auto rounded-md bg-neutral-100 p-2 text-center shadow-md md:absolute md:left-auto md:right-0 md:top-12 md:mt-auto md:w-96 dark:bg-neutral-800 [&>ol]:flex [&>ol]:flex-col [&>ol]:divide-y [&>ol]:divide-neutral-400/30 [&>ol]:dark:divide-neutral-900/50">
No Results
</div>
)
}

if (indexUiState.query === undefined) {
return null
}

return children
}
export default App
5 changes: 2 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"homepage": "https://authjs.dev",
"dependencies": {
"@ariakit/react": "^0.4.13",
"@docsearch/react": "3",
"@inkeep/widgets": "^0.2.289",
"@next/third-parties": "^14.2.15",
"@radix-ui/react-accordion": "^1.2.1",
Expand All @@ -39,9 +40,7 @@
"nextra": "3.0.15",
"nextra-theme-docs": "3.0.15",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-instantsearch": "^7.13.3",
"react-instantsearch-nextjs": "^0.2.5"
"react-dom": "18.3.1"
},
"devDependencies": {
"@types/node": "20.12.7",
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"duende-identityserver-6": "DuendeIdentityServer6",
"eveonline": "EVE Online",
"faceit": "FACEIT",
"figma": "Figma",
"foursquare": "Foursquare",
"freshbooks": "Freshbooks",
"fusionauth": "FusionAuth",
Expand All @@ -84,6 +85,7 @@
"kinde": "Kinde",
"line": "LINE",
"linkedin": "LinkedIn",
"logto": "Logto",
"mailchimp": "Mailchimp",
"mailru": "Mail.ru",
"mastodon": "Mastodon",
Expand Down Expand Up @@ -141,6 +143,7 @@
"identity-server4",
"keycloak",
"kinde",
"logto",
"mastodon",
"mattermost",
"nextcloud",
Expand Down
Loading

0 comments on commit 71b2b01

Please sign in to comment.