Skip to content

Commit 5e9ef82

Browse files
committed
Add Home link to example components
1 parent f2e141f commit 5e9ef82

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

client/src/examples/Ball3D.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'katex/dist/katex.min.css';
88
import { BlockMath } from 'react-katex';
99
import { Text, Button } from '@geist-ui/core';
1010
import ButtonForkOnGithub from '../components/ButtonForkOnGithub.jsx';
11+
import { Link } from 'react-router-dom';
1112

1213
const ROWS = 3;
1314
const COLS = 4;
@@ -44,6 +45,7 @@ export default function Ball3DExample() {
4445
const intervalRef = useRef(null);
4546

4647
const [chartState, setChartState] = useState({ labels: [], rewards: [], losses: [] });
48+
const [homeHover, setHomeHover] = useState(false);
4749

4850
const envRef = useRef({ rotX: 0, rotZ: 0, ballX: 0, ballZ: 0, velX: 0, velZ: 0 });
4951

@@ -209,6 +211,23 @@ export default function Ball3DExample() {
209211

210212
{/* UI overlay */}
211213
<div style={{ position: 'absolute', top: 10, left: 10, color: '#fff' }}>
214+
215+
{/* Home link */}
216+
<Link
217+
to="/"
218+
style={{
219+
fontFamily: 'monospace',
220+
color: '#fff',
221+
textDecoration: homeHover ? 'none' : 'underline',
222+
marginBottom: '4px',
223+
display: 'inline-block',
224+
}}
225+
onMouseEnter={() => setHomeHover(true)}
226+
onMouseLeave={() => setHomeHover(false)}
227+
>
228+
Home
229+
</Link>
230+
212231
<Text h1 style={{ margin: '0 0 12px 0', color: '#fff' }}>
213232
Ball 3D Example
214233
</Text>

client/src/examples/Basic.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'katex/dist/katex.min.css';
1515
import { BlockMath } from 'react-katex';
1616
import { Text, Button } from '@geist-ui/core';
1717
import ButtonForkOnGithub from '../components/ButtonForkOnGithub.jsx';
18+
import { Link } from 'react-router-dom';
1819

1920
ChartJS.register(LineElement, PointElement, LinearScale, CategoryScale);
2021

@@ -59,6 +60,9 @@ export default function BasicExample() {
5960

6061
const [chartState, setChartState] = useState({ labels: [], rewards: [], losses: [] });
6162

63+
// Add hover state for Home link
64+
const [homeHover, setHomeHover] = useState(false);
65+
6266
const step = useCallback((direction) => {
6367
setPos((prev) => {
6468
const next = Math.min(MAX_POS, Math.max(MIN_POS, prev + direction));
@@ -264,6 +268,21 @@ export default function BasicExample() {
264268
textShadow: '0 0 4px #000',
265269
}}
266270
>
271+
{/* Home link */}
272+
<Link
273+
to="/"
274+
style={{
275+
fontFamily: 'monospace',
276+
color: '#fff',
277+
textDecoration: homeHover ? 'none' : 'underline',
278+
marginBottom: '4px',
279+
display: 'inline-block',
280+
}}
281+
onMouseEnter={() => setHomeHover(true)}
282+
onMouseLeave={() => setHomeHover(false)}
283+
>
284+
Home
285+
</Link>
267286
<Text h1 style={{ margin: '0 0 12px 0', color: '#fff' }}>
268287
Basic Example - 1-D Move-To-Goal
269288
</Text>

client/src/examples/GridWorld.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { BlockMath } from 'react-katex';
88
import DebugConsole from '../components/DebugConsole.jsx';
99
import ChartPanel from '../components/ChartPanel.jsx';
1010
import ButtonForkOnGithub from '../components/ButtonForkOnGithub.jsx';
11+
import { Link } from 'react-router-dom';
1112

1213
const WS_URL = `${config.WS_BASE_URL}/ws/gridworld`;
1314
const CELL_SIZE = 1;
@@ -55,6 +56,7 @@ export default function GridWorldExample() {
5556
const [trained, setTrained] = useState(false);
5657
const [modelInfo, setModelInfo] = useState(null);
5758
const [chartState, setChartState] = useState({ labels: [], rewards: [], losses: [] });
59+
const [homeHover, setHomeHover] = useState(false);
5860
const wsRef = useRef(null);
5961
const intervalRef = useRef(null);
6062

@@ -179,6 +181,21 @@ export default function GridWorldExample() {
179181

180182
{/* Overlay UI */}
181183
<div style={{ position: 'absolute', top: 10, left: 10, color: '#fff' }}>
184+
{/* Home link */}
185+
<Link
186+
to="/"
187+
style={{
188+
fontFamily: 'monospace',
189+
color: '#fff',
190+
textDecoration: homeHover ? 'none' : 'underline',
191+
marginBottom: '4px',
192+
display: 'inline-block',
193+
}}
194+
onMouseEnter={() => setHomeHover(true)}
195+
onMouseLeave={() => setHomeHover(false)}
196+
>
197+
Home
198+
</Link>
182199
<Text h1 style={{ margin: '0 0 12px 0', color: '#fff' }}>
183200
GridWorld Example
184201
</Text>

0 commit comments

Comments
 (0)