-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathHubPicker.tsx
More file actions
77 lines (71 loc) · 2.53 KB
/
Copy pathHubPicker.tsx
File metadata and controls
77 lines (71 loc) · 2.53 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
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 The Pybricks Authors
import './hubPicker.scss';
import { Radio, RadioGroup } from '@blueprintjs/core';
import React from 'react';
import { useHubPickerSelectedHub } from './hooks';
import { Hub } from '.';
type HubIconProps = {
url: URL;
label: string;
};
const HubIcon: React.FunctionComponent<HubIconProps> = ({ url, label }) => {
return <img src={url.toString()} width={64} height={64} title={label} />;
};
type HubPickerProps = {
disabled?: boolean;
};
export const HubPicker: React.FunctionComponent<HubPickerProps> = ({ disabled }) => {
const [selectedHub, setSelectedHub] = useHubPickerSelectedHub();
return (
<RadioGroup
className="pb-hub-picker"
selectedValue={selectedHub}
disabled={disabled}
onChange={(e) => setSelectedHub(e.currentTarget.value as Hub)}
>
<Radio value={Hub.Move}>
<HubIcon
url={new URL('@pybricks/images/hub-move.png', import.meta.url)}
label="BOOST Move Hub"
/>
</Radio>
<Radio value={Hub.City}>
<HubIcon
url={new URL('@pybricks/images/hub-city.png', import.meta.url)}
label="City Hub"
/>
</Radio>
<Radio value={Hub.Technic}>
<HubIcon
url={new URL('@pybricks/images/hub-technic.png', import.meta.url)}
label="Technic Hub"
/>
</Radio>
<Radio value={Hub.Prime}>
<HubIcon
url={new URL('@pybricks/images/hub-prime.png', import.meta.url)}
label="SPIKE Prime Hub"
/>
</Radio>
<Radio value={Hub.Essential}>
<HubIcon
url={new URL('@pybricks/images/hub-essential.png', import.meta.url)}
label="SPIKE Essential Hub"
/>
</Radio>
<Radio value={Hub.Inventor}>
<HubIcon
url={new URL('@pybricks/images/hub-inventor.png', import.meta.url)}
label="MINDSTORMS Robot Inventor Hub"
/>
</Radio>
<Radio value={Hub.EV3}>
<HubIcon
url={new URL('@pybricks/images/hub-ev3.png', import.meta.url)}
label="MINDSTORMS EV3"
/>
</Radio>
</RadioGroup>
);
};