Skip to content

Add dark mode#2239

Open
IDisposable wants to merge 1 commit intomicrosoft:gh-pagesfrom
IDisposable:add-dark-mode
Open

Add dark mode#2239
IDisposable wants to merge 1 commit intomicrosoft:gh-pagesfrom
IDisposable:add-dark-mode

Conversation

@IDisposable
Copy link

Closes #2204

  • Add page head theme-stored/preference-driven light/dark toggle
  • Add topnav button to toggle light/dark
  • Defaults to light mode if not set
  • Add dark-mode color overrides to main.css
  • Upgrade to jekyll 4.4
  • Upgrade to webrick 1.9 jekyll plugin
  • Upgrade to bootstrap 5.3.3
  • Remove popper.js (it's part of bootstrap now)
  • Remove jQuery and just use standard browser
  • Replace attributes data-toggle -> data-bs-toggle (for accordions/nav menu)
  • Replace attributes data-target -> data-bs-target (for nav menu)
  • Replace attributes data-parent -> data-bs-parent (for menus)
  • Replace attributes data-ride -> data-bs-ride (for carousel)
  • Replace attributes ml-auto -> ms-auto (for nav menu)
  • Use bootstrap color CSS variables
  • Add adjustments to main.scss for links and jumbotron to retain appearance
  • Add theme management to page.js and upgrade to remove jQuery
  • Eliminate incompatible github-pages plugin and use standard github workflow

- Add page head theme-stored/preference-driven light/dark toggle
- Add topnav button to toggle light/dark
- Defaults to light mode if not set
- Add dark-mode color overrides to main.css
- Upgrade to jekyll 4.4
- Upgrade to webrick 1.9 jekyll plugin
- Upgrade to bootstrap 5.3.3
- Remove popper.js (it's part of bootstrap now)
- Remove jQuery and just use standard browser
- Replace attributes data-toggle -> data-bs-toggle (for accordions/nav menu)
- Replace attributes data-target -> data-bs-target (for nav menu)
- Replace attributes data-parent -> data-bs-parent (for menus)
- Replace attributes data-ride -> data-bs-ride (for carousel)
- Replace attributes ml-auto -> ms-auto (for nav menu)
- Use bootstrap color CSS variables
- Add adjustments to main.scss for links and jumbotron to retain appearance
- Add theme management to page.js and upgrade to remove jQuery
- Eliminate incompatible github-pages plugin and use standard github workflow
@@ -0,0 +1,51 @@
name: Deploy Jekyll site to Pages
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this can be done like this, but the current versions of jekyll do NOT work with the github-pages Gem, so we have to remove that and use GitHub Actions workflow instead.

Obviously, I cannot tell if this will work because I don't have your tokens/secrets... so let me know if you need me to adjust.

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<script>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents flash of light/dark on page load and respects local-store setting of theme. Falls back to browser preference using matchMedia

integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade to bootstrap 5.3.3 for free dark/light mode support.

Popper is included in 5.x

</a>

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bootstrap 5.x changed the data attributes to include the -bs- to avoid collisions, so we change those all over.

<li {% if page.sectionid=='specification' %} class="nav-item active" {% else %} class="nav-item" {% endif %}>
<a class="nav-link" href='{{ "/specifications/specification-current" | prepend: site.baseurl }}'>Specification</a>
</li>
<li class="nav-item">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the menu-line toggle (shows a sun or moon)

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" data-bs-theme="light">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure if there's no preference or mode previously selected, we fall back to light so it doesn't change appearance too much.

There is a lot of improvements in Bootstrap 5.x for fonts and sizing and such, so it's not an exact match, but it's better.

letter-spacing: .25px;
text-rendering: optimizeLegibility;
color: #242628;
color: var(--bs-body-color, #242628);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure we work with bootstrap theming and fall-back to our old colors all over.

top: -60px;
left: 0;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is to fix some differences in the way the sidebars rendered in 5.x (missing padding and colors) which resulted from CSS specificity issues.

color: var(--bs-secondary-color, #707070);
}

div.page-content > div.wrapper > div.header-container.bg-primary.jumbotron {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added to fix the index page, which rendered with a white bar between the navigation/menu bar and the "jumbotron" header.

margin-top: -1em;
}

// Theme toggle button
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of these changes are for dark-mode color overrides.

function onConsentChanged() {
function gtag() {
window.dataLayer.push(arguments)
document.addEventListener('DOMContentLoaded', function () {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed jQuery and use standard browser DOM stuff now.

});
}

// Theme toggle
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theme management

layout: default
---

<!-- Place this tag in your head or just before your close body tag. -->
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was complete duplicate since it was already rendered in the footer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dark theme on https://microsoft.github.io/language-server-protocol/

1 participant