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

Header width fixes and Port Selector Tweaks #38

Merged
merged 1 commit into from
Sep 5, 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
111 changes: 61 additions & 50 deletions src/components/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,71 @@ const meta: Meta<typeof HeaderComponent> = {
component: HeaderComponent,
};

const HeaderArgs = {
userRoles: [
'manage-users',
'download-manager',
'health-checks:edit',
],
portMenuItems: [
{ label: 'National Dashboard', link: '/national-pressure' },
{ label: 'CWL (Cardiff)', link: '/cwi' }
],
adminMenuItems: [
{ label: 'Home', link: '/', roles: []},
{ label: 'Access requests', link: '/access-requests', roles: ['manage-users']},
{ label: 'Alert notices', link: '/alerts', roles: ['manage-users']},
{ label: 'Drop-in sessions', link: '/drop-in-sessions', roles: ['manage-users']},
{ label: 'Download Manager', link: '/download', roles: ['download-manager']},
{ label: 'Export Config', link: '/export-config', roles: ['manage-users']},
{ label: 'Feature guides', link: '/feature-guides', roles: ['manage-users']},
{ label: 'Health checks', link: '/health-checks', roles: ['health-checks:edit']},
{ label: 'Health check pauses', link: '/health-check-pauses', roles: ['health-checks:edit']},
{ label: 'Feedback', link: '/user-feedback', roles: ['manage-users']},
{ label: 'Users', link: '/users', roles: ['manage-users']},
],
leftMenuItems: [
{
label: 'Port config',
link: '/port-config',
icon: 'Settings',
},
{
label: 'Feed',
link: '/feed',
icon: 'Equalizer',
}
],
rightMenuItems: [
{
label: "What's new",
link: '/whats-new',
icon: 'Article',
},
{
label: 'Training',
link: '/training',
icon: 'MenuBook',
}
],
maxWidth: 'none',
initialSelectedPortMenuItem: '',
routingFunction: (string: string) => console.log(string),
logoutLink: () => {},
}

export default meta;
type Story = StoryObj<typeof HeaderComponent>;

export const Header: Story = {
export const FullWidthHeader: Story = {
args: HeaderArgs,
parameters: {},
};

export const ConstrainedWidthHeader: Story = {
args: {
userRoles: [
'manage-users',
'download-manager',
'health-checks:edit',
],
portMenuItems: [
{ label: 'National Dashboard', link: '/national-pressure' },
{ label: 'CWL (Cardiff)', link: '/cwi' }
],
adminMenuItems: [
{ label: 'Home', link: '/', roles: []},
{ label: 'Access requests', link: '/access-requests', roles: ['manage-users']},
{ label: 'Alert notices', link: '/alerts', roles: ['manage-users']},
{ label: 'Drop-in sessions', link: '/drop-in-sessions', roles: ['manage-users']},
{ label: 'Download Manager', link: '/download', roles: ['download-manager']},
{ label: 'Export Config', link: '/export-config', roles: ['manage-users']},
{ label: 'Feature guides', link: '/feature-guides', roles: ['manage-users']},
{ label: 'Health checks', link: '/health-checks', roles: ['health-checks:edit']},
{ label: 'Health check pauses', link: '/health-check-pauses', roles: ['health-checks:edit']},
{ label: 'Feedback', link: '/user-feedback', roles: ['manage-users']},
{ label: 'Users', link: '/users', roles: ['manage-users']},
],
leftMenuItems: [
{
label: 'Port config',
link: '/port-config',
icon: 'Settings',
},
{
label: 'Feed',
link: '/feed',
icon: 'Equalizer',
}
],
rightMenuItems: [
{
label: "What's new",
link: '/whats-new',
icon: 'Article',
},
{
label: 'Training',
link: '/training',
icon: 'MenuBook',
}
],
initialSelectedPortMenuItem: '',
routingFunction: (string) => console.log(string),
logoutLink: () => {},
...HeaderArgs,
maxWidth: '1280px',
},
parameters: {},
};
8 changes: 5 additions & 3 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface IHeader {
rightMenuItems?: MenuItem[],
portMenuItems: MenuItem[],
initialSelectedPortMenuItem: string,
maxWidth: string,
routingFunction: (route: string) => void,
logoutLink: () => void,
}
Expand All @@ -37,6 +38,7 @@ const Header = ({
leftMenuItems,
portMenuItems,
initialSelectedPortMenuItem,
maxWidth,
routingFunction,
logoutLink
}: IHeader) => {
Expand All @@ -56,7 +58,7 @@ const Header = ({
return (
<AppBar sx={{backgroundColor: '#fff'}} elevation={0} position={"sticky"}>
<Box>
<Grid container sx={{maxWidth: '1200px', margin: '0 auto'}}>
<Grid container sx={{maxWidth, margin: '0 auto'}} maxWidth={'none'}>
<Grid item xs={8}>
<Box display="flex" mr={'auto'} sx={{
padding: 2,
Expand Down Expand Up @@ -120,7 +122,7 @@ const Header = ({
</Grid>
</Box>
<Box sx={{backgroundColor: '#f3f5f9', flexWrap: 'nowrap'}}>
<Grid container sx={{maxWidth: '1200px', margin: '0 auto'}}>
<Grid container sx={{maxWidth, margin: '0 auto'}}>
<Grid item xs={12} sx={{backgroundColor: '#f3f5f9', padding: 2, flexWrap: 'nowrap'}}>
<Grid container spacing={3}>
<Grid item flexGrow={{xs: 1, md: 0}}>
Expand Down Expand Up @@ -159,7 +161,7 @@ const Header = ({
Admin
</Button>
</Grid>}
<Grid item>
<Grid item display={{xs: 'none', md: 'block'}}>
<Grid container>
{
rightMenuItems && rightMenuItems.map((menuItem) => {
Expand Down
5 changes: 4 additions & 1 deletion src/components/Header/PortSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ const StyledSelect = styled(Select)<SelectProps>(({ theme }) => ({
fontWeight: 'bold !important',
fontSize: '0.875rem !important',
marginTop: '6px !important',
},
'& .MuiTypography-root': {
marginTop: 0,
}
}));

Expand All @@ -54,7 +57,7 @@ const PortSelector = ({handleChangePort, options, selectedOption}: IPortSelector
}

return (
<FormControl size="small">
<FormControl sx={{width: '100%'}}>
<StyledSelect
displayEmpty
data-testid={`port-selector-trigger`}
Expand Down
Loading