Template for starting apps, powered by Next.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

130 lines
2.5 KiB

  1. import * as React from 'react'
  2. import styled from 'styled-components'
  3. import * as T from '@tesseract-design/react-common'
  4. import {LeftSidebar} from '@theoryofnekomata/viewfinder'
  5. import DummyContent from '../../molecules/DummyContent'
  6. import Link from '../../molecules/Link'
  7. import Brand from '../../molecules/Brand'
  8. const TopBarComponent = styled('div')({
  9. backgroundColor: 'var(--color-bg, white)',
  10. '::before': {
  11. content: "''",
  12. width: '100%',
  13. height: '100%',
  14. position: 'absolute',
  15. top: 0,
  16. left: 0,
  17. pointerEvents: 'none',
  18. },
  19. '::after': {
  20. backgroundColor: 'black',
  21. opacity: 0.5,
  22. content: "''",
  23. width: '100%',
  24. height: '100%',
  25. position: 'absolute',
  26. top: 0,
  27. left: 0,
  28. pointerEvents: 'none',
  29. },
  30. })
  31. const SidebarMainComponent = styled('div')({
  32. backgroundColor: 'var(--color-bg, white)',
  33. zIndex: 2,
  34. '::after': {
  35. backgroundColor: 'black',
  36. opacity: 0.25,
  37. content: "''",
  38. width: '100%',
  39. height: '100%',
  40. position: 'absolute',
  41. top: 0,
  42. left: 0,
  43. pointerEvents: 'none',
  44. },
  45. })
  46. type Props = {
  47. query: string
  48. menuLinkLabel: string
  49. userLinkLabel: string
  50. searchQueryKey: string
  51. searchLabel: string
  52. searchHint: string
  53. popupQueryKey: string
  54. userPopupQueryValue: string
  55. sidebarSubpageQueryValue: string
  56. subpageQueryKey: string
  57. subpage: string
  58. }
  59. const LeftSidebarLayoutTemplate: React.FC<Props> = ({
  60. query,
  61. menuLinkLabel,
  62. userLinkLabel,
  63. searchQueryKey,
  64. searchLabel,
  65. searchHint,
  66. popupQueryKey,
  67. userPopupQueryValue,
  68. sidebarSubpageQueryValue,
  69. subpageQueryKey,
  70. subpage,
  71. }) => {
  72. return (
  73. <LeftSidebar.Layout
  74. brand={<Brand />}
  75. topBarComponent={TopBarComponent}
  76. sidebarMainComponent={SidebarMainComponent}
  77. sidebarMainOpen={subpage === sidebarSubpageQueryValue}
  78. topBarCenter={
  79. <form>
  80. <T.TextInput
  81. name={searchQueryKey}
  82. label={searchLabel}
  83. hint={searchHint}
  84. defaultValue={query}
  85. border
  86. alternate
  87. />
  88. </form>
  89. }
  90. menuLink={
  91. <Link
  92. href={{
  93. query: {
  94. [subpageQueryKey]: sidebarSubpageQueryValue,
  95. },
  96. }}
  97. >
  98. <T.Icon name="menu" label={menuLinkLabel} />
  99. </Link>
  100. }
  101. userLink={
  102. <Link
  103. href={{
  104. query: {
  105. [popupQueryKey]: userPopupQueryValue,
  106. },
  107. }}
  108. >
  109. <T.Icon name="user" label={userLinkLabel} />
  110. </Link>
  111. }
  112. sidebarMain={
  113. <LeftSidebar.SidebarMainContainer>
  114. <DummyContent />
  115. </LeftSidebar.SidebarMainContainer>
  116. }
  117. >
  118. <LeftSidebar.ContentContainer>
  119. <DummyContent />
  120. </LeftSidebar.ContentContainer>
  121. </LeftSidebar.Layout>
  122. )
  123. }
  124. export default LeftSidebarLayoutTemplate