diff --git a/apps/client/src/widgets/type_widgets/options/appearance.css b/apps/client/src/widgets/type_widgets/options/appearance.css index b3357aecd1..cedfd81301 100644 --- a/apps/client/src/widgets/type_widgets/options/appearance.css +++ b/apps/client/src/widgets/type_widgets/options/appearance.css @@ -15,6 +15,21 @@ .tn-number-unit-pair { margin-bottom: 0 !important; } + + > .dropdown { + flex: 1; + min-width: 120px; + + > .select-button { + width: 100%; + text-align: left; + } + } +} + +.font-picker-dropdown { + max-height: 300px; + overflow-y: auto; } .orientation-illustration { diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx index 6861f3643f..5a382637b1 100644 --- a/apps/client/src/widgets/type_widgets/options/appearance.tsx +++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx @@ -1,6 +1,7 @@ import "./appearance.css"; import { FontFamily, OptionNames } from "@triliumnext/commons"; +import { Fragment } from "preact"; import { useEffect, useState } from "preact/hooks"; import zoomService from "../../../components/zoom"; @@ -12,7 +13,9 @@ import Button from "../../react/Button"; import Column from "../../react/Column"; import FormCheckbox from "../../react/FormCheckbox"; import FormGroup from "../../react/FormGroup"; -import FormSelect, { FormSelectWithGroups } from "../../react/FormSelect"; +import Dropdown from "../../react/Dropdown"; +import { FormListHeader, FormListItem } from "../../react/FormList"; +import FormSelect from "../../react/FormSelect"; import FormText from "../../react/FormText"; import { FormTextBoxWithUnit } from "../../react/FormTextBox"; import { useTriliumOption, useTriliumOptionBool } from "../../react/hooks"; @@ -352,10 +355,9 @@ function Font({ name, label, description, fontFamilyOption, fontSizeOption, disa return (
- void; + disabled?: boolean; +} + +function FontPicker({ currentValue, onChange, disabled }: FontPickerProps) { + // Find the current font entry to display in the button + const currentFont = FONT_FAMILIES + .flatMap(group => group.items) + .find(item => item.value === currentValue); + const displayLabel = currentFont?.label ?? currentFont?.value ?? currentValue ?? ""; + + // Get the CSS font-family value for preview + const getFontFamily = (value: string) => { + // Generic fonts don't need preview styling + if (["theme", "system"].includes(value)) { + return undefined; + } + return value; + }; + + return ( + {displayLabel}} + disabled={disabled} + dropdownContainerClassName="font-picker-dropdown" + > + {FONT_FAMILIES.map(group => ( + + + {group.items.map(item => ( + onChange(item.value)} + checked={currentValue === item.value} + selected={currentValue === item.value} + > + + {item.label ?? item.value} + + + ))} + + ))} + + ); +} + function ElectronIntegration() { const [ zoomFactor ] = useTriliumOption("zoomFactor"); const [ nativeTitleBarVisible, setNativeTitleBarVisible ] = useTriliumOptionBool("nativeTitleBarVisible");