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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | 30x 311x 622x 30x 33x 66x 655x 66x 30x 33x 30x 151x 30x 344x 344x 344x 33x 151x 344x 30x 688x 30x 2810x 695x 30x 30x 205x 205x 30x 645x 205x | import { CaretRight } from "@assets/icons";
import GearSixIcon from "@assets/rebrandIcons/GearSixIcon";
import { Button } from "@common/Button";
import { ButtonProps } from "@common/Button/Button";
import { StyledIconButton } from "@common/IconButton";
import { Text } from "@common/Text";
import { Stack, styled } from "@mui/material";
import { palette } from "@palette";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
type TCommonProps = {
filters: TFilter[];
showMarkAllAsRead: boolean;
markAllAsRead: VoidFunction;
handleConfigurationClick: VoidFunction;
};
export const DesktopHeader = ({
filters,
showMarkAllAsRead,
markAllAsRead,
handleConfigurationClick,
}: TCommonProps) => {
return (
<Stack
direction="row"
alignItems="center"
justifyContent="space-between"
padding="0 16px"
borderBottom={`1px solid ${palette.liftedWhite[200]}`}
>
<SubsetOne>
{filters.map((f) => (
<FilterElement key={f.label} {...f} />
))}
</SubsetOne>
<SubsetOne gap={1}>
{showMarkAllAsRead && <MarkAllAsRead onClick={markAllAsRead} />}
<ConfigurationButton onClick={handleConfigurationClick} />
</SubsetOne>
</Stack>
);
};
export const MobileHeader = ({
filters,
onClose,
showMarkAllAsRead,
markAllAsRead,
handleConfigurationClick,
}: TCommonProps & {
onClose: () => void;
}) => {
return (
<Stack
direction="column"
alignItems="stretch"
padding="0 16px 16px"
gap={2}
>
<SubsetTwo>
<BackButton data-testid="back-button-mobile-screen" onClick={onClose} />
{showMarkAllAsRead && <MarkAllAsRead onClick={markAllAsRead} />}
</SubsetTwo>
<SubsetTwo>
<SubsetOne gap={1}>
{filters.map((f) => (
<FilterElement key={f.label} {...f} />
))}
</SubsetOne>
<ConfigurationButton onClick={handleConfigurationClick} />
</SubsetTwo>
</Stack>
);
};
const SubsetOne = styled(Stack)(() => ({
flexDirection: "row",
alignItems: "center",
}));
const SubsetTwo = styled(Stack)(() => ({
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
}));
const BackButton = (props: ButtonProps) => (
<BackButtonBase background="tertiary" {...props}>
<CaretRight rotate={180} fill={palette.gray[300]} /> Notifications
</BackButtonBase>
);
const MarkAllAsRead = (props: ButtonProps) => (
<BlueButtonBase background="tertiary" {...props}>
Mark all as read
</BlueButtonBase>
);
const ConfigurationButton = ({ onClick }: { onClick: VoidFunction }) => {
const { isMobileView } = useCustomTheme();
const iconSize = isMobileView ? 24 : 20;
return (
<IconButtonBase
onClick={onClick}
data-testid="notification-configuration-btn"
>
<GearSixIcon
width={iconSize}
height={iconSize}
stroke={palette.gray[300]}
path_fill={palette.gray[300]}
fill={palette.background.dimmedWhite}
/>
</IconButtonBase>
);
};
const BackButtonBase = styled(Button)(() => ({
fontSize: "14px",
fontWeight: 350,
lineHeight: "16.8px",
color: palette.black[100],
padding: 0,
}));
const BlueButtonBase = styled(Button)(({ theme }) => ({
fontSize: "10px",
fontWeight: 350,
lineHeight: "12px",
color: palette.accent[3],
padding: "8px 0",
height: "fit-content",
[theme.breakpoints.down("sm")]: {
fontSize: "14px",
lineHeight: "16.8px",
},
}));
const IconButtonBase = styled(StyledIconButton)(() => ({
width: "fit-content !important",
height: "fit-content !important",
padding: "0 !important",
"&:hover path": {
opacity: 1,
fill: palette.background.dimmedWhite,
path_fill: palette.neutral[80],
stroke: palette.neutral[80],
},
}));
type TFilterBadge = {
display: boolean;
text: string;
variant: string;
};
type TFilter = {
label: string;
onClick: () => void;
selected: boolean;
badge: TFilterBadge | null;
};
const FilterElement = ({ label, selected, onClick, badge }: TFilter) => {
return (
<FilterButtonBase
background="tertiary"
selected={selected}
onClick={onClick}
>
{label}
{badge?.display && (
<Badge
data-testid={`badge-text-counter-${badge?.text}`}
bgVariant={badge?.variant}
>
{badge?.text}
</Badge>
)}
</FilterButtonBase>
);
};
export const FilterButtonBase = styled(Button, {
shouldForwardProp: (prop) => prop !== "selected",
})<{ selected: boolean }>(({ theme, selected }) => ({
fontSize: "14px",
fontWeight: 350,
lineHeight: "16.8px",
color: selected ? palette.black[100] : palette.gray[300],
padding: "8px 12px",
display: "flex",
flexDirection: "row",
gap: "4px",
textDecoration: "none !important",
height: "fit-content",
transition: "all 50ms ease",
cursor: selected ? "default" : "pointer",
userSelect: "none",
[theme.breakpoints.down("sm")]: {
color: selected ? palette.neutral.white : palette.black[200],
boxShadow: "0px 5px 10px 0px #0000000D",
borderRadius: "24px",
backgroundColor: `${
selected ? palette.black[300] : palette.neutral.white
} !important`,
},
[theme.breakpoints.up("sm")]: {
border: "2px solid transparent",
borderRadius: 0,
borderBottom: `2px solid ${selected ? palette.black[300] : "transparent"}`,
},
}));
const badgeBackground: Record<string, string> = {
orange: palette.accent[4],
default: palette.accent[3],
};
const getBackground = (variant?: string) => {
Iif (!variant) return badgeBackground.default;
return badgeBackground[variant] || badgeBackground.default;
};
const Badge = styled(Text, {
shouldForwardProp: (prop) => prop !== "bgVariant",
})<{ bgVariant?: string }>(({ bgVariant }) => ({
fontSize: "11px",
fontWeight: 400,
lineHeight: "13.2px",
color: palette.neutral.white,
borderRadius: "100px",
backgroundColor: getBackground(bgVariant),
width: "min-content",
padding: "1px 4px",
}));
|