Skip to content

Commit

Permalink
Merge pull request #253 from zbynek/dark-theme
Browse files Browse the repository at this point in the history
[JENKINS-71997] Improve support for dark theme
  • Loading branch information
uhafner authored Dec 5, 2023
2 parents dd6b58d + 19427a5 commit b2cec1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/resources/io/jenkins/plugins/bootstrap5.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Use it like <st:adjunct includes="io.jenkins.plugins.bootstrap5"/>
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/popper.min.js"/>
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/bootstrap.min.js"/>
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/no-prototype.js"/>
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/theme-support.js"/>

<script>
const bootstrap5 = bootstrap;
Expand Down
10 changes: 10 additions & 0 deletions src/main/webapp/js/theme-support.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if (window.getThemeManagerProperty) {
const setBsTheme = () => document.body.dataset['bsTheme'] = getThemeManagerProperty('bootstrap', 'theme');
setBsTheme();

if (window.isSystemRespectingTheme) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
setBsTheme()
});
}
}

0 comments on commit b2cec1c

Please sign in to comment.