Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(react/settings): fix a margin between radios
Elian Doranc039f06c2b4b
diff --git a/apps/client/src/widgets/react/FormRadioGroup.tsx b/apps/client/src/widgets/react/FormRadioGroup.tsxindex e2264bfe41..ccfd0cf849 100644--- a/apps/client/src/widgets/react/FormRadioGroup.tsx+++ b/apps/client/src/widgets/react/FormRadioGroup.tsx@@ -11,23 +11,37 @@ interface FormRadioProps {onChange(newValue: string): void;}-export default function FormRadioGroup({ name, values, currentValue, onChange }: FormRadioProps) {+export default function FormRadioGroup({ values, ...restProps }: FormRadioProps) {return (<>{(values || []).map(({ value, label }) => (<div className="form-checkbox">- <label className="form-check-label tn-radio">- <input- className="form-check-input"- type="radio"- name={useUniqueName(name)}- value={value}- checked={value === currentValue}- onChange={e => onChange((e.target as HTMLInputElement).value)} />- {label}- </label>+ <FormRadio value={value} label={label} {...restProps} labelClassName="form-check-label" /></div>))}</>);+}++export function FormInlineRadioGroup({ values, ...restProps }: FormRadioProps) {+ return (+ <>+ {values.map(({ value, label }) => (<FormRadio value={value} label={label} {...restProps} />))}+ </>+ )+}++function FormRadio({ name, value, label, currentValue, onChange, labelClassName }: Omit<FormRadioProps, "values"> & { value: string, label: ComponentChildren, labelClassName?: string }) {+ return (+ <label className={`tn-radio ${labelClassName ?? ""}`}>+ <input+ className="form-check-input"+ type="radio"+ name={useUniqueName(name)}+ value={value}+ checked={value === currentValue}+ onChange={e => onChange((e.target as HTMLInputElement).value)} />+ {label}+ </label>+ )}\ No newline at end of filediff --git a/apps/client/src/widgets/type_widgets/options/i18n.tsx b/apps/client/src/widgets/type_widgets/options/i18n.tsxindex bd63c21793..796e3b0f44 100644--- a/apps/client/src/widgets/type_widgets/options/i18n.tsx+++ b/apps/client/src/widgets/type_widgets/options/i18n.tsx@@ -6,7 +6,7 @@ import OptionsSection from "./components/OptionsSection";import { useTriliumOption, useTriliumOptionInt } from "../../react/hooks";import type { Locale } from "@triliumnext/commons";import { isElectron, restartDesktopApp } from "../../../services/utils";-import FormRadioGroup from "../../react/FormRadioGroup";+import FormRadioGroup, { FormInlineRadioGroup } from "../../react/FormRadioGroup";import FormText from "../../react/FormText";import RawHtml from "../../react/RawHtml";import Admonition from "../../react/Admonition";@@ -63,14 +63,16 @@ function DateSettings() {return (<><OptionsRow label={t("i18n.first-day-of-the-week")}>- <FormRadioGroup- name="first-day-of-week"- values={[- { value: "0", label: t("i18n.sunday") },- { value: "1", label: t("i18n.monday") }- ]}- currentValue={firstDayOfWeek} onChange={setFirstDayOfWeek}- />+ <div role="group">+ <FormInlineRadioGroup+ name="first-day-of-week"+ values={[+ { value: "0", label: t("i18n.sunday") },+ { value: "1", label: t("i18n.monday") }+ ]}+ currentValue={firstDayOfWeek} onChange={setFirstDayOfWeek}+ />+ </div></OptionsRow><OptionsRow label={t("i18n.first-week-of-the-year")}>diff --git a/apps/client/src/widgets/type_widgets/options/i18n/i18n.ts b/apps/client/src/widgets/type_widgets/options/i18n/i18n.tsdeleted file mode 100644index 6c53cf6258..0000000000--- a/apps/client/src/widgets/type_widgets/options/i18n/i18n.ts+++ /dev/null@@ -1,29 +0,0 @@-import OptionsWidget from "../options_widget.js";-import server from "../../../../services/server.js";-import utils from "../../../../services/utils.js";-import { getAvailableLocales, t } from "../../../../services/i18n.js";--const TPL = /*html*/`-<div class="options-section">- <style>- .locale-options-container .option-row [aria-labelledby="first-week-of-year-label"] {- display: flex;- flex-direction: column;- }-- .locale-options-container .option-row [aria-labelledby="first-week-of-year-label"] .tn-radio {- margin-left: 0;- white-space: nowrap;- }- </style>-</div>-`;--export default class LocalizationOptions extends OptionsWidget {-- doRender() {- this.$widget = $(TPL);- this.$widget.find(".restart-app-button").on("click", utils.);- }--}