Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 3bfcda8

Browse files
committed
highlight column corresponding to selected cell
1 parent c1636ee commit 3bfcda8

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/skrubview/_data/templates/base.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
--skrubview-large: 1.2rem;
55
--skrubview-huge: 1.5rem;
66
--skrubview-max-content-width: 45rem;
7+
--skrubview-yellowish: #ffffaa;
78
}
89

910
{{ report_id_selector }}.skrubview-report summary > * {
@@ -212,7 +213,7 @@
212213
}
213214

214215
{{ report_id_selector }}.skrubview-report .skrubview-table-cell[data-is-selected] {
215-
background-color: #ffffaa;
216+
background-color: var(--skrubview-yellowish);
216217
border: 1px solid black;
217218
}
218219

src/skrubview/_data/templates/dataframe-columns.css

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{% from "utils.j2" import compact_id, collapse_const_id with context %}
22

3+
{{ report_id_selector }}.skrubview-report .skrubview-column-summary[data-is-highlighted] .skrubview-card-header {
4+
--header-color: var(--skrubview-yellowish);
5+
}
6+
7+
8+
39
{{ report_id_selector }}.skrubview-report .skrubview-float-end {
410
margin-inline-start: auto;
511
padding-inline-start: var(--skrubview-tiny);

src/skrubview/_data/templates/dataframe-sample.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<article class="skrubview-wrapper">
44
<div class="skrubview-horizontal-scroll">
5-
<table class="pure-table pure-table-striped" id="{{ table_id }}" data-powerbar-id="{{ powerbar_display_id }}">
5+
<table class="pure-table pure-table-striped" id="{{ table_id }}" data-powerbar-id="{{ powerbar_display_id }}" data-report-id="{{ report_id }}">
66
<thead>
77
<tr>
88
{% for column_name in summary.head.header %}
@@ -14,7 +14,7 @@
1414
{% for row in summary.head.data %}
1515
<tr>
1616
{% for idx in range(row.__len__()) %}
17-
<td class="skrubview-table-cell skrubview-ellided-short" data-parent-table-id="{{ table_id }}" data-display-box-id="{{ table_id }}_value_box" data-filter-snippet-box-id="{{ table_id }}_filter_snippet_box" data-value-repr-box-id="{{ table_id }}_value_repr_box" data-column-name-repr="{{ summary.head.header[idx].__repr__() }}" data-value-str="{{ row[idx].__str__() }}" data-value-repr="{{ row[idx].__repr__() }}" {%- if row[idx] is none -%} data-value-is-none="" {%- endif -%} data-dataframe-module="{{ summary.dataframe_module }}" onclick="displayValue(event)">
17+
<td class="skrubview-table-cell skrubview-ellided-short" data-parent-table-id="{{ table_id }}" data-display-box-id="{{ table_id }}_value_box" data-filter-snippet-box-id="{{ table_id }}_filter_snippet_box" data-value-repr-box-id="{{ table_id }}_value_repr_box" data-column-idx="{{ idx }}" data-column-name-repr="{{ summary.head.header[idx].__repr__() }}" data-value-str="{{ row[idx].__str__() }}" data-value-repr="{{ row[idx].__repr__() }}" {%- if row[idx] is none -%} data-value-is-none="" {%- endif -%} data-dataframe-module="{{ summary.dataframe_module }}" onclick="displayValue(event)">
1818
{%- if row[idx] is not none -%}
1919
{{ row[idx] }}
2020
{%- endif -%}
@@ -34,7 +34,7 @@
3434
{% for row in summary.tail.data %}
3535
<tr>
3636
{% for idx in range(row.__len__()) %}
37-
<td class="skrubview-table-cell skrubview-ellided-short" data-parent-table-id="{{ table_id }}" data-display-box-id="{{ table_id }}_value_box" data-filter-snippet-box-id="{{ table_id }}_filter_snippet_box" data-value-repr-box-id="{{ table_id }}_value_repr_box" data-column-name-repr="{{ summary.head.header[idx].__repr__() }}" data-value-str="{{ row[idx].__str__() }}" data-value-repr="{{ row[idx].__repr__() }}" {%- if row[idx] is none -%} data-value-is-none="" {%- endif -%} data-dataframe-module="{{ summary.dataframe_module }}" onclick="displayValue(event)">
37+
<td class="skrubview-table-cell skrubview-ellided-short" data-parent-table-id="{{ table_id }}" data-display-box-id="{{ table_id }}_value_box" data-filter-snippet-box-id="{{ table_id }}_filter_snippet_box" data-value-repr-box-id="{{ table_id }}_value_repr_box" data-column-idx="{{ idx }}" data-column-name-repr="{{ summary.head.header[idx].__repr__() }}" data-value-str="{{ row[idx].__str__() }}" data-value-repr="{{ row[idx].__repr__() }}" {%- if row[idx] is none -%} data-value-is-none="" {%- endif -%} data-dataframe-module="{{ summary.dataframe_module }}" onclick="displayValue(event)">
3838
{%- if row[idx] is not none -%}
3939
{{ row[idx] }}
4040
{%- endif -%}

src/skrubview/_data/templates/skrubview.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
function highlightColCard(reportId, colIdx){
2+
const reportElem = document.getElementById(reportId);
3+
const allCols = reportElem.querySelectorAll(".skrubview-column-summary");
4+
allCols.forEach(col => {col.removeAttribute("data-is-highlighted");});
5+
const targetCol = document.getElementById(`${reportId}_col_${colIdx}`);
6+
targetCol.dataset.isHighlighted = "";
7+
}
8+
9+
110
function updateColSelection(event) {
211
updateSelectedColsSnippet(event.target.dataset.reportId);
312
}
@@ -125,7 +134,6 @@ function updateSiblingBarContents(event) {
125134
}
126135

127136

128-
129137
function displayValue(event) {
130138
const elem = event.target;
131139
const table = document.getElementById(elem.dataset.parentTableId);
@@ -147,4 +155,6 @@ function displayValue(event) {
147155

148156
selectOneOf(powerbarId, ["table-cell-value", "table-cell-repr", "table-cell-filter"]);
149157
updateBarContent(powerbarId);
158+
159+
highlightColCard(table.dataset.reportId, elem.dataset.columnIdx);
150160
}

0 commit comments

Comments
 (0)