Skip to content

dark mode #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
-------------

**3.1.0 (unreleased)**

* Support for dark mode (`#381 <https://github.com/pytest-dev/pytest-html/issues/381>`_)

* Thanks to `@jkowalleck <https://github.com/jkowalleck>`_ for the PR

**3.0.0 (2020-10-28)**

* Respect ``--capture=no``, ``--show-capture=no``, and ``-s`` pytest flags (`#171 <https://github.com/pytest-dev/pytest-html/issues/171>`_)
Expand Down
88 changes: 88 additions & 0 deletions pytest_html/resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ body {
font-size: 12px;
/* do not increase min-width as some may use split screens */
min-width: 800px;
background-color: white;
color: #999;
}

Expand All @@ -28,6 +29,25 @@ table {
border-collapse: collapse;
}

@media (prefers-color-scheme: dark) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the browser support look like for this annotation? Will this break older browsers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems pretty recent: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme

How will older browsers handle this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

general browser support: https://caniuse.com/mdn-css_at-rules_media
special browser support: https://caniuse.com/prefers-color-scheme

old browsers will not be broken. they will simply ignore it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks!

body {
background-color: #222;
color: #aaa;
}
h1 {
color: #ccc;
}
h2 {
color: #ccc;
}
p {
color: #ccc;
}
a {
color: #c6c2ab;
}
}

/******************************
* SUMMARY INFORMATION
******************************/
Expand All @@ -41,6 +61,15 @@ table {
background-color: #f6f6f6;
}

@media (prefers-color-scheme: dark) {
#environment td {
border-color: #333;
}
#environment tr:nth-child(odd) {
background-color: #292929;
}
}

/******************************
* TEST RESULT COLORS
******************************/
Expand All @@ -54,6 +83,20 @@ span.error, span.failed, span.xpassed, .error .col-result, .failed .col-result,
color: red;
}

@media (prefers-color-scheme: dark) {
span.passed, .passed .col-result {
color: #4E9A06;
font-weight: bold;
}
span.skipped, span.xfailed, span.rerun, .skipped .col-result, .xfailed .col-result, .rerun .col-result {
color: #C4A000;
font-weight: bold;
}
span.error, span.failed, span.xpassed, .error .col-result, .failed .col-result, .xpassed .col-result {
color: #CC0000;
font-weight: bold;
}
}

/******************************
* RESULTS TABLE
Expand Down Expand Up @@ -84,6 +127,16 @@ span.error, span.failed, span.xpassed, .error .col-result, .failed .col-result,
font-weight: bold
}

@media (prefers-color-scheme: dark) {
#results-table {
border-color: #333;
color: #aaa;
}
#results-table th, #results-table td {
border-color: #333;
}
}

/*------------------
* 2. Extra
*------------------*/
Expand Down Expand Up @@ -142,9 +195,32 @@ div.video video {
cursor: pointer;
}

@media (prefers-color-scheme: dark) {
.log {
background-color: #0c0c0d;
border-color: #333;
color: #8c8c8c;
}
div.image {
border-color: #333;
}
div.video {
border-color: #333;
}
.expander::after {
color: #c6c2ab;
font-weight: normal;
}
.collapser::after {
color: #c6c2ab;
font-weight: normal;
}
}

/*------------------
* 3. Sorting items
*------------------*/

.sortable {
cursor: pointer;
}
Expand Down Expand Up @@ -175,3 +251,15 @@ div.video video {
/*finish triangle*/
border-top: 8px solid #999;
}

@media (prefers-color-scheme: dark) {
.inactive .sort-icon {
border-top-color: #333;
}
.asc.active .sort-icon {
border-bottom-color: #aaa;
}
.desc.active .sort-icon {
border-top-color: #aaa;
}
}