From 64bffb82b16263639dfedee111f5b09719b51ec0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 14 Aug 2025 21:55:16 +0300 Subject: [PATCH] feat(react/settings): port max content width --- apps/client/src/widgets/react/FormTextBox.tsx | 9 ++++ .../type_widgets/options/appearance.tsx | 30 +++++++++++- .../options/appearance/max_content_width.ts | 47 ------------------- 3 files changed, 38 insertions(+), 48 deletions(-) delete mode 100644 apps/client/src/widgets/type_widgets/options/appearance/max_content_width.ts diff --git a/apps/client/src/widgets/react/FormTextBox.tsx b/apps/client/src/widgets/react/FormTextBox.tsx index a545fa66c..abf0e9c5a 100644 --- a/apps/client/src/widgets/react/FormTextBox.tsx +++ b/apps/client/src/widgets/react/FormTextBox.tsx @@ -9,6 +9,15 @@ interface FormTextBoxProps extends Omit, " } export default function FormTextBox({ inputRef, className, type, currentValue, onChange, ...rest}: FormTextBoxProps) { + if (type === "number" && currentValue) { + const { min, max } = rest; + if (min && currentValue < min) { + currentValue = String(min); + } else if (max && currentValue > max) { + currentValue = String(max); + } + } + return ( {overrideThemeFonts === "true" && } {isElectron() && } + ) } @@ -159,7 +162,7 @@ function Fonts() { {t("fonts.not_all_fonts_available")}

- {t("fonts.apply_font_changes")} -

-`; - -export default class MaxContentWidthOptions extends OptionsWidget { - - private $maxContentWidth!: JQuery; - - doRender() { - this.$widget = $(TPL); - - this.$maxContentWidth = this.$widget.find(".max-content-width"); - - this.$maxContentWidth.on("change", async () => this.updateOption("maxContentWidth", String(this.$maxContentWidth.val()))); - - this.$widget.find(".reload-frontend-button").on("click", () => utils.reloadFrontendApp(t("max_content_width.reload_description"))); - } - - async optionsLoaded(options: OptionMap) { - this.$maxContentWidth.val(Math.max(MIN_VALUE, parseInt(options.maxContentWidth, 10))); - } -}