Skip to content

Commit 0a9e1e2

Browse files
hemanandrclaude
andcommitted
feat: create unified floating actions with route-based help
- Create FloatingActions component combining theme toggle and help button - Add route-based help URL mapping for contextual documentation - Remove individual help buttons from page headers to eliminate visual conflict - Position both actions together in top-right corner with minimal spacing - Improve UX with consistent floating action area 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 48a45ab commit 0a9e1e2

File tree

5 files changed

+72
-39
lines changed

5 files changed

+72
-39
lines changed

thingconnect.pulse.client/src/components/layout/AppShell.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { Outlet } from 'react-router-dom';
2-
import { Box, Flex, useBreakpointValue, IconButton } from '@chakra-ui/react';
2+
import { Box, Flex, useBreakpointValue } from '@chakra-ui/react';
33
import { useState } from 'react';
44
import { Navigation } from './Navigation';
55
import { Footer } from './Footer';
6-
import { Moon, Sun } from 'lucide-react';
7-
import { useColorMode } from '../ui/color-mode';
6+
import { FloatingActions } from './FloatingActions';
87

98
export function AppShell() {
109
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
1110
const sidebarWidth = useBreakpointValue({ base: '100%', md: '250px' });
1211
const isMobile = useBreakpointValue({ base: true, md: false });
13-
const { colorMode, toggleColorMode } = useColorMode();
1412

1513
const toggleSidebar = () => {
1614
setIsSidebarOpen(!isSidebarOpen);
@@ -65,20 +63,8 @@ export function AppShell() {
6563
{/* Footer */}
6664
<Footer />
6765

68-
{/* Floating Toggle Button */}
69-
<IconButton
70-
data-testid='theme-toggle'
71-
aria-label='Toggle color mode'
72-
variant='ghost'
73-
size='sm'
74-
position='fixed'
75-
top='16px'
76-
right='16px'
77-
zIndex={1100}
78-
onClick={toggleColorMode}
79-
>
80-
{colorMode === 'light' ? <Moon size={18} /> : <Sun size={18} />}
81-
</IconButton>
66+
{/* Floating Actions (Theme Toggle + Help Button) */}
67+
<FloatingActions />
8268
</Flex>
8369
);
8470
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { HStack, IconButton } from '@chakra-ui/react';
2+
import { Moon, Sun, HelpCircle } from 'lucide-react';
3+
import { useLocation } from 'react-router-dom';
4+
import { useColorMode } from '../ui/color-mode';
5+
import { Tooltip } from '../ui/tooltip';
6+
7+
// Route-to-help URL mapping
8+
const ROUTE_HELP_URLS: Record<string, string> = {
9+
'/': 'https://docs.thingconnect.io/pulse/user-guide/dashboard',
10+
'/configuration': 'https://docs.thingconnect.io/pulse/user-guide/configuration',
11+
'/history': 'https://docs.thingconnect.io/pulse/user-guide/viewing-history',
12+
'/settings': 'https://docs.thingconnect.io/pulse/user-guide/settings',
13+
'/about': 'https://docs.thingconnect.io/pulse/about',
14+
};
15+
16+
export function FloatingActions() {
17+
const { colorMode, toggleColorMode } = useColorMode();
18+
const location = useLocation();
19+
20+
const helpUrl = ROUTE_HELP_URLS[location.pathname];
21+
22+
const handleHelpClick = () => {
23+
if (helpUrl) {
24+
window.open(helpUrl, '_blank', 'noopener,noreferrer');
25+
}
26+
};
27+
28+
return (
29+
<HStack
30+
position="fixed"
31+
top="16px"
32+
right="16px"
33+
zIndex={1100}
34+
gap={1}
35+
data-testid="floating-actions"
36+
>
37+
{/* Help Button - only show if help URL exists for current route */}
38+
{helpUrl && (
39+
<Tooltip content="View Help">
40+
<IconButton
41+
data-testid="help-button"
42+
aria-label="View Help"
43+
variant="ghost"
44+
size="sm"
45+
onClick={handleHelpClick}
46+
_hover={{ bg: 'blue.50', _dark: { bg: 'blue.900' } }}
47+
>
48+
<HelpCircle size={18} />
49+
</IconButton>
50+
</Tooltip>
51+
)}
52+
53+
{/* Theme Toggle */}
54+
<Tooltip content="Toggle color mode">
55+
<IconButton
56+
data-testid="theme-toggle"
57+
aria-label="Toggle color mode"
58+
variant="ghost"
59+
size="sm"
60+
onClick={toggleColorMode}
61+
_hover={{ bg: 'gray.50', _dark: { bg: 'gray.800' } }}
62+
>
63+
{colorMode === 'light' ? <Moon size={18} /> : <Sun size={18} />}
64+
</IconButton>
65+
</Tooltip>
66+
</HStack>
67+
);
68+
}

thingconnect.pulse.client/src/pages/Configuration.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { TabsRoot, TabsList, TabsTrigger, TabsContent } from '@/components/ui/ta
44
import { ConfigurationEditor } from '@/components/config/ConfigurationEditor';
55
import { ConfigurationVersions } from '@/components/config/ConfigurationVersions';
66
import { Page } from '@/components/layout/Page';
7-
import { HelpButton } from '@/components/common/HelpButton';
87

98
export default function Configuration() {
109
const [refreshTrigger, setRefreshTrigger] = useState(0);
@@ -17,12 +16,6 @@ export default function Configuration() {
1716
title='Configuration Management'
1817
description='Manage monitoring endpoints and YAML configuration'
1918
testId='configuration-page'
20-
actions={
21-
<HelpButton
22-
helpUrl="https://docs.thingconnect.io/pulse/user-guide/configuration"
23-
tooltip="Configuration Help"
24-
/>
25-
}
2619
>
2720
<TabsRoot
2821
defaultValue='editor'

thingconnect.pulse.client/src/pages/Dashboard.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { StatusCard } from '@/components/status/StatusCard';
77
import { StatusPagination } from '@/components/status/StatusPagination';
88
import { Page } from '@/components/layout/Page';
99
import { PageSection } from '@/components/layout/PageSection';
10-
import { HelpButton } from '@/components/common/HelpButton';
1110
import type { LiveStatusParams } from '@/api/types';
1211

1312
export default function Dashboard() {
@@ -59,12 +58,6 @@ export default function Dashboard() {
5958
title='Dashboard'
6059
testId='dashboard-page'
6160
description='Real-time monitoring of network endpoints'
62-
actions={
63-
<HelpButton
64-
helpUrl="https://docs.thingconnect.io/pulse/user-guide/dashboard"
65-
tooltip="Dashboard Help"
66-
/>
67-
}
6861
>
6962
{/* <PageHeader
7063
title="Network Status Dashboard"

thingconnect.pulse.client/src/pages/History.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { AvailabilityChart, AvailabilityStats } from '@/components/AvailabilityC
1414
import { HistoryTable } from '@/components/HistoryTable';
1515
import { HistoryService } from '@/api/services/history.service';
1616
import { StatusService } from '@/api/services/status.service';
17-
import { HelpButton } from '@/components/common/HelpButton';
1817

1918
export default function History() {
2019
// State for filters
@@ -96,12 +95,6 @@ export default function History() {
9695
title='History'
9796
description='View historical monitoring data and export reports'
9897
testId='history-page'
99-
actions={
100-
<HelpButton
101-
helpUrl="https://docs.thingconnect.io/pulse/user-guide/viewing-history"
102-
tooltip="History Help"
103-
/>
104-
}
10598
>
10699
{/* <PageHeader
107100
title="Historical Data"

0 commit comments

Comments
 (0)