|
9 | 9 | {% if disable_turbo_cache %} |
10 | 10 | <meta name="turbo-cache-control" content="no-cache"> |
11 | 11 | {% endif %} |
| 12 | + <script> |
| 13 | + // Early inline script element here is necessary to prevent the "flash of |
| 14 | + // unstyled content" problem where the dark default theme is first rendered |
| 15 | + // followed by a sudden flash to light mode. |
| 16 | + // See https://en.wikipedia.org/wiki/Flash_of_unstyled_content. |
| 17 | + const theme = localStorage.getItem('theme') || 'dark'; |
| 18 | + document.documentElement.setAttribute('data-theme', theme); |
| 19 | + </script> |
12 | 20 | <link rel="icon" type="image/png" href="/static/img/favicon-32x32.png" sizes="32x32"> |
13 | 21 | <link rel="icon" type="image/png" href="/static/img/favicon-16x16.png" sizes="16x16"> |
14 | 22 | <link rel="preconnect" href="https://fonts.googleapis.com"> |
|
40 | 48 | <header class="top-bar"> |
41 | 49 | <div class="logo"> |
42 | 50 | <a href="{{ url_for('frontend_handlers.index') }}" aria-label="Home page"> |
43 | | - <img alt="OSV logo" src="/static/img/logo.png" srcset="/static/img/logo.png, /static/img/logo@2x.png 2x" |
| 51 | + <img alt="OSV logo" class="logo-img-light" src="/static/img/logo.png" srcset="/static/img/logo.png, /static/img/logo@4x.png 4x" |
| 52 | + width="54" height="20"> |
| 53 | + <img alt="OSV logo" class="logo-img-dark" src="/static/img/logo-dark.png" srcset="/static/img/logo-dark.png, /static/img/logo-dark@4x.png 4x" |
44 | 54 | width="54" height="20"> |
45 | 55 | </a> |
46 | 56 | </div> |
|
92 | 102 | </a> |
93 | 103 | </li> |
94 | 104 | {% endif %} |
95 | | - <li> |
| 105 | + <li class="theme-toggle-container"> |
| 106 | + <button id="theme-toggle" class="theme-toggle-btn" aria-label="Toggle theme"> |
| 107 | + <span class="material-icons icon-light-mode">light_mode</span> |
| 108 | + <span class="material-icons icon-dark-mode">dark_mode</span> |
| 109 | + </button> |
| 110 | + </li> |
| 111 | + <li class="github-container"> |
96 | 112 | <a class="logo-img" href="https://github.com/google/osv.dev" target="_blank" |
97 | 113 | aria-label="Go to our github page"> |
98 | 114 | <img class="logo-link" src="/static/img/github-mark-white.svg" alt="Github Logo" width="24" height="24"> |
|
0 commit comments