diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css index a729b4d85..fa55b04a6 100644 --- a/apps/client/src/stylesheets/style.css +++ b/apps/client/src/stylesheets/style.css @@ -1738,7 +1738,7 @@ button.close:hover { margin-bottom: 10px; } -.options-number-input { +.options-section input[type="number"] { /* overriding settings from .form-control */ width: 10em !important; flex-grow: 0 !important; diff --git a/apps/client/src/widgets/react/Button.tsx b/apps/client/src/widgets/react/Button.tsx index 5262cae66..d18e4b5c6 100644 --- a/apps/client/src/widgets/react/Button.tsx +++ b/apps/client/src/widgets/react/Button.tsx @@ -14,11 +14,11 @@ interface ButtonProps { onClick?: () => void; primary?: boolean; disabled?: boolean; - small?: boolean; + size: "normal" | "small" | "micro"; style?: CSSProperties; } -const Button = memo(({ buttonRef: _buttonRef, className, text, onClick, keyboardShortcut, icon, primary, disabled, small, style }: ButtonProps) => { +const Button = memo(({ buttonRef: _buttonRef, className, text, onClick, keyboardShortcut, icon, primary, disabled, size, style }: ButtonProps) => { // Memoize classes array to prevent recreation const classes = useMemo(() => { const classList: string[] = ["btn"]; @@ -30,11 +30,13 @@ const Button = memo(({ buttonRef: _buttonRef, className, text, onClick, keyboard if (className) { classList.push(className); } - if (small) { + if (size === "small") { classList.push("btn-sm"); + } else if (size === "micro") { + classList.push("btn-micro"); } return classList.join(" "); - }, [primary, className, small]); + }, [primary, className, size]); const buttonRef = _buttonRef ?? useRef(null); diff --git a/apps/client/src/widgets/react/FormText.tsx b/apps/client/src/widgets/react/FormText.tsx new file mode 100644 index 000000000..76ea6c3e6 --- /dev/null +++ b/apps/client/src/widgets/react/FormText.tsx @@ -0,0 +1,5 @@ +import { ComponentChildren } from "preact"; + +export default function FormText({ children }: { children: ComponentChildren }) { + return

{children}

+} \ No newline at end of file diff --git a/apps/client/src/widgets/react/FormTextBox.tsx b/apps/client/src/widgets/react/FormTextBox.tsx index 5477a9c4d..a545fa66c 100644 --- a/apps/client/src/widgets/react/FormTextBox.tsx +++ b/apps/client/src/widgets/react/FormTextBox.tsx @@ -1,27 +1,31 @@ import type { InputHTMLAttributes, RefObject } from "preact/compat"; +import FormText from "./FormText"; -interface FormTextBoxProps extends Pick, "placeholder" | "autoComplete" | "className" | "type" | "name" | "pattern" | "title" | "style"> { +interface FormTextBoxProps extends Omit, "onChange" | "value"> { id?: string; currentValue?: string; onChange?(newValue: string): void; inputRef?: RefObject; } -export default function FormTextBox({ id, type, name, className, currentValue, onChange, autoComplete, inputRef, placeholder, title, pattern, style }: FormTextBoxProps) { +export default function FormTextBox({ inputRef, className, type, currentValue, onChange, ...rest}: FormTextBoxProps) { return ( onChange?.(e.currentTarget.value)} - style={style} + {...rest} /> ); +} + +export function FormTextBoxWithUnit(props: FormTextBoxProps & { unit: string }) { + return ( + + ) } \ No newline at end of file diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx index d10ccbc68..bdccb5b18 100644 --- a/apps/client/src/widgets/type_widgets/options/appearance.tsx +++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx @@ -10,6 +10,9 @@ import server from "../../../services/server"; import FormCheckbox from "../../react/FormCheckbox"; import FormGroup from "../../react/FormGroup"; import { FontFamily, OptionNames } from "@triliumnext/commons"; +import FormTextBox, { FormTextBoxWithUnit } from "../../react/FormTextBox"; +import FormText from "../../react/FormText"; +import Button from "../../react/Button"; interface Theme { val: string; @@ -146,22 +149,30 @@ function ApplicationTheme() { function Fonts() { return ( - - - - + + + + + + {t("fonts.note_tree_and_detail_font_sizing")} + {t("fonts.not_all_fonts_available")} + +

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

-`; - -export default class FontsOptions extends OptionsWidget { - private $mainFontSize!: JQuery; - private $mainFontFamily!: JQuery; - private $treeFontSize!: JQuery; - private $treeFontFamily!: JQuery; - private $detailFontSize!: JQuery; - private $detailFontFamily!: JQuery; - private $monospaceFontSize!: JQuery; - private $monospaceFontFamily!: JQuery; - - private _isEnabled?: boolean; - - doRender() { - this.$widget = $(TPL); - - this.$mainFontSize = this.$widget.find(".main-font-size"); - this.$mainFontFamily = this.$widget.find(".main-font-family"); - - this.$treeFontSize = this.$widget.find(".tree-font-size"); - this.$treeFontFamily = this.$widget.find(".tree-font-family"); - - this.$detailFontSize = this.$widget.find(".detail-font-size"); - this.$detailFontFamily = this.$widget.find(".detail-font-family"); - - this.$monospaceFontSize = this.$widget.find(".monospace-font-size"); - this.$monospaceFontFamily = this.$widget.find(".monospace-font-family"); - - this.$widget.find(".reload-frontend-button").on("click", () => utils.reloadFrontendApp("changes from appearance options")); - } - - isEnabled() { - return !!this._isEnabled; - } - - async optionsLoaded(options: OptionMap) { - this._isEnabled = options.overrideThemeFonts === "true"; - this.toggleInt(this._isEnabled); - if (!this._isEnabled) { - return; - } - - this.$mainFontSize.val(options.mainFontSize); - this.fillFontFamilyOptions(this.$mainFontFamily, options.mainFontFamily); - - this.$treeFontSize.val(options.treeFontSize); - this.fillFontFamilyOptions(this.$treeFontFamily, options.treeFontFamily); - - this.$detailFontSize.val(options.detailFontSize); - this.fillFontFamilyOptions(this.$detailFontFamily, options.detailFontFamily); - - this.$monospaceFontSize.val(options.monospaceFontSize); - this.fillFontFamilyOptions(this.$monospaceFontFamily, options.monospaceFontFamily); - - const optionsToSave: OptionNames[] = ["mainFontSize", "treeFontSize", "monospaceFontSize"]; - - for (const optionName of optionsToSave) { - const $el = (this as any)[`$${optionName}`]; - $el.on("change", () => this.updateOption(optionName, $el.val())); - } - } - -}