mirror of
https://github.com/zadam/trilium.git
synced 2025-12-12 18:34:24 +01:00
feat(widgets): menu item with toggle
This commit is contained in:
parent
84bde62e05
commit
8fa9c25f2a
@ -1,9 +1,24 @@
|
|||||||
.dropdown-item .description {
|
.dropdown-item {
|
||||||
|
.description {
|
||||||
font-size: small;
|
font-size: small;
|
||||||
color: var(--muted-text-color);
|
color: var(--muted-text-color);
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-item span.bx {
|
span.bx {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-widget {
|
||||||
|
flex-grow: 1;
|
||||||
|
width: 100%;
|
||||||
|
--switch-track-width: 40px;
|
||||||
|
--switch-track-height: 20px;
|
||||||
|
--switch-thumb-width: 12px;
|
||||||
|
--switch-thumb-height: var(--switch-thumb-width);
|
||||||
|
|
||||||
|
.switch-name {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@ import { CommandNames } from "../../components/app_context";
|
|||||||
import { useStaticTooltip } from "./hooks";
|
import { useStaticTooltip } from "./hooks";
|
||||||
import { handleRightToLeftPlacement, isMobile } from "../../services/utils";
|
import { handleRightToLeftPlacement, isMobile } from "../../services/utils";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import FormToggle from "./FormToggle";
|
||||||
|
|
||||||
interface FormListOpts {
|
interface FormListOpts {
|
||||||
children: ComponentChildren;
|
children: ComponentChildren;
|
||||||
@ -132,6 +133,18 @@ export function FormListItem({ className, icon, value, title, active, disabled,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function FormListToggleableItem({ title, currentValue, onChange, ...props }: Omit<FormListItemOpts, "onClick" | "children"> & {
|
||||||
|
title: string;
|
||||||
|
currentValue: boolean;
|
||||||
|
onChange(newValue: boolean): void;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<FormListItem {...props}>
|
||||||
|
<FormToggle switchOnName={title} switchOffName={title} currentValue={currentValue} onChange={onChange} />
|
||||||
|
</FormListItem>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function FormListContent({ children, badges, description, disabled, disabledTooltip }: Pick<FormListItemOpts, "children" | "badges" | "description" | "disabled" | "disabledTooltip">) {
|
function FormListContent({ children, badges, description, disabled, disabledTooltip }: Pick<FormListItemOpts, "children" | "badges" | "description" | "disabled" | "disabledTooltip">) {
|
||||||
return <>
|
return <>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@ -5,9 +5,9 @@ interface FormToggleProps {
|
|||||||
currentValue: boolean | null;
|
currentValue: boolean | null;
|
||||||
onChange(newValue: boolean): void;
|
onChange(newValue: boolean): void;
|
||||||
switchOnName: string;
|
switchOnName: string;
|
||||||
switchOnTooltip: string;
|
switchOnTooltip?: string;
|
||||||
switchOffName: string;
|
switchOffName: string;
|
||||||
switchOffTooltip: string;
|
switchOffTooltip?: string;
|
||||||
helpPage?: string;
|
helpPage?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
@ -37,5 +37,5 @@ export default function FormToggle({ currentValue, helpPage, switchOnName, switc
|
|||||||
|
|
||||||
{ helpPage && <HelpButton className="switch-help-button" helpPage={helpPage} />}
|
{ helpPage && <HelpButton className="switch-help-button" helpPage={helpPage} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user