forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSidebarNav.tsx
More file actions
161 lines (145 loc) · 4.56 KB
/
Copy pathSidebarNav.tsx
File metadata and controls
161 lines (145 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import React from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { Folder, History, Box, Settings, LayoutGrid, Database, Activity, ShieldCheck } from 'lucide-react';
import { appStore, useAppStore } from '@/lib/store';
import logoDark from '../../assets/txio2.png';
import logoLight from '../../assets/txio3.png';
interface SidebarNavProps {
activeMode: string;
onModeChange: (mode: string) => void;
activeTabType?: string;
}
const TxioLogo = () => {
const { theme } = useAppStore();
const logo = theme === 'dark' ? logoDark : logoLight;
return (
<img
src={logo.src}
alt="txio"
className="w-6 h-6 object-contain drop-shadow-[0_0_6px_rgba(123,63,242,0.35)]"
/>
);
};
interface NavItemProps {
mode: string;
icon: React.ElementType;
label: string;
activeMode: string;
onModeChange: (mode: string) => void;
}
const NavItem: React.FC<NavItemProps> = ({
mode,
icon: Icon,
label,
activeMode,
onModeChange
}) => {
const isActive = activeMode === mode;
return (
<button
onClick={() => onModeChange(mode)}
className="relative group w-full flex items-center justify-center py-3"
title={label}
>
<AnimatePresence>
{isActive && (
<motion.div
layoutId="nav-pill"
className="absolute left-0 w-[2px] h-6 bg-electric-violet rounded-r-full shadow-[0_0_10px_rgba(123,63,242,0.6)]"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ type: 'spring', damping: 20, stiffness: 300 }}
/>
)}
</AnimatePresence>
<div className={`
relative p-2 rounded-xl transition-colors duration-200
${isActive
? 'text-electric-violet bg-electric-violet/[0.08]'
: 'text-slate-500 hover:text-slate-200 hover:bg-white/[0.04]'}
`}>
<Icon size={18} strokeWidth={isActive ? 2 : 1.75} className="relative z-10" />
</div>
</button>
);
};
export const SidebarNav: React.FC<SidebarNavProps> = ({
activeMode,
onModeChange,
activeTabType
}) => {
const containerVariants = {
hidden: { opacity: 0, x: -20 },
visible: {
opacity: 1,
x: 0,
transition: { staggerChildren: 0.05, delayChildren: 0.1 }
}
};
const itemVariants = {
hidden: { opacity: 0, scale: 0.8 },
visible: { opacity: 1, scale: 1 }
};
return (
<motion.div
initial="hidden"
animate="visible"
variants={containerVariants}
className="w-14 bg-near-black border-r border-white/[0.06] flex flex-col items-center py-4 gap-1 z-20 shrink-0 relative"
>
<motion.div
variants={itemVariants}
className="mb-4 group cursor-pointer relative"
onClick={() => appStore.setActiveTab(null)}
>
<div className="relative z-10 p-1.5 rounded-xl bg-white/[0.02] border border-white/[0.06] group-hover:border-electric-violet/30 transition-colors duration-300">
<TxioLogo />
</div>
</motion.div>
<div className="w-6 h-px bg-white/[0.06] mb-2"></div>
<motion.div variants={itemVariants} className="w-full">
<NavItem
mode="collections"
icon={LayoutGrid}
label="Collections"
activeMode={activeMode}
onModeChange={onModeChange}
/>
</motion.div>
<motion.div variants={itemVariants} className="w-full">
<NavItem
mode="history"
icon={Activity}
label="History"
activeMode={activeMode}
onModeChange={onModeChange}
/>
</motion.div>
<motion.div variants={itemVariants} className="w-full">
<NavItem
mode="env"
icon={Database}
label="Environments"
activeMode={activeMode}
onModeChange={onModeChange}
/>
</motion.div>
<div className="flex-1" />
<motion.div variants={itemVariants} className="w-full flex justify-center pb-1">
<button
onClick={() => appStore.openTab('settings')}
className={`
relative p-2 transition-colors duration-200 rounded-xl group
${activeTabType === 'settings'
? 'text-electric-violet bg-electric-violet/[0.08]'
: 'text-slate-500 hover:text-slate-200 hover:bg-white/[0.04]'}
`}
title="Settings"
>
<Settings size={18} strokeWidth={1.75} className="group-hover:rotate-45 transition-transform duration-500" />
</button>
</motion.div>
</motion.div>
);
};