fix: link (#115)

* start

* .

* seeding connections

* .

* wip

* wip: learning state

* wip: notes section

* wip: many

* topics

* chore: update schema

* update package

* update sidebar

* update page section

* feat: profile

* fix: remove z index

* fix: wrong type

* add avatar

* add avatar

* wip

* .

* store page section key

* remove atom page section

* fix rerender

* fix rerender

* fix rerender

* fix rerender

* fix link

* search light/dark mode

* bubble menu ui

* .

* fix: remove unecessary code

* chore: mark as old for old schema

* chore: adapt new schema

* fix: add topic schema but null for now

* fix: add icon on personal link

* fix: list item

* fix: set url fetched when editing

* fix: remove image

* feat: add icon to link

* feat: custom url zod validation

* fix: metadata test

* chore: update utils

* fix: link

* fix: url fetcher

* .

* .

* fix: add link, section

* chore: seeder

* .

* .

* .

* .

* fix: change checkbox to learning state

* fix: click outside editing form

* feat: constant

* chore: move to master folder

* chore: adapt new schema

* chore: cli for new schema

* fix: new schema for dev seed

* fix: seeding

* update package

* chore: forcegraph seed

* bottombar

* if isEdit delete icon

* showCreate X button

* .

* options

* chore: implement topic from public global group

* chore: update learning state

* fix: change implementation for outside click

* chore: implement new form param

* chore: update env example

* feat: link form refs exception

* new page button layout, link topic search fixed

* chore: enable topic

* chore: update seed

* profile

* chore: move framer motion package from root to web and add nuqs

* chore: add LearningStateValue

* chore: implement active state

* profile

* chore: use fancy switch and update const

* feat: filter implementation

* dropdown menu

* .

* sidebar topics

* topic selected color

* feat: topic detail

* fix: collapsible page

* pages - sorted by, layout, visible mode

* .

* .

* .

* topic status sidebar

* topic button and count

* fix: topic

* page delete/topic buttons

* search ui

* selected topic for page

* selected topic status sidebar

* removed footer

* update package

* .

---------

Co-authored-by: Nikita <github@nikiv.dev>
Co-authored-by: marshennikovaolga <marshennikova@gmail.com>
Co-authored-by: Kisuyo <ig.intr3st@gmail.com>
This commit is contained in:
Aslam
2024-08-26 19:35:00 +07:00
committed by GitHub
parent 7cbfcc705b
commit 2d270706a5
77 changed files with 3002 additions and 1327 deletions

View File

@@ -1,100 +1,66 @@
import { useState, useEffect, useRef } from "react"
import { usePathname } from "next/navigation"
import Link from "next/link"
import { useState, useRef } from "react"
import { Button } from "@/components/ui/button"
import { ChevronDown, BookOpen, Bookmark, GraduationCap, Check } from "lucide-react"
import { LaIcon } from "@/components/custom/la-icon"
import { SidebarItem } from "../sidebar"
const TOPICS = ["Nix", "Javascript", "Kubernetes", "Figma", "Hiring", "Java", "IOS", "Design"]
// const TOPICS = ["Nix", "Javascript", "Kubernetes", "Figma", "Hiring", "Java", "IOS", "Design"]
export const TopicSection = () => {
const [showOptions, setShowOptions] = useState(false)
const [selectedStatus, setSelectedStatus] = useState<string | null>(null)
const sectionRef = useRef<HTMLDivElement>(null)
const learningOptions = [
{ text: "To Learn", icon: <Bookmark size={16} />, color: "text-white/70" },
{
text: "Learning",
icon: <GraduationCap size={16} />,
color: "text-[#D29752]"
text: "To Learn",
icon: <LaIcon name="NotebookPen" className="size-3 flex-shrink-0" />,
color: "text-black dark:text-white"
},
{
text: "Learned",
icon: <Check size={16} />,
color: "text-[#708F51]"
}
text: "Learning",
icon: <LaIcon name="GraduationCap" className="size-4 flex-shrink-0" />,
color: "text-[#D29752]"
},
{ text: "Learned", icon: <LaIcon name="Check" className="size-4 flex-shrink-0" />, color: "text-[#708F51]" }
]
const statusSelect = (status: string) => {
setSelectedStatus(status === "Show All" ? null : status)
setShowOptions(false)
setSelectedStatus(prevStatus => (prevStatus === status ? null : status))
}
useEffect(() => {
const overlayClick = (event: MouseEvent) => {
if (sectionRef.current && !sectionRef.current.contains(event.target as Node)) {
setShowOptions(false)
}
const topicCounts = {
"To Learn": 2,
Learning: 5,
Learned: 3,
get total() {
return this["To Learn"] + this.Learning + this.Learned
}
document.addEventListener("mousedown", overlayClick)
return () => {
document.removeEventListener("mousedown", overlayClick)
}
}, [])
const availableOptions = selectedStatus
? [
{
text: "Show All",
icon: <BookOpen size={16} />,
color: "text-white"
},
...learningOptions.filter(option => option.text !== selectedStatus)
]
: learningOptions
// const topicClick = (topic: string) => {
// router.push(`/${topic.toLowerCase()}`)
// }
}
return (
<div className="space-y-1 overflow-hidden" ref={sectionRef}>
<Button
onClick={() => setShowOptions(!showOptions)}
className="bg-accent text-foreground hover:bg-accent/50 flex w-full items-center justify-between rounded-md px-3 py-2 text-sm font-medium"
>
<span>{selectedStatus ? `Topics: ${selectedStatus}` : "Topics"}</span>
<ChevronDown
size={16}
className={`transform transition-transform duration-200 ease-in-out ${
showOptions ? "rotate-0" : "rotate-[-90deg]"
}`}
/>
</Button>
{showOptions && (
<div className="rounded-md bg-neutral-800">
{availableOptions.map(option => (
<Button
key={option.text}
onClick={() => statusSelect(option.text)}
className={`flex w-full items-center justify-start space-x-2 rounded-md px-3 py-2 text-sm font-medium hover:bg-neutral-700 ${option.color} bg-inherit`}
>
<div className="text-foreground group/topics hover:bg-accent flex w-full items-center justify-between rounded-md px-2 py-2 text-xs font-medium">
<span className="text-black dark:text-white">Topics {topicCounts.total}</span>
<button className="opacity-0 transition-opacity duration-200 group-hover/topics:opacity-100">
<LaIcon name="Ellipsis" className="size-4 flex-shrink-0" />
</button>
</div>
<div>
{learningOptions.map(option => (
<Button
key={option.text}
onClick={() => statusSelect(option.text)}
className={`flex w-full items-center justify-between rounded-md py-1 pl-1 text-sm font-medium hover:bg-neutral-100 dark:hover:bg-neutral-100/20 ${option.color} ${
selectedStatus === option.text ? "bg-accent" : "bg-inherit"
} shadow-none`}
>
<div className="flex items-center gap-2">
{option.icon && <span className={option.color}>{option.icon}</span>}
<span>{option.text}</span>
</Button>
))}
</div>
)}
<div className="scrollbar-hide space-y-1 overflow-y-auto" style={{ maxHeight: "calc(100vh - 200px)" }}>
{TOPICS.map(topic => (
<SidebarItem key={topic} label={topic} url={`/${topic}`} />
</div>
<span className={`${option.color} mr-2`}>{topicCounts[option.text as keyof typeof topicCounts]}</span>
</Button>
))}
</div>
</div>
)
}
export default TopicSection