Skip to content

Commit 619a75a

Browse files
committed
Feature: Add hide-able Environment Table
1 parent fb15908 commit 619a75a

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

src/layout/css/style.scss

+11-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ table {
4646
border: $border-width solid #e6e6e6;
4747
vertical-align: top;
4848
}
49-
5049
tr:nth-child(odd) {
5150
background-color: #f6f6f6;
5251
}
@@ -210,6 +209,17 @@ div.media {
210209
}
211210
}
212211

212+
.environment .header.collapser h2 {
213+
&:hover::after {
214+
content: ' (hide details)';
215+
}
216+
}
217+
.environment .header.expander h2 {
218+
&:hover::after {
219+
content: ' (show details)';
220+
}
221+
}
222+
213223
/*------------------
214224
* 3. Sorting items
215225
*------------------*/

src/pytest_html/resources/index.jinja2

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
<h1 id="title"></h1>
1616
<p>Report generated on {{ date }} at {{ time }} by <a href="https://pypi.python.org/pypi/pytest-html">pytest-html</a>
1717
v{{ version }}</p>
18-
<h2>Environment</h2>
19-
<table id="environment"></table>
18+
<div class="environment">
19+
<div class="header collapser">
20+
<h2>Environment</h2>
21+
</div>
22+
<table id="environment"></table>
23+
</div>
2024
<!-- TEMPLATES -->
2125
<template id="template_environment_row">
2226
<tr>

src/pytest_html/resources/style.css

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pytest_html/scripts/main.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@ const renderStatic = () => {
1717
document.querySelector('#title').innerText = title
1818
document.querySelector('#head-title').innerText = title
1919
}
20-
const renderTable = () => {
20+
const renderEnvironmentTable = () => {
2121
const environment = manager.environment
2222
const rows = Object.keys(environment).map((key) => dom.getStaticRow(key, environment[key]))
2323
const table = document.querySelector('#environment')
2424
removeChildren(table)
2525
rows.forEach((row) => table.appendChild(row))
26+
27+
const header = document.querySelector('.environment .header')
28+
header.addEventListener('click', () => {
29+
table.classList.toggle('hidden')
30+
header.classList.toggle('collapser')
31+
header.classList.toggle('expander')
32+
})
2633
}
2734
renderTitle()
28-
renderTable()
35+
renderEnvironmentTable()
2936
}
3037

3138
const renderContent = (tests) => {

0 commit comments

Comments
 (0)