mirror of
https://github.com/zadam/trilium.git
synced 2025-12-06 15:34:26 +01:00
refactor(launch_bar): deduplicate launcher note props
This commit is contained in:
parent
a107c126e4
commit
a53322e7cb
@ -1,6 +1,6 @@
|
||||
import { Dispatch, StateUpdater, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
||||
import FNote from "../../entities/fnote";
|
||||
import { LaunchBarDropdownButton, useLauncherIconAndTitle } from "./launch_bar_widgets";
|
||||
import { LaunchBarDropdownButton, LauncherNoteProps, useLauncherIconAndTitle } from "./launch_bar_widgets";
|
||||
import { Dayjs, dayjs } from "@triliumnext/commons";
|
||||
import appContext from "../../components/app_context";
|
||||
import "./CalendarWidget.css";
|
||||
@ -30,7 +30,7 @@ const MONTHS = [
|
||||
t("calendar.december")
|
||||
];
|
||||
|
||||
export default function CalendarWidget({ launcherNote }: { launcherNote: FNote }) {
|
||||
export default function CalendarWidget({ launcherNote }: LauncherNoteProps) {
|
||||
const { title, icon } = useLauncherIconAndTitle(launcherNote);
|
||||
const [ calendarArgs, setCalendarArgs ] = useState<Pick<CalendarArgs, "activeDate" | "todaysDate">>();
|
||||
const [ date, setDate ] = useState<Dayjs>();
|
||||
|
||||
@ -7,12 +7,12 @@ import QuickSearchWidget from "../quick_search";
|
||||
import { isMobile } from "../../services/utils";
|
||||
import date_notes from "../../services/date_notes";
|
||||
import { CustomNoteLauncher } from "./GenericButtons";
|
||||
import { LaunchBarActionButton, LaunchBarContext, useLauncherIconAndTitle } from "./launch_bar_widgets";
|
||||
import { LaunchBarActionButton, LaunchBarContext, LauncherNoteProps, useLauncherIconAndTitle } from "./launch_bar_widgets";
|
||||
import dialog from "../../services/dialog";
|
||||
import { t } from "../../services/i18n";
|
||||
import { CommandNames } from "../../components/app_context";
|
||||
|
||||
export function CommandButton({ launcherNote }: { launcherNote: FNote }) {
|
||||
export function CommandButton({ launcherNote }: LauncherNoteProps) {
|
||||
const { icon, title } = useLauncherIconAndTitle(launcherNote);
|
||||
const [ command ] = useNoteLabel(launcherNote, "command");
|
||||
|
||||
@ -50,7 +50,7 @@ export function NoteLauncher({ launcherNote, ...restProps }: { launcherNote: FNo
|
||||
);
|
||||
}
|
||||
|
||||
export function ScriptLauncher({ launcherNote }: { launcherNote: FNote }) {
|
||||
export function ScriptLauncher({ launcherNote }: LauncherNoteProps) {
|
||||
const { icon, title } = useLauncherIconAndTitle(launcherNote);
|
||||
return (
|
||||
<LaunchBarActionButton
|
||||
@ -70,7 +70,7 @@ export function ScriptLauncher({ launcherNote }: { launcherNote: FNote }) {
|
||||
)
|
||||
}
|
||||
|
||||
export default function AiChatButton({ launcherNote }: { launcherNote: FNote }) {
|
||||
export default function AiChatButton({ launcherNote }: LauncherNoteProps) {
|
||||
const [ aiEnabled ] = useTriliumOptionBool("aiEnabled");
|
||||
const { icon, title } = useLauncherIconAndTitle(launcherNote);
|
||||
|
||||
@ -83,7 +83,7 @@ export default function AiChatButton({ launcherNote }: { launcherNote: FNote })
|
||||
)
|
||||
}
|
||||
|
||||
export function TodayLauncher({ launcherNote }: { launcherNote: FNote }) {
|
||||
export function TodayLauncher({ launcherNote }: LauncherNoteProps) {
|
||||
return (
|
||||
<CustomNoteLauncher
|
||||
launcherNote={launcherNote}
|
||||
@ -109,7 +109,7 @@ export function QuickSearchLauncherWidget() {
|
||||
)
|
||||
}
|
||||
|
||||
export function CustomWidget({ launcherNote }: { launcherNote: FNote }) {
|
||||
export function CustomWidget({ launcherNote }: LauncherNoteProps) {
|
||||
const [ widgetNote ] = useNoteRelationTarget(launcherNote, "widget");
|
||||
const [ widget, setWidget ] = useState<BasicWidget>();
|
||||
const parentComponent = useContext(ParentComponent) as BasicWidget | null;
|
||||
|
||||
@ -13,6 +13,11 @@ export const LaunchBarContext = createContext<{
|
||||
isHorizontalLayout: false
|
||||
})
|
||||
|
||||
export interface LauncherNoteProps {
|
||||
/** The corresponding {@link FNote} of type {@code launcher} in the hidden subtree of this launcher. Generally this launcher note holds information about the launcher via labels and relations, but also the title and the icon of the launcher. Not to be confused with the target note, which is specific to some launchers. */
|
||||
launcherNote: FNote;
|
||||
}
|
||||
|
||||
export function LaunchBarActionButton(props: Omit<ActionButtonProps, "className" | "noIconActionClass" | "titlePosition">) {
|
||||
const { isHorizontalLayout } = useContext(LaunchBarContext);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user