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 | 2x 152x 152x 152x | import React from "react";
import { Box, Stack } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import HFGiveSwitch from "@shared/HFInputs/HFGiveSwitch/HFGiveSwitch";
import { styled } from "@theme/v2/Provider";
import { GlobalSecurityFormValues } from "../types";
type SecurityToggleCardProps = {
name: keyof GlobalSecurityFormValues;
title: string;
description: string;
testId: string;
disabled?: boolean;
};
const SecurityToggleCard = ({
name,
title,
description,
testId,
disabled,
}: SecurityToggleCardProps) => {
const descriptionId = `${name}-description`;
return (
<CardContainer>
<Stack direction="row" alignItems="center" gap="16px">
<Stack gap="8px" flex={1}>
<GiveText variant="bodyS" fontWeight="medium" color="primary">
{title}
</GiveText>
<GiveText variant="bodyS" color="secondary" id={descriptionId}>
{description}
</GiveText>
</Stack>
<HFGiveSwitch
name={name}
disabled={disabled}
// inputProps is typed InputHTMLAttributes, which has no data-* index
// signature; the attribute still reaches the input.
inputProps={
{
"data-testid": testId,
"aria-label": title,
"aria-describedby": descriptionId,
} as React.InputHTMLAttributes<HTMLInputElement>
}
/>
</Stack>
</CardContainer>
);
};
const CardContainer = styled(Box)(({ theme }) => ({
borderRadius: "12px",
// 19 + the 1px border is the design's 20px inset, which it measures from the
// card's outer edge (the Figma stroke is drawn inside the frame bounds).
padding: "19px",
border: `1px solid ${theme.palette.border?.primary}`,
}));
export default SecurityToggleCard;
|