[WebProfilerBundle] Select default theme based on user preferences

This commit is contained in:
Javier Eguiluz 2019-06-07 09:48:55 +02:00
parent 482c357104
commit 0fc0a348b8

View File

@ -14,8 +14,11 @@
{% endblock %}
</head>
<body>
<script async>
document.body.classList.add(localStorage.getItem('symfony/profiler/theme') || 'theme-light', localStorage.getItem('symfony/profiler/width') || 'width-normal');
<script>
document.body.classList.add(
localStorage.getItem('symfony/profiler/theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'theme-dark' : 'theme-light'),
localStorage.getItem('symfony/profiler/width') || 'width-normal'
);
</script>
{% block body '' %}