Skip to content

Commit d2f4034

Browse files
committed
Ensure color-scheme meta tag is set
1 parent 1bbc782 commit d2f4034

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

material/assets/javascripts/bundle.b4d07000.min.js renamed to material/assets/javascripts/bundle.a51614de.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.b4d07000.min.js.map renamed to material/assets/javascripts/bundle.a51614de.min.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
</script>
241241
{% endblock %}
242242
{% block scripts %}
243-
<script src="{{ 'assets/javascripts/bundle.b4d07000.min.js' | url }}"></script>
243+
<script src="{{ 'assets/javascripts/bundle.a51614de.min.js' | url }}"></script>
244244
{% for path in config.extra_javascript %}
245245
{% if path.endswith(".mjs") %}
246246
<script type="module" src="{{ path | url }}"></script>

src/assets/javascripts/components/palette/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ export function mountPalette(
119119
const meta = h("meta", { name: "theme-color" })
120120
document.head.appendChild(meta)
121121

122+
// Add color scheme meta tag
123+
const scheme = h("meta", { name: "color-scheme" })
124+
document.head.appendChild(scheme)
125+
122126
/* Mount component on subscription */
123127
return defer(() => {
124128
const push$ = new Subject<Palette>()
@@ -145,10 +149,13 @@ export function mountPalette(
145149
.pipe(
146150
map(() => {
147151
const header = getComponentElement("header")
148-
const { backgroundColor } = window.getComputedStyle(header)
152+
const style = window.getComputedStyle(header)
153+
154+
// Set color scheme
155+
scheme.content = style.colorScheme
149156

150157
/* Return color in hexadecimal format */
151-
return backgroundColor.match(/\d+/g)!
158+
return style.backgroundColor.match(/\d+/g)!
152159
.map(value => (+value).toString(16).padStart(2, "0"))
153160
.join("")
154161
})

0 commit comments

Comments
 (0)