-
Notifications
You must be signed in to change notification settings - Fork 2k
Actual mobile toc; dark mode; speed up site loading #3950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
18f7b8f
0da2ebf
2bbe65f
90e30af
2881b23
b161535
32dcbc5
d3b7019
f71186f
da42c69
49d898d
d2ccf7c
cb1bd36
0103af0
72da5ec
0be1310
50ba5b6
54f5e4d
a28a588
0d43af2
673a53c
49bf5b8
6716e93
c82e538
ec51bb4
182494f
09738a5
f55d1e0
1bc73ff
f9e443f
5ec4770
11c7bcb
2bb249a
f945ba9
fd41a86
2ed5d08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,9 @@ title: Raspberry Pi Documentation | |
| description: >- # this means to ignore newlines until "baseurl:" | ||
| Raspberry Pi Documentation. | ||
| baseurl: "/documentation" # the subpath of your site, e.g. /blog | ||
| url: "" # the base hostname & protocol for your site, e.g. http://example.com | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sure that there must have been some reason why this was left empty; but that reason is probably now lost to the mists of time... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it might have an impact on the URLs used for the rptl header. Need to double-check the behaviour on a staging build before I release! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The header uses all absolute URLs so it shouldn’t be affected. |
||
| url: "https://www.raspberrypi.com/documentation" # the base hostname & protocol for your site, e.g. http://example.com | ||
| githuburl: "https://github.com/raspberrypi/documentation/" | ||
| mainsite: https://raspberrypi.com/ | ||
| githubbranch: master | ||
| githubbranch_edit: develop | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file (as with If you make changes here, they'll be lost whenever we need to update it for changes to the header or footer or are you wanting to break away from the site-wide versions and have a documentation-only version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To support dark mode, we do need to tweak the header and footer files, as otherwise they'll remain in light mode at all times. I've kept the tweaks minimal (mostly colour based, with some padding trimmed from the header to reduce excess space usage), so we could try to mostly share. But unless we add dark mode to the main site as well, this will require deviation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this PR is modifying both the navigation and also adding a dark-mode, I wonder if it might be worth splitting that into two separate PRs? I.e. get the navigation changes merged in, and then add dark-mode theme as separate (later) step? 🤔 Or would it be far too much work to disentangle the two things? Also, we'll probably want @jackbenwillis to design us some "light mode" and "dark mode" icons which would integrate with the design better than the generic sun and moon icons that you're currently using? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than modifying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great point. Opened https://github.com/raspberrypi/raspberrypi.com-header-and-footer/pull/81 to address this -- once we've merged that, I'll update this PR to use that new approach (and likely some new header and footer-specific variables). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
| text-size-adjust: 100%; | ||
| -webkit-font-smoothing: antialiased; | ||
| -moz-osx-font-smoothing: grayscale; | ||
| background: #f5f6f9; | ||
| background: var(--footer-bg); | ||
| overflow: hidden; | ||
| } | ||
| #__rptl-footer .__rptl-footer-container { | ||
|
|
@@ -63,7 +63,7 @@ | |
| } | ||
| #__rptl-footer .__rptl-footer-heading { | ||
| font-weight: 700; | ||
| color: #333333; | ||
| color: var(--subtle-text); | ||
| margin-bottom: 8px; | ||
| } | ||
| #__rptl-footer .__rptl-footer-list { | ||
|
|
@@ -75,11 +75,11 @@ | |
| } | ||
| #__rptl-footer .__rptl-footer-icon { | ||
| margin-right: 0.5em; | ||
| fill: #333; | ||
| fill: var(--subtle-text); | ||
| } | ||
| #__rptl-footer .__rptl-footer-link, #__rptl-footer .__rptl-footer-link--with-icon { | ||
| font-weight: 400; | ||
| color: #333; | ||
| color: var(--subtle); | ||
|
||
| text-decoration: none; | ||
| } | ||
| #__rptl-footer .__rptl-footer-link--with-icon { | ||
|
|
@@ -90,6 +90,24 @@ | |
| text-decoration: underline; | ||
| } | ||
| </style> | ||
|
|
||
| <div class="legal"> | ||
| <div class="legal-inner"> | ||
| <p id="copyright"> | ||
| You can view and edit the Raspberry Pi documentation source <a href="{{ site.githuburl }}">on Github</a>. Please read our <a href="{{ site.githuburl }}blob/{{ site.githubbranch }}/CONTRIBUTING.md">usage and contributions policy</a> before you make a Pull Request. | ||
| </p> | ||
| <p id="copyright"> | ||
| Raspberry Pi documentation is copyright © 2012-{{ site.time | date: '%Y' }} Raspberry Pi Ltd and is licensed under a <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International</a> (CC BY-SA) licence. | ||
| </p> | ||
| <p id="copyright"> | ||
| Some content originates from the <a href="http://elinux.org/">eLinux wiki</a>, and is licensed under a <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported</a> licence. | ||
| </p> | ||
| <p id="copyright"> | ||
| The terms HDMI, HDMI High-Definition Multimedia Interface, HDMI trade dress and the HDMI Logos are trademarks or registered trademarks of HDMI Licensing Administrator, Inc. | ||
| </p> | ||
| </div> | ||
| </div> | ||
|
|
||
| <footer id="__rptl-footer"> | ||
| <div class="__rptl-footer-container"> | ||
| <div class="__rptl-footer-row"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <link rel="shortcut icon" href="{{ site.baseurl }}/favicon.ico"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this different to the default behaviour of using https://www.raspberrypi.com/favicon.ico? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, local builds of the docs yell at you on the CLI about a missing favicon and lack a favicon entirely. I added this to fix the issue locally, and I think it shouldn't break anything. Though your sanity check is appreciated. Hopefully that makes sense now. |
||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <title>{{ page.title | strip_html}}</title> | ||
| <meta name="description" content="The official documentation for Raspberry Pi computers and microcontrollers"> | ||
|
|
@@ -17,9 +18,78 @@ | |
| <link rel="preconnect" href="https://IHWGNTJ1NP-dsn.algolia.net" crossorigin> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"/> | ||
| <link rel="stylesheet" href="{{ site.baseurl }}/css/style.css?ver={{ site.time | date: '%s' }}"> | ||
| <link rel="stylesheet" href="{{ site.baseurl }}/css/tabs.css?ver={{ site.time | date: '%s' }}"> | ||
| <link rel="stylesheet" href="{{ site.baseurl }}/css/asciidoctor-tabs.css?ver={{ site.time | date: '%s' }}"> | ||
| <link rel="stylesheet" href="{{ site.baseurl }}/css/syntax-highlighting.css?ver={{ site.time | date: '%s' }}"> | ||
| <link rel="stylesheet" href="{{ site.baseurl }}/css/tocbot.css"> | ||
| <script src="{{ site.baseurl }}/scripts/tocbot.js"></script> | ||
| <script> | ||
| /* Trigger Tocbot dynamic TOC, works with tocbot 3.0.2 */ | ||
| function makeToc() { | ||
| var oldtoc = document.getElementById('toc').nextElementSibling; | ||
| var newtoc = document.getElementById('tocbot'); | ||
| newtoc.setAttribute('id', 'tocbot'); | ||
| newtoc.setAttribute('class', 'js-toc'); | ||
| oldtoc.parentNode.replaceChild(newtoc, oldtoc); | ||
| tocbot.init({ contentSelector: '#content', | ||
| headingSelector: 'h1, h2, h3, h4', | ||
| smoothScroll: true, | ||
| includeHtml: true | ||
| }); | ||
| var handleTocOnResize = function() { | ||
| var width = window.innerWidth | ||
| || document.documentElement.clientWidth | ||
| || document.body.clientWidth; | ||
| if (width < 768) { | ||
| tocbot.refresh({ contentSelector: '#content', | ||
| headingSelector: 'h1, h2, h3, h4', | ||
| collapseDepth: 6, | ||
| activeLinkClass: 'ignoreactive', | ||
| throttleTimeout: 1000, | ||
| smoothScroll: true }); | ||
| } | ||
| else { | ||
| tocbot.refresh({ contentSelector: '#content', | ||
| headingSelector: 'h1, h2, h3, h4', | ||
| smoothScroll: true }); | ||
| } | ||
| }; | ||
| window.addEventListener('resize', handleTocOnResize); | ||
| handleTocOnResize(); | ||
| } | ||
|
|
||
| // toggles the site theme between dark and light | ||
| function toggleTheme() { | ||
| // fetch the theme from local storage (if it exists) | ||
| var theme = localStorage.getItem('theme'); | ||
| // if theme them has never been set, or is light, set the theme to the dark symbol in local storage to change it | ||
| if (localStorage.getItem('theme') !== null && theme == '🌝' ) { | ||
| localStorage.setItem('theme', '🌚'); | ||
| } else { | ||
| // otherwise, the theme is currently set to dark, so set the theme to the light symbol in local storage to change it | ||
| localStorage.setItem('theme', '🌝'); | ||
| } | ||
| // finally, toggle the light option off or on the body to change the display of the theme | ||
| document.body.classList.toggle('light'); | ||
| } | ||
|
|
||
| // initialises the site theme display | ||
| // of key interest here: from the user's perspective, the site defaults to the light theme... | ||
| // ...unless your browser uses prefers-color-scheme to ask for a dark theme | ||
| // from the site's perspective, we default to a dark theme, but toggle it to a light theme on load if the user doesn't ask for dark. | ||
| // why do this? To prevent an annoying light 'flash' for dark theme users. light theme users don't really notice or care if there's a dark anti-flash. | ||
| function initTheme() { | ||
| // fetch the theme from local storage (if it exists) | ||
| var theme = localStorage.getItem('theme'); | ||
| // if the theme has been set to light (null check to short circuit if not set) | ||
| if(theme !== null && theme === '🌝' | ||
| // if we can use matchMedia and the browser supports the dark color scheme | ||
| || (window.matchMedia && !window.matchMedia('(prefers-color-scheme: dark)').matches) | ||
| && theme !== '🌚') { | ||
| // toggles the theme from the default dark mode to the light version (which actually _shows_ by default to many users) | ||
| document.body.classList.toggle('light'); | ||
| } | ||
| } | ||
| </script> | ||
| <script async src="https://www.googletagmanager.com/gtag/js?id=G-V8TFXM3BKJ"></script> | ||
| <script> | ||
| window.dataLayer = window.dataLayer || []; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.