Skip to content

Commit 8989247

Browse files
authored
Merge pull request #1008 from pybricks/dlech
Pybricks tour
2 parents 5c74ad3 + ad774e0 commit 8989247

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+823
-104
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Added better error message when no files to backup ([support#681]).
99
- Added multi-step firmware flashing dialog.
1010
- Added support for flashing firmware via USB DFU.
11+
- Added an interactive introductory tour of the app.
1112

1213
### Fixed
1314
- Fixed deleting files that are not open in the editor.

blueprints-icons/16px/chevron-right.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

blueprints-icons/16px/more.svg

Lines changed: 0 additions & 10 deletions
This file was deleted.

blueprints-icons/16px/small-minus.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

blueprints-icons/16px/small-tick.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

blueprints-icons/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"react-dev-utils": "^12.0.1",
9292
"react-dom": "^16.13.1",
9393
"react-dropzone": "^14.2.2",
94+
"react-joyride": "^2.5.0",
9495
"react-monaco-editor": "^0.49.0",
9596
"react-popper": "^2.3.0",
9697
"react-redux": "^8.0.2",

src/activities/Activities.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import { cleanup } from '@testing-library/react';
55
import React from 'react';
66
import { testRender } from '../../test';
7-
import Activities, { Activity } from './Activities';
7+
import Activities from './Activities';
8+
import { Activity } from './hooks';
89

910
afterEach(() => {
1011
cleanup();

src/activities/Activities.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,18 @@
44
import './activities.scss';
55
import { Icon, Tab, Tabs } from '@blueprintjs/core';
66
import React, { useCallback, useEffect, useRef } from 'react';
7-
import { useLocalStorage } from 'usehooks-ts';
87
import Explorer from '../explorer/Explorer';
98
import Settings from '../settings/Settings';
9+
import { Activity, useActivitiesSelectedActivity } from './hooks';
1010
import { useI18n } from './i18n';
1111

12-
/** Indicates the selected activity. */
13-
export enum Activity {
14-
/** No activity is selected. */
15-
None = 'activity.none',
16-
/** The explorer activity is selected. */
17-
Explorer = 'activity.explorer',
18-
/** The settings activity is selected. */
19-
Settings = 'activity.settings',
20-
}
21-
2212
/**
2313
* React component that acts as a tab control to select activities.
2414
*/
2515
const Activities: React.VoidFunctionComponent = () => {
16+
const [selectedActivity, setSelectedActivity] = useActivitiesSelectedActivity();
2617
const i18n = useI18n();
2718

28-
const [selectedActivity, setSelectedActivity] = useLocalStorage(
29-
'activities.selectedActivity',
30-
Activity.Explorer,
31-
);
32-
3319
const handleAction = useCallback(
3420
(newActivity: Activity) => {
3521
// if activity is already selected, select none
@@ -110,6 +96,7 @@ const Activities: React.VoidFunctionComponent = () => {
11096
ref={tabsRef}
11197
>
11298
<Tab
99+
itemID="pb-activities-explorer-tab"
113100
aria-label={i18n.translate('explorer')}
114101
className="pb-activities-tablist-tab"
115102
id={Activity.Explorer}
@@ -125,6 +112,7 @@ const Activities: React.VoidFunctionComponent = () => {
125112
onMouseDown={(e) => e.stopPropagation()}
126113
/>
127114
<Tab
115+
itemID="pb-activities-settings-tab"
128116
aria-label={i18n.translate('settings')}
129117
className="pb-activities-tablist-tab"
130118
id={Activity.Settings}

src/activities/hooks.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-License-Identifier: MIT
2+
// Copyright (c) 2022 The Pybricks Authors
3+
4+
import { useLocalStorage } from 'usehooks-ts';
5+
6+
/** Indicates the selected activity. */
7+
export enum Activity {
8+
/** No activity is selected. */
9+
None = 'activity.none',
10+
/** The explorer activity is selected. */
11+
Explorer = 'activity.explorer',
12+
/** The settings activity is selected. */
13+
Settings = 'activity.settings',
14+
}
15+
16+
/**
17+
* React hook for getting and setting the selected activity in the activity panel.
18+
* @returns a tuple of the current state and the setter function (like useState()).
19+
*/
20+
export function useActivitiesSelectedActivity() {
21+
return useLocalStorage('activities.selectedActivity', Activity.Explorer);
22+
}

0 commit comments

Comments
 (0)