@@ -11,26 +11,28 @@ import {
1111 Anchor ,
1212 Tooltip ,
1313} from "@mantine/core" ;
14- import { useDisclosure } from "@mantine/hooks" ;
14+ import { useDisclosure , useViewportSize } from "@mantine/hooks" ;
1515import { IconBrandGithub , IconMoon , IconSun } from "@tabler/icons-react" ;
1616import { version } from "react" ;
1717
1818import { DevTool } from "./components/DevTool" ;
19- import { ExampleContent } from "./components/ExampleContent" ;
2019import { Github } from "./components/icons" ;
21- import { MainContent } from "./components/MainContent" ;
22- import { PlayGround } from "./components/PlayGroundContent" ;
23- import { StartContent } from "./components/StartContent" ;
2420import { usePreviewTypeWithRouter } from "./hooks/usePreviewType" ;
21+ import { Example } from "./views/Example" ;
22+ import { Main } from "./views/Main" ;
23+ import { PlayGround } from "./views/PlayGround" ;
24+ import { WorkerExample } from "./views/Worker" ;
2525
2626function App ( ) {
2727 const { colorScheme, toggleColorScheme } = useMantineColorScheme ( ) ;
2828
29+ const { width } = useViewportSize ( ) ;
30+
2931 const type = usePreviewTypeWithRouter ( ) ;
3032
3133 const [ opened , { toggle, close } ] = useDisclosure ( ) ;
3234
33- const goto = ( type : "main" | "example" | "try" ) => {
35+ const goto = ( type : "main" | "example" | "try" | "worker" ) => {
3436 const url = new URL ( window . location . href ) ;
3537 url . searchParams . set ( "type" , type ) ;
3638 url . searchParams . delete ( "tab" ) ;
@@ -51,12 +53,16 @@ function App() {
5153 < Title order = { 1 } className = "text-xl" >
5254 Git Diff View
5355 </ Title >
54- < small className = "ml-4 mr-1" > power by</ small >
55- < Tooltip label = { < span > Go to @my-react project, version: { version } </ span > } withArrow position = "top" >
56- < Anchor href = "https://github.com/MrWangJustToDo/MyReact" target = "_blank" >
57- < small > @my-react</ small >
58- </ Anchor >
59- </ Tooltip >
56+ { width > 900 && (
57+ < >
58+ < small className = "ml-4 mr-1" > power by</ small >
59+ < Tooltip label = { < span > Go to @my-react project, version: { version } </ span > } withArrow position = "top" >
60+ < Anchor href = "https://github.com/MrWangJustToDo/MyReact" target = "_blank" >
61+ < small > @my-react</ small >
62+ </ Anchor >
63+ </ Tooltip >
64+ </ >
65+ ) }
6066 </ Flex >
6167 < Flex columnGap = "16" visibleFrom = "sm" >
6268 < Button variant = "light" color = { type === "main" ? "blue" : "gray" } onClick = { ( ) => goto ( "main" ) } >
@@ -68,6 +74,9 @@ function App() {
6874 < Button variant = "light" color = { type === "try" ? "blue" : "gray" } onClick = { ( ) => goto ( "try" ) } >
6975 Playground
7076 </ Button >
77+ < Button variant = "light" color = { type === "worker" ? "blue" : "gray" } onClick = { ( ) => goto ( "worker" ) } >
78+ Worker
79+ </ Button >
7180 < Button
7281 variant = "default"
7382 color = "gray"
@@ -135,25 +144,13 @@ function App() {
135144 </ Button >
136145 </ AppShell . Navbar >
137146 < AppShell . Main >
138- { type === "main" && (
139- < >
140- < MainContent />
141- < StartContent />
142- < DevTool />
143- </ >
144- ) }
147+ { type === "main" && < Main /> }
145148 { type === "example" && (
146- < >
147- < ExampleContent className = "border-color h-[calc(100vh-60px-32px)] w-full overflow-hidden rounded-md border" />
148- < DevTool />
149- </ >
150- ) }
151- { type === "try" && (
152- < >
153- < PlayGround />
154- < DevTool />
155- </ >
149+ < Example className = "border-color h-[calc(100vh-60px-32px)] w-full overflow-hidden rounded-md border" />
156150 ) }
151+ { type === "try" && < PlayGround /> }
152+ { type === "worker" && < WorkerExample /> }
153+ < DevTool />
157154 </ AppShell . Main >
158155 </ AppShell >
159156 ) ;
0 commit comments