Skip to content

Commit cc4eeab

Browse files
committed
Correct some of the spellings of thermometer
1 parent 65d183a commit cc4eeab

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

src/ui/widgets/Thermometer/themometer.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { render } from "@testing-library/react";
55
import * as d3 from "d3";
66
import {
77
calculateMercuryHeight,
8-
calculateThemometerDimensions,
8+
calculateThermometerDimensions,
99
ThermometerComponent
1010
} from "./thermometer";
1111
import { Color } from "../../../types/color";
@@ -54,8 +54,8 @@ describe("Thermometer Component", () => {
5454
}
5555
} as Partial<DType> as DType;
5656

57-
describe("calculateThemometerDimensions", () => {
58-
it("should calculate correct dimensions for maximum themometer width", () => {
57+
describe("calculateThermometerDimensions", () => {
58+
it("should calculate correct dimensions for maximum thermometer width", () => {
5959
beforeEach(() => {
6060
vi.clearAllMocks();
6161
});
@@ -67,7 +67,7 @@ describe("Thermometer Component", () => {
6767
const expectedVerticalStemHeight =
6868
156 - expectedStemHalfWidth - expectedBulbRadius - bulbUpperHeight;
6969

70-
const dimensions = calculateThemometerDimensions(44, 160);
70+
const dimensions = calculateThermometerDimensions(44, 160);
7171

7272
expect(dimensions.outerWidth).toBe(44);
7373
expect(dimensions.outerHeight).toBe(160);
@@ -105,7 +105,7 @@ describe("Thermometer Component", () => {
105105
const expectedVerticalStemHeight =
106106
156 - expectedStemHalfWidth - expectedBulbRadius - bulbUpperHeight;
107107

108-
const dimensions = calculateThemometerDimensions(26, 160);
108+
const dimensions = calculateThermometerDimensions(26, 160);
109109

110110
expect(dimensions.outerWidth).toBe(26);
111111
expect(dimensions.outerHeight).toBe(160);
@@ -135,15 +135,15 @@ describe("Thermometer Component", () => {
135135
expect(dimensions.bulbRadius).toBeCloseTo(expectedBulbRadius, 3);
136136
});
137137

138-
it("should calculate correct dimensions for squat themometer", () => {
138+
it("should calculate correct dimensions for squat thermometer", () => {
139139
const expectedStemHalfWidth = 10;
140140
const bulbUpperHeight = expectedStemHalfWidth / 0.80901699;
141141
const expectedBulbRadius = expectedStemHalfWidth / 0.587785;
142142
const expectedTopOfStemY = expectedStemHalfWidth + 2;
143143
const expectedVerticalStemHeight =
144144
36 - expectedStemHalfWidth - expectedBulbRadius - bulbUpperHeight;
145145

146-
const dimensions = calculateThemometerDimensions(64, 40);
146+
const dimensions = calculateThermometerDimensions(64, 40);
147147

148148
expect(dimensions.outerWidth).toBe(64);
149149
expect(dimensions.outerHeight).toBe(40);
@@ -254,7 +254,7 @@ describe("Thermometer Component", () => {
254254
expect(result.mercurySurfaceLevelY).toBe(250);
255255
});
256256

257-
it("should fix mercury level to the maxium when value above maximum", () => {
257+
it("should fix mercury level to the maximum when value above maximum", () => {
258258
const value = mockDType(120);
259259

260260
const result = calculateMercuryHeight(

src/ui/widgets/Thermometer/thermometer.tsx

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { DType } from "../../../types";
1616

1717
// This is the angle between vertical and the line from the center of the bulb to the intersection of the stem and bulb
1818
export const bulbStemAngle = Math.PI / 5;
19-
export const themometerOutlineWidth = 2;
19+
export const thermometerOutlineWidth = 2;
2020

2121
export const ThermometerComponentProps = {
2222
minimum: FloatPropOpt,
@@ -27,7 +27,7 @@ export const ThermometerComponentProps = {
2727
fillColor: ColorPropOpt
2828
};
2929

30-
interface ThermomemterDimensions {
30+
interface ThermometerDimensions {
3131
outerWidth: number;
3232
outerHeight: number;
3333
bulbCenterX: number;
@@ -63,8 +63,8 @@ export const ThermometerComponent = (
6363
[fillColor]
6464
);
6565

66-
const themometerDimensions = useMemo(
67-
() => calculateThemometerDimensions(width, height),
66+
const thermometerDimensions = useMemo(
67+
() => calculateThermometerDimensions(width, height),
6868
[width, height]
6969
);
7070

@@ -76,28 +76,28 @@ export const ThermometerComponent = (
7676

7777
useEffect(() => {
7878
// Build the thermometer outline.
79-
const thermometerPath = drawThermometerPathOutline(themometerDimensions);
80-
const mercuryBulbPath = drawMercuryBulbPath(themometerDimensions);
79+
const thermometerPath = drawThermometerPathOutline(thermometerDimensions);
80+
const mercuryBulbPath = drawMercuryBulbPath(thermometerDimensions);
8181

8282
// Create SVG
8383
const thermometerSvgGroup = d3
8484
.select(svgRef.current)
85-
.attr("width", themometerDimensions.outerWidth)
86-
.attr("height", themometerDimensions.outerHeight);
85+
.attr("width", thermometerDimensions.outerWidth)
86+
.attr("height", thermometerDimensions.outerHeight);
8787

8888
// Add the thermometer outline
8989
thermometerSvgGroup
9090
.append("path")
9191
.attr("d", thermometerPath.toString())
9292
.attr("fill", colors.backgroundColor.toString())
9393
.attr("stroke", colors.borderColor.toString())
94-
.style("stroke-width", themometerOutlineWidth);
94+
.style("stroke-width", thermometerOutlineWidth);
9595

9696
thermometerSvgGroup
9797
.append("path")
9898
.attr("d", mercuryBulbPath.toString())
9999
.attr("fill", colors.mercuryColor.toString());
100-
}, [themometerDimensions, colors]);
100+
}, [thermometerDimensions, colors]);
101101

102102
useEffect(() => {
103103
// Fill stem with the correct amount of mercury
@@ -109,24 +109,24 @@ export const ThermometerComponent = (
109109
value,
110110
minimum,
111111
maximum,
112-
themometerDimensions.verticalStemHeight,
113-
themometerDimensions.topOfStemY
112+
thermometerDimensions.verticalStemHeight,
113+
thermometerDimensions.topOfStemY
114114
);
115115

116116
d3.select(svgRef.current)
117117
.append("rect")
118118
.attr(
119119
"x",
120-
themometerDimensions.leftSideStemX + themometerOutlineWidth / 2
120+
thermometerDimensions.leftSideStemX + thermometerOutlineWidth / 2
121121
)
122122
.attr("y", mercurySurfaceLevelY)
123123
.attr(
124124
"width",
125-
2 * themometerDimensions.stemHalfWidth - themometerOutlineWidth
125+
2 * thermometerDimensions.stemHalfWidth - thermometerOutlineWidth
126126
)
127-
.attr("height", mercuryHeight + themometerOutlineWidth)
127+
.attr("height", mercuryHeight + thermometerOutlineWidth)
128128
.attr("fill", colors.mercuryColor.toString());
129-
}, [value, maximum, minimum, themometerDimensions, colors]);
129+
}, [value, maximum, minimum, thermometerDimensions, colors]);
130130

131131
return (
132132
<Box
@@ -151,43 +151,43 @@ const ThermometerWidgetProps = {
151151
};
152152

153153
const drawThermometerPathOutline = (
154-
themometerDimensions: ThermomemterDimensions
154+
thermometerDimensions: ThermometerDimensions
155155
) => {
156156
const thermometerPath = d3.path();
157157

158158
// Start at the top-left of the tube
159159
thermometerPath.moveTo(
160-
themometerDimensions.leftSideStemX,
161-
themometerDimensions.topOfStemY
160+
thermometerDimensions.leftSideStemX,
161+
thermometerDimensions.topOfStemY
162162
);
163163

164164
// Draw semi-circular top of the stem
165165
thermometerPath.arcTo(
166-
themometerDimensions.leftSideStemX,
167-
themometerDimensions.topOfStemY - themometerDimensions.stemHalfWidth,
168-
themometerDimensions.bulbCenterX,
169-
themometerDimensions.topOfStemY - themometerDimensions.stemHalfWidth,
170-
themometerDimensions.stemHalfWidth
166+
thermometerDimensions.leftSideStemX,
167+
thermometerDimensions.topOfStemY - thermometerDimensions.stemHalfWidth,
168+
thermometerDimensions.bulbCenterX,
169+
thermometerDimensions.topOfStemY - thermometerDimensions.stemHalfWidth,
170+
thermometerDimensions.stemHalfWidth
171171
);
172172
thermometerPath.arcTo(
173-
themometerDimensions.rightSideStemX,
174-
themometerDimensions.topOfStemY - themometerDimensions.stemHalfWidth,
175-
themometerDimensions.rightSideStemX,
176-
themometerDimensions.topOfStemY,
177-
themometerDimensions.stemHalfWidth
173+
thermometerDimensions.rightSideStemX,
174+
thermometerDimensions.topOfStemY - thermometerDimensions.stemHalfWidth,
175+
thermometerDimensions.rightSideStemX,
176+
thermometerDimensions.topOfStemY,
177+
thermometerDimensions.stemHalfWidth
178178
);
179179

180180
// Draw right side of stem
181181
thermometerPath.lineTo(
182-
themometerDimensions.rightSideStemX,
183-
themometerDimensions.bottomOfStemY
182+
thermometerDimensions.rightSideStemX,
183+
thermometerDimensions.bottomOfStemY
184184
);
185185

186186
// Draw the bulb outline. Rotate angle by pi/2, to make relative to horizontal axis, rather than vertical.
187187
thermometerPath.arc(
188-
themometerDimensions.bulbCenterX,
189-
themometerDimensions.bulbCenterY,
190-
themometerDimensions.bulbRadius,
188+
thermometerDimensions.bulbCenterX,
189+
thermometerDimensions.bulbCenterY,
190+
thermometerDimensions.bulbRadius,
191191
bulbStemAngle - Math.PI / 2,
192192
-bulbStemAngle - Math.PI / 2,
193193
false
@@ -197,24 +197,24 @@ const drawThermometerPathOutline = (
197197
return thermometerPath;
198198
};
199199

200-
const drawMercuryBulbPath = (themometerDimensions: ThermomemterDimensions) => {
201-
// very similar to the thermometer outline bulb, but corrected for half the width of the thermomemter outline.
200+
const drawMercuryBulbPath = (thermometerDimensions: ThermometerDimensions) => {
201+
// very similar to the thermometer outline bulb, but corrected for half the width of the thermometer outline.
202202
const mercuryBulbPath = d3.path();
203203

204204
const bulbTopRightX =
205-
themometerDimensions.rightSideStemX -
206-
themometerOutlineWidth * 0.5 * Math.cos(bulbStemAngle);
205+
thermometerDimensions.rightSideStemX -
206+
thermometerOutlineWidth * 0.5 * Math.cos(bulbStemAngle);
207207
const bulbTopRightY =
208-
themometerDimensions.bottomOfStemY +
209-
themometerOutlineWidth * 0.5 * Math.sin(bulbStemAngle);
208+
thermometerDimensions.bottomOfStemY +
209+
thermometerOutlineWidth * 0.5 * Math.sin(bulbStemAngle);
210210

211211
mercuryBulbPath.moveTo(bulbTopRightX, bulbTopRightY);
212212

213213
// Draw the bulb outline
214214
mercuryBulbPath.arc(
215-
themometerDimensions.bulbCenterX,
216-
themometerDimensions.bulbCenterY,
217-
themometerDimensions.bulbRadius - themometerOutlineWidth * 0.5,
215+
thermometerDimensions.bulbCenterX,
216+
thermometerDimensions.bulbCenterY,
217+
thermometerDimensions.bulbRadius - thermometerOutlineWidth * 0.5,
218218
bulbStemAngle - Math.PI / 2,
219219
-bulbStemAngle - Math.PI / 2,
220220
false
@@ -224,13 +224,13 @@ const drawMercuryBulbPath = (themometerDimensions: ThermomemterDimensions) => {
224224
return mercuryBulbPath;
225225
};
226226

227-
export const calculateThemometerDimensions = (
227+
export const calculateThermometerDimensions = (
228228
width: number,
229229
height: number
230-
): ThermomemterDimensions => {
230+
): ThermometerDimensions => {
231231
// allow padding around the thermometer
232-
const innerWidth = width - themometerOutlineWidth;
233-
const innerHeight = height - themometerOutlineWidth - 2;
232+
const innerWidth = width - thermometerOutlineWidth;
233+
const innerHeight = height - thermometerOutlineWidth - 2;
234234

235235
// Stem half width is minimum of 10 or a quarter of the innerWidth
236236
const stemHalfWidth = Math.min(10, innerWidth * 0.25);
@@ -241,7 +241,7 @@ export const calculateThemometerDimensions = (
241241

242242
const verticalStemHeight =
243243
innerHeight - stemHalfWidth - bulbRadius - bulbUpperHeight;
244-
const topOfStemY = stemHalfWidth + 1 + 0.5 * themometerOutlineWidth;
244+
const topOfStemY = stemHalfWidth + 1 + 0.5 * thermometerOutlineWidth;
245245

246246
return {
247247
outerHeight: height,

0 commit comments

Comments
 (0)