From 2de78d0580a475ebd58dbbc1839f626edecfe8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 19 Jul 2024 14:58:53 +0100 Subject: [PATCH] chore: Styles and correct semantic html lists --- .../FlowEditor/components/Sidebar/Search.tsx | 69 ++++++++++--------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search.tsx index 6da4671347..4c7dedcf26 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Sidebar/Search.tsx @@ -1,6 +1,7 @@ import Box from "@mui/material/Box"; import Container from "@mui/material/Container"; import List from "@mui/material/List"; +import ListItem from "@mui/material/ListItem"; import ListItemButton from "@mui/material/ListItemButton"; import { styled } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; @@ -12,6 +13,7 @@ import { capitalize, get } from "lodash"; import { SLUGS } from "pages/FlowEditor/data/types"; import { useStore } from "pages/FlowEditor/lib/store"; import React, { ChangeEvent, useEffect } from "react"; +import { useNavigation } from "react-navi"; import { FONT_WEIGHT_BOLD, FONT_WEIGHT_SEMI_BOLD } from "theme"; import ChecklistItem from "ui/shared/ChecklistItem"; import Input from "ui/shared/Input"; @@ -26,7 +28,18 @@ const SearchResultRoot = styled(List)(({ theme }) => ({ const SearchResultCardRoot = styled(ListItemButton)(({ theme }) => ({ padding: theme.spacing(1), border: `1px solid ${theme.palette.common.black}`, - display: "block", + display: "block" +})); + +const ExternalPortalCard = styled(ListItemButton)(({ theme }) => ({ + backgroundColor: "black", + color: theme.palette.common.white, + "&:hover": { + backgroundColor: "black", + "& p:last-of-type": { + textDecoration: "underline", + } + } })); const SearchResults: React.FC<{ results: SearchResults }> = ({ @@ -39,7 +52,9 @@ const SearchResults: React.FC<{ results: SearchResults }> = ({ {results.map((result) => ( - + + + ))} @@ -160,6 +175,7 @@ const SearchResultCard: React.FC<{ result: SearchResult }> = ({ const ExternalPortalList: React.FC = () => { const externalPortals = useStore((state) => state.externalPortals); const hasExternalPortals = Object.keys(externalPortals).length; + const { navigate } = useNavigation(); if (!hasExternalPortals) return null; @@ -169,38 +185,27 @@ const ExternalPortalList: React.FC = () => { Your service also contains the following external portals, which have not been searched: + {Object.values(externalPortals).map(({ name, href }) => ( - ({ - backgroundColor: "black", - color: theme.palette.common.white, - mb: 2, - p: 1, - })} - key={`external-portal-card-${name}`} - > - - External portal • - - ({ - color: theme.palette.common.white, - textDecoration: "none", - borderBottom: "1px solid rgba(255, 255, 255, 0.75)", - })} - > - {href} - - + + navigate("../" + href)}> + + External portal • + + + {href.replaceAll("/", " / ")} + + + ))} + ); };