mirror of
https://github.com/linsa-io/linsa.git
synced 2026-03-25 10:31:36 +01:00
* wip * wip * wip3 * chore: utils * feat: add command * wip * fix: key duplicate * fix: move and check * fix: use react-use instead * fix: sidebar * chore: make dynamic * chore: tablet mode * chore: fix padding * chore: link instead of inbox * fix: use dnd kit * feat: add select component * chore: use atom * refactor: remove dnd provider * feat: disabled drag when sort is not manual * search route * . * feat: accessibility * fix: search * . * . * . * fix: sidebar collapsed * ai search layout * . * . * . * . * ai responsible content * . * . * . * . * . * global topic route * global topic correct route * topic buttons * sidebar search navigation * ai * Update jazz * . * . * . * . * . * learning status * . * . * chore: content header * fix: pointer none when dragging. prevent auto click after drag end * fix: confirm * fix: prevent drag when editing * chore: remove unused fn * fix: check propagation * chore: list * chore: tweak sonner * chore: update stuff * feat: add badge * chore: close edit when create * chore: escape on manage form * refactor: remove learn path * css: responsive item * chore: separate pages and topic * reafactor: remove new-schema * feat(types): extend jazz type so it can be nullable * chore: use new types * fix: missing deps * fix: link * fix: sidebar in layout * fix: quotes * css: use medium instead semi * Actual streaming and rendering markdown response * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * chore: metadata * feat: la-editor * . * fix: editor and page * . * . * . * . * . * . * fix: remove link * chore: page sidebar * fix: remove 'replace with learning status' * fix: link * fix: link * chore: update schema * chore: use new schema * fix: instead of showing error, just do unique slug * feat: create slug * refactor apply * update package json * fix: schema personal page * chore: editor * feat: pages * fix: metadata * fix: jazz provider * feat: handling data * feat: page detail * chore: server page to id * chore: use id instead of slug * chore: update content header * chore: update link header implementation * refactor: global.css * fix: la editor use animation frame * fix: editor export ref * refactor: page detail * chore: tidy up schema * chore: adapt to new schema * fix: wrap using settimeout * fix: wrap using settimeout * . * . --------- Co-authored-by: marshennikovaolga <marshennikova@gmail.com> Co-authored-by: Nikita <github@nikiv.dev> Co-authored-by: Anselm <anselm.eickhoff@gmail.com> Co-authored-by: Damian Tarnawski <gthetarnav@gmail.com>
132 lines
4.2 KiB
TypeScript
132 lines
4.2 KiB
TypeScript
"use client"
|
|
import { useState } from "react"
|
|
// import { useAccount } from "@/lib/providers/jazz-provider"
|
|
import { IoSearch, IoCloseOutline, IoChevronForward } from "react-icons/io5"
|
|
import AiSearch from "../../custom/ai-search"
|
|
|
|
interface ProfileTopicsProps {
|
|
topic: string
|
|
}
|
|
|
|
const ProfileTopics: React.FC<ProfileTopicsProps> = ({ topic }) => {
|
|
return (
|
|
<div className="flex cursor-pointer flex-row items-center justify-between rounded-lg bg-[#121212] p-3">
|
|
<p>{topic}</p>
|
|
<IoChevronForward className="text-white" size={20} />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
interface ProfileLinksProps {
|
|
linklabel: string
|
|
link: string
|
|
topic: string
|
|
}
|
|
|
|
interface ProfileTitleProps {
|
|
topicTitle: string
|
|
spanNumber: number
|
|
}
|
|
|
|
const ProfileTitle: React.FC<ProfileTitleProps> = ({ topicTitle, spanNumber }) => {
|
|
return (
|
|
<p className="pb-3 pl-2 text-base font-light text-white/50">
|
|
{topicTitle} <span className="text-white">{spanNumber}</span>
|
|
</p>
|
|
)
|
|
}
|
|
|
|
const ProfileLinks: React.FC<ProfileLinksProps> = ({ linklabel, link, topic }) => {
|
|
return (
|
|
<div className="flex flex-row items-center justify-between rounded-lg bg-[#121212] p-3 text-white">
|
|
<div className="flex flex-row items-center space-x-3">
|
|
<p className="text-base text-white">{linklabel}</p>
|
|
<div className="flex cursor-pointer flex-row items-center gap-1">
|
|
<p className="text-md text-white/10 transition-colors duration-300 hover:text-white/30">{link}</p>
|
|
</div>
|
|
</div>
|
|
<div className="cursor-default rounded-lg bg-[#1a1a1a] p-2 text-white/60">{topic}</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export const SearchWrapper = () => {
|
|
// const account = useAccount()
|
|
const [searchText, setSearchText] = useState("")
|
|
const [aiSearch, setAiSearch] = useState("")
|
|
const [showAiSearch, setShowAiSearch] = useState(false)
|
|
const [showAiPlaceholder, setShowAiPlaceholder] = useState(false)
|
|
|
|
const inputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
setSearchText(e.target.value)
|
|
if (e.target.value.trim() !== "") {
|
|
setShowAiPlaceholder(false)
|
|
setTimeout(() => setShowAiPlaceholder(true), 1000)
|
|
} else {
|
|
setShowAiPlaceholder(false)
|
|
setShowAiSearch(false)
|
|
}
|
|
}
|
|
|
|
const clearSearch = () => {
|
|
setSearchText("")
|
|
setShowAiSearch(false)
|
|
setShowAiPlaceholder(false)
|
|
}
|
|
|
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
if (e.key === "Enter" && searchText.trim() !== "") {
|
|
setShowAiSearch(true)
|
|
setAiSearch(searchText)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="flex h-full flex-auto flex-col overflow-hidden">
|
|
<div className="flex h-full w-full justify-center overflow-hidden">
|
|
<div className="w-full max-w-3xl px-4 sm:px-6 lg:px-8">
|
|
<div className="relative mb-2 mt-5 flex w-full flex-row items-center transition-colors duration-300 hover:text-white/60">
|
|
<IoSearch className="absolute left-3 text-white/30" size={20} />
|
|
<input
|
|
type="text"
|
|
autoFocus
|
|
value={searchText}
|
|
onChange={inputChange}
|
|
onKeyDown={handleKeyDown}
|
|
className="w-full rounded-[10px] bg-[#16181d] p-10 py-3 pl-10 pr-3 font-semibold tracking-wider text-white outline-none placeholder:font-light placeholder:text-white/30"
|
|
placeholder="Search..."
|
|
/>
|
|
{showAiPlaceholder && searchText && !showAiSearch && (
|
|
<div className="absolute right-10 text-sm text-white/30">press "Enter" for AI search</div>
|
|
)}
|
|
{searchText && (
|
|
<IoCloseOutline className="absolute right-3 cursor-pointer opacity-30" size={20} onClick={clearSearch} />
|
|
)}
|
|
</div>
|
|
{showAiSearch ? (
|
|
<div className="relative w-full">
|
|
<div className="absolute left-1/2 w-[110%] -translate-x-1/2">
|
|
<AiSearch searchQuery={searchText} />
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<>
|
|
<div className="my-5 space-y-1">
|
|
<ProfileTitle topicTitle="Topics" spanNumber={1} />
|
|
<ProfileTopics topic="Figma" />
|
|
</div>
|
|
|
|
<div className="my-5 space-y-1">
|
|
<ProfileTitle topicTitle="Links" spanNumber={3} />
|
|
<ProfileLinks linklabel="Figma" link="https://figma.com" topic="Figma" />
|
|
<ProfileLinks linklabel="Figma" link="https://figma.com" topic="Figma" />
|
|
<ProfileLinks linklabel="Figma" link="https://figma.com" topic="Figma" />
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|