Skip to content
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

Added dark mode button #2980

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added dark mode button #2980

wants to merge 1 commit into from

Conversation

yogi-25
Copy link

@yogi-25 yogi-25 commented May 1, 2023

I have added dark mode button and it is able to change the state ON and OFF.

Copy link
Collaborator

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

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

Thank you for making a contribution!

The change is welcome and it works, but:

  • the styling needs refinement, and
  • I think it would be better if dark mode is automatically selected for people who prefer it.

Please take a look at the screenshot by @gprasanth and his gist in which he shared the CSS that made it work, including the media selector that takes care of selecting dark mode automatically.

This is what your version of dark mode currently looks like in Safari:

screenshot

Copy link
Collaborator

Choose a reason for hiding this comment

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

Tip: try to avoid pure whitespace changes in your next few pull requests.

Comment on lines +27 to +28
background-color: #000000;
color: white;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hard white on deep black is considered uncomfortable for the eyes.

font-size: 14px;
line-height: 22px;
background: #f4f4f4 url(docs/images/background.png);
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no need to remove the background in light mode.

@@ -143,7 +162,7 @@
}
tt {
padding: 0px 3px;
background: #fff;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Preferably replace the background color in dark mode, rather than removing it in both modes.

Comment on lines +287 to +290
<!-- <div class="mode">
Dark mode:
<span class="change">OFF</span>
</div> -->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like you forgot to remove an outcomment here.

<span class="change">OFF</span>
</div> -->
<div class="mode">
<span class="change">OFF</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the button just says "ON"/"OFF", it is rather mysterious what it will do. For the color mode, this not too unproblematic because it is non-essential, but more people will be able to find the feature if you make it more self-describing.

Comment on lines +297 to +305
$( ".change" ).on("click", function() {
if( $( "body" ).hasClass( "dark" )) {
$( "body" ).removeClass( "dark" );
$( ".change" ).text( "OFF" );
} else {
$( "body" ).addClass( "dark" );
$( ".change" ).text( "ON" );
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kudos on making this work!

@jgonggrijp jgonggrijp linked an issue May 2, 2023 that may be closed by this pull request
Comment on lines +10 to +12
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js">
</script>

Choose a reason for hiding this comment

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

Formatting seems off here

Comment on lines +16 to +25
.change {
cursor: pointer;
border: 1px solid #555;
border-radius: 40%;
width: 20px;
text-align: center;
padding: 5px;
margin-left: 8px;

}

Choose a reason for hiding this comment

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

Another lint issue

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 mode support for homepage
3 participants