Layout scaffolding for Web apps.
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.

index.tsx 1.6 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import * as React from 'react';
  2. import clsx from 'clsx';
  3. import { Span } from '@tesseract-design/viewfinder-base';
  4. export interface TopBarProps extends Omit<React.HTMLProps<HTMLDivElement>, 'span'> {
  5. span?: Span,
  6. brand?: React.ReactNode,
  7. menuLink?: React.ReactNode,
  8. userLink?: React.ReactNode,
  9. }
  10. export const TopBar = React.forwardRef<HTMLDivElement, TopBarProps>(({
  11. span = 'normal',
  12. brand,
  13. menuLink,
  14. userLink,
  15. children,
  16. ...etcProps
  17. }, ref) => {
  18. return (
  19. <div className={clsx(
  20. 'fixed top-0 left-0 w-full z-[3] topbar',
  21. )}>
  22. <div
  23. {...etcProps}
  24. ref={ref}
  25. className="w-full h-full bg-topbar"
  26. >
  27. <div className={clsx(
  28. 'px-8 box-border mx-auto w-full h-full flex items-center relative z-[1]',
  29. span === 'narrow' && 'max-w-screen-2xs',
  30. span === 'normal' && 'max-w-screen-xs',
  31. span === 'wide' && 'max-w-screen-md',
  32. )}>
  33. {
  34. Boolean(brand as unknown)
  35. && (
  36. <div>
  37. {brand}
  38. </div>
  39. )
  40. }
  41. <div className="flex-auto px-8 box-border first:pl-0">
  42. {children}
  43. </div>
  44. <div className="flex items-center justify-end h-full whitespace-nowrap sm:min-w-32">
  45. {
  46. Boolean(menuLink as unknown)
  47. && (
  48. <div
  49. data-viewfinder="menu"
  50. className="w-topbar h-full"
  51. >
  52. {menuLink}
  53. </div>
  54. )
  55. }
  56. {
  57. Boolean(userLink as unknown)
  58. && (
  59. <div
  60. data-viewfinder="user"
  61. className="w-topbar h-full"
  62. >
  63. {userLink}
  64. </div>
  65. )
  66. }
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. )
  72. })
  73. TopBar.displayName = 'TopBar';