Skip to content

Commit 591b52f

Browse files
feat(core,ui): trigger image support (#134)
Howdy! I apologize for not reviewing the contributing guidelines more carefully and built this feature without first soliciting feedback from the team on the desire to implement this. I hope this request is received well. This PR adds support for specifying a trigger image via the config object or via the UI. We are interested in using the devtools package for more than just the tanstack ecosystem, and would like to consider replacing it with our engineering/dev logo (even though we're using tanstack for all the things!) If no logo is provided, it will default to the tanstack logo in the package. <img width="112" height="105" alt="image" src="https://github.com/user-attachments/assets/10a0728e-61cc-4eea-b076-e065a17651fb" /> **Via UI** <img width="430" alt="image" src="https://github.com/user-attachments/assets/42b7f024-114c-4cfb-879a-7a0a30b5892b" /> **Via Configuragion** ```tsx <TanStackDevtools config={{ triggerImage: "https://avatars.githubusercontent.com/u/1041792?v=4", }} /> ``` --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 2b77ace commit 591b52f

6 files changed

Lines changed: 33 additions & 4 deletions

File tree

docs/configuration.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ type KeyboardKey = ModifierKey | (string & {});
5757

5858
```
5959

60+
- `triggerImage` - The image used for the dev tools trigger
61+
62+
```ts
63+
{ triggerImage: string }
64+
65+
```
66+
6067
- `urlFlag` - The required flag that must be present in the url to enable devtools.
6168

6269
```ts

packages/devtools-ui/src/styles/use-styles.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ const stylesFactory = (theme: Theme = 'dark') => {
5959

6060
const t = (light: string, dark: string) => (theme === 'light' ? light : dark)
6161

62+
const wrapperSize = 320
63+
6264
return {
6365
logo: css`
6466
cursor: pointer;
@@ -78,7 +80,7 @@ const stylesFactory = (theme: Theme = 'dark') => {
7880

7981
selectWrapper: css`
8082
width: 100%;
81-
max-width: 300px;
83+
max-width: ${wrapperSize}px;
8284
display: flex;
8385
flex-direction: column;
8486
gap: 0.375rem;
@@ -129,7 +131,7 @@ const stylesFactory = (theme: Theme = 'dark') => {
129131
`,
130132
inputWrapper: css`
131133
width: 100%;
132-
max-width: 300px;
134+
max-width: ${wrapperSize}px;
133135
display: flex;
134136
flex-direction: column;
135137
gap: 0.375rem;
@@ -152,6 +154,7 @@ const stylesFactory = (theme: Theme = 'dark') => {
152154
`,
153155
input: css`
154156
appearance: none;
157+
box-sizing: border-box;
155158
width: 100%;
156159
padding: 0.75rem;
157160
border-radius: 0.5rem;

packages/devtools/src/components/trigger.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import type { Accessor } from 'solid-js'
88
export const Trigger = ({
99
isOpen,
1010
setIsOpen,
11+
image = TanStackLogo,
1112
}: {
1213
isOpen: Accessor<boolean>
1314
setIsOpen: (isOpen: boolean) => void
15+
image: string
1416
}) => {
1517
const { settings } = useDevtoolsSettings()
1618
const styles = useStyles()
@@ -28,7 +30,7 @@ export const Trigger = ({
2830
class={buttonStyle()}
2931
onClick={() => setIsOpen(!isOpen())}
3032
>
31-
<img src={TanStackLogo} alt="TanStack Logo" />
33+
<img src={image || TanStackLogo} alt="TanStack Devtools" />
3234
</button>
3335
)
3436
}

packages/devtools/src/context/devtools-store.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ export type DevtoolsStore = {
6161
* @default "dark"
6262
*/
6363
theme: 'light' | 'dark'
64+
/**
65+
* The image used for the dev tools trigger
66+
* @default TanStackLogo
67+
*/
68+
triggerImage: string
6469
}
6570
state: {
6671
activeTab: TabName
@@ -86,6 +91,7 @@ export const initialState: DevtoolsStore = {
8691
window.matchMedia('(prefers-color-scheme: dark)').matches
8792
? 'dark'
8893
: 'light',
94+
triggerImage: '',
8995
},
9096
state: {
9197
activeTab: 'plugins',

packages/devtools/src/devtools.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ export default function DevTools() {
201201
: true
202202
}
203203
>
204-
<Trigger isOpen={isOpen} setIsOpen={toggleOpen} />
204+
<Trigger
205+
isOpen={isOpen}
206+
setIsOpen={toggleOpen}
207+
image={settings().triggerImage}
208+
/>
205209
<MainPanel isResizing={isResizing} isOpen={isOpen}>
206210
<ContentPanel
207211
ref={(ref) => (panelRef = ref)}

packages/devtools/src/tabs/settings-tab.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ export const SettingsTab = () => {
7171
}
7272
checked={settings().hideUntilHover}
7373
/>
74+
<Input
75+
label="Trigger Image"
76+
description="Specify the URL of the image to use for the trigger"
77+
value={settings().triggerImage}
78+
placeholder="Default TanStack Logo"
79+
onChange={(value) => setSettings({ triggerImage: value })}
80+
/>
7481
<Select
7582
label="Theme"
7683
description="Choose the theme for the devtools panel"

0 commit comments

Comments
 (0)