Skip to content

Commit cc1be2b

Browse files
committed
feat: indicate current packet type in ProtocolOverview
1 parent 904b5a6 commit cc1be2b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/components/ProtocolOverview.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useState } from 'react'
21
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
32
import {
43
Card,
@@ -7,9 +6,10 @@ import {
76
CardHeader,
87
CardTitle,
98
} from '@/components/ui/card'
10-
import { TCP_IP_LAYERS, PACKET_TYPES } from '@/data'
9+
import { TCP_IP_LAYERS, PACKET_TYPES, type PacketTypes } from '@/data'
10+
import type { ValueOf } from '@/utils/types'
1111

12-
type Tab = 'overview' | 'layers' | 'packets'
12+
export type Tab = 'overview' | 'layers' | 'packets'
1313

1414
type TabOption = {
1515
value: Tab
@@ -24,13 +24,17 @@ const TABS: TabOption[] = [
2424

2525
const [overviewTab, layersTab, packetsTab] = TABS
2626

27-
function ProtocolOverview() {
28-
const [activeTab, setActiveTab] = useState<Tab>('overview')
27+
interface Props {
28+
activeTab: Tab
29+
setActiveTab: (tab: Tab) => void
30+
activePacketType: ValueOf<PacketTypes>['name'] | null
31+
}
2932

33+
function ProtocolOverview(props: Props) {
3034
return (
3135
<Tabs
32-
value={activeTab}
33-
onValueChange={(value) => setActiveTab(value as Tab)}
36+
value={props.activeTab}
37+
onValueChange={(value) => props.setActiveTab(value as Tab)}
3438
className="w-full"
3539
>
3640
<TabsList className="grid w-full grid-cols-3">
@@ -139,7 +143,7 @@ function ProtocolOverview() {
139143
{Object.values(PACKET_TYPES).map((packet) => (
140144
<div key={packet.name} className="flex items-center space-x-3">
141145
<div
142-
className="w-6 h-6 rounded"
146+
className={`w-6 h-6 rounded ${props.activePacketType === packet.name ? 'animate-pulse animate-bounce' : ''}`}
143147
style={{ backgroundColor: packet.color }}
144148
/>
145149
<div>

0 commit comments

Comments
 (0)