add tooltip stuff

[deploy]
This commit is contained in:
2023-07-18 01:40:30 +02:00
parent 4eb1e8c049
commit b04ed7fe7f
24 changed files with 1161 additions and 5143 deletions

View File

@@ -0,0 +1,16 @@
<script lang="ts">
import {layout} from "$lib/serial/connection"
import {KEYMAP_CODES} from "$lib/serial/keymap-codes"
export let id: number = 0
</script>
<table>
{#each $layout as layer, i}
{@const action = KEYMAP_CODES[layer[id]]}
<tr>
<th class="icon">counter_{i + 1}</th>
<td>{action?.id}</td>
</tr>
{/each}
</table>

View File

@@ -3,6 +3,7 @@
import type {CharaLayout} from "$lib/serialization/layout"
import {KEYMAP_CODES} from "$lib/serial/keymap-codes"
import type {KeyInfo} from "$lib/serial/keymap-codes"
import {editableLayout} from "$lib/editable-layout"
export let activeLayer = 0
export let keys: Record<"d" | "s" | "n" | "w" | "e", number>
@@ -19,13 +20,6 @@
return 25 * quadrant + layerOffsetIndex * layerOffset
}
function getKeyDescriptions(keys: KeyInfo[]): string {
return keys
.filter(it => !!it)
.map(({title, id, code}, i) => `${title || id || code} (${layerNames[i]})`)
.join("\n")
}
function getActions(id: number, layout: CharaLayout): KeyInfo[] {
return Array.from({length: 3}).map((_, i) => {
const actionId = layout?.[i][id]
@@ -38,7 +32,7 @@
{#each [keys.n, keys.e, keys.s, keys.w] as id, quadrant}
{@const actions = getActions(id, $layout)}
<button
title={getKeyDescriptions(actions)}
use:editableLayout={{id, quadrant}}
class:active={actions.some(it => it && $highlightActions?.includes(it.code))}
>
{#each actions as keyInfo, layer}