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

Commit

Permalink
highlight column corresponding to selected cell
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromedockes committed Jan 17, 2024
1 parent c1636ee commit 3bfcda8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/skrubview/_data/templates/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
--skrubview-large: 1.2rem;
--skrubview-huge: 1.5rem;
--skrubview-max-content-width: 45rem;
--skrubview-yellowish: #ffffaa;
}

{{ report_id_selector }}.skrubview-report summary > * {
Expand Down Expand Up @@ -212,7 +213,7 @@
}

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

Expand Down
6 changes: 6 additions & 0 deletions src/skrubview/_data/templates/dataframe-columns.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{% from "utils.j2" import compact_id, collapse_const_id with context %}

{{ report_id_selector }}.skrubview-report .skrubview-column-summary[data-is-highlighted] .skrubview-card-header {
--header-color: var(--skrubview-yellowish);
}



{{ report_id_selector }}.skrubview-report .skrubview-float-end {
margin-inline-start: auto;
padding-inline-start: var(--skrubview-tiny);
Expand Down
6 changes: 3 additions & 3 deletions src/skrubview/_data/templates/dataframe-sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<article class="skrubview-wrapper">
<div class="skrubview-horizontal-scroll">
<table class="pure-table pure-table-striped" id="{{ table_id }}" data-powerbar-id="{{ powerbar_display_id }}">
<table class="pure-table pure-table-striped" id="{{ table_id }}" data-powerbar-id="{{ powerbar_display_id }}" data-report-id="{{ report_id }}">
<thead>
<tr>
{% for column_name in summary.head.header %}
Expand All @@ -14,7 +14,7 @@
{% for row in summary.head.data %}
<tr>
{% for idx in range(row.__len__()) %}
<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)">
<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)">
{%- if row[idx] is not none -%}
{{ row[idx] }}
{%- endif -%}
Expand All @@ -34,7 +34,7 @@
{% for row in summary.tail.data %}
<tr>
{% for idx in range(row.__len__()) %}
<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)">
<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)">
{%- if row[idx] is not none -%}
{{ row[idx] }}
{%- endif -%}
Expand Down
12 changes: 11 additions & 1 deletion src/skrubview/_data/templates/skrubview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
function highlightColCard(reportId, colIdx){
const reportElem = document.getElementById(reportId);
const allCols = reportElem.querySelectorAll(".skrubview-column-summary");
allCols.forEach(col => {col.removeAttribute("data-is-highlighted");});
const targetCol = document.getElementById(`${reportId}_col_${colIdx}`);
targetCol.dataset.isHighlighted = "";
}


function updateColSelection(event) {
updateSelectedColsSnippet(event.target.dataset.reportId);
}
Expand Down Expand Up @@ -125,7 +134,6 @@ function updateSiblingBarContents(event) {
}



function displayValue(event) {
const elem = event.target;
const table = document.getElementById(elem.dataset.parentTableId);
Expand All @@ -147,4 +155,6 @@ function displayValue(event) {

selectOneOf(powerbarId, ["table-cell-value", "table-cell-repr", "table-cell-filter"]);
updateBarContent(powerbarId);

highlightColCard(table.dataset.reportId, elem.dataset.columnIdx);
}

0 comments on commit 3bfcda8

Please sign in to comment.