File size: 8,674 Bytes
227c43a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import React, { useState, useEffect } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { motion, AnimatePresence } from 'framer-motion';
import { Sun, Moon, Menu, X } from 'lucide-react';

function Navbar() {
  const [isOpen, setIsOpen] = useState(false);
  const [theme, setTheme] = useState(() => {
    // Check for saved theme in localStorage or default to quantumlight
    return localStorage.getItem('theme') || 'quantumlight';
  });
  const location = useLocation();

  useEffect(() => {
    const html = document.documentElement;
    const head = document.querySelector('head');
    
    // Set data-theme on both html and head for compatibility
    html.setAttribute('data-theme', theme);
    head.setAttribute('data-theme', theme);
    
    // Handle Tailwind dark mode
    if (theme === 'quantumdark') {
      html.classList.add('dark');
    } else {
      html.classList.remove('dark');
    }
    
    // Save theme to localStorage
    localStorage.setItem('theme', theme);
  }, [theme]);

  const toggleNavbar = () => setIsOpen(!isOpen);

  return (
    <motion.nav

      initial={{ y: -100 }}

      animate={{ y: 0 }}

      transition={{ type: "spring", stiffness: 100, damping: 20 }}

      className="fixed top-0 w-full z-50 bg-base-100/80 backdrop-blur-md border-b border-base-200/50"

    >

      <div className="container mx-auto px-4">

        <div className="flex items-center justify-between h-16">

          <motion.div

            whileHover={{ scale: 1.05 }}

            whileTap={{ scale: 0.95 }}

          >

            <Link className="flex items-center gap-2 text-xl font-bold" to="/">

              <motion.i

                animate={{ rotate: 360 }}

                transition={{ duration: 8, repeat: Infinity, ease: "linear" }}

                className="fas fa-atom text-primary"

              />

              <span className="bg-gradient-to-r from-primary to-secondary bg-clip-text text-transparent">

                GXS QuantumNexus

              </span>

            </Link>

          </motion.div>



          {/* Desktop Menu */}

          <div className="hidden lg:flex items-center space-x-1">

            {[

              { path: '/', label: 'Home', icon: 'fas fa-home' },

              //{ path: '/circuit-designer', label: 'Circuit Designer', icon: 'fas fa-project-diagram' },

              { path: '/glossary', label: 'Glossary', icon: 'fas fa-book' },

            ].map((item) => (

              <motion.div key={item.path} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }}>

                <Link

                  to={item.path}

                  className={`px-4 py-2 rounded-lg transition-all flex items-center gap-2 ${

                    location.pathname === item.path

                      ? 'bg-primary text-primary-content'

                      : 'hover:bg-base-200'

                  }`}

                >

                  <i className={`${item.icon} text-sm`}></i>

                  {item.label}

                </Link>

              </motion.div>

            ))}

            

            <motion.a

              whileHover={{ scale: 1.05 }}

              whileTap={{ scale: 0.95 }}

              href="https://www.facebook.com/ChuyenDoiXanh"

              target="_blank"

              rel="noopener noreferrer"

              className="px-4 py-2 rounded-lg hover:bg-base-200 transition-all flex items-center gap-2"

            >

              <i className="fab fa-Facebook text-sm"></i>

              Facebook

            </motion.a>

          </div>



          <div className="flex items-center gap-2">

            {/* Theme Toggle */}

            <motion.button

              whileHover={{ scale: 1.1 }}

              whileTap={{ scale: 0.9 }}

              onClick={() => setTheme(theme === 'quantumlight' ? 'quantumdark' : 'quantumlight')}

              className="p-2 rounded-lg hover:bg-base-200 transition-all"

            >

              <AnimatePresence mode="wait">

                {theme === 'quantumlight' ? (

                  <motion.div

                    key="sun"

                    initial={{ rotate: -90, opacity: 0 }}

                    animate={{ rotate: 0, opacity: 1 }}

                    exit={{ rotate: 90, opacity: 0 }}

                    transition={{ duration: 0.2 }}

                  >

                    <Sun size={20} />

                  </motion.div>

                ) : (

                  <motion.div

                    key="moon"

                    initial={{ rotate: -90, opacity: 0 }}

                    animate={{ rotate: 0, opacity: 1 }}

                    exit={{ rotate: 90, opacity: 0 }}

                    transition={{ duration: 0.2 }}

                  >

                    <Moon size={20} />

                  </motion.div>

                )}

              </AnimatePresence>

            </motion.button>



            {/* Mobile Menu Toggle */}

            <motion.button

              whileHover={{ scale: 1.1 }}

              whileTap={{ scale: 0.9 }}

              onClick={toggleNavbar}

              className="lg:hidden p-2 rounded-lg hover:bg-base-200 transition-all"

            >

              <AnimatePresence mode="wait">

                {isOpen ? (

                  <motion.div

                    key="close"

                    initial={{ rotate: -90, opacity: 0 }}

                    animate={{ rotate: 0, opacity: 1 }}

                    exit={{ rotate: 90, opacity: 0 }}

                    transition={{ duration: 0.2 }}

                  >

                    <X size={20} />

                  </motion.div>

                ) : (

                  <motion.div

                    key="menu"

                    initial={{ rotate: -90, opacity: 0 }}

                    animate={{ rotate: 0, opacity: 1 }}

                    exit={{ rotate: 90, opacity: 0 }}

                    transition={{ duration: 0.2 }}

                  >

                    <Menu size={20} />

                  </motion.div>

                )}

              </AnimatePresence>

            </motion.button>

          </div>

        </div>



        {/* Mobile Menu */}

        <AnimatePresence>

          {isOpen && (

            <motion.div

              initial={{ opacity: 0, height: 0 }}

              animate={{ opacity: 1, height: 'auto' }}

              exit={{ opacity: 0, height: 0 }}

              transition={{ duration: 0.3 }}

              className="lg:hidden border-t border-base-200/50 mt-2 pt-4 pb-4"

            >

              <div className="space-y-2">

                {[

                  { path: '/', label: 'Home', icon: 'fas fa-home' },

                  //{ path: '/circuit-designer', label: 'Circuit Designer', icon: 'fas fa-project-diagram' },

                  { path: '/glossary', label: 'Glossary', icon: 'fas fa-book' },

                ].map((item, index) => (

                  <motion.div

                    key={item.path}

                    initial={{ opacity: 0, x: -20 }}

                    animate={{ opacity: 1, x: 0 }}

                    transition={{ delay: index * 0.1 }}

                  >

                    <Link

                      to={item.path}

                      onClick={() => setIsOpen(false)}

                      className={`block px-4 py-3 rounded-lg transition-all flex items-center gap-3 ${

                        location.pathname === item.path

                          ? 'bg-primary text-primary-content'

                          : 'hover:bg-base-200'

                      }`}

                    >

                      <i className={item.icon}></i>

                      {item.label}

                    </Link>

                  </motion.div>

                ))}

                

                <motion.a

                  initial={{ opacity: 0, x: -20 }}

                  animate={{ opacity: 1, x: 0 }}

                  transition={{ delay: 0.3 }}

                  href="https://Facebook.com/ChuyenDoiXanh"

                  target="_blank"

                  rel="noopener noreferrer"

                  onClick={() => setIsOpen(false)}

                  className="block px-4 py-3 rounded-lg hover:bg-base-200 transition-all flex items-center gap-3"

                >

                  <i className="fab fa-Facebook"></i>

                  Facebook

                </motion.a>

              </div>

            </motion.div>

          )}

        </AnimatePresence>

      </div>

    </motion.nav>
  );
}

export default Navbar;