From 26d17c163d56a235c2157e4a664dab30b49a057f Mon Sep 17 00:00:00 2001 From: Tyler Hill Date: Sat, 23 Nov 2024 15:17:36 -0600 Subject: [PATCH] Collapsible RHS --- .../navigation/Carousel/carousel.tsx | 65 +++++++++-------- .../navigation/tabNavMenu/tabNavMenu.tsx | 70 ++++++++++++------- 2 files changed, 83 insertions(+), 52 deletions(-) diff --git a/src/components/navigation/Carousel/carousel.tsx b/src/components/navigation/Carousel/carousel.tsx index e515c5b6..53a87101 100644 --- a/src/components/navigation/Carousel/carousel.tsx +++ b/src/components/navigation/Carousel/carousel.tsx @@ -1,6 +1,7 @@ import type { ReactJSXElement } from '@emotion/react/types/jsx-namespace'; +import { Collapse, useMediaQuery } from '@mui/material'; import { AnimatePresence, motion } from 'framer-motion'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { TabNavMenu } from '@/components/navigation/tabNavMenu/tabNavMenu'; @@ -69,6 +70,10 @@ const Carousel = ({ names, children, compareLength }: CarouselProps) => { }); }; + const isSmallScreen = useMediaQuery('(max-width: 600px)'); + const [open, setOpen] = useState(!isSmallScreen); + useEffect(() => setOpen(!isSmallScreen), [isSmallScreen]); + return ( <> { options={Array.isArray(names) ? names : [names]} turner={turn} compareLength={compareLength} + open={open} + setOpen={setOpen} /> - -
- - {Array.isArray(children) - ? children.map((child, index) => ( -
- {child} -
- )) - : children} -
-
-
+ + +
+ + {Array.isArray(children) + ? children.map((child, index) => ( +
+ {child} +
+ )) + : children} +
+
+
+
); }; diff --git a/src/components/navigation/tabNavMenu/tabNavMenu.tsx b/src/components/navigation/tabNavMenu/tabNavMenu.tsx index f75a10a0..2e28009f 100644 --- a/src/components/navigation/tabNavMenu/tabNavMenu.tsx +++ b/src/components/navigation/tabNavMenu/tabNavMenu.tsx @@ -1,4 +1,5 @@ -import { Badge, Tab, Tabs } from '@mui/material'; +import KeyboardArrowIcon from '@mui/icons-material/KeyboardArrowRight'; +import { Badge, IconButton, Tab, Tabs, useMediaQuery } from '@mui/material'; import React from 'react'; /** @@ -11,6 +12,8 @@ type TabNavMenuProps = { turner: (displacement: number) => void; options: string[]; compareLength: number; + open: boolean; + setOpen: (arg0: boolean) => void; }; /** @@ -19,30 +22,49 @@ type TabNavMenuProps = { * which are held by the parent and passed to this component to be manipulated by the Tabs component. */ export const TabNavMenu = (props: TabNavMenuProps) => { + const isSmallScreen = useMediaQuery('(max-width: 600px)'); return ( - props.turner(newValue - props.value)} - aria-label="Tab switcher" - className="w-full grid grid-flow-row justify-center shadow dark:shadow-lg" - > - {props.options.map((option, index) => ( - - {option} - - - ) : ( - option - ) +
+ {isSmallScreen && ( + props.setOpen(!props.open)} + size="medium" + className={ + 'ml-2 transition-transform' + (props.open ? ' rotate-90' : '') } - /> - ))} - + > + + + )} +
+ props.turner(newValue - props.value)} + aria-label="Tab switcher" + className="shadow dark:shadow-lg" + variant="scrollable" + > + {props.options.map((option, index) => ( + + {option} + +
+ ) : ( + option + ) + } + onClick={() => props.setOpen(true)} + /> + ))} + +
+ ); };