-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add table preview to data cards (#97)
* Add ideas for table preview * Use solution with fixed grid * Add first working CSS table solution * Extract header from table object * Include CSS and JS file in sphinx extension * Add ideas how to include table preview * Continue work * Do not include table preview as text * Fix border of tables * Add more comments * Fix CSS * Fix padding * Add fix for vertical alignment * Remove first table * Reenable sphinx-audeering-theme * Add more CSS fixes * Enforce normal font size in nested table header * Cleanup CSS file * Finetune borders * Improve docstring * Mark clicked row * Call nested table preview * Adjust expected test results * Add doctest test * Try to fix doctests * Cleanup template * Fix tests * Ensure text in table preview is valid * Extend docstring of utils.parse_text() * Extend docstring of CSS and JS file * Add docstring to new test * Manage tables_preview with load_tables * Be more explicit in NA handling * Make parse_text private static method
- Loading branch information
Showing
11 changed files
with
412 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* Expand rows in Tables table to show preview of each tables content. | ||
/* | ||
/* Implementation based on https://github.com/chhikaradi1993/Expandable-table-row | ||
*/ | ||
.expanded-row-content { | ||
font-size: 13px; | ||
/* Add scroll bar if table preview is too big */ | ||
overflow: auto !important; | ||
/* Let column appear as additional row in next line */ | ||
display: grid; | ||
grid-column: 1/-1; | ||
justify-content: flex-start; | ||
border-left: none; | ||
} | ||
.hide-row { | ||
display: None; | ||
} | ||
table.clickable { | ||
/* Ensure we don't get double border lines */ | ||
border-bottom: none; | ||
border-right: none; | ||
/* Force to use full width */ | ||
width: 100%; | ||
} | ||
table.clickable td, | ||
table.clickable th { | ||
/* Ensure we don't get double border lines */ | ||
border-left: none; | ||
border-top: none; | ||
} | ||
table.preview td { | ||
/* Remove all borders inside preview table cells */ | ||
border-left: none; | ||
border-top: none; | ||
border-bottom: none; | ||
} | ||
table.clickable td:not(.expanded-row-content), | ||
table.clickable th { | ||
/* Allow to center cell copntent with `margin: auto` */ | ||
display: flex; | ||
} | ||
table.clickable td:not(.expanded-row-content) p, | ||
table.clickable th p { | ||
/* Verrtically center cell content */ | ||
margin: auto 0; | ||
} | ||
table.clickable td:not(.expanded-row-content) p:last-child, | ||
table.clickable th p:last-child { | ||
/* Verrtically center cell content for ReadTheDocs based themes*/ | ||
margin: auto 0 !important; | ||
} | ||
table.clickable td.expanded-row-content td, | ||
table.clickable td.expanded-row-content th { | ||
display: table-cell; | ||
} | ||
table.clickable tr.grid { | ||
/* Fixed grid of 3 columns */ | ||
display: grid; | ||
grid-template-columns: repeat(1, 1.1fr) 15% repeat(1, 1fr); | ||
} | ||
table.clickable tr.clickable { | ||
/* Show pointer as cursor to highlight the row can be clicked */ | ||
cursor: pointer; | ||
/* Overflow of table preview column */ | ||
justify-content: flex-start; | ||
} | ||
table.clickable tr.clicked td:not(.expanded-row-content) { | ||
/* Remove bottom border on clicked row when preview is shown */ | ||
border-bottom: none; | ||
} | ||
table.preview { | ||
/* Padding around table preview */ | ||
padding: 10px; | ||
} | ||
table.preview td { | ||
/* Ensure minimal distance between columns */ | ||
padding-right: 0.3em; | ||
} | ||
table.preview th { | ||
/* Use normal font in header row of preview table */ | ||
font-weight: normal !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Expand rows in Tables table to show preview of each tables content. | ||
// | ||
// Implementation based on https://github.com/chhikaradi1993/Expandable-table-row | ||
// | ||
const toggleRow = (row) => { | ||
// Toggle visibility of table preview | ||
row.getElementsByClassName('expanded-row-content')[0].classList.toggle('hide-row'); | ||
// Toggle clicked attribute on clicked table row. | ||
// This can be used to adjust appearance of clicked table, | ||
// e.g. remove bottom border | ||
if (row.className.indexOf("clicked") === -1) { | ||
row.classList.add("clicked"); | ||
} else { | ||
row.classList.remove("clicked"); | ||
} | ||
console.log(event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
audb >=1.6.5 # for audb.Dependencies.__eq__() | ||
audeer >=1.21.0 | ||
pytest | ||
tabulate |
Oops, something went wrong.