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

Redesign of carbon footprint page #373

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

royvivi29
Copy link
Contributor

@royvivi29 royvivi29 commented Oct 20, 2024

Issues Identification

close #369

Summary

I redesigned the entire Carbon Footprint page, updating the header, footer, main content, and JavaScript functionality. The header and footer were streamlined for better navigation and responsiveness. The main content was reorganized to improve readability and engagement, with added sections for data visualization. JavaScript updates enhanced interactivity, introducing dynamic content and real-time functionality. Overall, the changes improve usability, visual appeal, and mobile performance.

Details

Include any detailed information about the changes in this pull request.

Types of Changes

Please check the boxes that apply

  • [👍 ] New feature (non-breaking change that adds functionality)
  • [ 👍 ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Please check the boxes that apply

  • [👍 ] My code follows the style guidelines of this project
  • [ 👍 ] I have performed a self-review of my own code
  • [ ok] I have commented my code, particularly in hard-to-understand areas
  • [ok ] I have made corresponding changes to the documentation
  • [ ok] My changes generate no new warnings
  • [ ok] My changes do not break the current system and pass all existing test cases
  • [ ok] I have added tests that prove my fix is effective or that my feature works
  • [ ok] New and existing unit tests pass locally with my changes
  • [ ok] Any dependent changes have been merged and published in downstream modules

Screenshots

Screenshot 2024-10-20 160020
Screenshot 2024-10-20 204719
Screenshot 2024-10-20 204719 - Copy

Summary by CodeRabbit

  • New Features

    • Introduced a responsive navigation header with theme toggle functionality.
    • Added a progress bar that dynamically updates based on scroll position.
    • Implemented a newsletter subscription form and enhanced footer elements.
    • New form validation and calculation features for the carbon footprint calculator.
  • Style

    • Comprehensive styling overhaul, including dark mode support and improved responsiveness.
    • Enhanced styles for input fields, buttons, and social media icons for better interaction.

Copy link
Contributor

coderabbitai bot commented Oct 20, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request involve a comprehensive redesign of the Carbon Footprint Page, enhancing both the CSS and HTML files. Key modifications include the introduction of a universal reset style, a new progress bar, improved navigation, and responsive design features. Dark mode styling is added, and the overall layout is optimized for better user interaction. JavaScript functionality is also implemented for theme toggling and form validation, significantly improving the user experience and functionality of the carbon footprint calculator.

Changes

File Change Summary
Carbo-footprint.css Added universal reset styles, new styles for progress bar, header, navigation, dark mode, input fields, buttons, and responsive design adjustments. Enhanced aesthetics and layout for various components.
carbon-footprint.html Updated stylesheet link, added progress bar and navigation header, implemented theme toggle, expanded footer, and added JavaScript for interactivity and form validation.
.vscode/settings.json Modified live server port setting from 5501 to 5502.

Assessment against linked issues

Objective Addressed Explanation
Enhanced user experience with intuitive interface (369)
Improved functionality with interactive tools (369)
Simplified process of tracking carbon footprint (369)

Possibly related PRs

Suggested labels

level3

Poem

🐇 In the garden where the footprints lay,
A new design hops in to brighten the day.
With colors that dance and a progress bar's cheer,
The carbon we track brings the future near.
So toggle your theme, let the journey unfold,
Together we’ll save, let the story be told! 🌱


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

netlify bot commented Oct 20, 2024

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

Name Link
🔨 Latest commit d0792ff
🔍 Latest deploy log https://app.netlify.com/sites/manageyourwaste/deploys/67152850c0b23400087c7336

@royvivi29 royvivi29 closed this Oct 20, 2024
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: 10

🧹 Outside diff range and nitpick comments (3)
carbon-footprint.html (2)

24-24: Fix capitalization in navigation menu item 'About Us'

In the navigation menu, "About US" should be "About Us" to maintain consistent capitalization throughout the site.

Apply this diff to correct the text:

-<li><a href="#about">About US</a></li>
+<li><a href="#about">About Us</a></li>

129-130: Replace curly apostrophes with straight apostrophes

Curly apostrophes can cause encoding issues in some environments. Replacing them with straight apostrophes ensures better compatibility.

Apply this diff to fix the apostrophe:

-    tips = 'You are doing well, but there’s room for improvement. Try to recycle more!';
+    tips = 'You are doing well, but there's room for improvement. Try to recycle more!';
Carbo-footprint.css (1)

85-87: Unnecessary display: none; for #menu-toggle

The #menu-toggle button is set to display: none; by default and then shown in the media query. Consider using a mobile-first approach or adding comments for clarity.

Add a comment to clarify the purpose:

#menu-toggle {
    display: none; /* Hide menu toggle on larger screens */
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 388d133 and 1007bd7.

📒 Files selected for processing (2)
  • Carbo-footprint.css (2 hunks)
  • carbon-footprint.html (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
carbon-footprint.html (1)

61-70: Ensure 'box-icon' components are properly included

The social media icons use <box-icon> elements, which require the Boxicons library. Verify that the library is properly included so the icons render correctly.

Run the following script to check for the inclusion of the Boxicons library:

This script searches for references to Boxicons in your HTML files to ensure the icons will display.

Carbo-footprint.css (1)

125-132: Redundant background color for main in dark mode

The main element has a light background color (#EDF6F9), which might not be appropriate in dark mode. Consider adjusting it when in dark mode.

Verify if main retains the light background in dark mode and adjust accordingly.

@@ -4,9 +4,36 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carbon Footprint Calculator</title>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="Carbo-footprint.css">
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the stylesheet filename to 'carbon-footprint.css'

The stylesheet link currently points to Carbo-footprint.css, which seems to be a typo. Updating it to carbon-footprint.css will ensure the styles load correctly.

Apply this diff to fix the filename:

-<link rel="stylesheet" href="Carbo-footprint.css">
+<link rel="stylesheet" href="carbon-footprint.css">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<link rel="stylesheet" href="Carbo-footprint.css">
<link rel="stylesheet" href="carbon-footprint.css">

Comment on lines +117 to +118
const netWaste = wasteAmount - recycledAmount;
const carbonFootprint = netWaste * 0.5; // Example factor
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Handle potential negative net waste values

If the recycled amount exceeds the waste amount, the net waste becomes negative, leading to an incorrect carbon footprint calculation. Adding a check to ensure netWaste is non-negative will improve accuracy.

Apply this diff to handle negative net waste values:

 const netWaste = wasteAmount - recycledAmount;
+const adjustedNetWaste = Math.max(netWaste, 0);
-const carbonFootprint = netWaste * 0.5; // Example factor
+const carbonFootprint = adjustedNetWaste * 0.5; // Example factor
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const netWaste = wasteAmount - recycledAmount;
const carbonFootprint = netWaste * 0.5; // Example factor
const netWaste = wasteAmount - recycledAmount;
const adjustedNetWaste = Math.max(netWaste, 0);
const carbonFootprint = adjustedNetWaste * 0.5; // Example factor

Comment on lines +112 to +113
alert("Please enter valid numbers.");
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Provide validation feedback within the page instead of using alerts

Using alert for validation messages can interrupt the user experience. Displaying messages within the page is less intrusive and provides a better UX.

Apply this diff to display validation messages on the page:

-    alert("Please enter valid numbers.");
+    const resultDiv = document.getElementById('result');
+    resultDiv.innerHTML = "<strong>Please enter valid numbers.</strong>";
+    return;

Make similar adjustments for other validation messages to maintain consistency.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
alert("Please enter valid numbers.");
return;
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = "<strong>Please enter valid numbers.</strong>";
return;

Comment on lines +111 to +114
if (isNaN(wasteAmount) || isNaN(recycledAmount)) {
alert("Please enter valid numbers.");
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Validate that input values are non-negative

Currently, users can enter negative values for waste amounts, which may not make sense in this context. Adding validation to ensure inputs are non-negative enhances data integrity.

Apply this diff to validate non-negative inputs:

 if (isNaN(wasteAmount) || isNaN(recycledAmount)) {
     alert("Please enter valid numbers.");
     return;
 }
+if (wasteAmount < 0 || recycledAmount < 0) {
+    alert("Please enter non-negative numbers.");
+    return;
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (isNaN(wasteAmount) || isNaN(recycledAmount)) {
alert("Please enter valid numbers.");
return;
}
if (isNaN(wasteAmount) || isNaN(recycledAmount)) {
alert("Please enter valid numbers.");
return;
}
if (wasteAmount < 0 || recycledAmount < 0) {
alert("Please enter non-negative numbers.");
return;
}

Comment on lines +138 to +147
const progressBar = document.getElementById('progress-bar');
if (progressBar) {
window.addEventListener('scroll', () => {
const windowHeight = window.innerHeight;
const documentHeight = document.documentElement.scrollHeight;
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const scrollPercentage = (scrollTop / (documentHeight - windowHeight)) * 100;

<script src="script.js"></script>
progressBar.style.width = scrollPercentage + '%';
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize scroll event listener for better performance

Attaching a function directly to the scroll event can impact performance due to the high frequency of scroll events. Consider throttling or debouncing the event handler.

Apply this diff to throttle the scroll event handler using requestAnimationFrame:

-    window.addEventListener('scroll', () => {
+    let ticking = false;
+    window.addEventListener('scroll', () => {
+        if (!ticking) {
+            window.requestAnimationFrame(() => {
             const windowHeight = window.innerHeight;
             const documentHeight = document.documentElement.scrollHeight;
             const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
             const scrollPercentage = (scrollTop / (documentHeight - windowHeight)) * 100;
             progressBar.style.width = scrollPercentage + '%';
+                ticking = false;
+            });
+            ticking = true;
+        }
     });

This approach improves performance by reducing the number of times the function executes during scrolling.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const progressBar = document.getElementById('progress-bar');
if (progressBar) {
window.addEventListener('scroll', () => {
const windowHeight = window.innerHeight;
const documentHeight = document.documentElement.scrollHeight;
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const scrollPercentage = (scrollTop / (documentHeight - windowHeight)) * 100;
<script src="script.js"></script>
progressBar.style.width = scrollPercentage + '%';
});
const progressBar = document.getElementById('progress-bar');
if (progressBar) {
let ticking = false;
window.addEventListener('scroll', () => {
if (!ticking) {
window.requestAnimationFrame(() => {
const windowHeight = window.innerHeight;
const documentHeight = document.documentElement.scrollHeight;
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const scrollPercentage = (scrollTop / (documentHeight - windowHeight)) * 100;
progressBar.style.width = scrollPercentage + '%';
ticking = false;
});
ticking = true;
}
});

Comment on lines +200 to +205
.social-media {
display: flex;
justify-content: center;
gap: 15px; /* Space between the icons */
margin-top: 20px;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Duplicate .social-media class definitions

The .social-media class is defined twice with different styles at lines 200-205 and 286-288. This can lead to confusion and unexpected styling issues.

To resolve this, consider merging the styles or renaming one of the classes to prevent conflicts.

/* Combine the styles or rename one of the classes */
.social-media {
    display: flex;
    justify-content: center;
    gap: 15px; /* Space between the icons */
    margin-top: 20px;
+   margin: 20px 0; /* Combined margin styles */
}

Also applies to: 286-288

Comment on lines +206 to +215

.social-media a {
display: inline-block;
font-size: 2rem;
color: #6366F1; /* Adjust this to match your site's theme */
transition: color 0.3s ease;
}
.social-media a:hover {
color: #4f50c4; /* Darker color on hover */
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Conflicting styles for .social-media a

The styles for .social-media a are defined twice with differing properties at lines 206-215 and 290-293. This might result in inconsistent styling for social media links.

Consider unifying these styles or using more specific class names to avoid conflicts.

/* Combine the styles for .social-media a */
.social-media a {
    display: inline-block;
    font-size: 2rem;
-   color: #6366F1; /* Original color */
+   color: white; /* Unified color */
    margin: 0 10px;
    transition: color 0.3s ease;
}

.social-media a:hover {
    color: #4f50c4; /* Darker color on hover */
}

Also applies to: 290-293

Comment on lines +114 to +122
@media (max-width: 768px) {
.nav-menu {
display: none; /* Hide nav menu on smaller screens */
}

.container {
max-width: 600px;
margin: auto;
#menu-toggle {
display: block; /* Show menu toggle button */
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Merge media queries for better maintainability

There are two separate @media (max-width: 768px) queries with overlapping styles at lines 114-122 and 222-249. Merging them can simplify the CSS and make it easier to maintain.

Combine the media queries into one:

@media (max-width: 768px) {
    .nav-menu {
        display: none; /* Hide nav menu on smaller screens */
    }

    #menu-toggle {
        display: block; /* Show menu toggle button */
    }

+   header {
+       flex-wrap: wrap;
+   }
+  
+   nav {
+       order: 3;
+       width: 100%;
+       margin-top: 15px;
+   }
+  
+   nav ul {
+       flex-direction: column;
+       display: none;
+   }
+  
+   nav ul.show {
+       display: flex;
+   }
+  
+   nav ul li {
+       margin: 10px 0;
+   }
}

Also applies to: 222-249

justify-content: center;
align-items: center;
min-height: 100vh; /* Makes sure the content is vertically centered */
background-color: #EDF6F9; /* Light background for the main section */
padding: 20px;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Missing box-sizing on containers

Adding box-sizing: border-box; to the .container class ensures padding and border are included in the total width and height, preventing layout issues.

Apply this diff to add box-sizing:

main .container {
    width: 100%; /* Ensures the container takes full width but stays within max-width */
    max-width: 600px; /* Keeps the layout consistent */
    background-color: #FFDDD2; /* Matches the container's background */
    border: 1px solid #006D77;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
+   box-sizing: border-box;
}

Also applies to: 133-141

Carbo-footprint.css Show resolved Hide resolved
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.

Redesign of Carbon Footprint Page
2 participants