Skip to content

Commit 9582329

Browse files
committed
code refactored
1 parent d14f725 commit 9582329

File tree

1 file changed

+42
-43
lines changed

1 file changed

+42
-43
lines changed

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

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Box, VStack, Text, Icon, Image, HStack, Badge, Button } from '@chakra-ui/react';
22
import { Link as RouterLink, useLocation } from 'react-router-dom';
33
import { Wifi, Activity, LogOut, Users } from 'lucide-react';
4-
import thingConnectIcon from
5-
'@/assets/ThingConnectPulseLogo.svg';
4+
import thingConnectIcon from '@/assets/thingconnect-pulse-logo.svg';
65
import { Clock, Wrench, Settings, Info, Dashboard, Help } from '@/icons';
76
import { useAuth } from '@/features/auth/context/AuthContext';
87
interface NavigationProps {
@@ -58,49 +57,49 @@ export function Navigation({ onItemClick }: NavigationProps) {
5857
{navigationItems
5958
.filter(item => !item.adminOnly || isAdmin)
6059
.map(item => {
61-
const isActive = !item.external && isActiveRoute(item.path);
62-
const ItemContent = (
63-
<HStack
64-
px={3}
65-
py={2.5}
66-
borderRadius='lg'
67-
color={isActive ? 'blue.600' : 'gray.600'}
68-
bg={isActive ? 'whiteAlpha.950' : 'transparent'}
69-
border={isActive ? '1px solid' : undefined}
70-
borderColor={isActive ? 'border' : undefined}
71-
_hover={
72-
isActive
73-
? undefined
74-
: {
75-
bg: 'blackAlpha.50',
76-
_dark: { bg: 'gray.700' },
77-
}
78-
}
79-
_dark={{
80-
color: isActive ? 'blue.200' : 'gray.200',
81-
bg: isActive ? 'blackAlpha.200' : undefined,
82-
border: isActive ? '1px solid rgba(255,255,255,0.1)' : undefined,
83-
}}
84-
>
85-
<Icon as={item.icon} boxSize={4} />
86-
<Text fontSize='sm' fontWeight='medium' letterSpacing='0.025em' lineHeight='1.2'>
87-
{item.label}
88-
</Text>
89-
</HStack>
90-
);
60+
const isActive = !item.external && isActiveRoute(item.path);
61+
const ItemContent = (
62+
<HStack
63+
px={3}
64+
py={2.5}
65+
borderRadius='lg'
66+
color={isActive ? 'blue.600' : 'gray.600'}
67+
bg={isActive ? 'whiteAlpha.950' : 'transparent'}
68+
border={isActive ? '1px solid' : undefined}
69+
borderColor={isActive ? 'border' : undefined}
70+
_hover={
71+
isActive
72+
? undefined
73+
: {
74+
bg: 'blackAlpha.50',
75+
_dark: { bg: 'gray.700' },
76+
}
77+
}
78+
_dark={{
79+
color: isActive ? 'blue.200' : 'gray.200',
80+
bg: isActive ? 'blackAlpha.200' : undefined,
81+
border: isActive ? '1px solid rgba(255,255,255,0.1)' : undefined,
82+
}}
83+
>
84+
<Icon as={item.icon} boxSize={4} />
85+
<Text fontSize='sm' fontWeight='medium' letterSpacing='0.025em' lineHeight='1.2'>
86+
{item.label}
87+
</Text>
88+
</HStack>
89+
);
9190

92-
return item.external ? (
93-
<Box as='a' key={item.path} asChild onClick={onItemClick}>
94-
<a href={item.path} target='_blank' rel='noopener noreferrer'>
91+
return item.external ? (
92+
<Box as='a' key={item.path} asChild onClick={onItemClick}>
93+
<a href={item.path} target='_blank' rel='noopener noreferrer'>
94+
{ItemContent}
95+
</a>
96+
</Box>
97+
) : (
98+
<RouterLink key={item.path} to={item.path} onClick={onItemClick}>
9599
{ItemContent}
96-
</a>
97-
</Box>
98-
) : (
99-
<RouterLink key={item.path} to={item.path} onClick={onItemClick}>
100-
{ItemContent}
101-
</RouterLink>
102-
);
103-
})}
100+
</RouterLink>
101+
);
102+
})}
104103
</VStack>
105104
<Box p={4} borderTop='1px' borderColor='gray.200' _dark={{ borderColor: 'gray.700' }}>
106105
<VStack align='stretch' gap={4}>

0 commit comments

Comments
 (0)