diff --git a/i18n/de.json b/i18n/de.json index 87c5dac..3cdd9ba 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": { @@ -121,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" } } }, @@ -134,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": { @@ -144,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 c1c4b22..d9d9a5a 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": { @@ -131,7 +138,7 @@ "title": "Hex to HSL", "description": "Converts a hex color to HSL format.", "options": { - "valuesOnly": "Include in hsl(...)" + "valuesOnly": "Include in hsl(...)" } } }, @@ -144,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 new file mode 100644 index 0000000..1be343c --- /dev/null +++ b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/page.tsx @@ -0,0 +1,74 @@ +"use client" +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; + setFahrenheit(value); + const num = parseFloat(value); + + 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(""); + return; + } + setFahrenheit(convertTemp("CF", num).toFixed(2) + "°F"); + } + + return ( +
+

{t("title")}

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

{t("description.title")}

+

+ {t("description.text")} +

+
+
+ ); +} + 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..7efc513 --- /dev/null +++ b/src/app/[locale]/(tools)/conversion/celcius-to-fahrenheit/tempraturConverter.tsx @@ -0,0 +1,18 @@ +export function convertTemp(mode: "CF" | "FC", 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/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); } 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); } 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