Design system.
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.
 
 
 

194 lines
6.6 KiB

  1. import * as React from 'react';
  2. import {Layouts, Widgets} from '@tesseract-design/viewfinder-react';
  3. import Link from 'next/link';
  4. import {Brand} from '@/components/Brand';
  5. import {PLATFORMS} from '@/utils/data';
  6. export interface Page {
  7. id: string;
  8. href: string;
  9. label: string;
  10. }
  11. export interface DocsLayoutProps {
  12. componentPages?: { name: string; components: Page[] }[];
  13. docsPages?: Page[];
  14. examplePages?: Page[];
  15. sidebarOpen?: boolean;
  16. platforms?: any;
  17. children?: React.ReactNode;
  18. currentPlatform?: string;
  19. currentVersion?: string;
  20. }
  21. const createSidebarPageLink = (p: Page) => (
  22. <div
  23. key={p.id}
  24. >
  25. <Link
  26. href={p.href}
  27. className="no-underline font-semibold m-0 p-0 leading-none h-8 flex items-center cursor-pointer uppercase text-sm"
  28. >
  29. <Layouts.LeftSidebar.SidebarContentContainer>
  30. {p.label}
  31. </Layouts.LeftSidebar.SidebarContentContainer>
  32. </Link>
  33. </div>
  34. );
  35. export const DocsLayout: React.FC<DocsLayoutProps> = ({
  36. sidebarOpen = false,
  37. componentPages = [],
  38. docsPages = [],
  39. examplePages = [],
  40. platforms = [],
  41. currentPlatform,
  42. currentVersion,
  43. children,
  44. }) => {
  45. return (
  46. <Layouts.LeftSidebar.Root
  47. topBarWidget={
  48. <Widgets.TopBar
  49. span="wide"
  50. brand={
  51. <Link
  52. href="/"
  53. className="no-underline block"
  54. >
  55. <Brand
  56. platform={currentPlatform}
  57. version={currentVersion}
  58. />
  59. </Link>
  60. }
  61. menuLink={
  62. <Link
  63. href={{
  64. query: {
  65. open: 'sidebar',
  66. },
  67. }}
  68. className="no-underline p-0 m-0"
  69. >
  70. <svg
  71. className="w-6 h-6 fill-none stroke-current stroke-2 linejoin-round linecap-round"
  72. viewBox="0 0 24 24"
  73. role="presentation"
  74. >
  75. <line x1="3" y1="12" x2="21" y2="12"/>
  76. <line x1="3" y1="6" x2="21" y2="6"/>
  77. <line x1="3" y1="18" x2="21" y2="18"/>
  78. </svg>
  79. </Link>
  80. }
  81. />
  82. }
  83. sidebarBaseWidget={
  84. <Widgets.LeftSidebarBase
  85. open={sidebarOpen}
  86. >
  87. <div className="min-h-full py-4 box-border flex flex-col gap-8">
  88. <div>
  89. <nav>
  90. <Layouts.LeftSidebar.SidebarContentContainer>
  91. <h1>
  92. Docs
  93. </h1>
  94. </Layouts.LeftSidebar.SidebarContentContainer>
  95. <div className="flex flex-col gap-2 my-8">
  96. {docsPages?.map(createSidebarPageLink)}
  97. </div>
  98. </nav>
  99. <nav>
  100. <Layouts.LeftSidebar.SidebarContentContainer>
  101. <h1>
  102. Platforms
  103. </h1>
  104. </Layouts.LeftSidebar.SidebarContentContainer>
  105. <div className="flex flex-col gap-2 my-8">
  106. <Layouts.LeftSidebar.SidebarContentContainer>
  107. <div className="flex gap-8">
  108. {platforms.map((platformName) => {
  109. // TODO make platform selection a select with optgroup labels for platforms and versions
  110. const platform = PLATFORMS[platformName as keyof typeof PLATFORMS];
  111. return (
  112. <Link
  113. key={platformName}
  114. href={platform.href}
  115. className="no-underline font-semibold leading-none h-8 flex items-center cursor-pointer uppercase text-sm"
  116. >
  117. {platform.label}
  118. </Link>
  119. );
  120. })}
  121. </div>
  122. </Layouts.LeftSidebar.SidebarContentContainer>
  123. </div>
  124. </nav>
  125. {/*<div>*/}
  126. {/* <Layouts.LeftSidebar.SidebarContentContainer>*/}
  127. {/* <h1>*/}
  128. {/* Categories*/}
  129. {/* </h1>*/}
  130. {/* </Layouts.LeftSidebar.SidebarContentContainer>*/}
  131. {/* {componentPages.map(({name, components}) => (*/}
  132. {/* <nav key={name}>*/}
  133. {/* <h2>*/}
  134. {/* <Layouts.LeftSidebar.SidebarContentContainer>*/}
  135. {/* {name}*/}
  136. {/* </Layouts.LeftSidebar.SidebarContentContainer>*/}
  137. {/* </h2>*/}
  138. {/* <div className="flex flex-col gap-2 my-8">*/}
  139. {/* {components?.map(createSidebarPageLink)}*/}
  140. {/* </div>*/}
  141. {/* </nav>*/}
  142. {/* ))}*/}
  143. {/*</div>*/}
  144. {/*<nav>*/}
  145. {/* <Layouts.LeftSidebar.SidebarContentContainer>*/}
  146. {/* <h1>*/}
  147. {/* Examples*/}
  148. {/* </h1>*/}
  149. {/* </Layouts.LeftSidebar.SidebarContentContainer>*/}
  150. {/* <div className="flex flex-col gap-4 my-4">*/}
  151. {/* {examplePages?.map(createSidebarPageLink)}*/}
  152. {/* </div>*/}
  153. {/*</nav>*/}
  154. </div>
  155. <div className="mb-8">
  156. <Layouts.LeftSidebar.SidebarContentContainer>
  157. <div className="flex gap-8">
  158. <Link
  159. href="https://code.modal.sh/tesseract-design/tesseract"
  160. className="no-underline font-semibold leading-none h-8 flex items-center cursor-pointer uppercase text-sm"
  161. >
  162. Repo
  163. </Link>
  164. <Link
  165. href="https://code.modal.sh/tesseract-design/tesseract"
  166. className="no-underline font-semibold leading-none h-8 flex items-center cursor-pointer uppercase text-sm"
  167. >
  168. Website
  169. </Link>
  170. <Link
  171. href="https://code.modal.sh/tesseract-design/tesseract/issues"
  172. className="no-underline font-semibold leading-none h-8 flex items-center cursor-pointer uppercase text-sm"
  173. >
  174. Issues
  175. </Link>
  176. </div>
  177. </Layouts.LeftSidebar.SidebarContentContainer>
  178. </div>
  179. </div>
  180. </Widgets.LeftSidebarBase>
  181. }
  182. >
  183. <Layouts.LeftSidebar.MainContentContainer>
  184. {children}
  185. </Layouts.LeftSidebar.MainContentContainer>
  186. </Layouts.LeftSidebar.Root>
  187. )
  188. };