Skip to content

Commit b49954d

Browse files
Merge pull request #11 from quantamu/feat/bloch-sphere
Added a Quantum Gates interactive page.
2 parents b516d38 + fbad181 commit b49954d

8 files changed

Lines changed: 952 additions & 1 deletion

File tree

‎package-lock.json‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"react-rotating-text": "^1.4.1",
1717
"react-router-dom": "^7.1.1",
1818
"react-scripts": "5.0.1",
19+
"three": "^0.187.0",
1920
"web-vitals": "^4.2.4"
2021
},
2122
"scripts": {

‎src/App.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { Suspense, lazy } from 'react';
22
import { HashRouter as Router, Route, Routes, useNavigate } from 'react-router-dom';
33
import { Container } from 'react-bootstrap';
44

@@ -17,6 +17,9 @@ import Footer from './components/footer';
1717
import ScrollingCarousel from "./components/ScrollingCarousel";
1818
import QubitAnimation from './components/QubitAnimation';
1919

20+
// Loaded only when someone opens the Gates page (keeps three.js out of the main bundle)
21+
const QuantumGates = lazy(() => import('./QuantumGates'));
22+
2023
function App() {
2124
return (
2225
<Router>
@@ -31,6 +34,14 @@ function App() {
3134
<Route path='/officers' element= {<Officers />} />
3235
<Route path='/resources' element= {<Resources />} />
3336
<Route path='/newsletter' element={<Newsletter />} />
37+
<Route
38+
path='/gates'
39+
element={
40+
<Suspense fallback={<p>Loading quantum gates...</p>}>
41+
<QuantumGates />
42+
</Suspense>
43+
}
44+
/>
3445
</Routes>
3546
</Container>
3647

‎src/QuantumGates.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import BlochSphere from './components/BlochSphere/BlochSphere';
3+
4+
function QuantumGates() {
5+
return (
6+
<main className='gates-page'>
7+
<h1 className='gates-page-title'>Quantum Gates</h1>
8+
<p className='gates-page-intro'>
9+
Every single-qubit gate is a rotation of the Bloch sphere. Pick a starting state,
10+
apply gates, and watch the qubit move. Try H → T → H, or apply Z to |0⟩ and see
11+
what happens.
12+
</p>
13+
<BlochSphere />
14+
</main>
15+
);
16+
}
17+
18+
export default QuantumGates;
Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
/* Bloch sphere demo, matched to the Quant A&M site theme */
2+
3+
.bloch {
4+
display: grid;
5+
grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
6+
gap: 24px;
7+
max-width: 1100px;
8+
margin: 0 auto;
9+
padding: 20px;
10+
color: #e8e6f3;
11+
text-align: left;
12+
}
13+
14+
/* ---------- 3D canvas ---------- */
15+
.bloch-stage {
16+
position: relative;
17+
border-radius: 16px;
18+
border: 2px solid transparent;
19+
background:
20+
radial-gradient(circle at 50% 45%, #3a3556 0%, #2b2840 70%) padding-box,
21+
linear-gradient(90deg, #6b4dff, #e22514) border-box;
22+
box-shadow: 0 8px 28px rgba(107, 77, 255, 0.18);
23+
overflow: hidden;
24+
display: flex;
25+
}
26+
27+
.bloch-canvas {
28+
flex: 1;
29+
width: 100%;
30+
min-height: 520px;
31+
cursor: grab;
32+
touch-action: none;
33+
}
34+
35+
.bloch-canvas:active {
36+
cursor: grabbing;
37+
}
38+
39+
.bloch-canvas {
40+
position: relative;
41+
min-width: 0;
42+
}
43+
44+
.bloch-canvas canvas {
45+
position: absolute;
46+
inset: 0;
47+
width: 100%;
48+
height: 100%;
49+
display: block;
50+
}
51+
52+
.bloch-hint {
53+
position: absolute;
54+
bottom: 10px;
55+
left: 0;
56+
right: 0;
57+
margin: 0;
58+
text-align: center;
59+
font-size: 0.8rem;
60+
color: #8a86a3;
61+
pointer-events: none;
62+
}
63+
64+
/* ---------- Control panel ---------- */
65+
.bloch-panel {
66+
display: flex;
67+
flex-direction: column;
68+
gap: 18px;
69+
}
70+
71+
.bloch-group h3 {
72+
margin: 0 0 8px;
73+
font-size: 0.8rem;
74+
font-weight: 700;
75+
letter-spacing: 0.08em;
76+
text-transform: uppercase;
77+
color: #b9b4d0;
78+
}
79+
80+
.bloch-theta {
81+
margin-left: 6px;
82+
color: #5cf08a;
83+
text-transform: none;
84+
letter-spacing: 0;
85+
}
86+
87+
.bloch-buttons {
88+
display: flex;
89+
flex-wrap: wrap;
90+
gap: 8px;
91+
}
92+
93+
.bloch-buttons.gates {
94+
display: grid;
95+
grid-template-columns: repeat(4, 1fr);
96+
}
97+
98+
.bloch-btn {
99+
min-width: 52px;
100+
padding: 8px 12px;
101+
border: 1px solid #4a4566;
102+
border-radius: 10px;
103+
background: #34304a;
104+
color: #e8e6f3;
105+
font-family: inherit;
106+
font-size: 0.95rem;
107+
font-weight: 600;
108+
cursor: pointer;
109+
transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
110+
}
111+
112+
.bloch-btn:hover {
113+
transform: translateY(-1px);
114+
border-color: #6b4dff;
115+
}
116+
117+
.bloch-btn:focus-visible,
118+
.bloch-reset:focus-visible,
119+
.bloch-slider:focus-visible {
120+
outline: 2px solid #5cf08a;
121+
outline-offset: 2px;
122+
}
123+
124+
.bloch-btn.gate {
125+
background: linear-gradient(#34304a, #34304a) padding-box,
126+
linear-gradient(90deg, #6b4dff, #e22514) border-box;
127+
border: 1px solid transparent;
128+
}
129+
130+
.bloch-btn.gate:active {
131+
transform: translateY(1px);
132+
}
133+
134+
.bloch-btn.state.active {
135+
background: #5cf08a;
136+
border-color: #5cf08a;
137+
color: #1f1d2b;
138+
}
139+
140+
.bloch-slider {
141+
width: 100%;
142+
margin: 2px 0 10px;
143+
accent-color: #6b4dff;
144+
}
145+
146+
/* ---------- Readout ---------- */
147+
.bloch-readout,
148+
.bloch-gate-info {
149+
padding: 14px 16px;
150+
border-radius: 12px;
151+
background: #34304a;
152+
}
153+
154+
.bloch-ket {
155+
margin: 0 0 6px;
156+
font-family: 'Cambria Math', 'STIX Two Math', Georgia, serif;
157+
font-size: 1.1rem;
158+
word-break: break-word;
159+
}
160+
161+
.bloch-ket span {
162+
color: #5cf08a;
163+
}
164+
165+
.bloch-coords {
166+
margin: 0;
167+
font-size: 0.85rem;
168+
color: #b9b4d0;
169+
}
170+
171+
.bloch-gate-info p {
172+
margin: 0 0 10px;
173+
font-size: 0.9rem;
174+
line-height: 1.4;
175+
}
176+
177+
.bloch-matrix {
178+
display: flex;
179+
align-items: center;
180+
gap: 8px;
181+
font-family: 'Cambria Math', 'STIX Two Math', Georgia, serif;
182+
}
183+
184+
.bloch-prefix {
185+
font-size: 1rem;
186+
}
187+
188+
.bloch-matrix-grid {
189+
display: grid;
190+
grid-template-columns: repeat(2, auto);
191+
gap: 4px 18px;
192+
padding: 6px 12px;
193+
border-left: 2px solid #b9b4d0;
194+
border-right: 2px solid #b9b4d0;
195+
border-radius: 6px;
196+
text-align: center;
197+
}
198+
199+
.bloch-note {
200+
margin: 0;
201+
padding: 10px 14px;
202+
border-left: 3px solid #e22514;
203+
border-radius: 6px;
204+
background: rgba(226, 37, 20, 0.1);
205+
font-size: 0.85rem;
206+
line-height: 1.4;
207+
}
208+
209+
.bloch-history {
210+
margin: 0 0 10px;
211+
font-family: 'Cambria Math', 'STIX Two Math', Georgia, serif;
212+
font-size: 1rem;
213+
word-break: break-word;
214+
}
215+
216+
.bloch-reset {
217+
padding: 8px 22px;
218+
border: none;
219+
border-radius: 999px;
220+
background: linear-gradient(90deg, #5cf08a, #5b8cff);
221+
color: #1f1d2b;
222+
font-family: inherit;
223+
font-weight: 700;
224+
cursor: pointer;
225+
}
226+
227+
.bloch-reset:hover {
228+
opacity: 0.9;
229+
}
230+
231+
/* ---------- Page wrapper ---------- */
232+
.gates-page {
233+
padding: 20px;
234+
text-align: center;
235+
}
236+
237+
.gates-page-title {
238+
font-family: 'Open Sans', sans-serif;
239+
font-size: 3rem;
240+
margin: 10px 0 6px;
241+
background: linear-gradient(90deg, #6b4dff, #e22514);
242+
background-clip: text;
243+
-webkit-background-clip: text;
244+
-webkit-text-fill-color: transparent;
245+
display: inline-block;
246+
}
247+
248+
.gates-page-intro {
249+
max-width: 680px;
250+
margin: 0 auto 10px;
251+
color: #b9b4d0;
252+
line-height: 1.5;
253+
}
254+
255+
/* ---------- Mobile ---------- */
256+
@media (max-width: 860px) {
257+
.bloch {
258+
grid-template-columns: 1fr;
259+
padding: 12px;
260+
}
261+
262+
.bloch-canvas {
263+
min-height: 380px;
264+
}
265+
266+
.gates-page-title {
267+
font-size: 2.25rem;
268+
}
269+
}

0 commit comments

Comments
 (0)