Skip to content
Prev Previous commit
Next Next commit
fix: Make tap_action work on labels
  • Loading branch information
MindFreeze committed Jan 27, 2026
commit a3ae2afd799142ebbb94e8670f7f15b373a9007a
12 changes: 6 additions & 6 deletions __tests__/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ exports[`SankeyChart matches a simple snapshot 2`] = `

<div class="spacerv" style="height:2.5px;"></div>

<div class="box type-entity" style="height:195px;">
<div style="background-color:var(--primary-color);" title="2W " class="">
<div class="box type-entity" style="height:195px;" title="2W ">
<div style="background-color:var(--primary-color);" class="">

</div>
<div class="label" style="line-height:15px;">
Expand All @@ -59,8 +59,8 @@ exports[`SankeyChart matches a simple snapshot 2`] = `



<div class="box type-entity" style="height:97px;">
<div style="background-color:var(--primary-color);" title="1W " class="">
<div class="box type-entity" style="height:97px;" title="1W ">
<div style="background-color:var(--primary-color);" class="">

</div>
<div class="label" style="line-height:15px;">
Expand All @@ -74,8 +74,8 @@ exports[`SankeyChart matches a simple snapshot 2`] = `

<div class="spacerv" style="height:6px;"></div>

<div class="box type-entity" style="height:97px;">
<div style="background-color:var(--primary-color);" title="1W " class="">
<div class="box type-entity" style="height:97px;" title="1W ">
<div style="background-color:var(--primary-color);" class="">

</div>
<div class="label" style="line-height:15px;">
Expand Down
32 changes: 16 additions & 16 deletions __tests__/__snapshots__/remaining.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ exports[`SankeyChart with remaining type entities matches snapshot 2`] = `

<div class="spacerv" style="height:69.5px;"></div>

<div class="box type-entity" style="height:61px;">
<div style="background-color:var(--warning-color);" title="1.8kW Total" class="">
<div class="box type-entity" style="height:61px;" title="1.8kW Total">
<div style="background-color:var(--warning-color);" class="">

</div>
<div class="label" style="line-height:15px;">
Expand Down Expand Up @@ -80,8 +80,7 @@ exports[`SankeyChart with remaining type entities matches snapshot 2`] = `

<div class="spacerv" style="height:5px;"></div>

<div class="box type-remaining_child_state" style="height:190px;">
<div style="background-color:darkslateblue;" title="5.6kW Total
<div class="box type-remaining_child_state" style="height:190px;" title="5.6kW Total
All
All
All
Expand All @@ -95,7 +94,8 @@ IDK
IDK
IDK
IDK
IDK" class="">
IDK">
<div style="background-color:darkslateblue;" class="">

</div>
<div class="label" style="line-height:15px;">
Expand Down Expand Up @@ -145,9 +145,9 @@ IDK" class="">



<div class="box type-entity" style="height:63px;">
<div style="background-color:var(--primary-color);" title="1.9kW Varmtvann
Blaa" class="">
<div class="box type-entity" style="height:63px;" title="1.9kW Varmtvann
Blaa">
<div style="background-color:var(--primary-color);" class="">

</div>
<div class="label" style="line-height:15px;">
Expand All @@ -161,8 +161,8 @@ Blaa" class="">

<div class="spacerv" style="height:5.5px;"></div>

<div class="box type-entity" style="height:63px;">
<div style="background-color:var(--primary-color);" title="1.9kВ Avfukter" class="">
<div class="box type-entity" style="height:63px;" title="1.9kВ Avfukter">
<div style="background-color:var(--primary-color);" class="">

</div>
<div class="label" style="line-height:15px;">
Expand All @@ -176,8 +176,8 @@ Blaa" class="">

<div class="spacerv" style="height:5.5px;"></div>

<div class="box type-entity" style="height:63px;">
<div style="background-color:var(--primary-color);" title="1.9kW " class="">
<div class="box type-entity" style="height:63px;" title="1.9kW ">
<div style="background-color:var(--primary-color);" class="">

</div>
<div class="label" style="line-height:15px;">
Expand Down Expand Up @@ -210,8 +210,8 @@ Blaa" class="">

<div class="spacerv" style="height:68.5px;"></div>

<div class="box type-passthrough" style="height:63px;">
<div style="background-color:red;" title="1.9kW " class="">
<div class="box type-passthrough" style="height:63px;" title="1.9kW ">
<div style="background-color:red;" class="">

</div>

Expand All @@ -225,8 +225,8 @@ Blaa" class="">

<div class="spacerv" style="height:68.5px;"></div>

<div class="box type-entity" style="height:63px;">
<div style="background-color:red;" title="1.9kW " class="">
<div class="box type-entity" style="height:63px;" title="1.9kW ">
<div style="background-color:red;" class="">

</div>
<div class="label" style="line-height:15px;">
Expand Down
15 changes: 9 additions & 6 deletions src/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ export function renderSection(props: {
${extraSpacers
? html`<div class="spacerv" style=${styleMap({ [sizeProp]: extraSpacers + 'px' })}></div>`
: null}
<div class=${'box type-' + box.config.type!} style=${styleMap({ [sizeProp]: box.size + 'px' })}>
<div
class=${'box type-' + box.config.type!}
style=${styleMap({ [sizeProp]: box.size + 'px' })}
@click=${() => props.onTap(box)}
@dblclick=${() => props.onDoubleTap(box)}
@mouseenter=${() => props.onMouseEnter(box)}
@mouseleave=${props.onMouseLeave}
title=${formattedState + box.unit_of_measurement + ' ' + name}
>
<div
style=${styleMap({ backgroundColor: box.color })}
@click=${() => props.onTap(box)}
@dblclick=${() => props.onDoubleTap(box)}
@mouseenter=${() => props.onMouseEnter(box)}
@mouseleave=${props.onMouseLeave}
title=${formattedState + box.unit_of_measurement + ' ' + name}
class=${props.highlightedEntities.includes(box.config) ? 'hl' : ''}
>
${show_icons && isNotPassthrough
Expand Down