From 681d82c8535109adffd8ed78cc7ca092a8d6db32 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 29 Mar 2023 10:59:00 +0200 Subject: [PATCH] SONAR-18868 Fix Main and Top Bars positionning --- .../src/components/MainAppBar.tsx | 28 ++++++++----------- .../design-system/src/components/TopBar.tsx | 27 ++++++------------ .../main/js/app/components/AdminContainer.tsx | 4 +-- .../AdminContainer-test.tsx.snap | 4 +-- 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/server/sonar-web/design-system/src/components/MainAppBar.tsx b/server/sonar-web/design-system/src/components/MainAppBar.tsx index 6de796006c2..b3575702258 100644 --- a/server/sonar-web/design-system/src/components/MainAppBar.tsx +++ b/server/sonar-web/design-system/src/components/MainAppBar.tsx @@ -25,19 +25,14 @@ import { LAYOUT_LOGO_MARGIN_RIGHT, LAYOUT_LOGO_MAX_HEIGHT, LAYOUT_LOGO_MAX_WIDTH, + LAYOUT_VIEWPORT_MIN_WIDTH, } from '../helpers/constants'; import { themeBorder, themeColor, themeContrast } from '../helpers/theme'; -const MainAppBarContainerDiv = styled.div` - height: ${LAYOUT_GLOBAL_NAV_HEIGHT}px; -`; - const MainAppBarDiv = styled.div` - ${tw`sw-fixed`} + ${tw`sw-sticky sw-top-0`} ${tw`sw-flex`}; ${tw`sw-items-center`}; - ${tw`sw-left-0`}; - ${tw`sw-right-0`}; ${tw`sw-px-6`}; ${tw`sw-w-full`}; ${tw`sw-box-border`}; @@ -47,6 +42,7 @@ const MainAppBarDiv = styled.div` border-bottom: ${themeBorder('default')}; color: ${themeContrast('mainBar')}; height: ${LAYOUT_GLOBAL_NAV_HEIGHT}px; + min-width: ${LAYOUT_VIEWPORT_MIN_WIDTH}px; `; const MainAppBarNavLogoDiv = styled.div` @@ -75,15 +71,13 @@ export function MainAppBar({ Logo, }: React.PropsWithChildren<{ Logo: React.ElementType }>) { return ( - - - - - - - - {children} - - + + + + + + + {children} + ); } diff --git a/server/sonar-web/design-system/src/components/TopBar.tsx b/server/sonar-web/design-system/src/components/TopBar.tsx index f808c2d17ad..fd09469f997 100644 --- a/server/sonar-web/design-system/src/components/TopBar.tsx +++ b/server/sonar-web/design-system/src/components/TopBar.tsx @@ -18,33 +18,22 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import styled from '@emotion/styled'; -import { DetailedHTMLProps, HTMLAttributes, PropsWithChildren } from 'react'; import tw from 'twin.macro'; -import { LAYOUT_GLOBAL_NAV_HEIGHT } from '../helpers'; +import { LAYOUT_GLOBAL_NAV_HEIGHT, LAYOUT_VIEWPORT_MIN_WIDTH } from '../helpers'; import { themeColor, themeContrast } from '../helpers/theme'; -interface Props { - id?: string; -} - -export function TopBar({ - children, - ...props -}: PropsWithChildren & DetailedHTMLProps, HTMLElement>) { - return ( - - {children} - - ); -} - -const BaseStyle = styled.nav` - ${tw`sw-sticky`} +export const TopBar = styled.nav` + ${tw`sw-sticky sw-top-0`} ${tw`sw-z-top-navbar`} ${tw`sw-px-6 sw-pt-4`} + ${tw`sw-box-border`}; + ${tw`sw-w-full`}; ${tw`sw-font-sans`} ${tw`sw-text-sm`} + min-width: ${LAYOUT_VIEWPORT_MIN_WIDTH}px; + top: ${LAYOUT_GLOBAL_NAV_HEIGHT}px; + background-color: ${themeColor('navbar')}; color: ${themeContrast('navbar')}; `; diff --git a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx index 82ab8d97641..80db7939184 100644 --- a/server/sonar-web/src/main/js/app/components/AdminContainer.tsx +++ b/server/sonar-web/src/main/js/app/components/AdminContainer.tsx @@ -122,7 +122,7 @@ export class AdminContainer extends React.PureComponent + <> - + ); } } diff --git a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap index 6d04b34fa6d..631a82fbf2e 100644 --- a/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/__tests__/__snapshots__/AdminContainer-test.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`should render correctly 1`] = ` -
+ -
+ `; -- 2.39.5