Skip to content

Commit 19427a5

Browse files
committed
Improve support for dark theme
1 parent dd6b58d commit 19427a5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/main/resources/io/jenkins/plugins/bootstrap5.jelly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Use it like <st:adjunct includes="io.jenkins.plugins.bootstrap5"/>
1515
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/popper.min.js"/>
1616
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/bootstrap.min.js"/>
1717
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/no-prototype.js"/>
18+
<script type="text/javascript" src="${resURL}/plugin/bootstrap5-api/js/theme-support.js"/>
1819

1920
<script>
2021
const bootstrap5 = bootstrap;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
if (window.getThemeManagerProperty) {
2+
const setBsTheme = () => document.body.dataset['bsTheme'] = getThemeManagerProperty('bootstrap', 'theme');
3+
setBsTheme();
4+
5+
if (window.isSystemRespectingTheme) {
6+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
7+
setBsTheme()
8+
});
9+
}
10+
}

0 commit comments

Comments
 (0)