From a566c10cd284d9e055343dfdcc249d75bc3da3a3 Mon Sep 17 00:00:00 2001 From: jackson Date: Thu, 5 Sep 2024 13:21:28 +0100 Subject: [PATCH] Header width fixes and Port Selector tweaks --- src/components/Header/Header.stories.tsx | 111 +++++++++++++---------- src/components/Header/Header.tsx | 8 +- src/components/Header/PortSelector.tsx | 5 +- 3 files changed, 70 insertions(+), 54 deletions(-) diff --git a/src/components/Header/Header.stories.tsx b/src/components/Header/Header.stories.tsx index 2183981..0700776 100644 --- a/src/components/Header/Header.stories.tsx +++ b/src/components/Header/Header.stories.tsx @@ -7,60 +7,71 @@ const meta: Meta = { 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; -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: {}, }; diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 31c02ad..dcd8bc0 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -21,6 +21,7 @@ export interface IHeader { rightMenuItems?: MenuItem[], portMenuItems: MenuItem[], initialSelectedPortMenuItem: string, + maxWidth: string, routingFunction: (route: string) => void, logoutLink: () => void, } @@ -37,6 +38,7 @@ const Header = ({ leftMenuItems, portMenuItems, initialSelectedPortMenuItem, + maxWidth, routingFunction, logoutLink }: IHeader) => { @@ -56,7 +58,7 @@ const Header = ({ return ( - + - + @@ -159,7 +161,7 @@ const Header = ({ Admin } - + { rightMenuItems && rightMenuItems.map((menuItem) => { diff --git a/src/components/Header/PortSelector.tsx b/src/components/Header/PortSelector.tsx index ee6544c..f3de29f 100644 --- a/src/components/Header/PortSelector.tsx +++ b/src/components/Header/PortSelector.tsx @@ -35,6 +35,9 @@ const StyledSelect = styled(Select)(({ theme }) => ({ fontWeight: 'bold !important', fontSize: '0.875rem !important', marginTop: '6px !important', + }, + '& .MuiTypography-root': { + marginTop: 0, } })); @@ -54,7 +57,7 @@ const PortSelector = ({handleChangePort, options, selectedOption}: IPortSelector } return ( - +