Skip to content

Commit 1c14bcb

Browse files
authored
Dark mode option (#360)
* Dark mode test WIP * Dark mode test refactoring with simple filtering and counter-filtering * Add margin for the dark mode toggle * Exclude images, videos, table borders * Update CHANGELOG.md * Update link in CHANGELOG.md * Remove some comments
1 parent 43aad67 commit 1c14bcb

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
Back to [Readme](README.md).
99

10+
## [3.8.2] - 2024-10-30
11+
12+
### Added
13+
14+
* Dark mode
15+
1016
## [3.8.1] - 2024-09-12
1117

1218
### Changed
@@ -918,6 +924,8 @@ the core component is now the reporting engine that is the base for other forms
918924

919925
Initial project version on GitHub and Maven Central.
920926

927+
[3.8.2]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.8.2
928+
921929
[3.8.1]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.8.1
922930

923931
[3.8.0]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.8.0

engine/src/main/resources/template/css/cluecumber.css

+20-1
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,23 @@ tr.even td, tr.odd td {
297297

298298
.multiRunChildren {
299299
margin-top: 1rem;
300-
}
300+
}
301+
302+
html.dark-mode {
303+
filter: invert(100%) hue-rotate(180deg);
304+
}
305+
306+
html.dark-mode img,
307+
html.dark-mode video,
308+
html.dark-mode .color-passed,
309+
html.dark-mode .color-failed,
310+
html.dark-mode .color-skipped,
311+
html.dark-mode .border-color-passed,
312+
html.dark-mode .border-color-failed,
313+
html.dark-mode .border-color-skipped{
314+
filter: invert(100%) hue-rotate(180deg);
315+
}
316+
317+
#dark-mode-toggle {
318+
margin-right: 10px;
319+
}

engine/src/main/resources/template/macros/navigation.ftl

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ limitations under the License.
6161
</li>
6262
</#list>
6363
</ul>
64+
<button id="dark-mode-toggle" class="btn btn-secondary btn-sm">Toggle Dark Mode</button>
6465
<span class="text-light">${reportDetails.date}</span>
6566
</div>
6667
</nav>

engine/src/main/resources/template/snippets/js.ftl

+20
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,29 @@ limitations under the License.
125125
if (${expandPreviousScenarioRuns?c}) {
126126
$("[data-cluecumber-item='multi-run-button']").click();
127127
}
128+
129+
const isDarkMode = localStorage.getItem('darkMode') === 'enabled';
130+
if (isDarkMode) {
131+
document.documentElement.classList.add('dark-mode');
132+
}
133+
updateToggleButton(isDarkMode);
134+
135+
document.getElementById('dark-mode-toggle').addEventListener('click', toggleDarkMode);
128136
}
129137
);
130138
139+
function toggleDarkMode() {
140+
document.documentElement.classList.toggle('dark-mode');
141+
const isDarkMode = document.documentElement.classList.contains('dark-mode');
142+
localStorage.setItem('darkMode', isDarkMode ? 'enabled' : 'disabled');
143+
updateToggleButton(isDarkMode);
144+
}
145+
146+
function updateToggleButton(isDarkMode) {
147+
const button = document.getElementById('dark-mode-toggle');
148+
button.textContent = isDarkMode ? 'Toggle Light Mode' : 'Toggle Dark Mode';
149+
}
150+
131151
function resizeIframe(iframe) {
132152
setInterval(function () {
133153
try {

examples/maven-example/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>blog.softwaretester</groupId>
88
<artifactId>maven-example</artifactId>
9-
<version>3.8.1</version>
9+
<version>3.8.2</version>
1010
<packaging>pom</packaging>
1111

1212
<properties>

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</modules>
2222

2323
<properties>
24-
<revision>3.8.1</revision>
24+
<revision>3.8.2</revision>
2525
<maven.compiler.source>11</maven.compiler.source>
2626
<maven.compiler.target>11</maven.compiler.target>
2727
<maven.compiler.release>11</maven.compiler.release>

0 commit comments

Comments
 (0)