moved createPetActions into pet menu component
This commit is contained in:
@@ -13,45 +13,13 @@
|
|||||||
import DebugBar from "./components/debug-bar.svelte";
|
import DebugBar from "./components/debug-bar.svelte";
|
||||||
import Neko from "./components/neko/neko.svelte";
|
import Neko from "./components/neko/neko.svelte";
|
||||||
import PetMenu from "./components/pet-menu.svelte";
|
import PetMenu from "./components/pet-menu.svelte";
|
||||||
|
import { createPetActions } from "./components/pet-menu/events";
|
||||||
|
import type { UserBasicDto } from "$lib/bindings";
|
||||||
|
|
||||||
function createPetActions(name: string) {
|
function getFriend(friendId: string): UserBasicDto | undefined {
|
||||||
// TODO: replace `name` with full user object, onClicks with proper actions
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
icon: "👋",
|
|
||||||
label: `Wave at ${name}`,
|
|
||||||
onClick: () => {
|
|
||||||
console.log(`Wave at ${name}`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "💬",
|
|
||||||
label: `Message ${name}`,
|
|
||||||
onClick: () => {
|
|
||||||
console.log(`Message ${name}`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "🔔",
|
|
||||||
label: `Ping ${name}`,
|
|
||||||
onClick: () => {
|
|
||||||
console.log(`Ping ${name}`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: "🔎",
|
|
||||||
label: `Inspect ${name}`,
|
|
||||||
onClick: () => {
|
|
||||||
console.log(`Inspect ${name}`);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFriendName(friendId: string) {
|
|
||||||
return (
|
return (
|
||||||
($appData?.friends ?? []).find((friend) => friend.friend?.id === friendId)
|
($appData?.friends ?? []).find((friend) => friend.friend?.id === friendId)
|
||||||
?.friend?.name || friendId
|
?.friend ?? undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -73,7 +41,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#each Object.entries($friendsCursorPositions) as [friendId, position] (friendId)}
|
{#each Object.entries($friendsCursorPositions) as [friendId, position] (friendId)}
|
||||||
{#if $friendActiveDollSpriteUrls[friendId]}
|
{#if $friendActiveDollSpriteUrls[friendId]}
|
||||||
{@const friendName = getFriendName(friendId)}
|
{@const friend = getFriend(friendId)}
|
||||||
<Neko
|
<Neko
|
||||||
targetX={position.raw.x}
|
targetX={position.raw.x}
|
||||||
targetY={position.raw.y}
|
targetY={position.raw.y}
|
||||||
@@ -82,8 +50,8 @@
|
|||||||
initialY={position.raw.y}
|
initialY={position.raw.y}
|
||||||
>
|
>
|
||||||
<PetMenu
|
<PetMenu
|
||||||
actions={createPetActions(friendName)}
|
actions={createPetActions(friend!)}
|
||||||
ariaLabel={`Open ${friendName} actions`}
|
ariaLabel={`Open ${friend?.name} actions`}
|
||||||
/>
|
/>
|
||||||
</Neko>
|
</Neko>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,5 +1,40 @@
|
|||||||
|
import type { UserBasicDto } from "$lib/bindings";
|
||||||
|
|
||||||
export type CloseHandler = () => void;
|
export type CloseHandler = () => void;
|
||||||
|
|
||||||
|
export function createPetActions(user: UserBasicDto) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
icon: "👋",
|
||||||
|
label: `Wave at ${user.name}`,
|
||||||
|
onClick: () => {
|
||||||
|
console.log(`Wave at ${user.name}`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "💬",
|
||||||
|
label: `Message ${user.name}`,
|
||||||
|
onClick: () => {
|
||||||
|
console.log(`Message ${user.name}`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "🔔",
|
||||||
|
label: `Ping ${user.name}`,
|
||||||
|
onClick: () => {
|
||||||
|
console.log(`Ping ${user.name}`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: "🔎",
|
||||||
|
label: `Inspect ${user.name}`,
|
||||||
|
onClick: () => {
|
||||||
|
console.log(`Inspect ${user.name}`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export function createDocumentPointerHandler(
|
export function createDocumentPointerHandler(
|
||||||
isOpen: () => boolean,
|
isOpen: () => boolean,
|
||||||
rootEl: () => HTMLDivElement | null,
|
rootEl: () => HTMLDivElement | null,
|
||||||
|
|||||||
Reference in New Issue
Block a user