Skip to content

Commit

Permalink
bippy added inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Jan 9, 2025
1 parent 38efef2 commit dd24872
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/client/context/RDTContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export type RdtClientConfig = Pick<
| "requireUrlFlag"
| "openHotkey"
| "urlFlag"
| "enableInspector"
| "routeBoundaryGradient"
>

Expand Down
5 changes: 5 additions & 0 deletions src/client/context/rdtReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export type ReactRouterDevtoolsState = {
timeline: TimelineEvent[]
terminals: Terminal[]
settings: {
/**
* Enables the bippy inspector to inspect react components
*/
enableInspector: boolean
/**
* The breakpoints to show in the corner so you can see the current breakpoint that you defined
*/
Expand Down Expand Up @@ -165,6 +169,7 @@ export const initialState: ReactRouterDevtoolsState = {
terminals: [{ id: 0, locked: false, output: [], history: [] }],
server: undefined,
settings: {
enableInspector: false,
showRouteBoundariesOn: "click",
breakpoints: [
{ name: "", min: 0, max: 639 },
Expand Down
3 changes: 2 additions & 1 deletion src/client/react-router-dev-tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
setStorageItem,
} from "./utils/storage.js"
import "../input.css"
import { Inspector } from "bippy/inspect"
import { useHotkeys } from "react-hotkeys-hook"
import type { RdtPlugin } from "../index.js"
import { Breakpoints } from "./components/Breakpoints.js"
Expand All @@ -28,7 +29,6 @@ import { useListenToRouteChange } from "./hooks/detached/useListenToRouteChange.
import { useDebounce } from "./hooks/useDebounce.js"
import { useDevServerConnection } from "./hooks/useDevServerConnection.js"
import { useOpenElementSource } from "./hooks/useOpenElementSource.js"

const recursivelyChangeTabIndex = (node: Element | HTMLElement, remove = true) => {
if (remove) {
node.setAttribute("tabIndex", "-1")
Expand Down Expand Up @@ -102,6 +102,7 @@ const DevTools = ({ plugins: pluginArray }: ReactRouterDevtoolsProps) => {
<Trigger isOpen={isOpen} setIsOpen={setIsOpen} />
<LiveUrls />
<Breakpoints />
<Inspector enabled={settings.enableInspector} />
<MainPanel isOpen={isOpen}>
<div className="flex h-full">
<Tabs plugins={plugins} setIsOpen={setIsOpen} />
Expand Down
8 changes: 8 additions & 0 deletions src/client/tabs/SettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export const SettingsTab = () => {
>
Show breakpoint indicator
</Checkbox>
<Checkbox
id="enableInspector"
hint="This allows you to render an inspector provided by bippy to inspect react components"
onChange={() => setSettings({ enableInspector: !settings.enableInspector })}
value={settings.enableInspector}
>
Enable react component inspector
</Checkbox>

<hr className="mt-2 border-gray-700" />
<Stack gap="lg">
Expand Down
1 change: 1 addition & 0 deletions test-apps/react-router-vite/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { reactRouterDevTools, defineRdtConfig } from "react-router-devtools"
import inspect from "vite-plugin-inspect"
const config = defineRdtConfig({
client: {
enableInspector: true,
defaultOpen: false,
position: "top-right",
requireUrlFlag: false,
Expand Down

0 comments on commit dd24872

Please sign in to comment.