From 823038d71ea05556fc725d72a063b157d1610a84 Mon Sep 17 00:00:00 2001 From: StephDietz Date: Mon, 13 May 2024 11:22:44 -0500 Subject: [PATCH] css fix --- app/components/panel.tsx | 262 +++++++++++++++++++-------------------- 1 file changed, 126 insertions(+), 136 deletions(-) diff --git a/app/components/panel.tsx b/app/components/panel.tsx index e95441e..6535983 100644 --- a/app/components/panel.tsx +++ b/app/components/panel.tsx @@ -1,151 +1,141 @@ -"use client"; +'use client'; -import { useRouter } from "next/navigation"; -import { useOptimistic, useTransition, useState } from "react"; -import { ChevronDownIcon } from "@heroicons/react/24/outline"; -import { FunnelIcon } from "@heroicons/react/24/outline"; -import clsx from "clsx"; +import { useRouter } from 'next/navigation'; +import { useOptimistic, useTransition, useState } from 'react'; +import { ChevronDownIcon } from '@heroicons/react/24/outline'; +import { FunnelIcon } from '@heroicons/react/24/outline'; +import clsx from 'clsx'; interface ExpandedSections { - [key: string]: boolean; + [key: string]: boolean; } export default function Panel({ - selectedAuthors, - allAuthors, + selectedAuthors, + allAuthors }: { - selectedAuthors: string[]; - allAuthors: string[]; + selectedAuthors: string[]; + allAuthors: string[]; }) { - let router = useRouter(); - let [pending, startTransition] = useTransition(); - let [optimisticAuthors, setOptimisticAuthors] = - useOptimistic(selectedAuthors); - let [expandedSections, setExpandedSections] = useState({}); - let [isPanelVisible, setPanelVisibility] = useState(false); + let router = useRouter(); + let [pending, startTransition] = useTransition(); + let [optimisticAuthors, setOptimisticAuthors] = useOptimistic(selectedAuthors); + let [expandedSections, setExpandedSections] = useState({}); + let [isPanelVisible, setPanelVisibility] = useState(false); - const authorGroups = allAuthors.reduce( - (acc: { [key: string]: string[] }, author: string) => { - const firstLetter = author[0].toUpperCase(); // Get the first letter, capitalize it - if (!acc[firstLetter]) { - acc[firstLetter] = []; // Initialize the array if this is the first author with this letter - } - acc[firstLetter].push(author); // Add the author to the appropriate array - return acc; // Return the updated accumulator - }, - {} as { [key: string]: string[] }, - ); - const toggleSection = (letter: string): void => { - setExpandedSections((prev: Record) => ({ - ...prev, - [letter]: !prev[letter], - })); - }; + const authorGroups = allAuthors.reduce( + (acc: { [key: string]: string[] }, author: string) => { + const firstLetter = author[0].toUpperCase(); // Get the first letter, capitalize it + if (!acc[firstLetter]) { + acc[firstLetter] = []; // Initialize the array if this is the first author with this letter + } + acc[firstLetter].push(author); // Add the author to the appropriate array + return acc; // Return the updated accumulator + }, + {} as { [key: string]: string[] } + ); + const toggleSection = (letter: string): void => { + setExpandedSections((prev: Record) => ({ + ...prev, + [letter]: !prev[letter] + })); + }; - return ( -
- -
-
-
-

- Authors -

- {Object.entries(authorGroups).map(([letter, authors]) => ( -
- -
- {expandedSections[letter] && - authors.map((author) => ( - +
+
+
+

Authors

+ {Object.entries(authorGroups).map(([letter, authors]) => ( +
+ +
+ {expandedSections[letter] && + authors.map((author) => ( + - ))} -
-
- ))} -
-
+ router.push(`?${newParams}`); + }); + }} + key={author} + className="flex items-center space-x-2 text-xs text-left" + > + +
{author}
+ + ))} +
+
+ ))} +
+
- {optimisticAuthors.length > 0 && ( -
-
- {optimisticAuthors.map((author) => ( -

{author}

- ))} -
- -
- )} -
-
- ); + {optimisticAuthors.length > 0 && ( +
+
+ {optimisticAuthors.map((author) => ( +

{author}

+ ))} +
+ +
+ )} +
+ + ); }