Skip to content

fix aiSearchBar component #1858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 4, 2024
Merged
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
9 changes: 8 additions & 1 deletion src/components/Header/aiSearch/SearchButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { clsx } from "~/lib"
import styles from "./searchButton.module.css"
import { useEffect, useState } from "react"

const searchIcon = (
<svg
Expand All @@ -25,6 +26,12 @@ const searchIcon = (
)

export const SearchButton = ({ variant }: { variant: "default" | "bottomBar" }) => {
const [isMac, setIsMac] = useState(false)
useEffect(() => {
const checkIsMac = typeof navigator !== "undefined" ? navigator.userAgent.toUpperCase().indexOf("MAC") >= 0 : false
setIsMac(checkIsMac)
}, [])

return variant === "default" ? (
<button className={clsx(styles.default, "search-widget-trigger")}>
<svg
Expand All @@ -48,7 +55,7 @@ export const SearchButton = ({ variant }: { variant: "default" | "bottomBar" })
</defs>
</svg>
<span className={styles.text}>Search Chainlink Docs</span>
<div className={styles.shortcut}>K</div>
<div className={styles.shortcut}>{isMac ? "⌘" : "Ctrl+"}K</div>
</button>
) : (
<button className={clsx(styles.bottomBar, "search-widget-trigger")}>
Expand Down