From 754ddeaa8d3e3e4f3efc93d5bb22c68c31bb5c36 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Mon, 6 May 2024 08:11:47 +0100 Subject: feat(ui): scroll history infinitely (#1999) * wip, history scrolls right! * wip * virtual scroll fucking worksssss * paging works :) * scroll search results now too --- ui/src/App.css | 16 +++++ ui/src/components/HistoryList.tsx | 126 ++++++++++++++++++--------------- ui/src/components/HistorySearch.tsx | 12 ++-- ui/src/components/dotfiles/Aliases.tsx | 2 +- ui/src/components/history/Stats.tsx | 67 ++++++++++++++++-- ui/src/global.d.ts | 1 + ui/src/pages/History.tsx | 53 ++++++++++++-- ui/src/state/models.ts | 34 ++++++++- ui/src/state/store.ts | 23 +++++- ui/src/styles.css | 94 ++++++++++++------------ 10 files changed, 304 insertions(+), 124 deletions(-) create mode 100644 ui/src/global.d.ts (limited to 'ui/src') diff --git a/ui/src/App.css b/ui/src/App.css index 5a32a1a5..cf6d3123 100644 --- a/ui/src/App.css +++ b/ui/src/App.css @@ -9,3 +9,19 @@ html { .logo.react:hover { filter: drop-shadow(0 0 2em #61dafb); } + +.history-header { + height: 150px; +} + +.history-search { + height: 64px; +} + +.history-list { + height: calc(100vh - 150px - 64px); +} + +.history-item { + height: 90px; +} diff --git a/ui/src/components/HistoryList.tsx b/ui/src/components/HistoryList.tsx index 9616ecf0..7cdeacd8 100644 --- a/ui/src/components/HistoryList.tsx +++ b/ui/src/components/HistoryList.tsx @@ -1,3 +1,4 @@ +import { useRef } from "react"; import { ChevronRightIcon } from "@heroicons/react/20/solid"; // @ts-ignore @@ -19,70 +20,81 @@ function msToTime(ms: number) { export default function HistoryList(props: any) { return ( - + + ); + })} + ); } diff --git a/ui/src/components/HistorySearch.tsx b/ui/src/components/HistorySearch.tsx index 08bed2a8..b3c8492a 100644 --- a/ui/src/components/HistorySearch.tsx +++ b/ui/src/components/HistorySearch.tsx @@ -3,12 +3,12 @@ import { ArrowPathIcon } from "@heroicons/react/24/outline"; import { MagnifyingGlassIcon } from "@heroicons/react/20/solid"; interface HistorySearchProps { - refresh: (query: string) => void; + query: string; + refresh: () => void; + setQuery: (query: string) => void; } export default function HistorySearch(props: HistorySearchProps) { - let [searchQuery, setSearchQuery] = useState(""); - return (
{ - setSearchQuery(query.target.value); - props.refresh(query.target.value); + props.setQuery(query.target.value); + props.refresh(); }} />
@@ -45,7 +45,7 @@ export default function HistorySearch(props: HistorySearchProps) { type="button" className="-m-2.5 p-2.5 text-gray-400 hover:text-gray-500" onClick={() => { - props.refresh(searchQuery); + props.refresh(); }} >