Skip to content

add dark mode toggle(fixes #3628) #3634

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

VamsiVD
Copy link
Contributor

@VamsiVD VamsiVD commented Jun 29, 2025

Important: Do not tick a checkbox if you haven’t performed its action.

Before Creating the Pull Request

  • Verify the changes are on a new branch other than master – it should say "compare: branch-name".
  • Start the pull request title with lowercase letters, e.g., add githubusername.md.
  • Add issue number to the end of the pull request title when applicable, e.g., update mi-faq.md (fixes #3264).

After Creating the Pull Request

  • Go to "Commits" tab, make sure the commit username is clickable and linked to your GitHub account correctly.
  • Review the "Files changed" tab to ensure there are no unnecessary files or changes included in the pull request.
  • Verify that the raw.githack preview link is included in the description.
    • Preview the MDwiki rendered changes using the raw.githack link. Ensure it displays as expected without any errors.
  • Drop a link to this pull request in our discord channel.

Description, Screenshots and/or Screencast

changed the theme to cyborg, so the website is in darkmode.

Screenshot 2025-06-29 150107

fixes #3628

Raw.Githack Preview Link

https://raw.githack.com/vamsivd/vamsivd.github.io/3628-add-dark-mode/index.html#!index.md

Copy link
Member

@JunhaoZhou66 JunhaoZhou66 left a comment

Choose a reason for hiding this comment

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

Interesting idea, but we generally use a light model on the website. It is better to create a button that can change between dark and light.

Copy link
Contributor

@Okuro3499 Okuro3499 left a comment

Choose a reason for hiding this comment

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

@VamsiVD I agree with @3011089503 it will be better to have a button that will allow user to switch to their preferred theme

@VamsiVD VamsiVD changed the title change theme to cyborg (fixes #3628) add dark mode toggle(fixes #3628) Jul 2, 2025
@VamsiVD
Copy link
Contributor Author

VamsiVD commented Jul 2, 2025

I added a toggle button and made a custom CSS file, because the cyborg theme makes the text misaligned.

@VamsiVD VamsiVD requested review from Okuro3499 and JunhaoZhou66 July 2, 2025 15:59
@VamsiVD
Copy link
Contributor Author

VamsiVD commented Jul 3, 2025

Fixed an issue of the button hiding the hamburger menu when zooming in; made the button look simple and clean

@dogi dogi requested review from paulbert, dogi and Mutugiii July 4, 2025 20:09
@dogi
Copy link
Member

dogi commented Jul 4, 2025

@VamsiVD WOW

Copy link
Member

@paulbert paulbert left a comment

Choose a reason for hiding this comment

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

First off, this looks really good! Happy to see a bit of mdwiki hacking!

One potentially breaking issue is that if someone uses the build process for the wiki (see here), it'll overwrite the changes you made on index.html.

  • Changes to the HTML should move over to index.tmpl. If you're feeling up for it, you could move that button into where the navigation renders in mdwiki/js/main.js, but that is probably more work than is needed since it seems to be appearing in a decent spot.
  • Scripts should move into a file in mdwiki/js/ and that file path should be added in Grintfile.js.

Then I just have a few changes in addition to that which are not blocking. I'm a little rusty on my jQuery so feel free to let me know if there are any quirks which make changing CSS attributes necessary with jQuery, but generally I think modifying the CSS classes for elements and changing the contents of elements are the two things that should be done with jQuery. Everything else leave up to the CSS.

<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Copy link
Member

Choose a reason for hiding this comment

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

Extra space here.


<script>
$(document).ready(function () {
var $html = $('html');
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you use this reference for checking if dark mode is set in code, and the body class is used in CSS. I think it'd be a little cleaner to just apply the dark-mode class once.

style="position: fixed; top: 6px; right: 60px; z-index: 9999; border-radius: 100px; padding: 10px 10px; cursor: pointer; font-size: 18px; transition: all 0.3s ease;border:none">
<span id="toggleIcon">🌙</span>
</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Copy link
Member

@paulbert paulbert Jul 10, 2025

Choose a reason for hiding this comment

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

This is a duplicate script addition, let's remove this one and keep the one in <head>.

$html.addClass('dark-mode');
$body.addClass('dark-mode');
$navbar.removeClass('navbar-default').addClass('navbar-inverse');
$darkModeToggleBtn.css({
Copy link
Member

Choose a reason for hiding this comment

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

Let's try to move this to the CSS.

e.preventDefault();
setDarkMode(!$html.hasClass('dark-mode'));
});
$darkModeToggleBtn.hover(
Copy link
Member

Choose a reason for hiding this comment

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

This should be doable with CSS, also.

@@ -0,0 +1,57 @@
body.dark-mode {
Copy link
Member

Choose a reason for hiding this comment

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

Just a semantic comment, but since this isn't an external library let's put this in a new mdwiki/css/ directory

@VamsiVD
Copy link
Contributor Author

VamsiVD commented Jul 10, 2025

I’ll take care of it

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.

Adding dark mode to the website
7 participants