Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit e4a575d

Browse files
committed
Rename correctly components
1 parent 6f957a3 commit e4a575d

File tree

6 files changed

+19
-31
lines changed

6 files changed

+19
-31
lines changed

src/view/components/clue/Clue.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { SENSOR_LIST, VSCODE_MESSAGES_TO_WEBVIEW } from "../../constants";
77
import "../../styles/Simulator.css";
88
import * as TOOLBAR_SVG from "../../svgs/toolbar_svg";
99
import ToolBar from "../toolbar/ToolBar";
10-
import { MicrobitSimulator } from "./ClueSimulator";
10+
import { ClueSimulator } from "./ClueSimulator";
1111

1212
// Component grouping the functionality for micro:bit functionalities
1313
interface IState {
@@ -46,7 +46,7 @@ export class Clue extends React.Component<{}, IState> {
4646
render() {
4747
return (
4848
<React.Fragment>
49-
<MicrobitSimulator />
49+
<ClueSimulator />
5050
<ToolBar
5151
buttonList={MICROBIT_TOOLBAR_BUTTONS}
5252
onUpdateSensor={this.updateSensor}

src/view/components/clue/ClueImage.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { VIEW_STATE } from "../../constants";
66
import CONSTANTS, { MICROBIT_BUTTON_STYLING_CLASSES } from "../../constants";
77
import { ViewStateContext } from "../../context";
88
import "../../styles/Microbit.css";
9-
import { IRefObject, MicrobitSvg } from "./Clue_svg";
9+
import { IRefObject, ClueSvg } from "./Clue_svg";
1010

1111
interface EventTriggers {
1212
onMouseUp: (event: Event, buttonKey: string) => void;
@@ -16,7 +16,6 @@ interface EventTriggers {
1616
}
1717
interface IProps {
1818
eventTriggers: EventTriggers;
19-
leds: number[][];
2019
displayMessage: string;
2120
}
2221

@@ -32,21 +31,19 @@ export enum BUTTONS_KEYS {
3231
}
3332
// Displays the SVG and call necessary svg modification.
3433
export class ClueImage extends React.Component<IProps, {}> {
35-
private svgRef: React.RefObject<MicrobitSvg> = React.createRef();
34+
private svgRef: React.RefObject<ClueSvg> = React.createRef();
3635
constructor(props: IProps) {
3736
super(props);
3837
}
3938
componentDidMount() {
4039
const svgElement = this.svgRef.current;
4140
if (svgElement) {
42-
// updateAllLeds(this.props.leds, svgElement.getLeds());
4341
setupAllButtons(this.props.eventTriggers, svgElement.getButtons());
4442
this.setupKeyPresses(this.props.eventTriggers.onKeyEvent);
4543
}
4644
}
4745
componentDidUpdate() {
4846
if (this.svgRef.current) {
49-
// updateAllLeds(this.props.leds, this.svgRef.current.getLeds());
5047
if (this.context === VIEW_STATE.PAUSE) {
5148
disableAllButtons(this.svgRef.current.getButtons());
5249
} else if (this.context === VIEW_STATE.RUNNING) {
@@ -85,7 +82,7 @@ export class ClueImage extends React.Component<IProps, {}> {
8582
};
8683
render() {
8784
return (
88-
<MicrobitSvg
85+
<ClueSvg
8986
ref={this.svgRef}
9087
displayImage={this.props.displayMessage}
9188
/>

src/view/components/clue/ClueSimulator.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import {
33
CONSTANTS,
44
// DEVICE_LIST_KEY,
5-
MICROBIT_BUTTONS_KEYS,
5+
AB_BUTTONS_KEYS,
66
WEBVIEW_MESSAGES,
77
} from "../../constants";
88
import PlayLogo from "../../svgs/play_svg";
@@ -14,14 +14,7 @@ import { BUTTONS_KEYS, ClueImage } from "./ClueImage";
1414

1515
// import * as fs from "fs";
1616

17-
const DEFAULT_CLUE_STATE: IMicrobitState = {
18-
leds: [
19-
[0, 0, 0, 0, 0],
20-
[0, 0, 0, 0, 0],
21-
[0, 0, 0, 0, 0],
22-
[0, 0, 0, 0, 0],
23-
[0, 0, 0, 0, 0],
24-
],
17+
const DEFAULT_CLUE_STATE: IClueState = {
2518
buttons: { button_a: false, button_b: false },
2619
displayMessage: "",
2720
};
@@ -31,15 +24,14 @@ interface IState {
3124
running_file: string;
3225
play_button: boolean;
3326
selected_file: string;
34-
clue: IMicrobitState;
27+
clue: IClueState;
3528
}
3629

37-
interface IMicrobitState {
38-
leds: number[][];
30+
interface IClueState {
3931
buttons: { button_a: boolean; button_b: boolean };
4032
displayMessage: string;
4133
}
42-
export class MicrobitSimulator extends React.Component<any, IState> {
34+
export class ClueSimulator extends React.Component<any, IState> {
4335
private imageRef: React.RefObject<ClueImage> = React.createRef();
4436
constructor() {
4537
super({});
@@ -118,7 +110,6 @@ export class MicrobitSimulator extends React.Component<any, IState> {
118110
onMouseLeave: this.onMouseLeave,
119111
onKeyEvent: this.onKeyEvent,
120112
}}
121-
leds={this.state.clue.leds}
122113
displayMessage={this.state.clue.displayMessage}
123114
/>
124115
</div>
@@ -160,13 +151,13 @@ export class MicrobitSimulator extends React.Component<any, IState> {
160151
protected handleButtonClick = (key: string, isActive: boolean) => {
161152
let newButtonState = this.state.clue.buttons;
162153
switch (key) {
163-
case MICROBIT_BUTTONS_KEYS.BTN_A:
154+
case AB_BUTTONS_KEYS.BTN_A:
164155
newButtonState.button_a = isActive;
165156
break;
166-
case MICROBIT_BUTTONS_KEYS.BTN_B:
157+
case AB_BUTTONS_KEYS.BTN_B:
167158
newButtonState.button_b = isActive;
168159
break;
169-
case MICROBIT_BUTTONS_KEYS.BTN_AB:
160+
case AB_BUTTONS_KEYS.BTN_AB:
170161
newButtonState = {
171162
button_a: isActive,
172163
button_b: isActive,

src/view/components/clue/Clue_svg.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface IProps {
1111
displayImage: string;
1212
}
1313

14-
export class MicrobitSvg extends React.Component<IProps, {}> {
14+
export class ClueSvg extends React.Component<IProps, {}> {
1515
private svgRef: React.RefObject<SVGSVGElement> = React.createRef();
1616

1717
private buttonRefs: IRefObject = {

src/view/components/microbit/MicrobitSimulator.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22
import {
33
CONSTANTS,
44
DEVICE_LIST_KEY,
5-
MICROBIT_BUTTONS_KEYS,
5+
AB_BUTTONS_KEYS,
66
WEBVIEW_MESSAGES,
77
} from "../../constants";
88
import PlayLogo from "../../svgs/play_svg";
@@ -162,13 +162,13 @@ export class MicrobitSimulator extends React.Component<any, IState> {
162162
protected handleButtonClick = (key: string, isActive: boolean) => {
163163
let newButtonState = this.state.microbit.buttons;
164164
switch (key) {
165-
case MICROBIT_BUTTONS_KEYS.BTN_A:
165+
case AB_BUTTONS_KEYS.BTN_A:
166166
newButtonState.button_a = isActive;
167167
break;
168-
case MICROBIT_BUTTONS_KEYS.BTN_B:
168+
case AB_BUTTONS_KEYS.BTN_B:
169169
newButtonState.button_b = isActive;
170170
break;
171-
case MICROBIT_BUTTONS_KEYS.BTN_AB:
171+
case AB_BUTTONS_KEYS.BTN_AB:
172172
newButtonState = {
173173
button_a: isActive,
174174
button_b: isActive,

src/view/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const CONSTANTS = {
4747
SIMULATOR_BUTTON_WIDTH: 60,
4848
TOOLBAR_INFO: `Explore what's on the board:`,
4949
};
50-
export const MICROBIT_BUTTONS_KEYS = {
50+
export const AB_BUTTONS_KEYS = {
5151
BTN_A: "BTN_A",
5252
BTN_B: "BTN_B",
5353
BTN_AB: "BTN_AB",

0 commit comments

Comments
 (0)