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.
 
 
 

61 lignes
1.1 KiB

  1. import * as React from 'react'
  2. import styled, { createGlobalStyle } from 'styled-components'
  3. import TopBar from '../../widgets/TopBar'
  4. import {configVar, loadConfig} from '../../utilities/helpers'
  5. const Config = createGlobalStyle({
  6. ...loadConfig(),
  7. })
  8. const ContentBase = styled('main')({
  9. boxSizing: 'border-box',
  10. })
  11. export const ContentContainer = styled('div')({
  12. padding: '0 1rem',
  13. boxSizing: 'border-box',
  14. margin: '0 auto',
  15. maxWidth: `calc(${configVar('base-width')} * 3)`,
  16. width: '100%',
  17. })
  18. type Props = {
  19. brand?: React.ReactNode,
  20. userLink?: React.ReactNode,
  21. topBarCenter?: React.ReactChild,
  22. topBarComponent?: React.ElementType,
  23. }
  24. export const Layout: React.FC<Props> = ({
  25. brand,
  26. userLink,
  27. topBarCenter,
  28. topBarComponent = 'div',
  29. children,
  30. }) => {
  31. return (
  32. <>
  33. <Config />
  34. {
  35. (
  36. brand
  37. || userLink
  38. || topBarCenter
  39. )
  40. && (
  41. <TopBar
  42. brand={brand}
  43. userLink={userLink}
  44. baseComponent={topBarComponent}
  45. >
  46. {topBarCenter}
  47. </TopBar>
  48. )
  49. }
  50. <ContentBase>
  51. {children}
  52. </ContentBase>
  53. </>
  54. )
  55. }