Skip to content

Commit 31bd56a

Browse files
authored
106 change led usage of width and height props (#108)
* Added height prop and set style.height to use it * Updated LED tests
1 parent c0f47de commit 31bd56a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/ui/widgets/LED/led.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,18 @@ describe("width property is used", (): void => {
8282
// so whatever is input has 5 subtracted from it, this makes it
8383
// look more like CS-Studio
8484
expect(renderedLed.props.style.width).toBe("5px");
85+
expect(renderedLed.props.style.height).toBe("15px");
86+
});
87+
});
88+
89+
describe("height property is used", (): void => {
90+
it("height changes the size of the LED", (): void => {
91+
const renderedLed = renderLed({ ...DEFAULT_PROPS, height: 10 });
92+
93+
// Width in CS-Studio doesn't quite match width in the browser,
94+
// so whatever is input has 5 subtracted from it, this makes it
95+
// look more like CS-Studio
96+
expect(renderedLed.props.style.width).toBe("15px");
8597
expect(renderedLed.props.style.height).toBe("5px");
8698
});
8799
});

src/ui/widgets/LED/led.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { WIDGET_DEFAULT_SIZES } from "../EmbeddedDisplay/bobParser";
1919
*/
2020
export const LedProps = {
2121
width: FloatPropOpt,
22+
height: FloatPropOpt,
2223
onColor: ColorPropOpt,
2324
offColor: ColorPropOpt,
2425
lineColor: ColorPropOpt,
@@ -41,6 +42,7 @@ export const LedComponent = (props: LedComponentProps): JSX.Element => {
4142
offColor = Color.fromRgba(60, 100, 60),
4243
lineColor = Color.fromRgba(50, 50, 50, 178),
4344
width = WIDGET_DEFAULT_SIZES["led"][0],
45+
height = WIDGET_DEFAULT_SIZES["led"][1],
4446
alarmSensitive = false,
4547
bit = -1
4648
} = props;
@@ -64,7 +66,7 @@ export const LedComponent = (props: LedComponentProps): JSX.Element => {
6466
// make sizes similar to size in CS-Studio, five taken
6567
// away from default in css file too
6668
style.width = `${width - 5}px`;
67-
style.height = `${width - 5}px`;
69+
style.height = `${height - 5}px`;
6870

6971
let className = classes.Led;
7072
if (alarmSensitive) {

0 commit comments

Comments
 (0)