Skip to content

Commit 12732fe

Browse files
authored
refactor(router-devtools-core): allow styling of TanStackRouterDevtoolsPanel (#4671)
1 parent cd1de7e commit 12732fe

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

examples/react/basic-devtools-panel/src/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
createRootRoute,
1313
} from '@tanstack/react-router'
1414
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
15+
import './styles.css'
1516

1617
const rootRoute = createRootRoute({
1718
component: () => (

packages/router-devtools-core/src/TanStackRouterDevtoolsPanelCore.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,28 @@ interface TanStackRouterDevtoolsPanelCoreOptions {
4040
class TanStackRouterDevtoolsPanelCore {
4141
#router: any
4242
#routerState: any
43+
#style: any
44+
#className: any
4345
#shadowDOMTarget?: ShadowRoot
4446
#isMounted = false
4547
#setIsOpen?: (isOpen: boolean) => void
4648
#dispose?: () => void
4749
#Component: any
4850

4951
constructor(config: TanStackRouterDevtoolsPanelCoreOptions) {
50-
const { router, routerState, shadowDOMTarget, setIsOpen } = config
52+
const {
53+
router,
54+
routerState,
55+
shadowDOMTarget,
56+
setIsOpen,
57+
style,
58+
className,
59+
} = config
5160

5261
this.#router = createSignal(router)
5362
this.#routerState = createSignal(routerState)
63+
this.#style = createSignal(style)
64+
this.#className = createSignal(className)
5465
this.#shadowDOMTarget = shadowDOMTarget
5566
this.#setIsOpen = setIsOpen
5667
}
@@ -63,6 +74,8 @@ class TanStackRouterDevtoolsPanelCore {
6374
const dispose = render(() => {
6475
const [router] = this.#router
6576
const [routerState] = this.#routerState
77+
const [style] = this.#style
78+
const [className] = this.#className
6679
const shadowDOMTarget = this.#shadowDOMTarget
6780
const setIsOpen = this.#setIsOpen
6881

@@ -89,6 +102,8 @@ class TanStackRouterDevtoolsPanelCore {
89102
routerState={routerState}
90103
shadowDOMTarget={shadowDOMTarget}
91104
setIsOpen={setIsOpen}
105+
style={style}
106+
className={className}
92107
/>
93108
</DevtoolsOnCloseContext.Provider>
94109
</ShadowDomTargetContext.Provider>
@@ -115,6 +130,14 @@ class TanStackRouterDevtoolsPanelCore {
115130
this.#routerState[1](routerState)
116131
}
117132

133+
setStyle(style: any) {
134+
this.#style[1](style)
135+
}
136+
137+
setClassName(className: any) {
138+
this.#className[1](className)
139+
}
140+
118141
setOptions(options: Partial<TanStackRouterDevtoolsPanelCoreOptions>) {
119142
if (options.shadowDOMTarget !== undefined) {
120143
this.#shadowDOMTarget = options.shadowDOMTarget
@@ -125,6 +148,14 @@ class TanStackRouterDevtoolsPanelCore {
125148
if (options.routerState !== undefined) {
126149
this.setRouterState(options.routerState)
127150
}
151+
152+
if (options.style !== undefined) {
153+
this.setStyle(options.style)
154+
}
155+
156+
if (options.className !== undefined) {
157+
this.setClassName(options.className)
158+
}
128159
}
129160
}
130161

0 commit comments

Comments
 (0)