Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/lib/dartdoc/dartdoc_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ extension DartDocPageRender on DartDocPage {
'width': '0',
'style': 'display:none;visibility:hidden',
})),
// NOTE: dartdoc's own initialization will still run, but it is not in conflict
// with the current script.
d.script(src: staticUrls.getAssetUrl('/static/js/dark-init.js')),
d.div(id: 'overlay-under-drawer'),
_renderHeader(options),
_renderMain(options),
Expand Down
8 changes: 8 additions & 0 deletions app/test/dartdoc/dartdoc_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ void main() {
contains('https://www.googletagmanager.com/'));
firstNoScript.remove();

// removing extra dark-theme initializer script
renderedXmlDoc.descendantElements
.where((e) =>
e.localName == 'script' &&
e.getAttribute('src')!.endsWith('/dark-init.js'))
.single
.remove();

// removing extra logo
final firstLogo = renderedXmlDoc.descendantElements.firstWhere(
(e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</head>
<body class="light-theme" data-base-href="../../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</head>
<body class="light-theme" data-base-href="../" data-using-base-href="false">
<noscript>&lt;iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MX6DBN9" height="0" width="0" style="display:none;visibility:hidden">&lt;/iframe></noscript>
<script src="/static/hash-%%etag%%/js/dark-init.js"></script>
<div id="overlay-under-drawer"></div>
<header id="title">
<span id="sidenav-left-toggle" class="material-symbols-outlined" role="button" tabindex="0">menu</span>
Expand Down
7 changes: 7 additions & 0 deletions static/js/dark-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
// ignore errors e.g. when media query matching is not supported
}

// NOTE: dartdoc currently does not support externally supported color scheme,
// and we disable that part for the affected URLs.
// TODO: remove this part when dartdoc supports the above detection too
if (window.location.pathname.startsWith('/documentation/')) {
mediaPrefersDarkScheme = false;
}

// Detects whether the control widget was set to use a specific theme
let colorTheme = window.localStorage.getItem('colorTheme');
let lightThemeIsSet = colorTheme == 'false';
Expand Down