Files
flipper/desktop/static/index.html
Michel Weststrate f9c8bf8941 Fix dark mode startup error
Summary:
Changelog: Fixed startup error when loading default theme

The theme defaulted to `auto`, instead of `system`, causing an startup exception. Fixed by adding types and having a more defensive startup check.

Fixes https://github.com/facebook/flipper/issues/2835

Reviewed By: jknoxville

Differential Revision: D30866648

fbshipit-source-id: 83b6d9fc235eaa0a7e959df4276d3f378eed7d1f
2021-09-10 07:04:43 -07:00

35 lines
1.2 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link id="flipper-theme-import" rel="stylesheet">
<link rel="stylesheet" href="graphiql/graphiql.css">
<link rel="stylesheet" href="vis/vis.min.css">
<title>Flipper</title>
</head>
<body>
<div id="root"></div>
<script>
global.electronRequire = window.require;
</script>
<script>
// load correct theme (n.b. this doesn't handle system value specifically, will assume light in such cases)
try {
if (JSON.parse(window.process.env.CONFIG).darkMode === 'dark') {
document.getElementById('flipper-theme-import').href="themes/dark.css";
} else {
document.getElementById('flipper-theme-import').href="themes/light.css";
}
} catch(e) {
console.error("Failed to initialize theme", e);
document.getElementById('flipper-theme-import').href="themes/light.css";
}
window.addEventListener('flipper-store-ready', () => global.flipperInit());
</script>
<script src="bundle.js"></script>
</body>
</html>