mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
chore(react/settings): fix a margin between radios
This commit is contained in:
parent
520effbbb7
commit
c039f06c2b
@ -11,23 +11,37 @@ interface FormRadioProps {
|
|||||||
onChange(newValue: string): void;
|
onChange(newValue: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function FormRadioGroup({ name, values, currentValue, onChange }: FormRadioProps) {
|
export default function FormRadioGroup({ values, ...restProps }: FormRadioProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{(values || []).map(({ value, label }) => (
|
{(values || []).map(({ value, label }) => (
|
||||||
<div className="form-checkbox">
|
<div className="form-checkbox">
|
||||||
<label className="form-check-label tn-radio">
|
<FormRadio value={value} label={label} {...restProps} labelClassName="form-check-label" />
|
||||||
<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>
|
|
||||||
</div>
|
</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>
|
||||||
|
)
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ import OptionsSection from "./components/OptionsSection";
|
|||||||
import { useTriliumOption, useTriliumOptionInt } from "../../react/hooks";
|
import { useTriliumOption, useTriliumOptionInt } from "../../react/hooks";
|
||||||
import type { Locale } from "@triliumnext/commons";
|
import type { Locale } from "@triliumnext/commons";
|
||||||
import { isElectron, restartDesktopApp } from "../../../services/utils";
|
import { isElectron, restartDesktopApp } from "../../../services/utils";
|
||||||
import FormRadioGroup from "../../react/FormRadioGroup";
|
import FormRadioGroup, { FormInlineRadioGroup } from "../../react/FormRadioGroup";
|
||||||
import FormText from "../../react/FormText";
|
import FormText from "../../react/FormText";
|
||||||
import RawHtml from "../../react/RawHtml";
|
import RawHtml from "../../react/RawHtml";
|
||||||
import Admonition from "../../react/Admonition";
|
import Admonition from "../../react/Admonition";
|
||||||
@ -63,14 +63,16 @@ function DateSettings() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<OptionsRow label={t("i18n.first-day-of-the-week")}>
|
<OptionsRow label={t("i18n.first-day-of-the-week")}>
|
||||||
<FormRadioGroup
|
<div role="group">
|
||||||
name="first-day-of-week"
|
<FormInlineRadioGroup
|
||||||
values={[
|
name="first-day-of-week"
|
||||||
{ value: "0", label: t("i18n.sunday") },
|
values={[
|
||||||
{ value: "1", label: t("i18n.monday") }
|
{ value: "0", label: t("i18n.sunday") },
|
||||||
]}
|
{ value: "1", label: t("i18n.monday") }
|
||||||
currentValue={firstDayOfWeek} onChange={setFirstDayOfWeek}
|
]}
|
||||||
/>
|
currentValue={firstDayOfWeek} onChange={setFirstDayOfWeek}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</OptionsRow>
|
</OptionsRow>
|
||||||
|
|
||||||
<OptionsRow label={t("i18n.first-week-of-the-year")}>
|
<OptionsRow label={t("i18n.first-week-of-the-year")}>
|
||||||
|
@ -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.);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user