Skip to content
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

Dark mode option #360

Merged
merged 7 commits into from
Oct 30, 2024
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [3.8.2] - 2024-10-30

### Added

* Dark mode

## [3.8.1] - 2024-09-12

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

Initial project version on GitHub and Maven Central.

[3.8.2]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.8.2

[3.8.1]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.8.1

[3.8.0]: https://github.com/trivago/cluecumber-report-plugin/tree/v3.8.0
Expand Down
21 changes: 20 additions & 1 deletion engine/src/main/resources/template/css/cluecumber.css
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,23 @@ tr.even td, tr.odd td {

.multiRunChildren {
margin-top: 1rem;
}
}

html.dark-mode {
filter: invert(100%) hue-rotate(180deg);
}

html.dark-mode img,
html.dark-mode video,
html.dark-mode .color-passed,
html.dark-mode .color-failed,
html.dark-mode .color-skipped,
html.dark-mode .border-color-passed,
html.dark-mode .border-color-failed,
html.dark-mode .border-color-skipped{
filter: invert(100%) hue-rotate(180deg);
}

#dark-mode-toggle {
margin-right: 10px;
}
1 change: 1 addition & 0 deletions engine/src/main/resources/template/macros/navigation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ limitations under the License.
</li>
</#list>
</ul>
<button id="dark-mode-toggle" class="btn btn-secondary btn-sm">Toggle Dark Mode</button>
<span class="text-light">${reportDetails.date}</span>
</div>
</nav>
Expand Down
20 changes: 20 additions & 0 deletions engine/src/main/resources/template/snippets/js.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,29 @@ limitations under the License.
if (${expandPreviousScenarioRuns?c}) {
$("[data-cluecumber-item='multi-run-button']").click();
}

const isDarkMode = localStorage.getItem('darkMode') === 'enabled';
if (isDarkMode) {
document.documentElement.classList.add('dark-mode');
}
updateToggleButton(isDarkMode);

document.getElementById('dark-mode-toggle').addEventListener('click', toggleDarkMode);
}
);

function toggleDarkMode() {
document.documentElement.classList.toggle('dark-mode');
const isDarkMode = document.documentElement.classList.contains('dark-mode');
localStorage.setItem('darkMode', isDarkMode ? 'enabled' : 'disabled');
updateToggleButton(isDarkMode);
}

function updateToggleButton(isDarkMode) {
const button = document.getElementById('dark-mode-toggle');
button.textContent = isDarkMode ? 'Toggle Light Mode' : 'Toggle Dark Mode';
}

function resizeIframe(iframe) {
setInterval(function () {
try {
Expand Down
2 changes: 1 addition & 1 deletion examples/maven-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>blog.softwaretester</groupId>
<artifactId>maven-example</artifactId>
<version>3.8.1</version>
<version>3.8.2</version>
<packaging>pom</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</modules>

<properties>
<revision>3.8.1</revision>
<revision>3.8.2</revision>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
Expand Down
Loading