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

Commit 5ddb822

Browse files
committed
Linting and adding spaces for cleaner code
1 parent a3b6e31 commit 5ddb822

File tree

4 files changed

+46
-51
lines changed

4 files changed

+46
-51
lines changed

src/view/components/Simulator.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33

44
import * as React from "react";
55
import { CONSTANTS } from "../constants";
6+
import "../styles/Simulator.css";
67
import PlayLogo from "../svgs/play_svg";
78
import StopLogo from "../svgs/stop_svg";
89
import { BUTTON_NEUTRAL, BUTTON_PRESSED } from "./cpx/Cpx_svg_style";
910
import CpxImage, { updatePinTouch, updateSwitch } from "./cpx/CpxImage";
1011
import Dropdown from "./Dropdown";
1112
import ActionBar from "./simulator/ActionBar"
1213

13-
14-
import "../styles/Simulator.css";
15-
1614
interface ICpxState {
1715
pixels: number[][];
1816
brightness: number;

src/view/components/cpx/Cpx_svg_style.tsx

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,43 @@ export const POWER_LED_OFF: string = "#FFFFFF";
2424

2525
// Adapted from : https://github.com/microsoft/pxt/blob/master/pxtsim/simlib.ts
2626
export function rgbToHsl(
27-
rgb: [number, number, number]
27+
rgb: [number, number, number]
2828
): [number, number, number] {
29-
const [r, g, b] = rgb;
30-
const [r$, g$, b$] = [r / 255, g / 255, b / 255];
31-
const cMin = Math.min(r$, g$, b$);
32-
const cMax = Math.max(r$, g$, b$);
33-
const cDelta = cMax - cMin;
34-
let h: number = 0,
35-
s: number,
36-
l: number;
37-
const maxAndMin = cMax + cMin;
29+
const [r, g, b] = rgb;
30+
const [r$, g$, b$] = [r / 255, g / 255, b / 255];
31+
const cMin = Math.min(r$, g$, b$);
32+
const cMax = Math.max(r$, g$, b$);
33+
const cDelta = cMax - cMin;
34+
let h: number = 0,
35+
s: number,
36+
l: number;
37+
const maxAndMin = cMax + cMin;
3838

39-
// Luminosity
40-
l = (maxAndMin / 2) * 100;
39+
// Luminosity
40+
l = (maxAndMin / 2) * 100;
4141

42-
if (cDelta === 0) {
43-
s = 0;
44-
h = 0;
45-
} else {
46-
// Hue
47-
switch (cMax) {
48-
case r$:
49-
h = 60 * (((g$ - b$) / cDelta) % 6);
50-
break;
51-
case g$:
52-
h = 60 * ((b$ - r$) / cDelta + 2);
53-
break;
54-
case b$:
55-
h = 60 * ((r$ - g$) / cDelta + 4);
56-
break;
57-
}
42+
if (cDelta === 0) {
43+
s = 0;
44+
h = 0;
45+
} else {
46+
// Hue
47+
switch (cMax) {
48+
case r$:
49+
h = 60 * (((g$ - b$) / cDelta) % 6);
50+
break;
51+
case g$:
52+
h = 60 * ((b$ - r$) / cDelta + 2);
53+
break;
54+
case b$:
55+
h = 60 * ((r$ - g$) / cDelta + 4);
56+
break;
57+
}
5858

59-
// Saturation
60-
if (l > 50) { s = 100 * (cDelta / (2 - maxAndMin)); }
61-
else { s = 100 * (cDelta / maxAndMin); }
62-
}
59+
// Saturation
60+
l > 50 ? s = 100 * (cDelta / (2 - maxAndMin)) : s = 100 * (cDelta / maxAndMin);
61+
}
6362

64-
return [Math.floor(h), Math.floor(s), Math.floor(l)];
63+
return [Math.floor(h), Math.floor(s), Math.floor(l)];
6564
}
6665

6766
export const SVG_STYLE = `

src/view/container/device/Device.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,34 @@ import * as TOOLBAR_SVG from "../../svgs/toolbar_svg";
1212
const CPX_TOOLBAR_BUTTONS: Array<{ label: any, image: any }> = [{
1313
image: TOOLBAR_SVG.SLIDER_SWITCH_SVG,
1414
label: TOOLBAR_ICON_ID.SWITCH,
15-
}, {
15+
},{
1616
image: TOOLBAR_SVG.PUSH_BUTTON_SVG,
1717
label: TOOLBAR_ICON_ID.PUSH_BUTTON,
18-
},
19-
{
18+
},{
2019
image: TOOLBAR_SVG.RED_LED_SVG,
2120
label: TOOLBAR_ICON_ID.RED_LED,
22-
}, {
21+
},{
2322
image: TOOLBAR_SVG.SOUND_SVG,
2423
label: TOOLBAR_ICON_ID.SOUND,
25-
}
26-
, {
27-
image: TOOLBAR_SVG.TEMPERATURE_SVG,
24+
},{
25+
image: TOOLBAR_SVG.TEMPERATURE_SVG,
2826
label: TOOLBAR_ICON_ID.TEMPERATURE,
29-
}, {
27+
},{
3028
image: TOOLBAR_SVG.LIGHT_SVG,
3129
label: TOOLBAR_ICON_ID.LIGHT,
32-
}
33-
, {
34-
image: TOOLBAR_SVG.NEO_PIXEL_SVG,
30+
},{
31+
image: TOOLBAR_SVG.NEO_PIXEL_SVG,
3532
label: TOOLBAR_ICON_ID.NEO_PIXEL,
36-
}, {
33+
},{
3734
image: TOOLBAR_SVG.SPEAKER_SVG,
3835
label: TOOLBAR_ICON_ID.SPEAKER,
39-
}, {
36+
},{
4037
image: TOOLBAR_SVG.MOTION_SVG,
4138
label: TOOLBAR_ICON_ID.MOTION,
42-
}, {
39+
},{
4340
image: TOOLBAR_SVG.IR_SVG,
4441
label: TOOLBAR_ICON_ID.IR,
45-
}, {
42+
},{
4643
image: TOOLBAR_SVG.GPIO_SVG,
4744
label: TOOLBAR_ICON_ID.GPIO,
4845
}]

src/view/styles/ToolBar.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
border-width: 1px;
1616
border-style: solid;
1717
}
18+
1819
.toolbar-icon {
1920
box-shadow: 0px 0px 20px rgba(0, 0, 0, 30%);
2021
border-color: var(--vscode-highContrastButtonBorderOverride-color);

0 commit comments

Comments
 (0)