From 329265c08ca780c2f6a38bc879e54a46e5184903 Mon Sep 17 00:00:00 2001 From: Liontg6 Date: Sun, 14 Sep 2025 17:51:22 +0200 Subject: [PATCH 1/4] added a conversion folder with a celcius to fahrenheit tool --- i18n/de.json | 7 ++ i18n/en.json | 7 ++ .../conversion/celcius-to-fahrenheit/page.tsx | 67 +++++++++++++++++++ .../tempraturConverter.tsx | 18 +++++ src/lib/navigation.ts | 12 ++++ 5 files changed, 111 insertions(+) create mode 100644 src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx create mode 100644 src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx diff --git a/i18n/de.json b/i18n/de.json index 87c5dac..dc2abb9 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -75,6 +75,13 @@ "description": "Kodiert oder dekodiert Text als Base64" } }, + "conversion": { + "title": "Umrechnung", + "CelciusToFahrenheit": { + "title": "Celcius zu Fahrenheit", + "description": "Temperaturumrechner" + } + }, "color": { "title": "Farbe", "hexToHSL": { diff --git a/i18n/en.json b/i18n/en.json index c1c4b22..68b1071 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -79,6 +79,13 @@ "description": "Encode or decode text as Unicode Binary" } }, + "conversion": { + "title": "Conversion", + "CelciusToFahrenheit": { + "title": "Celcius To Fahrenheit", + "description": "Temperature Converter" + } + }, "color": { "title": "Color", "hexToHSL": { diff --git a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx new file mode 100644 index 0000000..ad1f992 --- /dev/null +++ b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx @@ -0,0 +1,67 @@ +"use client" +import { Section } from "@/components/ui/Section"; +import { useState } from "react"; +import { convertTemp } from "./tempraturConverter"; + +export default function TemperatureConverter() { + const [fahrenheit, setFahrenheit] = useState(""); + const [celsius, setCelsius] = useState(""); + // Handlers for input changes + function handleFahrenheitChange(e: React.ChangeEvent) { + const value = e.target.value; + setFahrenheit(value); + const num = parseFloat(value); + if (!isNaN(num)) { + setCelsius(convertTemp("FC", num).toFixed(2) + "°C"); + } else { + setCelsius(""); + } + } + + function handleCelsiusChange(e: React.ChangeEvent) { + const value = e.target.value; + setCelsius(value); + const num = parseFloat(value); + if (!isNaN(num)) { + setFahrenheit(convertTemp("CF", num).toFixed(2) + "°F"); + } else { + setFahrenheit(""); + } + } + + return ( +
+

Fahrenheit ⇄ Celsius Converter

+
+
+ + +
+ +
+ + +
+
+
+

Was macht dieser Converter?

+

+ Dieser Converter rechnet Temperaturen zwischen Fahrenheit und Celsius um. Gib einen Wert ein und erhalte sofort das Ergebnis in der anderen Einheit. +

+
+
+ ); +} + diff --git a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx new file mode 100644 index 0000000..a60f379 --- /dev/null +++ b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx @@ -0,0 +1,18 @@ +export function convertTemp(mode: string, input: number,): number{ + let newTemp: number; + if(mode == 'CF'){ + newTemp = CF(input); + }else{ + newTemp = FC(input); + } + return newTemp; +} + +export function CF(input: number): number{ + return input * 1.8 + 32 +} + +export function FC(input: number): number{ + return (input - 32)/1.8 +} + diff --git a/src/lib/navigation.ts b/src/lib/navigation.ts index 2d19e94..f8dc182 100644 --- a/src/lib/navigation.ts +++ b/src/lib/navigation.ts @@ -137,6 +137,18 @@ export const menuData: Array Date: Sat, 27 Sep 2025 16:09:56 +0200 Subject: [PATCH 2/4] fix: type conversion --- src/app/[locale]/(tools)/pdf/split/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/[locale]/(tools)/pdf/split/page.tsx b/src/app/[locale]/(tools)/pdf/split/page.tsx index 210b4f7..be1dedb 100644 --- a/src/app/[locale]/(tools)/pdf/split/page.tsx +++ b/src/app/[locale]/(tools)/pdf/split/page.tsx @@ -36,6 +36,7 @@ export default function PDFSplit() { (async () => { const newPdfFile = await PDFDocument.load(await file.arrayBuffer()); + setPdfFile(newPdfFile); setFileNameWithoutExtension(file.name.split(".").slice(0, -1).join(".")); @@ -81,7 +82,7 @@ export default function PDFSplit() { for (let i = 0; i < splittedPDFs.length; i++) { const pdf = splittedPDFs[i]; const pdfBytes = await pdf.save(); - const pdfReader = new BlobReader(new Blob([pdfBytes])); + const pdfReader = new BlobReader(new Blob([pdfBytes as BlobPart])); await zipWriter.add(`${fileNameWithoutExtension}-${i + 1}.pdf`, pdfReader); } From 77aa7aad1d3f5f5710730433cbca65424fef7997 Mon Sep 17 00:00:00 2001 From: Liontg6 Date: Sat, 27 Sep 2025 16:27:14 +0200 Subject: [PATCH 3/4] fix: format and pdf sample type conversion error --- .../conversion/celcius-to-fahrenheit/page.tsx | 14 ++++++++------ .../celcius-to-fahrenheit/tempraturConverter.tsx | 12 ++++++------ .../[locale]/(tools)/pdf/SampleGenerator/page.tsx | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx index ad1f992..0548bfb 100644 --- a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx +++ b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx @@ -11,22 +11,24 @@ export default function TemperatureConverter() { const value = e.target.value; setFahrenheit(value); const num = parseFloat(value); - if (!isNaN(num)) { - setCelsius(convertTemp("FC", num).toFixed(2) + "°C"); - } else { + + if (isNaN(num)) { setCelsius(""); + return; } + + setCelsius(convertTemp("FC", num).toFixed(2) + "°C"); } function handleCelsiusChange(e: React.ChangeEvent) { const value = e.target.value; setCelsius(value); const num = parseFloat(value); - if (!isNaN(num)) { - setFahrenheit(convertTemp("CF", num).toFixed(2) + "°F"); - } else { + if (isNaN(num)) { setFahrenheit(""); + return; } + setFahrenheit(convertTemp("CF", num).toFixed(2) + "°F"); } return ( diff --git a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx index a60f379..7efc513 100644 --- a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx +++ b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx @@ -1,18 +1,18 @@ -export function convertTemp(mode: string, input: number,): number{ +export function convertTemp(mode: "CF" | "FC", input: number): number { let newTemp: number; - if(mode == 'CF'){ + if (mode == 'CF') { newTemp = CF(input); - }else{ + } else { newTemp = FC(input); } return newTemp; } -export function CF(input: number): number{ +export function CF(input: number): number { return input * 1.8 + 32 } -export function FC(input: number): number{ - return (input - 32)/1.8 +export function FC(input: number): number { + return (input - 32) / 1.8 } diff --git a/src/app/[locale]/(tools)/pdf/SampleGenerator/page.tsx b/src/app/[locale]/(tools)/pdf/SampleGenerator/page.tsx index 4738ea8..9ddb9fe 100644 --- a/src/app/[locale]/(tools)/pdf/SampleGenerator/page.tsx +++ b/src/app/[locale]/(tools)/pdf/SampleGenerator/page.tsx @@ -50,7 +50,7 @@ export default function PDFSampleGenerator() { const pdfBytes = await pdfDoc.save() - const blob = new Blob([pdfBytes], { type: 'application/pdf' }); + const blob = new Blob([pdfBytes as BlobPart], { type: 'application/pdf' }); await saveBlobToFileWithDialog(blob); } From 633db905ea0b1ab95e97a2fd2ba6dd4e3f648d6c Mon Sep 17 00:00:00 2001 From: Liontg6 Date: Sat, 27 Sep 2025 17:11:15 +0200 Subject: [PATCH 4/4] add: translations --- i18n/de.json | 15 +++++++++++++-- i18n/en.json | 13 ++++++++++++- .../conversion/celcius-to-fahrenheit/page.tsx | 15 ++++++++++----- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/i18n/de.json b/i18n/de.json index dc2abb9..3cdd9ba 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -128,7 +128,7 @@ "title": "Hex zu HSL", "description": "Konvertiert eine Hex-Farbe in das HSL-Format.", "options": { - "valuesOnly": "In hsl(...) einfügen" + "valuesOnly": "In hsl(...) einfügen" } } }, @@ -141,6 +141,17 @@ "dropFiles": "Dateien hierhin ziehen und ablegen oder klicken, um auszuwählen" } } + }, + "conversion": { + "CelciusToFahrenheit": { + "title": "Fahrenheit ⇄ Celsius Rechner", + "fahrenheit": "Fahrenheit", + "celcius": "Celcius", + "description": { + "title": "Was macht dieser Converter?", + "text": "Dieser Converter rechnet Temperaturen zwischen Fahrenheit und Celsius um. Gib einen Wert ein und erhalte sofort das Ergebnis in der anderen Einheit." + } + } } }, "translationTable": { @@ -151,4 +162,4 @@ "swapSides": "Seiten tauschen", "clearInput": "Eingabe löschen" } -} +} \ No newline at end of file diff --git a/i18n/en.json b/i18n/en.json index 68b1071..d9d9a5a 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -138,7 +138,7 @@ "title": "Hex to HSL", "description": "Converts a hex color to HSL format.", "options": { - "valuesOnly": "Include in hsl(...)" + "valuesOnly": "Include in hsl(...)" } } }, @@ -151,6 +151,17 @@ "dropFiles": "Drag & drop files here, or click to select" } } + }, + "conversion": { + "CelciusToFahrenheit": { + "title": "Fahrenheit ⇄ Celsius converter", + "fahrenheit": "Fahrenheit", + "celcius": "Celcius", + "description": { + "title": "What does this converter do?", + "text": "This converter converts temperatures between Fahrenheit and Celsius. Enter a value and get the result in the other unit instantly." + } + } } }, "translationTable": { diff --git a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx index 0548bfb..1be343c 100644 --- a/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx +++ b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx @@ -2,10 +2,15 @@ import { Section } from "@/components/ui/Section"; import { useState } from "react"; import { convertTemp } from "./tempraturConverter"; +import { useTranslations } from "next-intl"; + export default function TemperatureConverter() { const [fahrenheit, setFahrenheit] = useState(""); const [celsius, setCelsius] = useState(""); + + const t = useTranslations("tools.conversion.CelciusToFahrenheit") + // Handlers for input changes function handleFahrenheitChange(e: React.ChangeEvent) { const value = e.target.value; @@ -33,10 +38,10 @@ export default function TemperatureConverter() { return (
-

Fahrenheit ⇄ Celsius Converter

+

{t("title")}

- +
- +
-

Was macht dieser Converter?

+

{t("description.title")}

- Dieser Converter rechnet Temperaturen zwischen Fahrenheit und Celsius um. Gib einen Wert ein und erhalte sofort das Ergebnis in der anderen Einheit. + {t("description.text")}