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

Adding new 404 error themes #156

Merged
merged 5 commits into from
Oct 27, 2024

Conversation

Khushalsarode
Copy link
Contributor

@Khushalsarode Khushalsarode commented Aug 25, 2024

  1. galaxy
  2. starwars

screenshot:
galaxy
starwars

closes #155

Summary by CodeRabbit

  • New Features

    • Introduced new custom 404 error pages for "Galaxy" and "Star Wars" themes to enhance user experience.
    • Implemented engaging designs and animations for the 404 error pages.
  • Styling

    • Added unique CSS styles for "Galaxy" and "Star Wars" themes to enrich the visual presentation of error pages.
  • Interactivity

    • Implemented dynamic particle animations on error pages to create an immersive user experience.

Copy link

coderabbitai bot commented Aug 25, 2024

Walkthrough

The changes introduce two new themes for 404 error pages: "Galaxy" and "Starwars." Each theme includes dedicated HTML, CSS, and JavaScript files that enhance user experience with themed visuals and animations. The "Galaxy" theme features a particle system with space-related graphics, while the "Starwars" theme incorporates elements from the franchise, providing engaging error pages for users when a requested page is not found.

Changes

Files Change Summary
galaxy/js/404.js Introduced a configuration object for a particle system using tsParticles, defining properties like number of particles, color, shape, size, movement, and opacity.
starwars/404.html, starwars/css/style.css, starwars/js/script.js Introduced the "Starwars" themed 404 error page with HTML structure, CSS for styling, and JavaScript for particle effects.
galaxy/404.html, galaxy/css/404.css Created a new HTML file for the "Galaxy" themed 404 error page, including Google Analytics and styled elements for user interaction.

Assessment against linked issues

Objective Addressed Explanation
Want to add two new themes: "galaxy" & "starwars" (#[155])

🐰 In the galaxy so bright,
A 404 takes flight,
With stars and wars in view,
Error pages now anew!
Hop along, don’t be blue,
The cosmos calls to you! ✨🌌


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e1d5d6d and 7492e0b.

📒 Files selected for processing (2)
  • starwars/css/style.css (1 hunks)
  • starwars/js/script.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • starwars/css/style.css
  • starwars/js/script.js

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

@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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7808215 and a44c52a.

Files ignored due to path filters (7)
  • __screenshots/galaxy.png is excluded by !**/*.png
  • __screenshots/starwars.png is excluded by !**/*.png
  • galaxy/image/astroid.png is excluded by !**/*.png
  • starwars/image/deadstar.png is excluded by !**/*.png
  • starwars/image/ship1.png is excluded by !**/*.png
  • starwars/image/ship2.png is excluded by !**/*.png
  • starwars/image/ship3.png is excluded by !**/*.png
Files selected for processing (7)
  • data/pages.json (1 hunks)
  • galaxy/404.html (1 hunks)
  • galaxy/css/404.css (1 hunks)
  • galaxy/js/404.js (1 hunks)
  • starwars/404.html (1 hunks)
  • starwars/css/style.css (1 hunks)
  • starwars/js/script.js (1 hunks)
Files skipped from review due to trivial changes (2)
  • galaxy/css/404.css
  • starwars/css/style.css
Additional comments not posted (23)
starwars/404.html (6)

1-2: LGTM!

The DOCTYPE declaration and HTML tag are correctly specified.

The code changes are approved.


3-11: LGTM!

The Google Analytics script is correctly included and configured.

The code changes are approved.


13-18: LGTM!

The title, font, stylesheet, and favicon are correctly included.

The code changes are approved.


19-28: LGTM!

The tsParticles container and error message content are correctly included.

The code changes are approved.


30-31: LGTM!

The tsParticles script is correctly included.

The code changes are approved.


32-33: LGTM!

The closing tags for body and html are correctly specified.

The code changes are approved.

galaxy/js/404.js (1)

1-64: LGTM!

The configuration object for tsParticles is correctly defined and the call to load tsParticles is correctly included.

The code changes are approved.

galaxy/404.html (6)

1-2: LGTM!

The DOCTYPE declaration and HTML tag are correctly specified.

The code changes are approved.


3-17: LGTM!

The Google Analytics script is correctly included and configured.

The code changes are approved.


19-27: LGTM!

The title, font, stylesheet, and favicon are correctly included.

The code changes are approved.


29-43: LGTM!

The tsParticles container and error message content are correctly included.

The code changes are approved.


45-49: LGTM!

The tsParticles script is correctly included.

The code changes are approved.


50-51: LGTM!

The closing tags for body and html are correctly specified.

The code changes are approved.

starwars/js/script.js (8)

1-2: LGTM!

The frame rate limit is set correctly.

The code changes are approved.


3-10: LGTM!

The configuration for the number of particles and density is set correctly.

The code changes are approved.


11-17: LGTM!

The configuration for the color and animation is set correctly.

The code changes are approved.


18-42: Reminder: Replace image paths.

The configuration for the shape is set correctly. However, ensure that the paths to the images are replaced with the correct custom SVGs.

Verify that the image paths are correct and accessible.


43-49: LGTM!

The configuration for the size is set correctly.

The code changes are approved.


50-70: LGTM!

The configuration for the movement is set correctly. The custom path generator adds a circular motion to the particles.

The code changes are approved.


71-80: LGTM!

The configuration for the opacity and retina detection is set correctly.

The code changes are approved.


81-83: LGTM!

The tsParticles.load function is called correctly.

The code changes are approved.

data/pages.json (2)

153-156: LGTM!

The entry for "Galaxy 404" is formatted correctly and the URLs appear to be valid.

The code changes are approved.


157-160: LGTM!

The entry for "Starwars 404" is formatted correctly and the URLs appear to be valid.

The code changes are approved.

@Khushalsarode
Copy link
Contributor Author

@matteobruni
should i only push the code, its failed as i edited and pushed data.json

@matteobruni
Copy link
Contributor

@matteobruni should i only push the code, its failed as i edited and pushed data.json

Don't worry about Codacy, only Node.js CI is required, and it's failing too.

Copy link

@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: 8

🧹 Outside diff range and nitpick comments (5)
starwars/404.html (1)

1-41: Overall assessment: Good implementation with room for improvement

The Star Wars-themed 404 error page is well-structured and creative. However, there are several areas where it can be enhanced:

  1. Improve accessibility with proper ARIA labels and semantic HTML.
  2. Optimize performance by using defer for scripts and considering local hosting of libraries.
  3. Enhance user experience with more helpful error messages and proper link functionality.
  4. Address potential privacy concerns with Google Analytics implementation.
  5. Clarify the source and implementation of the Star Wars font.

Please review and address the suggestions in the previous comments. Once these improvements are made, the 404 error page will provide a better user experience while maintaining its creative Star Wars theme.

Consider creating a consistent error page template that can be easily customized for different themes (like Galaxy and Star Wars) to ensure a uniform user experience across various error pages in your project.

starwars/css/style.css (2)

1-8: LGTM with a suggestion for font fallback.

The body styles are well-defined for a full-page theme. However, consider adding a fallback font for better cross-platform compatibility.

Consider updating the font-family declaration:

-  font-family: "Star Wars", sans-serif;
+  font-family: "Star Wars", "Roboto", sans-serif;

19-47: LGTM with a suggestion for improved accessibility.

The .error-container styles are well-structured and visually appealing. The use of text shadows enhances readability against the dark background.

Consider increasing the contrast ratio for better accessibility:

 .error-container p {
   font-size: 1.2em;
-  color: #cccccc;
+  color: #e0e0e0;
   margin: 20px 0;
   text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.4);
 }
starwars/js/script.js (2)

11-18: Consider reducing the color animation speed for a more subtle effect.

The color choices are great for the Star Wars theme. However, the animation speed of 20 might be too fast for a space-themed background. A slower speed could create a more subtle and immersive effect.

Consider reducing the animation speed:

 animation: {
   enable: true,
-  speed: 20,
+  speed: 10,
   sync: true,
 },

44-50: Adjust base particle size for better proportion.

The current base size of 25 might be too large relative to the image sizes (100x100). A smaller base size would create better proportions and allow for more particles on screen without overcrowding.

Consider reducing the base size:

 size: {
-  value: 25,
+  value: 15,
   random: {
     enable: true,
     minimumValue: 3,
   },
 },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a44c52a and ab9d6d7.

📒 Files selected for processing (4)
  • galaxy/js/404.js (1 hunks)
  • starwars/404.html (1 hunks)
  • starwars/css/style.css (1 hunks)
  • starwars/js/script.js (1 hunks)
🧰 Additional context used
🔇 Additional comments (12)
starwars/404.html (4)

1-2: LGTM: Proper HTML5 structure and language declaration.

The HTML5 doctype and language declaration are correctly implemented, following best practices for accessibility and SEO.


18-26: 🛠️ Refactor suggestion

Enhance <head> section for better performance and SEO.

The <head> section is well-structured, but consider the following improvements:

  1. Add meta description for better SEO.
  2. Use preload for critical resources like custom CSS.
  3. The Star Wars font link seems incorrect. There's no official "Star Wars" font family on Google Fonts.

Add a meta description:

<meta name="description" content="404 Error - Star Wars themed error page">

Preload critical CSS:

<link rel="preload" href="css/style.css" as="style">

Could you clarify the source of the Star Wars font? If it's a custom font, consider using font-display: swap for better performance:

#!/bin/bash
# Check if there's a custom font declaration in the CSS file
rg --type css 'font-family:\s*["\']?Star Wars["\']?' css/style.css

38-39: 🛠️ Refactor suggestion

Consider performance optimizations for script loading.

The script inclusions are correct, but consider these optimizations:

  1. Add defer attribute to both script tags to improve page load performance.
  2. Consider hosting the tsParticles library locally for better control over versioning and availability.

Update the script tags as follows:

<script defer src="https://cdn.jsdelivr.net/npm/tsparticles@2/tsparticles.bundle.min.js"></script>
<script defer src="js/script.js"></script>

Let's check the content of the custom script file:

#!/bin/bash
# Display the content of script.js
cat js/script.js

Could you provide more information about the functionality implemented in script.js? This would help ensure that the Star Wars theme is properly applied using tsParticles.


27-36: 🛠️ Refactor suggestion

Enhance accessibility and usability of the error page content.

The content structure is good, but consider these improvements:

  1. Add aria-label to the tsParticles container for screen readers.
  2. Use semantic HTML for the error message structure (e.g., <main>, <header>).
  3. The "Return to Home" link should have a proper href attribute.
  4. Consider adding more context or suggestions for the user.

Here's an example of how to implement these changes:

-<div id="tsparticles"></div>
+<div id="tsparticles" aria-label="Star Wars themed particle animation background"></div>

-<div class="error-container">
+<main class="error-container">
+  <header>
     <h1>404 WARS!</h1>
     <h2>The Force is not with you</h2>
+  </header>
   <p>It seems the page you are looking for is lost in the galaxy...</p>
+  <p>Try using the force to search for what you're looking for, or return to our Jedi Council (home page).</p>
-  <a href="#" class="home-button">Return to Home</a>
+  <a href="/" class="home-button">Return to Home</a>
+</main>

Let's check if there are any other 404 pages in the project for consistency:

galaxy/js/404.js (1)

55-61: Opacity configuration looks great

The opacity settings are well-configured. The base opacity of 0.8 with randomization down to 0.3 will create a nice depth effect in the animation, enhancing the space-like atmosphere.

starwars/css/style.css (4)

10-17: LGTM! Proper positioning for background particles.

The #tsparticles styles are correctly set to cover the entire viewport and stay behind other content.


49-61: LGTM! Well-styled button with smooth transitions.

The .home-button styles are consistent with the Star Wars theme and include appropriate transitions for a polished user experience.


63-66: LGTM! Appropriate hover effects.

The hover styles for .home-button provide good visual feedback to the user, enhancing the interactive experience.


1-66: Great job on the Star Wars themed CSS!

Overall, the CSS for the Star Wars themed 404 page is well-structured and visually appealing. It successfully creates an immersive experience while maintaining good usability. The use of appropriate colors, text shadows, and transitions enhances the theme and user interaction.

A few minor suggestions were made to improve font fallback and accessibility, but these are small tweaks to an already solid implementation. Great work on creating a themed 404 page that aligns well with the PR objectives!

starwars/js/script.js (3)

1-10: LGTM: Basic configuration and particle number settings are well-defined.

The FPS limit of 60 and 300 particles with density enabled should provide a smooth and visually appealing effect without overloading the browser.


72-83: LGTM: Opacity settings and final configuration are well-defined.

The opacity settings provide good variety for particle visibility, and enabling retina detection ensures high-quality visuals on all displays. The tsParticles.load() call at the end correctly initializes the particle system with the defined configuration.


1-83: Overall, great implementation of the Star Wars-themed particle system.

The configuration successfully creates a visually appealing and thematic 404 error page using the tsParticles library. The suggestions provided in the review comments will further enhance the visual appeal, responsiveness, and maintainability of the particle system. Great job on implementing this feature!

starwars/404.html Show resolved Hide resolved
galaxy/js/404.js Show resolved Hide resolved
galaxy/js/404.js Show resolved Hide resolved
galaxy/js/404.js Show resolved Hide resolved
galaxy/js/404.js Show resolved Hide resolved
galaxy/js/404.js Show resolved Hide resolved
starwars/js/script.js Show resolved Hide resolved
starwars/js/script.js Outdated Show resolved Hide resolved
Copy link

@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: 0

🧹 Outside diff range and nitpick comments (2)
starwars/js/script.js (2)

11-18: LGTM: Vibrant color configuration with animation.

The color configuration looks great. The diverse palette fits the Star Wars theme well, and the animation adds a dynamic element to the particles.

Consider adding a comment explaining the significance of each color in the Star Wars context, if applicable. For example:

// Colors represent iconic elements: 
// white (stormtroopers), yellow (C-3PO), red (lightsabers), green (Yoda), blue (R2-D2)

72-83: LGTM: Good opacity configuration and initialization.

The opacity settings and final setup look good. The range of opacity values will add depth to the particle effect, and enabling retina detection ensures the animation looks crisp on high-resolution displays.

Consider adding error handling to the tsParticles.load() call to gracefully handle any initialization failures:

tsParticles.load("tsparticles", particles)
  .catch(error => {
    console.error("Failed to load particle system:", error);
    // Optionally, implement a fallback or show an error message to the user
  });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ab9d6d7 and e1d5d6d.

📒 Files selected for processing (2)
  • starwars/css/style.css (1 hunks)
  • starwars/js/script.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • starwars/css/style.css
🧰 Additional context used
🔇 Additional comments (4)
starwars/js/script.js (4)

1-10: LGTM: Good configuration for particle system basics.

The basic configuration looks solid. The FPS limit of 60 ensures smooth animations, and 300 particles with density enabled should provide a visually appealing effect while maintaining good performance.


44-50: LGTM: Good size configuration for visual diversity.

The size configuration looks good. Setting a base size of 25 with random sizing enabled and a minimum value of 3 will create a nice variety in particle sizes, enhancing the visual appeal of the effect.


19-43: 🛠️ Refactor suggestion

Enhance visual variety and ensure correct image loading.

The use of custom Star Wars-themed images for particles is excellent. However, two improvements can be made:

  1. Consider varying the sizes of different particle images to add more visual interest.
  2. Use absolute paths for image sources to ensure they load correctly regardless of the script's location.

Apply these changes:

 shape: {
   type: "image",
   image: [
     {
-      src: "./image/deadstar.png",
+      src: "/assets/images/starwars/deadstar.png",
       width: 100,
       height: 100,
     },
     {
-      src: "./image/ship1.png",
+      src: "/assets/images/starwars/ship1.png",
-      width: 100,
+      width: 80,
-      height: 100,
+      height: 80,
     },
     {
-      src: "./image/ship2.png",
+      src: "/assets/images/starwars/ship2.png",
-      width: 100,
+      width: 60,
-      height: 100,
+      height: 60,
     },
     {
-      src: "./image/ship3.png",
+      src: "/assets/images/starwars/ship3.png",
-      width: 100,
+      width: 40,
-      height: 100,
+      height: 40,
     },
   ],
 },

51-71: 🛠️ Refactor suggestion

Enhance movement configuration for better responsiveness and clarity.

The circular motion path is a great addition, simulating orbital movements. However, two improvements can be made:

  1. Make the radius responsive to screen size for better adaptability.
  2. Clarify the purpose of the delay value in the path configuration.

Consider applying these changes:

 path: {
   delay: {
     value: 0.2,
   },
   generator: (particle, time) => {
     const angle = time / 1000;
-    const radius = 200;
+    const radius = Math.min(window.innerWidth, window.innerHeight) / 4;
     return {
       x: Math.cos(angle) * radius,
       y: Math.sin(angle) * radius,
     };
   },
 },

Also, please add a comment explaining the purpose of the delay value.

@Khushalsarode
Copy link
Contributor Author

@matteobruni can we try now?

@Khushalsarode
Copy link
Contributor Author

Khushalsarode commented Oct 21, 2024

Screenshot 2024-10-22 022106

@matteobruni
done

@matteobruni matteobruni merged commit 866c699 into tsparticles:main Oct 27, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Want to add two new theme: "galaxy" & "starwars"
2 participants