Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 34x 153x 153x 560x 65x 495x 34x 34x 495x 495x 495x 34x 65x | import { Box, Stack } from "@mui/material";
import { ArrowLeftIcon, ArrowRightIcon } from "@phosphor-icons/react";
import GiveButton from "@shared/Button/GiveButton";
import GiveIconButton from "@shared/IconButton/GiveIconButton";
import GiveText from "@shared/Text/GiveText";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { useAppTheme } from "@theme/v2/Provider";
import React from "react";
import { PaginationProps } from "./GiveTable.types";
import useThemeSettings from "@components/EnterpriseSettings/Branding/hooks/useThemeSettings";
const GivePagination = ({
currentPage,
pages,
onClick,
previousDisabled,
nextDisabled,
onClickNext,
onClickPrevious,
}: PaginationProps) => {
const { isMobileView } = useCustomThemeV2();
return (
<Stack
data-testid="give-pagination"
direction="row"
gap={isMobileView ? "12px" : "16px"}
sx={{
width: "fit-content",
}}
>
{isMobileView ? (
<GiveIconButton
Icon={ArrowLeftIcon}
size="small"
disabled={previousDisabled}
onClick={onClickPrevious}
/>
) : (
<GiveButton
label="Previous"
startIcon={<ArrowLeftIcon size={18} />}
color="light"
variant="ghost"
size="small"
sx={{
width: "fit-content",
}}
disabled={previousDisabled}
onClick={onClickPrevious}
/>
)}
<Stack direction="row" gap={isMobileView ? "5px" : "8px"}>
{pages.map((page, index) => {
if (page === "space") {
return <Space key={`space-${index}`} />;
}
return (
<Page
key={page}
page={page}
state={currentPage === page ? State.SELECTED : State.IDLE}
onClick={() => onClick && onClick(page)}
/>
);
})}
</Stack>
{isMobileView ? (
<GiveIconButton
Icon={ArrowRightIcon}
size="small"
disabled={nextDisabled}
onClick={onClickNext}
/>
) : (
<GiveButton
label="Next"
endIcon={<ArrowRightIcon size={18} />}
color="light"
variant="ghost"
size="small"
sx={{
width: "fit-content",
}}
disabled={nextDisabled}
onClick={onClickNext}
/>
)}
</Stack>
);
};
const State = {
IDLE: "idle",
SELECTED: "selected",
} as const;
interface TPage {
page: number | string;
state: (typeof State)[keyof typeof State];
onClick?: React.MouseEventHandler<HTMLDivElement>;
}
const Page = ({ page, state, onClick }: TPage) => {
const { palette } = useAppTheme();
const { bgColorHighlight, textColor, isGradientText } = useThemeSettings();
return (
<Box
onClick={onClick}
sx={{
cursor: state === State.SELECTED ? "default" : "pointer",
height: "36px",
width: "36px",
borderRadius: "8px",
display: "flex",
justifyContent: "center",
alignItems: "center",
transition: "all 0.2s",
background:
state === State.SELECTED
? bgColorHighlight || palette.gradient["ocean-blue"]?.highlight
: "transparent",
"&:hover": {
background:
state === State.SELECTED
? bgColorHighlight || palette.gradient["ocean-blue"]?.highlight
: palette.primitive?.transparent["darken-5"],
},
}}
>
<GiveText
variant="bodyS"
sx={{
...(isGradientText && state === State.SELECTED
? {
background: textColor,
WebkitBackgroundClip: "text",
WebkitTextFillColor: "transparent",
}
: {
color:
state === State.SELECTED ? textColor || "link" : "primary",
}),
}}
>
{page}
</GiveText>
</Box>
);
};
const Space = () => {
return (
<Box
sx={{
cursor: "default",
height: "36px",
width: "36px",
display: "flex",
justifyContent: "center",
alignItems: "center",
background: "transparent",
}}
>
<GiveText variant="bodyS" color="primary">
...
</GiveText>
</Box>
);
};
export default GivePagination;
|