Debian Codegraph @

frontend/src/reports/editor/AppMenuSubItem.svelte

raw
1 <!--
2 @component
3 A sub-item in an app menu.
4 -->
5 <script lang="ts">
6 import type { Snippet } from "svelte";
7
8 interface Props {
9 /** A title (optional) for the element. */
10 title?: string;
11 /** Whether this menu item should be marked as selected. */
12 selected?: boolean;
13 /** The action to execute on click. */
14 action: () => void;
15 children: Snippet;
16 right?: Snippet;
17 }
18
19 let { title, selected = false, action, children, right }: Props = $props();
20 </script>
21
22 <li
23 class:selected
24 {title}
25 role="menuitem"
26 onclick={action}
27 onkeydown={(event) => {
28 if (event.key === "Enter") {
29 action();
30 }
31 }}
32 >
33 {@render children()}
34 {#if right}
35 <span>
36 {@render right()}
37 </span>
38 {/if}
39 </li>
40
41 <style>
42 .selected::before {
43 content: "›";
44 }
45
46 li {
47 padding: 0.25em 0.5em;
48 }
49
50 span {
51 float: right;
52 }
53
54 li:hover,
55 li:focus-visible {
56 background-color: var(--background-darker);
57 }
58 </style>