From e7dcc0fbbbbb56154b0f8fcf8a1b64ead205ed65 Mon Sep 17 00:00:00 2001 From: Francesco Menghi <53121061+menghif@users.noreply.github.com> Date: Fri, 19 Apr 2024 20:52:30 -0400 Subject: [PATCH] create Accordion menu for mobile settings --- .../Preferences/PreferencesModal.tsx | 129 +++++++++++++----- 1 file changed, 97 insertions(+), 32 deletions(-) diff --git a/src/components/Preferences/PreferencesModal.tsx b/src/components/Preferences/PreferencesModal.tsx index c51a2484..d5e014b1 100644 --- a/src/components/Preferences/PreferencesModal.tsx +++ b/src/components/Preferences/PreferencesModal.tsx @@ -12,6 +12,11 @@ import { List, useColorMode, useMediaQuery, + Accordion, + AccordionIcon, + AccordionButton, + AccordionItem, + AccordionPanel, } from "@chakra-ui/react"; import { RefObject, useState } from "react"; import ModelsSettings from "./ModelsSettings"; @@ -76,45 +81,105 @@ function PreferencesModal({ isOpen, onClose, finalFocusRef }: PreferencesModalPr const [isSmallViewport] = useMediaQuery("(max-width: 600px)"); return ( - + - - User Settings - - + + + User Settings + + + {!isSmallViewport && } - - - {settings.map((setting, index) => ( - handleSettingClick(setting)} - onKeyDown={(e) => { - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - handleSettingClick(setting); - } - }} - cursor="pointer" - _hover={getHoverStyle(setting)} - p={2} - ps={4} - borderRadius="md" - color={getColorStyle(setting)} - bg={getBackgroundStyle(setting)} + {isSmallViewport ? ( + + + - + - {setting.name} + {selectedSetting.name} - - ))} - - - {isSmallViewport && } + + + + + {settings.map((setting, index) => ( + handleSettingClick(setting)} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + handleSettingClick(setting); + } + }} + cursor="pointer" + _hover={getHoverStyle(setting)} + p={1} + pl={2} + borderRadius="md" + color={getColorStyle(setting)} + bg={getBackgroundStyle(setting)} + > + + + + + + {setting.name} + + + + ))} + + + + + ) : ( + + + {settings.map((setting, index) => ( + handleSettingClick(setting)} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + handleSettingClick(setting); + } + }} + cursor="pointer" + _hover={getHoverStyle(setting)} + p={2} + ps={4} + borderRadius="md" + color={getColorStyle(setting)} + bg={getBackgroundStyle(setting)} + > + + + + + {setting.name} + + + ))} + + + )} {selectedSetting.name === "Models" && } {selectedSetting.name === "Web Handlers" && } {selectedSetting.name === "System Prompt" && }