import { useState } from "react"; import { Box, Paper, Typography, LinearProgress, Pagination as MuiPagination, PaginationItem, Input, ButtonBase, useTheme, useMediaQuery, } from "@mui/material"; import { ReactComponent as DoubleCheckIcon } from "@icons/Analytics/doubleCheck.svg"; import { ReactComponent as NextIcon } from "@icons/Analytics/next.svg"; import { ReactComponent as LeftArrowIcon } from "@icons/Analytics/leftArrow.svg"; import { ReactComponent as RightArrowIcon } from "@icons/Analytics/rightArrow.svg"; import type { PaginationRenderItemParams } from "@mui/material"; type AnswerProps = { title: string; percent: number; highlight?: boolean; }; const ANSWERS_MOCK: Record = { "Добавьте ответ": 67, "Вопрос пропущен": 7, Другое: 27, }; const Answer = ({ title, percent, highlight }: AnswerProps) => { const theme = useTheme(); return ( span": { background: highlight ? "#D9C0F9" : "#9A9AAF1A" }, "&::before": { content: `"${title}"`, position: "absolute", zIndex: 1, left: "20px", top: "50%", transform: "translateY(-50%)", color: highlight ? theme.palette.brightPurple.main : theme.palette.grey3.main, }, }} /> {`${percent}%`} ); }; const Pagination = () => { const [count, setCount] = useState(50); const [page, setPage] = useState(1); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down(855)); const getPaginationItem = (props: PaginationRenderItemParams) => { if (props.type === "start-ellipsis" || props.type === "end-ellipsis") { return; } if (props.type !== "previous" && props.type !== "next" && props.page) { if (isMobile) { const allowedPages = [ page - 1 < 1 ? page + 2 : page - 1, page, page + 1 > count ? page - 2 : page + 1, ]; if (!allowedPages.includes(props.page)) { return; } } const allowedPages = [ page - 2 < 1 ? page + 3 : page - 2, page - 1 < 1 ? page + 4 : page - 1, page, page + 1 > count ? page - 4 : page + 1, page + 2 > count ? page - 3 : page + 2, ]; if (!allowedPages.includes(props.page)) { return; } } return ( ); }; return ( setPage(Number(target.value.replace(/\D/, ""))) } sx={{ height: "30px", width: "65px", borderRadius: "5px", padding: "10px", marginRight: "5px", boxShadow: "0 0 20px rgba(0, 0, 0, 0.15)", backgroundColor: theme.palette.background.paper, }} /> setPage(page)} renderItem={getPaginationItem} sx={{ "& .MuiButtonBase-root": { borderRadius: "5px", margin: "0 5px", height: "30px", background: theme.palette.background.paper, boxShadow: "0 0 20px rgba(0, 0, 0, 0.15)", "&.Mui-selected": { background: theme.palette.background.paper, color: theme.palette.brightPurple.main, }, "&.MuiPaginationItem-previousNext": { margin: "0 15px", background: theme.palette.brightPurple.main, }, }, }} /> ); }; export const Answers = () => { const [answers, setAnswers] = useState>(ANSWERS_MOCK); const theme = useTheme(); return ( Заголовок вопроса. Варианты ответов {Object.entries(answers).map(([title, percent], index) => ( ))} ); };