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

Implement Dark Mode for the Website (#422) #425

Merged
merged 2 commits into from
Nov 10, 2024

Conversation

Mohitranag18
Copy link
Contributor

@Mohitranag18 Mohitranag18 commented Nov 10, 2024

Description:

To enhance the website's usability and improve user experience, this PR introduces a dark mode feature, allowing users to toggle between light and dark themes. This change aims to reduce eye strain, particularly during nighttime or low-light browsing.

Requirements:

  • Added a toggle button in the website's header to enable/disable dark mode.
  • Adjusted all website elements, including text, backgrounds, buttons, and icons, for dark mode while maintaining readability and aesthetic harmony.
  • Ensured theme preference persists across sessions via local storage.
  • Verified compatibility and responsiveness across all devices and screen sizes.

Acceptance Criteria:

  • A visible, accessible dark mode toggle is present for theme switching.
  • Consistent color scheme across all pages in dark mode with appropriate contrast.
  • Theme preference (light or dark) is remembered on subsequent visits.
  • Dark mode is cohesive with the existing design elements and complements the site's overall theme.

Additional Context:

This dark mode implementation is designed to enhance accessibility and modernize the website's user interface. The dark color palette aligns with current design aesthetics and complies with accessibility standards for a seamless and enjoyable user experience.

Screenshot 2024-11-10 at 06-00-22 Waste Management

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a dark mode theme toggle for enhanced user experience.
    • Added a slider feature for eco-tips to improve content engagement.
    • Enhanced form validation for signup and login processes.
  • Styling Improvements

    • Updated various sections with new dark mode styles and improved visual separation using borders.
    • Added hover effects for interactive elements.
  • Bug Fixes

    • Improved error handling for newsletter subscriptions and form submissions.

Copy link

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. 😊

1 similar comment
Copy link

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. 😊

Copy link

netlify bot commented Nov 10, 2024

Deploy Preview for manageyourwaste failed. Why did it fail? →

Name Link
🔨 Latest commit adf8b70
🔍 Latest deploy log https://app.netlify.com/sites/manageyourwaste/deploys/673097595ea6a30008faa9a7

Copy link
Contributor

coderabbitai bot commented Nov 10, 2024

Walkthrough

The changes in this pull request involve updates to index.html, script.js, styles.css, and styles.js to implement and enhance dark mode functionality across the website. This includes the addition of the darkmodetext class for various headings and paragraphs, improvements to form validation and error handling in JavaScript, and the introduction of new CSS classes for dark mode styling. The overall aim is to improve user experience through better accessibility and visual consistency in both light and dark themes.

Changes

File Change Summary
index.html Added darkmodetext class to multiple headings and paragraphs; changed <h3> to <h2> for sections.
script.js Introduced new slider feature for eco-tips; enhanced form validation with validateSignup function; improved error handling for newsletter subscription.
styles.css Updated sections with borders; removed background colors; added new classes for dark mode styling.
styles.js Implemented dark mode toggle functionality; added event listener for theme toggle button.

Possibly related issues

  • Implement Dark Mode for the Website (Implement Dark Mode for the Website #422): This PR addresses the implementation of dark mode, aligning with the objectives of adding a toggle and ensuring consistent styling across the site.

Possibly related PRs

Suggested labels

gssoc-ext, hacktoberfest, level3, hacktoberfest-accepted

Suggested reviewers

  • GarimaSingh0109

Poem

In the night, a toggle's light,
Dark mode whispers, "Hold me tight."
Texts aglow, borders bright,
A rabbit's hop brings pure delight!
With every click, the colors sway,
User joy, come out to play! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Outside diff range and nitpick comments (5)
styles.js (3)

22-22: Consider performance optimization for DOM queries.

The querySelectorAll operation could be expensive if there are many elements with the darkmodetext class.

Consider using a more specific selector or caching elements by their IDs if possible:

-const whitetext = document.querySelectorAll(".darkmodetext");
+// If these elements are in specific containers, use more specific selectors
+const whitetext = document.querySelectorAll("#main-content .darkmodetext");

27-28: Improve code comment accuracy.

The comment refers to .whitetext class but the code uses .darkmodetext.

-    // Loop through each element with the .whitetext class and toggle .dark-mode3
+    // Toggle dark mode styling for text elements

Missing dark mode styles for form visibility states

The verification reveals that while dark mode classes exist, there are no specific dark mode styles defined for .button-active and .form-register states. This could lead to visibility and contrast issues when the dark theme is active.

  • Add dark mode specific styles for .button-active in dark mode to ensure proper contrast and visibility
  • Define dark mode styles for .form-register to maintain form visibility in dark theme
  • Consider adding specific styles for .dark-mode .button-active and .dark-mode .form-register
🔗 Analysis chain

Line range hint 1-18: Verify form visibility in dark mode.

While the form toggling logic is sound, we should ensure that the form visibility states and button active states remain visually distinct in both light and dark modes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if there are corresponding dark mode styles for form visibility states
# Look for .button-active and .form-register styling in dark mode

rg -l "\.button-active" "\.form-register" | xargs rg "dark-mode.*\.button-active" "dark-mode.*\.form-register"

Length of output: 235


Script:

#!/bin/bash
# Let's try a different approach to find CSS styles
# First, let's find all CSS files
fd -e css | xargs rg -A 2 "\.button-active|\.form-register"

Length of output: 1291


Script:

#!/bin/bash
# Let's try to find the styles file directly and check its content
rg -l "styles\." --type html
rg -l "\.css" --type html

Length of output: 504


Script:

#!/bin/bash
# Let's examine the content of index.html and register.html to find the actual stylesheet references
# and then check their content for the relevant styles
cat index.html register.html | rg "<link.*stylesheet.*css"

Length of output: 285


Script:

#!/bin/bash
# Now let's check the content of styles.css for button-active and form-register styles
# and their dark mode variants
cat styles.css | rg -A 3 "\.button-active|\.form-register|\.dark-mode"

Length of output: 215

styles.css (1)

334-337: Consider consolidating duplicate hover effects.

The same hover effect is duplicated across multiple components. Consider creating a shared class to reduce code duplication.

+.hover-scale {
+  transition: transform 0.3s ease;
+}
+
+.hover-scale:hover {
+  transform: scale(1.05);
+}

 .feature-card {
   width: 300px;
   background-color: #fff;
   border-radius: 8px;
   box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
   padding: 15px;
-  transition: transform 0.3s ease;
+  @extend .hover-scale;
 }
-.feature-card:hover {
-  transform: scale(1.05);
-}

 .mission-item {
   width: 23%;
   background-color: #fff;
   padding: 15px;
   border-radius: 8px;
   box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
   text-align: center;
-  transition: transform 0.3s ease;
+  @extend .hover-scale;
 }
-.mission-item:hover {
-  transform: scale(1.05);
-}

 .value-card {
   width: 23%;
   background-color: #fff;
   padding: 15px;
   border-radius: 8px;
   box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
-  transition: transform 0.3s ease;
+  @extend .hover-scale;
 }
-.value-card:hover {
-  transform: scale(1.05);
-}

Also applies to: 466-469, 492-495

index.html (1)

Line range hint 38-40: Enhance accessibility of the theme toggle button

The theme toggle button needs proper ARIA labels and keyboard support for better accessibility.

-<div id="theme-toggle" aria-label="Toggle darok mde">🌓</div>
+<button 
+    id="theme-toggle"
+    aria-label="Toggle dark mode"
+    role="switch"
+    aria-checked="false"
+    tabindex="0">
+    🌓
+</button>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4ee2a67 and adf8b70.

📒 Files selected for processing (4)
  • index.html (8 hunks)
  • script.js (0 hunks)
  • styles.css (12 hunks)
  • styles.js (1 hunks)
💤 Files with no reviewable changes (1)
  • script.js
🔇 Additional comments (1)
styles.css (1)

148-150: LGTM! Border styling changes improve visual hierarchy.

The transition from background colors to bordered sections with subtle shadows creates better visual separation while maintaining a clean, modern look. The colored accents (green, blue) effectively distinguish different sections.

Also applies to: 202-203, 256-258, 628-628

styles.js Show resolved Hide resolved
styles.js Show resolved Hide resolved
styles.css Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Show resolved Hide resolved
@khushi-joshi-05 khushi-joshi-05 merged commit adf8b70 into GarimaSingh0109:main Nov 10, 2024
4 of 8 checks passed
@Mohitranag18
Copy link
Contributor Author

@khushi-joshi-05 can you please assign label to it

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

Successfully merging this pull request may close these issues.

3 participants