fix: Context Menu positioning

This commit is contained in:
LynithDev 2024-05-11 21:18:25 +02:00
parent 4f4af3f3e2
commit f823d610d0
3 changed files with 31 additions and 2 deletions

View file

@ -1,7 +1,31 @@
import { invoke } from '@tauri-apps/api/core';
import { listen } from '@tauri-apps/api/event';
const _test_cluster = {
cluster: {
id: 'd09575a6-7c17-4399-a7a3-a117fffa5420',
name: 'Placeholder Name',
createdAt: 1715454720,
cover: null,
group: null,
client: {
type: 'Vanilla',
},
},
manifest: {
id: '1.0 cluster',
manifest: {
id: '1.8.9',
javaVersion: {
majorVersion: 8,
},
},
},
} as Core.ClusterWithManifest;
export async function getCluster(uuid: string): Promise<Core.ClusterWithManifest> {
return _test_cluster;
return await invoke<Core.ClusterWithManifest>(
'plugin:onelauncher|get_cluster',
{ uuid },
@ -29,6 +53,7 @@ export async function getClustersGrouped(): Promise<Map<string, WithIndex<Core.C
}
export async function getClusters(): Promise<Core.ClusterWithManifest[]> {
return [_test_cluster];
return await invoke<Core.ClusterWithManifest[]>('plugin:onelauncher|get_clusters');
}

View file

@ -30,6 +30,7 @@ export async function clearNotifications(): Promise<void> {
}
export async function getNotifications(): Promise<Core.Notification[]> {
return [];
return await invoke('plugin:onelauncher|notifications_get');
}

View file

@ -29,7 +29,10 @@ function ContextMenu(props: ContextMenuProps) {
return (
<Popup
style={{ top: `${pos().y}px`, left: `${pos().x}px` }}
ref={(el) => {
el.style.left = `${pos().x}px`;
el.style.top = `${pos().y}px`;
}}
visible={props.visible}
setVisible={props.setVisible}
>
@ -56,7 +59,7 @@ ContextMenu.Row = function (props: ContextMenuRowProps) {
return (
<div
onClick={e => props.onClick?.(e)}
class="flex items-center gap-x-2 m-px px-1.5 py-0.5 rounded-mdlg hover:bg-gray-0.05 active:bg-gray-0.10 [&>svg]:w-[18px]"
class="flex items-center gap-x-2 m-px px-1.5 py-0.5 rounded-lg hover:bg-gray-0.05 active:bg-gray-0.10 [&>svg]:w-[18px]"
>
{props.icon}
{props.text}