diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 63d28e6..0000000 --- a/src/App.css +++ /dev/null @@ -1,44 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} - -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} - -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/src/App.tsx b/src/App.tsx index a4e48f7..747f2cf 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,35 +1,169 @@ -import {useState} from 'react' -import reactLogo from './assets/react.svg' -import viteLogo from '/vite.svg' -import './App.css' +import {ChangeEventHandler, KeyboardEventHandler, ReactNode, useCallback, useEffect, useRef, useState} from "react"; +import {FixedSizeList as List} from "react-window"; +import Select, {createFilter, MenuListProps} from "react-select"; +import * as R from 'ramda'; -function App() { - const [count, setCount] = useState(0) +import {useQuery} from "@tanstack/react-query"; + +const height = 35; + +function MenuList(props: MenuListProps) { + const { + options, + children, + maxHeight, + getValue + } = props as Omit & { + children: ReactNode[] + }; + + const [value] = getValue(); + const initialOffset = options.indexOf(value) * height; + + return ( + {({ + index, + style + }) =>
{children[index]}
} +
); +} + +interface Option { + label: string, + value: string, + data: { + backlinks: unknown[] + aliases?: string[] + } +} + +export function LargeSelect() { + const { + data: options, + isLoading, + } = useQuery({ + queryKey: ['obsidian-metadata'], + initialData: [], + queryFn: async () => { + const response = await fetch("http://100.115.154.44:9002/metadata") + const fullData: any[] = await response.json(); + + return R.sortBy(v => -(v.data.backlinks?.length ?? 0), fullData.map(md => ({ + value: md.relativePath, + label: md.fileName, + data: md, + }) as Option)); + }, + }); + + const [selected, setSelected] = useState