Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

MainAppBar.tsx 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2023 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import styled from '@emotion/styled';
  21. import tw from 'twin.macro';
  22. import {
  23. LAYOUT_GLOBAL_NAV_HEIGHT,
  24. LAYOUT_LOGO_MARGIN_RIGHT,
  25. LAYOUT_LOGO_MAX_HEIGHT,
  26. LAYOUT_LOGO_MAX_WIDTH,
  27. } from '../helpers/constants';
  28. import { themeBorder, themeColor, themeContrast } from '../helpers/theme';
  29. const MainAppBarContainerDiv = styled.div`
  30. height: ${LAYOUT_GLOBAL_NAV_HEIGHT}px;
  31. `;
  32. const MainAppBarDiv = styled.div`
  33. ${tw`sw-fixed`}
  34. ${tw`sw-flex`};
  35. ${tw`sw-items-center`};
  36. ${tw`sw-left-0`};
  37. ${tw`sw-px-6`};
  38. ${tw`sw-right-0`};
  39. ${tw`sw-w-full`};
  40. ${tw`sw-box-border`};
  41. ${tw`sw-z-global-navbar`};
  42. background: ${themeColor('mainBar')};
  43. border-bottom: ${themeBorder('default')};
  44. color: ${themeContrast('mainBar')};
  45. height: ${LAYOUT_GLOBAL_NAV_HEIGHT}px;
  46. `;
  47. const MainAppBarNavLogoDiv = styled.div`
  48. margin-right: ${LAYOUT_LOGO_MARGIN_RIGHT}px;
  49. img,
  50. svg {
  51. ${tw`sw-object-contain`};
  52. max-height: ${LAYOUT_LOGO_MAX_HEIGHT}px;
  53. max-width: ${LAYOUT_LOGO_MAX_WIDTH}px;
  54. }
  55. `;
  56. const MainAppBarNavLogoLink = styled.a`
  57. border: none;
  58. `;
  59. const MainAppBarNavRightDiv = styled.div`
  60. flex-grow: 2;
  61. height: 100%;
  62. `;
  63. export function MainAppBar({
  64. children,
  65. Logo,
  66. }: React.PropsWithChildren<{ Logo: React.ElementType }>) {
  67. return (
  68. <MainAppBarContainerDiv>
  69. <MainAppBarDiv>
  70. <MainAppBarNavLogoDiv>
  71. <MainAppBarNavLogoLink href="/">
  72. <Logo />
  73. </MainAppBarNavLogoLink>
  74. </MainAppBarNavLogoDiv>
  75. <MainAppBarNavRightDiv>{children}</MainAppBarNavRightDiv>
  76. </MainAppBarDiv>
  77. </MainAppBarContainerDiv>
  78. );
  79. }