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

[DRTII-1518] Header design tweaks #40

Merged
merged 3 commits into from
Sep 13, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@drt/drt-react-components",
"version": "1.5.0",
"version": "1.5.1",
"description": "React components for DRT applications",
"main": "dist/cjs/bundle.js",
"module": "dist/esm/bundle.js",
Expand Down
85 changes: 67 additions & 18 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const Header = ({
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const [selectedPortOption, setSelectedPortOption] = React.useState<string>(initialSelectedPortMenuItem);
const open = Boolean(anchorEl);

const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
Expand All @@ -58,30 +59,83 @@ const Header = ({
return (
<AppBar sx={{backgroundColor: '#fff'}} elevation={0} position={"sticky"}>
<Box>
<Grid container sx={{maxWidth, margin: '0 auto'}} maxWidth={'none'}>
<Grid container sx={{maxWidth, margin: '0 auto', padding: '12px'}} maxWidth={'none'}>
<Grid item xs={8}>
<Box display="flex" mr={'auto'} sx={{
padding: 2,
padding: {
xs: 0,
md: 2,
},
'& svg': {
width: '35px'
}
}}>
<Link href="https://drt.homeoffice.gov.uk/"><Crest data-testid="crest"/></Link>
<Typography color="inherit" noWrap sx={{flexGrow: 0, fontSize: '1.3rem', mr: 2, color: '#000'}}>Border
Force</Typography>
<Typography color="inherit" noWrap sx={{flexGrow: 0, lineHeight: '2rem', fontSize: '1rem', color: '#000'}}
display={{xs: 'none', md: 'block'}}>Dynamic Response Tool</Typography>
<Link href="https://drt.homeoffice.gov.uk/" style={{
display: 'flex',
textDecoration: 'none',
}}>
<Crest data-testid="crest"/>
<Grid container sx={{
flexWrap: {
xs: 'wrap',
md: 'nowrap',
}
}}>
<Grid item>
<Typography color="inherit" noWrap sx={{
flexGrow: 0,
fontSize: {
xs: '1rem',
sm: '1.3rem',
},
lineHeight: {
xs: '1.2rem',
sm: '2rem',
},
mr: 2,
color: '#000'
}}>
Border Force
</Typography>
</Grid>
<Grid item sx={{
width: {
xs: '100%',
sm: 'auto',
}
}}>
<Typography color="inherit" noWrap
sx={{
flexGrow: 0,
color: '#404252',
fontSize: {
xs: '0.7rem',
sm: '1rem',
},
lineHeight: {
xs: '1rem',
sm: '2.1rem',
},
}}>
Dynamic Response Tool
</Typography>
</Grid>
</Grid>
</Link>
</Box>
</Grid>
<Grid item xs={4} sx={{padding: 2}} display={{xs: 'none', md: 'block'}}>
<Box display="flex" ml={'auto'}>
<Typography variant="body1" color="inherit" noWrap
<Typography variant="body1" noWrap color={'#000'}
sx={{flexGrow: 1, textAlign: 'right'}}><strong>Contact:</strong>&nbsp;<Link
href="mailto:[email protected]">[email protected]</Link></Typography>
</Box>
</Grid>
{hasAdminMenuRoles &&
<Grid item xs={4} sx={{padding: 2, textAlign: 'right'}} display={{xs: 'block', md: 'none'}}>
<Grid item xs={4} sx={{padding: {
xs: 0,
md: 2,
}, textAlign: 'right'}} display={{xs: 'block', md: 'none'}}>

<Button
data-testid="mobile-admin-menu-trigger"
Expand All @@ -99,14 +153,6 @@ const Header = ({
anchorEl={anchorEl}
open={open}
onClose={handleClose}
anchorOrigin={{
vertical: 'top',
horizontal: 'left',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'left',
}}
>
{adminMenuItems.map((item) => {
const hasRole = item.roles && (item.roles.filter(role => userRoles.includes(role)).length > 0);
Expand All @@ -123,7 +169,10 @@ const Header = ({
</Box>
<Box sx={{backgroundColor: '#f3f5f9', flexWrap: 'nowrap'}}>
<Grid container sx={{maxWidth, margin: '0 auto'}}>
<Grid item xs={12} sx={{backgroundColor: '#f3f5f9', padding: 2, flexWrap: 'nowrap'}}>
<Grid item xs={12} sx={{backgroundColor: '#f3f5f9', px: 2, py: {
xs: '6px',
md: '12px',
}, flexWrap: 'nowrap'}}>
<Grid container spacing={3}>
<Grid item flexGrow={{xs: 1, md: 0}}>
<PortSelector options={portMenuItems} handleChangePort={routingFunction}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/PortSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const StyledSelect = styled(Select)<SelectProps>(({ theme }) => ({
}
}
},
'& .MuiListItemText-root *': {
'& .MuiListItemText-root': {
fontWeight: 'bold !important',
fontSize: '0.875rem !important',
marginTop: '6px !important',
Expand Down Expand Up @@ -66,7 +66,7 @@ const PortSelector = ({handleChangePort, options, selectedOption}: IPortSelector
variant="standard"
onChange={onChange}>
<MenuItem value={""} disabled>
<ListItemText><em>Select an airport...</em></ListItemText>
<ListItemText><em>Select a location...</em></ListItemText>
</MenuItem>
{options?.map((option) => {
return (
Expand Down
Loading