Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update constraints page styles #3179

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions editor.planx.uk/src/@planx/components/PlanningConstraints/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
import groupBy from "lodash/groupBy";
import React, { ReactNode } from "react";
import ReactHtmlParser from "react-html-parser";
import { FONT_WEIGHT_SEMI_BOLD } from "theme";
import Caret from "ui/icons/Caret";
import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml";

Expand All @@ -30,20 +31,22 @@ const CATEGORY_COLORS: Record<string, string> = {
const PREFIX = "ConstraintsList";

const classes = {
content: `${PREFIX}-content`
}
content: `${PREFIX}-content`,
};

interface StyledAccordionProps extends BoxProps {
category: string;
}

const StyledAccordion = styled(Accordion, {
shouldForwardProp: (prop) => !["category", "metadata", "content", "data"].includes(prop as string),
shouldForwardProp: (prop) =>
!["category", "metadata", "content", "data"].includes(prop as string),
})<StyledAccordionProps>(({ theme, category }) => ({
borderLeft: `5px solid ${CATEGORY_COLORS[category]}`,
paddingRight: 0,
width: "100%",
position: "relative",
background: CATEGORY_COLORS[category],
"&::after": {
content: "''",
position: "absolute",
Expand All @@ -54,7 +57,7 @@ const StyledAccordion = styled(Accordion, {
background: theme.palette.border.main,
},
[`&.${classes.content}`]: {
margin: [1.5, 0]
margin: [1.5, 0],
},
}));

Expand Down Expand Up @@ -94,9 +97,9 @@ export default function ConstraintsList({
py={1}
px={2}
pl={2.5}
style={{
fontWeight: 700,
color: "black",
sx={{
fontWeight: FONT_WEIGHT_SEMI_BOLD,
color: (theme) => theme.palette.text.primary,
}}
>
{category}
Expand Down Expand Up @@ -142,13 +145,21 @@ function ConstraintListItem({ children, ...props }: ConstraintListItemProps) {
aria-controls={`${item}-panel`}
classes={{ content: classes.content }}
expandIcon={<Caret />}
sx={{ pr: 1.5 }}
sx={{ pr: 1.5, background: `rgba(255, 255, 255, 0.8)` }}
>
<Typography variant="body2" pr={1.5}>{children}</Typography>
<Typography variant="body2" pr={1.5}>
{children}
</Typography>
</AccordionSummary>
<AccordionDetails sx={{ px: 1.5, py: 2 }}>
<AccordionDetails
sx={{
px: 1.5,
py: 2,
background: (theme) => theme.palette.background.default,
}}
>
<>
<Typography variant="h3" component="h4" gutterBottom>
<Typography variant="h4" gutterBottom>
{`This property ${props?.content}`}
</Typography>
{Boolean(props.data?.length) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useStore } from "pages/FlowEditor/lib/store";
import { handleSubmit } from "pages/Preview/Node";
import React from "react";
import useSWR, { Fetcher } from "swr";
import { FONT_WEIGHT_SEMI_BOLD } from "theme";
import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml";
import { stringify } from "wkt";

Expand Down Expand Up @@ -236,7 +235,7 @@ export function PlanningConstraintsContent(
)}
{!showError && positiveConstraints.length > 0 && (
<>
<Typography variant="h3" component="h2" gutterBottom>
<Typography variant="h3" component="h2" mt={3}>
These are the planning constraints we think apply to this property
</Typography>
<ConstraintsList data={positiveConstraints} metadata={metadata} />
Expand All @@ -258,15 +257,15 @@ export function PlanningConstraintsContent(
positiveConstraints.length === 0 &&
negativeConstraints.length > 0 && (
<>
<Typography variant="h3" component="h2">
<Typography variant="h3" component="h2" gutterBottom mt={3}>
It looks like there are no constraints on this property
</Typography>
<Typography variant="body2">
<Typography variant="body1" gutterBottom>
Based on the information you've given it looks like there are no
planning constraints on your property that might limit what you
can do.
</Typography>
<Typography variant="body2">
<Typography variant="body1" gutterBottom>
Continue with your application to tell us more about your project.
</Typography>
<SimpleExpand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const SimpleExpand: React.FC<PropsWithChildren<Props>> = ({
const [show, setShow] = React.useState(false);
return (
<>
<Box mx={1}>
<Box>
<StyledButton
onClick={() => setShow(!show)}
aria-expanded={show}
Expand Down
Loading