Skip to content

Commit 07b4bcf

Browse files
Non-connect scenarios (#331)
Tweak action enablement and placeholder screen to allow use of actions when the tool isn't connected. This will help in import scenarios and allow some initial exploration without a micro:bit. We still think there's a gap in basic introduction prior to the connect flow but will review separately. --------- Co-authored-by: Grace <grace@microbit.org> Co-authored-by: Grace <145345672+microbit-grace@users.noreply.github.com>
1 parent acc8652 commit 07b4bcf

17 files changed

+433
-270
lines changed

lang/ui.en.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@
119119
"defaultMessage": "WebUSB connection dialog with BBC micro:bit entry labelled 1 and Connect button labelled 2",
120120
"description": "Alt text for image in connect help dialog"
121121
},
122+
"connect-or-import": {
123+
"defaultMessage": "<link1>Connect a data collection micro:bit</link1> or <link2>import data samples</link2>",
124+
"description": "Empty data samples page text"
125+
},
126+
"connect-to-record-body": {
127+
"defaultMessage": "Connect a micro:bit to record a data sample.",
128+
"description": "Insufficient data modal content"
129+
},
130+
"connect-to-record-title": {
131+
"defaultMessage": "You don't have a micro:bit connected",
132+
"description": "Connect to record modal title"
133+
},
122134
"connectFailed.bluetooth1": {
123135
"defaultMessage": "The connection to the micro:bit could not be established.",
124136
"description": ""
@@ -859,6 +871,10 @@
859871
"defaultMessage": "More edit in MakeCode options",
860872
"description": "Aria label for the additional actions menu to the right of the Edit in MakeCode button"
861873
},
874+
"no-data-samples": {
875+
"defaultMessage": "No data samples",
876+
"description": "Empty data samples page status text"
877+
},
862878
"not-found": {
863879
"defaultMessage": "micro:bit AI creator home page",
864880
"description": "Page not found link text"

src/components/AddDataGridRow.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ interface AddDataGridRowProps {
1111
gesture: GestureData;
1212
selected: boolean;
1313
onSelectRow: () => void;
14-
startRecording: () => void;
14+
onRecord: () => void;
1515
showWalkThrough: boolean;
1616
}
1717

1818
const DataSampleGridRow = ({
1919
gesture,
2020
selected,
2121
onSelectRow,
22-
startRecording,
22+
onRecord,
2323
showWalkThrough,
2424
}: AddDataGridRowProps) => {
2525
const intl = useIntl();
@@ -55,18 +55,15 @@ const DataSampleGridRow = ({
5555
readOnly={false}
5656
/>
5757
{showWalkThrough ? (
58-
<AddDataGridWalkThrough
59-
gesture={gesture}
60-
startRecording={startRecording}
61-
/>
58+
<AddDataGridWalkThrough gesture={gesture} onRecord={onRecord} />
6259
) : (
6360
<>
6461
{gesture.name.length > 0 || gesture.recordings.length > 0 ? (
6562
<DataRecordingGridItem
6663
data={gesture}
6764
selected={selected}
6865
onSelectRow={onSelectRow}
69-
startRecording={startRecording}
66+
onRecord={onRecord}
7067
/>
7168
) : (
7269
// Empty grid item to fill column space

src/components/AddDataGridWalkThrough.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import UpCurveArrow from "./UpCurveArrow";
77

88
interface AddDataGridWalkThrough {
99
gesture: GestureData;
10-
startRecording: () => void;
10+
onRecord: () => void;
1111
}
1212

1313
const AddDataGridWalkThrough = ({
1414
gesture,
15-
startRecording,
15+
onRecord,
1616
}: AddDataGridWalkThrough) => {
1717
return (
1818
<>
@@ -30,7 +30,7 @@ const AddDataGridWalkThrough = ({
3030
<DataRecordingGridItem
3131
data={gesture}
3232
selected={true}
33-
startRecording={startRecording}
33+
onRecord={onRecord}
3434
/>
3535
{/* Empty grid item to fill first column of grid */}
3636
<GridItem />

src/components/ConnectFirstView.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import {
2+
Button,
3+
Modal,
4+
ModalBody,
5+
ModalCloseButton,
6+
ModalContent,
7+
ModalFooter,
8+
ModalHeader,
9+
ModalOverlay,
10+
Text,
11+
} from "@chakra-ui/react";
12+
import { ComponentProps, useCallback } from "react";
13+
import { FormattedMessage } from "react-intl";
14+
import { useConnectionStage } from "../connection-stage-hooks";
15+
16+
const ConnectToRecordDialog = ({
17+
onClose,
18+
...rest
19+
}: Omit<ComponentProps<typeof Modal>, "children">) => {
20+
const { actions } = useConnectionStage();
21+
22+
const handleConnect = useCallback(() => {
23+
onClose();
24+
actions.startConnect();
25+
}, [actions, onClose]);
26+
27+
return (
28+
<Modal
29+
closeOnOverlayClick={false}
30+
motionPreset="none"
31+
size="md"
32+
isCentered
33+
onClose={onClose}
34+
{...rest}
35+
>
36+
<ModalOverlay>
37+
<ModalContent>
38+
<ModalHeader>
39+
<FormattedMessage id="connect-to-record-title" />
40+
</ModalHeader>
41+
<ModalBody>
42+
<ModalCloseButton />
43+
<Text>
44+
<FormattedMessage id="connect-to-record-body" />
45+
</Text>
46+
</ModalBody>
47+
<ModalFooter justifyContent="flex-end">
48+
<Button variant="primary" onClick={handleConnect}>
49+
<FormattedMessage id="footer.connectButton" />
50+
</Button>
51+
</ModalFooter>
52+
</ModalContent>
53+
</ModalOverlay>
54+
</Modal>
55+
);
56+
};
57+
58+
export default ConnectToRecordDialog;

src/components/DataRecordingGridItem.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ interface DataRecordingGridItemProps {
2020
data: GestureData;
2121
selected: boolean;
2222
onSelectRow?: () => void;
23-
startRecording: () => void;
23+
onRecord: () => void;
2424
}
2525

2626
const DataRecordingGridItem = ({
2727
data,
2828
selected,
2929
onSelectRow,
30-
startRecording,
30+
onRecord,
3131
}: DataRecordingGridItemProps) => {
3232
const intl = useIntl();
3333
const deleteGestureRecording = useStore((s) => s.deleteGestureRecording);
@@ -62,14 +62,14 @@ const DataRecordingGridItem = ({
6262
height="fit-content"
6363
width="fit-content"
6464
rounded="full"
65-
onClick={startRecording}
65+
onClick={onRecord}
6666
variant="ghost"
6767
_hover={{ backgroundColor: "transparent" }}
6868
aria-label={intl.formatMessage(
6969
{ id: "content.data.recordAction" },
7070
{ action: data.name }
7171
)}
72-
isDisabled={!isConnected}
72+
opacity={isConnected ? 1 : 0.5}
7373
icon={
7474
<Icon
7575
as={RecordIcon}

0 commit comments

Comments
 (0)