From 9cb79556eb55ff9d8ab31f4b63c45724da08125a Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Wed, 23 Jul 2025 16:55:13 +0100 Subject: [PATCH] Seperate out components --- .../convert/ConvertFromImageSettings.tsx | 41 ++++++++++ .../tools/convert/ConvertSettings.tsx | 79 ++++--------------- .../tools/convert/ConvertToImageSettings.tsx | 68 ++++++++++++++++ 3 files changed, 124 insertions(+), 64 deletions(-) create mode 100644 frontend/src/components/tools/convert/ConvertFromImageSettings.tsx create mode 100644 frontend/src/components/tools/convert/ConvertToImageSettings.tsx diff --git a/frontend/src/components/tools/convert/ConvertFromImageSettings.tsx b/frontend/src/components/tools/convert/ConvertFromImageSettings.tsx new file mode 100644 index 000000000..a272d90b3 --- /dev/null +++ b/frontend/src/components/tools/convert/ConvertFromImageSettings.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import { Stack, Text, Select } from "@mantine/core"; +import { useTranslation } from "react-i18next"; +import { COLOR_TYPES } from "../../../constants/convertConstants"; +import { ConvertParameters } from "../../../hooks/tools/convert/useConvertParameters"; + +interface ConvertFromImageSettingsProps { + parameters: ConvertParameters; + onParameterChange: (key: keyof ConvertParameters, value: any) => void; + disabled?: boolean; +} + +const ConvertFromImageSettings = ({ + parameters, + onParameterChange, + disabled = false +}: ConvertFromImageSettingsProps) => { + const { t } = useTranslation(); + + return ( + + {t("convert.pdfOptions", "PDF Options")}: + val && onParameterChange('imageOptions', { - ...parameters.imageOptions, - colorType: val as typeof COLOR_TYPES[keyof typeof COLOR_TYPES] - })} - data={[ - { value: COLOR_TYPES.COLOR, label: t("convert.color", "Color") }, - { value: COLOR_TYPES.GREYSCALE, label: t("convert.greyscale", "Greyscale") }, - { value: COLOR_TYPES.BLACK_WHITE, label: t("convert.blackwhite", "Black & White") }, - ]} - disabled={disabled} - /> - typeof val === 'number' && onParameterChange('imageOptions', { - ...parameters.imageOptions, - dpi: val - })} - min={72} - max={600} - step={1} - disabled={disabled} - /> - - val && onParameterChange('imageOptions', { - ...parameters.imageOptions, - colorType: val as typeof COLOR_TYPES[keyof typeof COLOR_TYPES] - })} - data={[ - { value: COLOR_TYPES.COLOR, label: t("convert.color", "Color") }, - { value: COLOR_TYPES.GREYSCALE, label: t("convert.greyscale", "Greyscale") }, - { value: COLOR_TYPES.BLACK_WHITE, label: t("convert.blackwhite", "Black & White") }, - ]} - disabled={disabled} - /> - + )} diff --git a/frontend/src/components/tools/convert/ConvertToImageSettings.tsx b/frontend/src/components/tools/convert/ConvertToImageSettings.tsx new file mode 100644 index 000000000..69a727d12 --- /dev/null +++ b/frontend/src/components/tools/convert/ConvertToImageSettings.tsx @@ -0,0 +1,68 @@ +import React from "react"; +import { Stack, Text, Select, NumberInput, Group } from "@mantine/core"; +import { useTranslation } from "react-i18next"; +import { COLOR_TYPES, OUTPUT_OPTIONS } from "../../../constants/convertConstants"; +import { ConvertParameters } from "../../../hooks/tools/convert/useConvertParameters"; + +interface ConvertToImageSettingsProps { + parameters: ConvertParameters; + onParameterChange: (key: keyof ConvertParameters, value: any) => void; + disabled?: boolean; +} + +const ConvertToImageSettings = ({ + parameters, + onParameterChange, + disabled = false +}: ConvertToImageSettingsProps) => { + const { t } = useTranslation(); + + return ( + + {t("convert.imageOptions", "Image Options")}: + + val && onParameterChange('imageOptions', { + ...parameters.imageOptions, + singleOrMultiple: val as typeof OUTPUT_OPTIONS[keyof typeof OUTPUT_OPTIONS] + })} + data={[ + { value: OUTPUT_OPTIONS.SINGLE, label: t("convert.single", "Single") }, + { value: OUTPUT_OPTIONS.MULTIPLE, label: t("convert.multiple", "Multiple") }, + ]} + disabled={disabled} + /> + + ); +}; + +export default ConvertToImageSettings; \ No newline at end of file