Skip to content

Commit

Permalink
style: Map + label tab style update (#3616)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianjon3s authored Sep 3, 2024
1 parent 6ae1d93 commit 3bfb8b7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
37 changes: 30 additions & 7 deletions editor.planx.uk/src/@planx/components/MapAndLabel/Public/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import TabContext from "@mui/lab/TabContext";
import TabPanel from "@mui/lab/TabPanel";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import Tab from "@mui/material/Tab";
import { lighten, styled } from "@mui/material/styles";
import Tab, { tabClasses, TabProps } from "@mui/material/Tab";
import Tabs from "@mui/material/Tabs";
import Typography from "@mui/material/Typography";
import { SiteAddress } from "@planx/components/FindProperty/model";
Expand Down Expand Up @@ -39,6 +40,20 @@ function a11yProps(index: number) {
};
}

const StyledTab = styled((props: TabProps) => (
<Tab {...props} disableFocusRipple disableTouchRipple disableRipple />
))<TabProps>(({ theme }) => ({
textTransform: "none",
textAlign: "right",
fontWeight: FONT_WEIGHT_SEMI_BOLD,
fontSize: theme.typography.body1.fontSize,
minWidth: "120px",
[`&.${tabClasses.selected}`]: {
background: lighten(theme.palette.border.light, 0.2),
color: theme.palette.text.primary,
},
})) as typeof Tab;

const VerticalFeatureTabs: React.FC<{ features: Feature[] }> = ({
features,
}) => {
Expand All @@ -63,19 +78,27 @@ const VerticalFeatureTabs: React.FC<{ features: Feature[] }> = ({
editFeature(parseInt(newValue, 10));
}}
aria-label="Select a feature to enter data"
sx={{ borderRight: 1, borderColor: "divider" }}
TabIndicatorProps={{
style: {
width: "4px",
},
}}
sx={{
borderRight: 1,
borderColor: (theme) => theme.palette.border.main,
}}
>
{features.map((feature, i) => (
<Tab
<StyledTab
key={`tab-${i}`}
value={i.toString()}
label={`${schema.type} ${feature.properties?.label}`}
disableRipple
disableTouchRipple
{...a11yProps(i)}
{...(isFeatureInvalid(i) && {
sx: (theme) => ({
borderRight: `12px solid ${theme.palette.error.main}`,
// Appear over tab indicator
zIndex: 2,
borderLeft: `5px solid ${theme.palette.error.main}`,
}),
})}
/>
Expand All @@ -98,7 +121,7 @@ const VerticalFeatureTabs: React.FC<{ features: Feature[] }> = ({
}}
>
<Box>
<Typography component="h2" variant="h3">
<Typography component="h2" variant="h3" gutterBottom>
{`${schema.type} ${feature.properties?.label}`}
</Typography>
<Typography variant="body2" mb={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface MapContainerProps {

export const MapContainer = styled(Box)<MapContainerProps>(
({ theme, environment, size }) => ({
padding: theme.spacing(1, 0, 1, 0),
padding: theme.spacing(0.5, 0, 0.5, 0),
width: "100%",
maxWidth: "none",
"& my-map": {
Expand Down

0 comments on commit 3bfb8b7

Please sign in to comment.