Skip to content

Commit a372a73

Browse files
committed
update ui
1 parent c38c011 commit a372a73

File tree

12 files changed

+634
-272
lines changed

12 files changed

+634
-272
lines changed

packages/react-router-devtools/src/client/components/RouteToggle.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const RouteToggle = () => {
1212
className={cx(styles.routeToggle.icon, routeViewMode === "tree" && styles.routeToggle.iconActive)}
1313
onClick={() => setSettings({ routeViewMode: "tree" })}
1414
name="Network"
15+
title="Grid"
1516
/>
1617
/
1718
<Icon
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { useStyles } from "../styles/use-styles.js"
2+
3+
interface TabContentProps {
4+
children: React.ReactNode
5+
}
6+
7+
export const TabContent = ({ children }: TabContentProps) => {
8+
const { styles } = useStyles()
9+
return <div className={styles.tabContent.container}>{children}</div>
10+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { ReactNode } from "react"
2+
import { cx, useStyles } from "../styles/use-styles.js"
3+
4+
interface TabHeaderProps {
5+
icon: ReactNode
6+
title: string
7+
rightContent?: ReactNode
8+
gradientDirection?: "ltr" | "rtl"
9+
}
10+
11+
export const TabHeader = ({ icon, title, rightContent, gradientDirection = "ltr" }: TabHeaderProps) => {
12+
const { styles } = useStyles()
13+
return (
14+
<div className={cx(styles.tabHeader.container, gradientDirection === "rtl" && styles.tabHeader.containerRtl)}>
15+
<div className={styles.tabHeader.leftContent}>
16+
{icon}
17+
<h2 className={styles.tabHeader.title}>{title}</h2>
18+
</div>
19+
{rightContent && <div className={styles.tabHeader.rightContent}>{rightContent}</div>}
20+
</div>
21+
)
22+
}

packages/react-router-devtools/src/client/components/icon/Icon.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type IconSizes = keyof typeof IconSize
1717

1818
interface IconProps extends SVGProps<SVGSVGElement> {
1919
name: IconName
20+
title?: string
2021
testId?: string
2122
className?: string
2223
size?: IconSizes
@@ -29,7 +30,7 @@ const strokeIcon: Partial<IconName>[] = []
2930
* Icon component wrapper for SVG icons.
3031
* @returns SVG icon as a react component
3132
*/
32-
export const Icon = ({ name, testId, className, size = "sm", ...props }: IconProps) => {
33+
export const Icon = ({ name, title, testId, className, size = "sm", ...props }: IconProps) => {
3334
const { styles } = useStyles()
3435
const iconSize = IconSize[size]
3536
const isEmptyFill = emptyFill.includes(name)
@@ -46,7 +47,7 @@ export const Icon = ({ name, testId, className, size = "sm", ...props }: IconPro
4647
data-name={name}
4748
{...props}
4849
>
49-
<title>{name}</title>
50+
<title>{title ?? name}</title>
5051
<defs>
5152
<symbol
5253
id="Layout"

packages/react-router-devtools/src/client/hooks/useTabs.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { useMemo } from "react"
2-
import type { ReactRouterDevtoolsState } from "../context/rdtReducer.js"
32
import { useSettingsContext } from "../context/useRDTContext.js"
43
import type { ReactRouterDevtoolsProps } from "../react-router-dev-tools.js"
54
import { type Tab, tabs } from "../tabs/index.js"
6-
import type { Tabs } from "../tabs/index.js"
75

8-
const shouldHideTimeline = (activeTab: Tabs, tab: Tab | undefined, settings: ReactRouterDevtoolsState["settings"]) => {
9-
if (activeTab === "routes" && settings.routeViewMode === "tree") return true
6+
const shouldHideTimeline = (tab: Tab | undefined) => {
107
return tab?.hideTimeline
118
}
129

@@ -18,8 +15,8 @@ export const useTabs = (pluginsArray?: ReactRouterDevtoolsProps["plugins"]) => {
1815

1916
const { Component, hideTimeline } = useMemo(() => {
2017
const tab = allTabs.find((tab) => tab.id === activeTab)
21-
return { Component: tab?.component, hideTimeline: shouldHideTimeline(activeTab, tab, settings) }
22-
}, [activeTab, allTabs, settings])
18+
return { Component: tab?.component, hideTimeline: shouldHideTimeline(tab) }
19+
}, [activeTab, allTabs])
2320

2421
return {
2522
visibleTabs: allTabs,

packages/react-router-devtools/src/client/layout/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const Tab = ({
3535
<div
3636
data-testid={tab.id}
3737
onClick={() => (onClick ? onClick() : setSettings({ activeTab: tab.id as TabsType }))}
38+
title={typeof tab.name === "string" ? tab.name : undefined}
3839
className={cx(
3940
"group",
4041
styles.layout.tabs.tab,
@@ -43,7 +44,6 @@ const Tab = ({
4344
)}
4445
>
4546
<div className={cx(className, styles.layout.tabs.tabIcon)}>{tab.icon}</div>
46-
<div className={styles.layout.tabs.tabTooltip}>{tab.name}</div>
4747
</div>
4848
)
4949
}

0 commit comments

Comments
 (0)