mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 15:25:51 +01:00
chore(react/collections): reintroduce calendar title & type touch bar
This commit is contained in:
@@ -26,6 +26,15 @@ interface ButtonProps {
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
interface SegmentedControlProps {
|
||||
mode: "single" | "buttons";
|
||||
segments: {
|
||||
label: string;
|
||||
}[];
|
||||
selectedIndex?: number;
|
||||
onChange?: (selectedIndex: number, isSelected: boolean) => void;
|
||||
}
|
||||
|
||||
interface TouchBarContextApi {
|
||||
addItem(item: TouchBarItem): void;
|
||||
TouchBar: typeof Electron.TouchBar;
|
||||
@@ -72,6 +81,8 @@ export default function TouchBar({ children }: TouchBarProps) {
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Touch bar state", isFocused, items);
|
||||
|
||||
return (
|
||||
<TouchBarContext.Provider value={api}>
|
||||
{children}
|
||||
@@ -119,3 +130,17 @@ export function TouchBarButton({ label, click, enabled }: ButtonProps) {
|
||||
|
||||
return <></>;
|
||||
}
|
||||
|
||||
export function TouchBarSegmentedControl({ mode, segments, selectedIndex, onChange }: SegmentedControlProps) {
|
||||
const api = useContext(TouchBarContext);
|
||||
|
||||
if (api) {
|
||||
const item = new api.TouchBar.TouchBarSegmentedControl({
|
||||
mode, segments, selectedIndex,
|
||||
change: onChange
|
||||
});
|
||||
api.addItem(item);
|
||||
}
|
||||
|
||||
return <></>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user