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 | 1853x 1853x 1853x 1778x 1369x 7253x 409x 287x 736x 122x 122x 122x 247x | import { Stack } from "@mui/material";
import { GiveTabProps } from "./GiveTab.types";
import GivePill from "./GivePill";
import { useAppTheme } from "@theme/v2/Provider";
import GiveLineTab from "./GiveLineTab";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import GiveProgressTab from "./GiveProgressTab";
import GiveSelect from "@shared/GiveInputs/GiveSelect";
import GiveText from "@shared/Text/GiveText";
export default function GiveTabs({
items,
onClick,
type = "pill",
variant,
selected,
containerSx,
tabSx,
hideMobileTitle,
selectedTabSx,
applyGradient,
}: GiveTabProps) {
const { palette } = useAppTheme();
const { isMobileView } = useCustomThemeV2();
if (!items || !items.length) return null;
if (type === "pill")
return (
<Stack direction="row" sx={containerSx}>
{items.map((item, index) => (
<GivePill
key={index}
variant={variant !== "underline" ? variant : undefined}
{...item}
selectedTabSx={selectedTabSx}
selected={item.value === selected}
onClick={item?.onClickItem || onClick}
tabSx={tabSx}
/>
))}
</Stack>
);
if (type === "line")
return (
<Stack
direction="row"
justifyContent="flex-start"
sx={{
width: "100%",
gap: "20px",
...(variant === "underline" && {
borderBottom: `1px solid ${palette.border?.primary}`,
}),
...containerSx,
}}
>
{items.map((item, index) => (
<GiveLineTab
key={index}
{...item}
selected={item.value === selected}
onClick={item?.onClickItem || onClick}
tabSx={tabSx}
selectedTabSx={selectedTabSx}
dataTestId={item.dataTestId || `give-tab-${item.value}`}
applyGradient={applyGradient}
/>
))}
</Stack>
);
Eif (type === "segmented")
if (items.length < 4 || !isMobileView) {
return (
<Stack
direction="row"
gap="2px"
sx={{
border: `1px solid ${palette.border?.secondary}`,
borderRadius: "12px",
padding: "4px",
width: "fit-content",
...containerSx,
}}
>
{items.map((item, index) => (
<GivePill
key={index}
variant="segmented"
{...item}
selected={item.value === selected}
onClick={onClick}
tabSx={tabSx}
/>
))}
</Stack>
);
} else
Ereturn (
<GiveSelect
options={items}
value={selected}
onChange={(item) => onClick?.(item.target.value as string)}
/>
);
if (type === "stepper")
return (
<>
<Stack direction="row" gap="12px" sx={containerSx}>
{items.map((item, index) => (
<GiveProgressTab
key={index}
{...item}
selected={item.value === selected}
onClick={onClick}
hideMobileTitle={hideMobileTitle && isMobileView}
progress={
hideMobileTitle && isMobileView && item.value === selected
? 100
: item.progress
}
/>
))}
</Stack>
{hideMobileTitle && isMobileView && (
<GiveText variant="bodyXS" color="primary" mt="12px">
{items.find((item) => item.value === selected)?.label}
</GiveText>
)}
</>
);
else return <></>;
}
|