Skip to content

Conversation

@Anubhava2105
Copy link

Enhanced Theme Toggle with Improved Icons and Animations

Changes

  • Dark Mode Icon: Enhanced sun icon with clear rays for better visibility
  • Light Mode Icon: Added a proper crescent moon icon with smoother curves
  • Random Mode Icon: Implemented a dice-like icon with white dots to represent randomness
  • Animation: Added a subtle shake animation when hovering over the random theme icon
  • Accessibility: Improved title attributes to provide clearer context for each theme state
  • Color Theming: Updated the random theme to use a green color palette for better visual distinctiveness

#Screenshots
image
image
image

- Add better sun and moon icons for light/dark modes
- Implement custom dice icon for random theme with green color
- Add shake animation effect for random theme icon
- Ensure proper visibility of theme toggle elements in all modes
- Improve accessibility with descriptive hover titles
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Anubhava2105, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the user experience of the theme toggle feature. It replaces generic icons with visually distinct sun, moon, and dice SVGs for dark, light, and random themes, respectively. The random theme now boasts a unique green color scheme and an engaging shake animation on hover. Furthermore, accessibility is improved by dynamically updating the toggle button's title attribute to inform users about the current theme and the next available option.

Highlights

  • Enhanced Icons: Introduced distinct SVG icons for dark (sun), light (crescent moon), and random (dice) theme modes, replacing the previous single icon.
  • Random Theme Styling: Updated the random theme to feature a unique green color palette for its toggle icon and added a subtle shake animation that triggers on hover.
  • Accessibility Improvements: Enhanced the theme toggle button's 'title' attribute to dynamically provide clearer context for the current theme state and the next available option.
  • Dynamic Icon Display: Implemented CSS to dynamically control the visibility and transition of the appropriate theme icon based on the currently active theme.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@deepsource-io
Copy link

deepsource-io bot commented Oct 3, 2025

Here's the code health analysis summary for commits e9e2a62..b1863b0. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython✅ SuccessView Check ↗
DeepSource Secrets LogoSecrets✅ SuccessView Check ↗
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does a great job of enhancing the theme toggle feature with new icons for each state and a fun shake animation for the random theme. The accessibility improvement of updating the button's title attribute is also a valuable addition. My review includes a few suggestions to refine the implementation. In the JavaScript file, there's an opportunity to reduce code duplication by creating a helper function for updating the theme button's title. In the CSS, some rules for styling the new random theme icon appear to be redundant and could be simplified, and an animation rule could be removed for a minor performance optimization.

Comment on lines 383 to 388
const themeLabels = {
dark: 'Currently in dark mode, click for light mode',
light: 'Currently in light mode, click for random mode',
random: 'Currently in random mode, click for dark mode',
};
elmThemeToggleButton.setAttribute('title', themeLabels[currentTheme] || 'Toggle theme');
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This block of code, including the themeLabels object, is a duplicate of the logic at lines 315-320. To improve maintainability and follow the DRY (Don't Repeat Yourself) principle, you could refactor this.

I'd suggest defining the themeLabels object once at a higher scope (e.g., near your other constants) and creating a small helper function to set the title. You could then call this function both on initialization and here in the click handler.

Example refactoring:

// At a higher scope in the file
const themeLabels = {
  dark: 'Currently in dark mode, click for light mode',
  light: 'Currently in light mode, click for random mode',
  random: 'Currently in random mode, click for dark mode',
};

function updateThemeButtonTitle() {
  if (elmThemeToggleButton) {
    elmThemeToggleButton.setAttribute('title', themeLabels[currentTheme] || 'Toggle theme');
  }
}

// Then you can simply call `updateThemeButtonTitle()` here and on line 314.

Comment on lines 64 to 76
[data-theme='random'] .random-icon {
color: var(--toggle-icon-color);
}

[data-theme='random'] .random-icon rect {
fill: var(--toggle-icon-color);
stroke: var(--toggle-icon-color);
}

[data-theme='random'] .theme-toggle:hover .random-icon rect {
fill: var(--toggle-icon-hover);
stroke: var(--toggle-icon-hover);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

These styling rules for the random icon and its rectangle appear to be redundant. The color property is already set on all theme toggle SVGs in the rule at lines 46-55, and the rect element inside the SVG uses currentColor for its fill and stroke, so it should inherit the color from its parent SVG automatically. This also applies to the :hover state.

Removing these rules would make the styling more consistent with the other icons (sun-icon, moon-icon) and simplify the CSS. The existing rules for .theme-toggle svg and .theme-toggle:hover svg should be sufficient.

Comment on lines 126 to 128
.theme-toggle:hover .random-icon {
animation: shake 0.8s ease;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This rule applies the shake animation to the .random-icon on hover, regardless of the current theme. When the theme is not 'random', this icon is invisible (opacity: 0), so the browser is doing unnecessary work animating an element that isn't visible. This can be a minor performance issue.

The rule at lines 131-133 already handles the animation when the random theme is active. You can safely remove this rule to avoid the unnecessary animation.

Made the changes given by gemini code assist to improve code maintainability
@jbampton jbampton self-assigned this Oct 3, 2025
@jbampton jbampton added this to Chess Oct 3, 2025
@jbampton jbampton added this to the Hacktoberfest milestone Oct 3, 2025
@jbampton jbampton moved this to In Progress in Chess Oct 3, 2025
@jbampton jbampton added help wanted Extra attention is needed javascript Pull requests that update javascript code css nunjucks labels Oct 3, 2025
@Anubhava2105
Copy link
Author

Hey, why are these checks failing? I don't think it has anything to do with the code.

@jbampton
Copy link
Member

jbampton commented Oct 4, 2025

Hey, why are these checks failing? I don't think it has anything to do with the code.

Those checks are just general failing tests we have.

There are other open issues to fix those

@jbampton
Copy link
Member

jbampton commented Oct 4, 2025

If any of the gemini conversations are completed you should click resolve

@jbampton jbampton marked this pull request as draft October 4, 2025 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

css frontend help wanted Extra attention is needed javascript Pull requests that update javascript code nunjucks

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

FRONT: Change theme toggle icon to sun / mon / and special one (for random) after clicking on each one

2 participants