diff --git a/editor.planx.uk/src/@planx/components/PlanningConstraints/List.tsx b/editor.planx.uk/src/@planx/components/PlanningConstraints/List.tsx index b7b9b25226..0a571e3947 100644 --- a/editor.planx.uk/src/@planx/components/PlanningConstraints/List.tsx +++ b/editor.planx.uk/src/@planx/components/PlanningConstraints/List.tsx @@ -1,6 +1,7 @@ +import Accordion from "@mui/material/Accordion"; +import AccordionDetails from "@mui/material/AccordionDetails"; +import AccordionSummary from "@mui/material/AccordionSummary"; import Box, { BoxProps } from "@mui/material/Box"; -import Button from "@mui/material/Button"; -import Collapse from "@mui/material/Collapse"; import Link from "@mui/material/Link"; import List from "@mui/material/List"; import ListItem from "@mui/material/ListItem"; @@ -13,7 +14,7 @@ import type { Metadata, } from "@opensystemslab/planx-core/types"; import groupBy from "lodash/groupBy"; -import React, { ReactNode, useState } from "react"; +import React, { ReactNode } from "react"; import ReactHtmlParser from "react-html-parser"; import Caret from "ui/icons/Caret"; import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml"; @@ -26,17 +27,22 @@ const CATEGORY_COLORS: Record = { Flooding: "#ECECEC", }; -interface StyledConstraintProps extends BoxProps { +const PREFIX = "ConstraintsList"; + +const classes = { + content: `${PREFIX}-content` +} + +interface StyledAccordionProps extends BoxProps { category: string; } -const StyledConstraint = styled(Box, { - shouldForwardProp: (prop) => prop !== "category", -})(({ theme, category }) => ({ +const StyledAccordion = styled(Accordion, { + shouldForwardProp: (prop) => !["category", "metadata", "content", "data"].includes(prop as string), +})(({ theme, category }) => ({ borderLeft: `5px solid ${CATEGORY_COLORS[category]}`, paddingRight: 0, width: "100%", - color: theme.palette.text.primary, position: "relative", "&::after": { content: "''", @@ -47,6 +53,9 @@ const StyledConstraint = styled(Box, { height: "1px", background: theme.palette.border.main, }, + [`&.${classes.content}`]: { + margin: [1.5, 0] + }, })); interface ConstraintsListProps { @@ -123,100 +132,73 @@ interface ConstraintListItemProps { } function ConstraintListItem({ children, ...props }: ConstraintListItemProps) { - const [showConstraintData, setShowConstraintData] = useState(false); + const item = props.metadata?.name.replaceAll(" ", "-"); return ( - - + } + sx={{ pr: 1.5 }} > - - - - - <> - - {`This property ${props?.content}`} - - {Boolean(props.data?.length) && ( - - {props.data && - props.data.map( - (record: any) => - record.name && ( - - - {record.name}{" "} - {record.name && record["documentation-url"] && ( - - ( - - source - - ) - - )} - - - ), - )} - - )} - - - + {children} + + + <> + + {`This property ${props?.content}`} - - - + {Boolean(props.data?.length) && ( + + {props.data && + props.data.map( + (record: any) => + record.name && ( + + + {record.name}{" "} + {record.name && record["documentation-url"] && ( + + ( + + source + + ) + + )} + + + ), + )} + + )} + + + + + + ); } diff --git a/editor.planx.uk/src/@planx/components/Result/Public/ResultReason.tsx b/editor.planx.uk/src/@planx/components/Result/Public/ResultReason.tsx index e7521ec41d..7080d82568 100644 --- a/editor.planx.uk/src/@planx/components/Result/Public/ResultReason.tsx +++ b/editor.planx.uk/src/@planx/components/Result/Public/ResultReason.tsx @@ -135,11 +135,10 @@ const ResultReason: React.FC = ({ const hasMoreInfo = question.data.info ?? question.data.policyRef; const toggleAdditionalInfo = () => setExpanded(!expanded); - const ariaLabel = `${question.data.text}: Your answer was: ${response}. ${ - hasMoreInfo + const ariaLabel = `${question.data.text}: Your answer was: ${response}. ${hasMoreInfo ? "Click to expand for more information about this question." : "" - }`; + }`; const { trackBackwardsNavigation } = useAnalyticsTracking(); @@ -155,7 +154,6 @@ const ResultReason: React.FC = ({ onChange={() => hasMoreInfo && toggleAdditionalInfo()} expanded={expanded} elevation={0} - square > { const themeOptions = getThemeOptions(teamTheme); const theme = responsiveFontSizes(createTheme(themeOptions), { factor: 3 });