mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 14:36:22 -05:00
The calculators have no Temperature calculator (#987)
The Celsius/Fahrenheit/Kelvin converter is removed from the Calculators page and from the search suggestions. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
d11b72bbd1
commit
bb7a66b0d6
3 changed files with 0 additions and 88 deletions
|
|
@ -2,7 +2,6 @@ import React from "react";
|
|||
import {Breadcrumbs, useTitle} from "./Common";
|
||||
import {Button, Header, Icon} from "./ui";
|
||||
import {useCalcQuery} from "../hooks/customHooks";
|
||||
import {TemperatureCalculator} from "./calculators/TemperatureCalculator";
|
||||
import {ElectricalCalculators} from "./calculators/ElectricalCalculators";
|
||||
import {DipoleAntennaCalculator} from "./calculators/HamCalculators";
|
||||
import {Link} from "react-router";
|
||||
|
|
@ -40,7 +39,6 @@ export const useCalculators = () => {
|
|||
{key: 'water', icon: 'tint', button: 'Water Storage', group: 'Preparedness & Storage', contents: <WaterCalculator/>},
|
||||
{key: 'ration', icon: 'food', button: 'Food Storage', group: 'Preparedness & Storage', contents: <FoodStorageCalculator/>},
|
||||
{key: 'antenna', icon: 'signal', button: 'Antenna', group: 'Radio & Communications', contents: <DipoleAntennaCalculator/>},
|
||||
{key: 'temperature', icon: 'thermometer', button: 'Temperature', group: 'Tools & Reference', contents: <TemperatureCalculator/>},
|
||||
{key: 'qrCode', icon: 'qrcode', button: 'QR Code', group: 'Tools & Reference', contents: <QRCodeCalculator/>},
|
||||
{key: 'otp', icon: 'lock', button: 'One Time Pad', title: 'One Time Pad', group: 'Radio & Communications', contents: <OneTimePadCalculator/>},
|
||||
{key: 'vin', icon: 'car', button: 'VIN Decoder', title: 'VIN Decoder', group: 'Tools & Reference', contents: <VinDecoderCalculator/>},
|
||||
|
|
|
|||
|
|
@ -49,11 +49,6 @@ const SUGGESTED_APPS = [
|
|||
{location: '/videos/channel', title: 'Channels', description: 'View the Channels of your Videos'},
|
||||
{location: '/zim', title: 'Zim', description: 'View your Zims'},
|
||||
{location: '/zim/manage', title: 'Manage Zim', description: 'Manage your Zims'},
|
||||
{
|
||||
location: '/more/calculators?calc=temperature',
|
||||
title: 'Temperature Calculator',
|
||||
description: 'Convert Celsius, Fahrenheit, Kelvin'
|
||||
},
|
||||
{
|
||||
location: '/more/calculators?calc=electrical',
|
||||
title: 'Electrical Calculator',
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
import React from "react";
|
||||
import {roundDigits} from "../Common";
|
||||
import {Grid, NumberInput} from "../ui";
|
||||
|
||||
export function TemperatureCalculator() {
|
||||
const [state, setState] = React.useState({
|
||||
celsius: '',
|
||||
fahrenheit: '',
|
||||
kelvin: '',
|
||||
})
|
||||
|
||||
const handleInputChange = (name, value) => {
|
||||
if (value === '' || value === undefined || value === null) {
|
||||
// User has cleared the input;
|
||||
setState({celsius: '', fahrenheit: '', kelvin: ''});
|
||||
return
|
||||
}
|
||||
|
||||
const stringValue = `${value}`;
|
||||
const numValue = parseFloat(stringValue.endsWith('.') ? `${stringValue}0` : stringValue);
|
||||
console.debug(`Calculating ${value} ${name}`);
|
||||
let newCelsius;
|
||||
let newKelvin;
|
||||
let newFahrenheit;
|
||||
if (name === 'fahrenheit') {
|
||||
newFahrenheit = value;
|
||||
newCelsius = roundDigits((numValue - 32) / 1.8);
|
||||
newKelvin = roundDigits(newCelsius + 273.15);
|
||||
} else if (name === 'celsius') {
|
||||
newCelsius = value;
|
||||
newFahrenheit = roundDigits((numValue * 1.8) + 32);
|
||||
newKelvin = roundDigits(numValue + 273.15);
|
||||
} else if (name === 'kelvin') {
|
||||
newKelvin = value;
|
||||
newCelsius = roundDigits(numValue - 273.15);
|
||||
newFahrenheit = roundDigits((newCelsius * 1.8) + 32);
|
||||
}
|
||||
if (newFahrenheit < -459.67) {
|
||||
console.warn('Temperature was below absolute zero!');
|
||||
newCelsius = -273.3;
|
||||
newFahrenheit = -459.67;
|
||||
newKelvin = 0;
|
||||
}
|
||||
setState({
|
||||
celsius: newCelsius,
|
||||
fahrenheit: newFahrenheit,
|
||||
kelvin: newKelvin
|
||||
});
|
||||
}
|
||||
|
||||
const handleClick = (e) => {
|
||||
e.target.select();
|
||||
}
|
||||
|
||||
return <Grid>
|
||||
<Grid.Col span={4}>
|
||||
<NumberInput
|
||||
value={state.celsius}
|
||||
rightSection='°C'
|
||||
onChange={value => handleInputChange('celsius', value)}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={4}>
|
||||
<NumberInput
|
||||
value={state.fahrenheit}
|
||||
rightSection='°F'
|
||||
onChange={value => handleInputChange('fahrenheit', value)}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={4}>
|
||||
<NumberInput
|
||||
value={state.kelvin}
|
||||
rightSection='K'
|
||||
onChange={value => handleInputChange('kelvin', value)}
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue