Skip to content

Add shadow toggle options#1581

Merged
extesy merged 1 commit intoextesy:masterfrom
LiliaDoe:Add-box-shadow-toggle-option
Mar 21, 2025
Merged

Add shadow toggle options#1581
extesy merged 1 commit intoextesy:masterfrom
LiliaDoe:Add-box-shadow-toggle-option

Conversation

@LiliaDoe
Copy link
Copy Markdown
Contributor

Adds options to toggle viewer shadow and caption/details shadows

Copy link
Copy Markdown
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.

Hello @LiliaDoe, 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!

Summary of Changes

This pull request adds options to toggle the shadow behind the image viewer and the shadow behind captions and details. It introduces new settings in the options menu, allowing users to customize the appearance of these elements. The changes involve modifications to the locale file for new option descriptions, the options HTML file to include the new checkboxes, and the JavaScript files to handle the new options and apply the shadow toggles.

Highlights

  • New Options: Adds two new options: one to toggle the shadow behind the image viewer and another to toggle the shadow behind captions and details.
  • UI Changes: Updates the options page (html/options.html) with checkboxes for the new shadow options.
  • Logic Implementation: Modifies the JavaScript files (hoverzoom.js, options.js, common.js) to implement the shadow toggling functionality based on the user's settings.

Changelog

Click here to see the changelog
  • _locales/en/messages.json
    • Added new messages for the shadow toggle options and their tooltips, including 'optEnableViewerShadow', 'optEnableViewerShadowTooltip', 'optEnableCaptionDetailShadow', and 'optEnableCaptionDetailShadowTooltip'. These messages provide the text displayed in the options menu and the tooltips that appear when hovering over the options.
  • html/options.html
    • Added checkboxes for enabling/disabling the viewer shadow and caption/detail shadow. The new elements include the checkbox inputs with IDs 'chkViewerShadowEnabled' and 'chkCaptionDetailShadowEnabled', along with labels and tooltips.
  • js/common.js
    • Added default values for the new shadow options to the factorySettings object. The new properties are viewerShadowEnabled and captionDetailShadowEnabled, both initialized to true.
  • js/hoverzoom.js
    • Modified the hzViewer CSS to remove the box shadow if the viewerShadowEnabled option is disabled. This is done by setting imgFullSizeCss.boxShadow = 'none' when the option is false (line 1947).
    • Added logic to toggle caption and detail box shadows based on the captionDetailShadowEnabled option. If disabled, the boxShadow property is set to 'none' for hzCaptionCss, hzMiscellaneousCss, and hzDetailCss (lines 2116-2120).
  • js/options.js
    • Updated the saveOptions function to save the state of the new shadow options. The values of the 'chkViewerShadowEnabled' and 'chkCaptionDetailShadowEnabled' checkboxes are now stored in the options object (lines 53-54).
    • Updated the restoreOptions function to restore the state of the new shadow options when the options page is loaded. The checkboxes are triggered to be checked or unchecked based on the stored values of options.viewerShadowEnabled and options.captionDetailShadowEnabled (lines 200-201).
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Trivia time!

What CSS property is commonly used to add shadows to elements?

Click here for the answer
The `box-shadow` property is commonly used to add shadows to elements in CSS.

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.

Copy link
Copy Markdown
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

The pull request introduces shadow toggle options for the image viewer and caption/details, enhancing user customization. The changes are well-structured and cover the necessary files for options, localization, and logic implementation. However, there are a few areas that could be improved for better user experience and code maintainability.

Summary of Findings

  • Missing shadow toggle logic in hoverzoom.js: The code only disables the shadow for the image viewer but doesn't include logic to re-enable it if the option is toggled back on. This could lead to a confusing user experience if the shadow doesn't reappear when expected.
  • Inconsistent naming in common.js: The naming convention for the shadow-related options in common.js is slightly inconsistent. It would be better to use a consistent prefix like enable for all boolean options.
  • Missing default values in options.js: The code doesn't handle cases where the shadow-related options are undefined during restoration. Providing default values ensures that the options work correctly even if they are not explicitly set in the storage.

Merge Readiness

The pull request is almost ready for merging. Addressing the missing shadow toggle logic, inconsistent naming, and missing default values would significantly improve the code's robustness and user experience. I am unable to directly approve this pull request, and recommend that these comments be addressed before merging, and that others review and approve this code before merging.

Comment thread js/hoverzoom.js
Comment on lines +1947 to +1948
if (!options.viewerShadowEnabled)
imgFullSizeCss.boxShadow = 'none';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This code disables the shadow, but there's no corresponding logic to re-enable it if options.viewerShadowEnabled becomes true again. Consider adding an else block to set imgFullSizeCss.boxShadow to its default value when the option is enabled.

            if (!options.viewerShadowEnabled)
                imgFullSizeCss.boxShadow = 'none';
            else
                imgFullSizeCss.boxShadow = '1px 1px 5px rgba(0, 0, 0, 0.5), -1px 1px 5px rgba(0, 0, 0, 0.5), 1px -1px 5px rgba(0, 0, 0, 0.5), -1px -1px 5px rgba(0, 0, 0, 0.5)';

Comment thread js/hoverzoom.js
Comment on lines +2116 to +2120
if (!options.captionDetailShadowEnabled) { //Toggles caption and detail box shadow off if option is disabled
hzCaptionCss.boxShadow = 'none';
hzMiscellaneousCss.boxShadow = 'none';
hzDetailCss.boxShadow = 'none';
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the viewer shadow, there's no logic to re-enable the caption/detail shadow if the option is toggled back on. Add an else block to restore the default boxShadow values when options.captionDetailShadowEnabled is true.

            if (!options.captionDetailShadowEnabled) { //Toggles caption and detail box shadow off if option is disabled
                hzCaptionCss.boxShadow = 'none';
                hzMiscellaneousCss.boxShadow = 'none';
                hzDetailCss.boxShadow = 'none';
            } else {
                hzCaptionCss.boxShadow = '1px 1px 5px rgba(0, 0, 0, 0.5), -1px 1px 5px rgba(0, 0, 0, 0.5), 1px -1px 5px rgba(0, 0, 0, 0.5), -1px -1px 5px rgba(0, 0, 0, 0.5)';
                hzMiscellaneousCss.boxShadow = '1px 1px 5px rgba(0, 0, 0, 0.5), -1px 1px 5px rgba(0, 0, 0, 0.5), 1px -1px 5px rgba(0, 0, 0, 0.5), -1px -1px 5px rgba(0, 0, 0, 0.5)';
                hzDetailCss.boxShadow = '1px 1px 5px rgba(0, 0, 0, 0.5), -1px 1px 5px rgba(0, 0, 0, 0.5), 1px -1px 5px rgba(0, 0, 0, 0.5), -1px -1px 5px rgba(0, 0, 0, 0.5)';
            }

@sonarqubecloud
Copy link
Copy Markdown

@extesy extesy merged commit ccf0821 into extesy:master Mar 21, 2025
3 checks passed
@LiliaDoe LiliaDoe deleted the Add-box-shadow-toggle-option branch March 21, 2025 23:52
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.

2 participants