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

style: Map + label tab style update #3616

Merged
merged 1 commit into from
Sep 3, 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
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}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this on the left 👍

}),
})}
/>
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
Loading