diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 8bdf077..9a6bc25 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -37,7 +37,7 @@ function Button({ variant === "cta" && "bg-[#7B60F3] text-white hover:bg-[#9184F6] active:bg-[#B3AAF9]", variant === "menu" && - "text-[#7D7D7D] hover:bg-[#F0F0F0] active:bg-[#F8F7FE] active:text-[#7B60F3] disabled:text-[#D6D6D6] disabled:bg-[#F6F6F6]", + "text-[#7D7D7D] hover:bg-[#F0F0F0] active:bg-[#F8F7FE] active:text-[#7B60F3] disabled:text-[#D6D6D6] disabled:bg-[#F6F6F6] hover:text-[#7B60F3]", size === "large" && "2xl:p-[1.111vw] p-4 button-m 2xl:rounded-[0.833vw] rounded-xl", size === "medium" && diff --git a/src/components/NewSelect.tsx b/src/components/NewSelect.tsx index 2f979a6..32c67c0 100644 --- a/src/components/NewSelect.tsx +++ b/src/components/NewSelect.tsx @@ -1,5 +1,112 @@ -function NewSelect() { - return
; +import { useEffect, useState } from "react"; +import ChevronDownIcon from "./icons/ChevronDownIcon"; +import ChevronUpIcon from "./icons/ChevronUpIcon"; +import clsx from "clsx"; +import CloseIcon from "./icons/CloseIcon"; + +function NewSelect({ + data, + isGrid, + placeholder, +}: { + data: T[]; + isGrid: boolean; + placeholder: string; +}) { + const [selectedValues, setSelectedValues] = useState([]); + const [isSelectVisible, setIsSelectVisible] = useState(false); + + const handleSelectClick = (item: T) => { + const isItemSelected = selectedValues.some((val) => val.name === item.name); + + if (isItemSelected) { + setSelectedValues( + selectedValues.filter((value) => value.name !== item.name) + ); + } else { + setSelectedValues([...selectedValues, item]); + } + }; + + useEffect(() => { + console.log(selectedValues); + }, [selectedValues]); + + return isGrid ? ( +
+
+ {data.map((item) => ( +
{item.name}
+ ))} +
+
+ ) : ( +
+
setIsSelectVisible(!isSelectVisible)} + > +
+ {selectedValues.length > 0 + ? selectedValues.map((value, index) => { + return ( +
+ {value.name + + (index !== selectedValues.length - 1 ? ", " : "")} +
+ ); + }) + : placeholder} +
+ + {isSelectVisible ? : } + +
+
+
+
setSelectedValues([])} + > + + + + Выбрать всё +
+
+ {data.map((item, index) => ( +
handleSelectClick(item)} + > + {item.name} +
+ ))} +
+
+
+ ); } export default NewSelect; diff --git a/src/components/icons/ChevronDownIcon.tsx b/src/components/icons/ChevronDownIcon.tsx index 2010e71..c51c9a5 100644 --- a/src/components/icons/ChevronDownIcon.tsx +++ b/src/components/icons/ChevronDownIcon.tsx @@ -4,7 +4,7 @@ function ChevronDownIcon() { diff --git a/src/components/icons/ChevronUpIcon.tsx b/src/components/icons/ChevronUpIcon.tsx new file mode 100644 index 0000000..6cc4ffd --- /dev/null +++ b/src/components/icons/ChevronUpIcon.tsx @@ -0,0 +1,15 @@ +function ChevronUpIcon() { + return ( + + + + ); +} + +export default ChevronUpIcon; diff --git a/src/pages/DashboardPage.tsx b/src/pages/DashboardPage.tsx index 2a1a1c2..9edac6a 100644 --- a/src/pages/DashboardPage.tsx +++ b/src/pages/DashboardPage.tsx @@ -9,6 +9,7 @@ import SessionCard from "../components/SessionCard"; import Button from "../components/Button"; import ChevronRightIcon from "../components/icons/ChevronRightIcon"; import { useNavigate } from "react-router"; +import NewSelect from "../components/NewSelect"; function DashboardPage() { const { data: me } = useQuery({ @@ -60,6 +61,22 @@ function DashboardPage() {
+

Последние сеансы