-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devtools): breadcrumb component for switch between tabs of react…
… devtools
- Loading branch information
Showing
6 changed files
with
79 additions
and
43 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/devtools/client/src/entries/client/routes/react/[tab]/layout.config.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { SelectLink } from '@/components/SelectLink'; | ||
|
||
export const handle = { | ||
breadcrumb: [ | ||
{ title: 'React' }, | ||
{ | ||
title: ( | ||
<SelectLink | ||
items={[ | ||
{ to: '/react/components', title: 'Components' }, | ||
{ to: '/react/profiler', title: 'Profiler' }, | ||
]} | ||
/> | ||
), | ||
}, | ||
], | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/devtools/client/src/entries/client/routes/react/[tab]/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Outlet } from '@modern-js/runtime/router'; | ||
|
||
export default function Layout() { | ||
return <Outlet />; | ||
} |
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
packages/devtools/client/src/entries/client/routes/react/[tab]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Box, useThemeContext } from '@radix-ui/themes'; | ||
import React from 'react'; | ||
import { | ||
createBridge, | ||
createStore, | ||
initialize, | ||
} from 'react-devtools-inline/frontend'; | ||
import { useAsync } from 'react-use'; | ||
import { useParams } from '@modern-js/runtime/router'; | ||
import { setupMountPointConnection } from '@/entries/client/rpc'; | ||
|
||
const connTask = setupMountPointConnection(); | ||
|
||
const Page: React.FC = () => { | ||
const params = useParams(); | ||
const ctx = useThemeContext(); | ||
const browserTheme = ctx.appearance === 'light' ? 'light' : 'dark'; | ||
|
||
const { value: InnerView } = useAsync(async () => { | ||
const { mountPoint, wall } = await connTask; | ||
const bridge = createBridge(window.parent, wall); | ||
const store = createStore(bridge); | ||
const ret = initialize(window.parent, { bridge, store }); | ||
mountPoint.activateReactDevtools(); | ||
return ret; | ||
}, []); | ||
|
||
return ( | ||
<Box | ||
style={{ | ||
position: 'fixed', | ||
left: 'var(--navigator-width)', | ||
top: 'var(--breadcrumb-height)', | ||
bottom: 0, | ||
right: 0, | ||
}} | ||
> | ||
{InnerView && ( | ||
<InnerView | ||
browserTheme={browserTheme} | ||
overrideTab={params.tab === 'profiler' ? 'profiler' : 'components'} | ||
hideSettings={false} | ||
/> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Page; |
7 changes: 7 additions & 0 deletions
7
packages/devtools/client/src/entries/client/routes/react/page.loader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { LoaderFunctionArgs, redirect } from '@modern-js/runtime/router'; | ||
import { resolveURL } from 'ufo'; | ||
|
||
export default ({ request }: LoaderFunctionArgs) => { | ||
const target = resolveURL(request.url, './components'); | ||
return redirect(target); | ||
}; |
44 changes: 1 addition & 43 deletions
44
packages/devtools/client/src/entries/client/routes/react/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1 @@ | ||
import { Box, useThemeContext } from '@radix-ui/themes'; | ||
import React from 'react'; | ||
import { | ||
createBridge, | ||
createStore, | ||
initialize, | ||
} from 'react-devtools-inline/frontend'; | ||
import { useAsync } from 'react-use'; | ||
import { setupMountPointConnection } from '../../rpc'; | ||
|
||
const connTask = setupMountPointConnection(); | ||
|
||
const Page: React.FC = () => { | ||
const ctx = useThemeContext(); | ||
const browserTheme = ctx.appearance === 'light' ? 'light' : 'dark'; | ||
|
||
const { value: InnerView } = useAsync(async () => { | ||
const { mountPoint, wall } = await connTask; | ||
const bridge = createBridge(window.parent, wall); | ||
const store = createStore(bridge); | ||
const ret = initialize(window.parent, { bridge, store }); | ||
mountPoint.activateReactDevtools(); | ||
return ret; | ||
}, []); | ||
|
||
return ( | ||
<Box | ||
style={{ | ||
position: 'fixed', | ||
left: 'var(--navigator-width)', | ||
top: 'var(--breadcrumb-height)', | ||
bottom: 0, | ||
right: 0, | ||
}} | ||
> | ||
{InnerView && ( | ||
<InnerView browserTheme={browserTheme} hideSettings={false} /> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Page; | ||
export default null; |