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

refactor(image): [image] refactor the image theme #2236

Merged
merged 2 commits into from
Oct 12, 2024
Merged

refactor(image): [image] refactor the image theme #2236

merged 2 commits into from
Oct 12, 2024

Conversation

Youyou-smiles
Copy link
Collaborator

@Youyou-smiles Youyou-smiles commented Oct 11, 2024

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Updated visual styles for the image viewer component, including a new background color for the mask and modifications to button and action element styles.
    • Enhanced error handling styles for the image component, incorporating new variable names and improved visual representation.
  • Bug Fixes

    • Adjusted test cases to reflect the updated CSS properties for the image viewer component, ensuring accurate visual representation during testing.
  • Documentation

    • Enhanced clarity on the new theming system and variable naming conventions within the image viewer and image components.

Copy link

coderabbitai bot commented Oct 11, 2024

Walkthrough

The pull request introduces modifications to the Playwright testing suite for the image viewer component, specifically updating expected CSS property values related to the visual style of a mask element. Additionally, significant changes are made to the styling properties in the index.less and vars.less files for the image viewer and image components, including updates to CSS variable names and values, reflecting a transition to a new theming system.

Changes

File(s) Change Summary
examples/sites/demos/pc/app/image/keep-style.spec.ts, Updated expected CSS background color for mask element from rgba(0, 0, 0, 0.5) to rgba(0, 0, 0, 0.08).
examples/sites/demos/pc/app/image/preview.spec.ts
packages/theme/src/image-viewer/index.less, Modified multiple styling properties, including background, opacity, dimensions, and hover states for various classes.
packages/theme/src/image-viewer/vars.less Overhauled CSS variable declarations, changing prefixes and values to align with a new theming system.
packages/theme/src/image/index.less, Adjusted display properties for error handling styles, changing from variable references to fixed values.
packages/theme/src/image/vars.less Updated several CSS variables related to image error handling, transitioning to new variable names and values.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

🐇 In the garden of code, we hop and play,
With colors and styles, brightening the day.
From rgba shades to variables anew,
The image viewer shines, with a fresh hue!
So let’s tweak and test, with joy in our hearts,
For every small change, a masterpiece starts! 🌼


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.

@github-actions github-actions bot added the refactoring Refactoring (重构) label Oct 11, 2024
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: 7

🧹 Outside diff range and nitpick comments (4)
examples/sites/demos/pc/app/image/keep-style.spec.ts (1)

21-21: LGTM. Consider adding a comment for clarity.

The change to the expected background color of the mask element from 'rgba(0, 0, 0, 0.5)' to 'rgba(0, 0, 0, 0.08)' appears to be intentional and aligns with the refactoring of the image theme. This reduces the opacity of the mask from 50% to 8%, making it less opaque.

Consider adding a brief comment explaining the reason for this specific color change, which could help future maintainers understand the design decision. For example:

// Mask opacity reduced to 8% for a lighter overlay effect
await expect(mask).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.08)')
packages/theme/src/image/index.less (1)

Line range hint 1-124: Summary of changes and potential impact

The modifications in this file are part of the larger refactoring effort for the image theme. The changes replace CSS variable usage with fixed inline-block display values, which promotes consistency but may reduce theme customizability.

Consider the following points for the overall refactoring process:

  1. Ensure that removing CSS variables aligns with the project's theming strategy and doesn't negatively impact existing theme configurations.
  2. Look for opportunities to refactor common styles to improve maintainability, as suggested in the previous comment.
  3. Document these changes in the component's documentation, especially if they affect public APIs or customization options.
  4. Update any related test cases to reflect these new fixed display values.

These considerations will help maintain the balance between consistency and flexibility in the component's styling.

packages/theme/src/image/vars.less (2)

15-15: Approved: Font size variable updated for consistency

The font size variable has been updated to use a more standardized naming convention (--tv-font-size-md). This change likely improves consistency across the theme system.

Ensure that --tv-font-size-md is properly defined and its value is appropriate for the error text in the image component.


19-19: Approved: Background color variable updated for consistency

The background color variable has been updated to use a more standardized naming convention (--tv-color-bg). This change improves consistency across the theme system.

The new variable --tv-color-bg seems more generic than the previous one. Ensure that this doesn't unintentionally affect the visual design of the error state in the image component.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between feea189 and 277bcae.

📒 Files selected for processing (6)
  • examples/sites/demos/pc/app/image/keep-style.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/image/preview.spec.ts (1 hunks)
  • packages/theme/src/image-viewer/index.less (5 hunks)
  • packages/theme/src/image-viewer/vars.less (1 hunks)
  • packages/theme/src/image/index.less (1 hunks)
  • packages/theme/src/image/vars.less (1 hunks)
🧰 Additional context used
🔇 Additional comments (21)
examples/sites/demos/pc/app/image/preview.spec.ts (1)

21-21: LGTM. Please verify color consistency and document the change.

The update to the expected background color aligns with the PR's objective of refactoring the image theme. However, to ensure completeness:

  1. Please verify that this new color value (rgba(0, 0, 0, 0.08)) is consistent with other parts of the codebase and the new theme.
  2. Consider adding a brief comment explaining the reason for this specific color change, as it's a significant reduction in opacity (from 0.5 to 0.08).

To verify color consistency, you can run:

examples/sites/demos/pc/app/image/keep-style.spec.ts (1)

Line range hint 1-52: Overall, the test case looks well-structured and comprehensive.

The test case covers various aspects of the image viewer component, including:

  1. Initial rendering and styling
  2. Zoom in/out functionality
  3. Rotation
  4. Navigation between images
  5. Closing the viewer

The change to the mask's background color is the only modification, and it has been appropriately updated in the test. The rest of the test case remains robust and should continue to provide good coverage for the component's functionality.

packages/theme/src/image/index.less (1)

51-51: Verify the impact of removing the CSS variable for display property

The change from var(--ti-image-error-display) to inline-block for the error text display property removes the flexibility provided by the CSS variable. While this ensures consistent behavior, it might limit theme customization.

Please confirm if this change aligns with the refactoring goals and doesn't negatively impact any existing theme configurations. Consider the following script to check for any other usages of the removed variable:

packages/theme/src/image/vars.less (3)

15-21: Overall: Significant updates to theming variables

The changes in this file represent a shift towards a more standardized theming system. Here are the key points:

  1. All variables now use the --tv- prefix instead of --ti-common-, indicating a move to a new naming convention.
  2. Fallback values have been removed, increasing reliance on the new theming system.
  3. The --ti-image-error-display variable has been removed entirely.

These changes likely improve the consistency and maintainability of the theming system. However, they also introduce some potential risks:

  1. Ensure that all new variables (--tv-font-size-md, --tv-color-text-weaken, --tv-color-bg, --tv-line-height-number) are properly defined in the new theming system.
  2. Verify that the removal of fallback values doesn't cause issues in environments where the new theme variables might not be available.
  3. Check if the removal of --ti-image-error-display affects the component's behavior or if this property is now controlled elsewhere.

To ensure these changes don't introduce unintended side effects, consider running visual regression tests on the image component, particularly focusing on its error state display.


21-21: Approved: Line height variable updated for consistency

The line height variable has been updated to use a more standardized naming convention (--tv-line-height-number). This change improves consistency across the theme system.

Verify that --tv-line-height-number is properly defined and its value is appropriate for the error text:

#!/bin/bash
# Search for the definition of --tv-line-height-number
rg --type css "tv-line-height-number"

17-17: Approved: Text color variable updated for consistency

The text color variable has been updated to use a more standardized naming convention (--tv-color-text-weaken). This change improves consistency across the theme system.

Verify that --tv-color-text-weaken is properly defined:

✅ Verification successful

Verified: --tv-color-text-weaken is properly defined

The --tv-color-text-weaken variable is correctly defined in packages/theme/src/base/vars.less and is consistently used across other theme files. The update in packages/theme/src/image/vars.less to use this standardized variable ensures consistency within the theme system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the definition of --tv-color-text-weaken
rg --type css "tv-color-text-weaken"

Length of output: 37


Script:

#!/bin/bash
# Search for the definition of --tv-color-text-weaken in LESS files
rg --type less "--tv-color-text-weaken"

Length of output: 464


Script:

#!/bin/bash
# Search for the definition of --tv-color-text-weaken in LESS files
rg --type less "--tv-color-text-weaken"

Length of output: 464


Script:

#!/bin/bash
# Search for the definition of --tv-color-text-weaken in LESS files
rg --type less -- "--tv-color-text-weaken"

Length of output: 1251

packages/theme/src/image-viewer/vars.less (2)

14-27: Ensure All New Variables Are Defined

Verify that all the new variables prefixed with --tv- are defined in the theming system and that they map to the correct values. This helps prevent runtime errors due to undefined variables and ensures consistency across components.

You can run the following script to confirm that all variables are defined:

#!/bin/bash
# Description: Check for undefined --tv- variables in the theme source files

# Test: List all --tv- variables and check their definitions
rg --no-heading --line-number '--tv-[a-zA-Z0-9\-]+' packages/theme/src/ | sort | uniq

17-17: Verify the Variable --tv-color-bg-control-unactive

Ensure that the variable --tv-color-bg-control-unactive is defined in your theming system and correctly references the intended background color. If it's a new variable, make sure it's added to the appropriate variables file.

Run the following script to check if the variable is defined elsewhere in the codebase:

✅ Verification successful

Reattempt Verification for --tv-color-bg-control-unactive

The previous script encountered a syntax error. Please run the corrected script below to verify if the variable is defined.


Variable --tv-color-bg-control-unactive is Properly Defined

The variable is defined in packages/theme/src/base/vars.less and used appropriately in packages/theme/src/image-viewer/vars.less.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for the definition of --tv-color-bg-control-unactive

# Test: Find the variable definition in the theme source files
rg --no-heading --line-number '--tv-color-bg-control-unactive' packages/theme/src/

Length of output: 509


Script:

#!/bin/bash
# Description: Search for the definition of --tv-color-bg-control-unactive

# Corrected command with proper quoting
rg -e '--tv-color-bg-control-unactive' packages/theme/src/

Length of output: 298

packages/theme/src/image-viewer/index.less (13)

23-23: LGTM

Setting the background of &__wrapper to none is appropriate to remove any default background styling, ensuring transparency and relying on parent elements for background properties.


38-38: LGTM

Assigning opacity: 1 to &__btn ensures that the button is fully opaque, which is suitable for visibility and user interaction.


43-45: LGTM

Defining explicit width, height, and fill properties for the SVG within &__btn enhances consistency and ensures that the icons display correctly across different environments.


50-55: LGTM

Updating the positioning, dimensions, font size, and background color of &__close using CSS variables improves maintainability and theming flexibility.


63-63: LGTM

Adding the &__canvas class enhances the component structure, providing a dedicated area for rendering the image content.


73-79: LGTM

Updating &__actions with new positioning, dimensions, padding, background color, and border-radius using CSS variables enhances theming capabilities and aligns with design standards.


88-88: LGTM

Changing justify-content to space-around in &__actions-inner ensures that the action items are evenly distributed, improving the user interface and interaction.


91-92: LGTM

Applying CSS variables for fill and margin-right in SVG icons within &__actions-inner promotes consistency and eases theme customization.


101-101: LGTM

Setting display: inline-block for &__actions-divider is appropriate for aligning dividers correctly alongside inline elements.


105-109: LGTM

Defining display, dimensions, line-height, and font-size for &__actions-count using CSS variables improves consistency and adaptability to different themes.


117-120: LGTM

Updating &__next and &__prev with dimensions and font sizes using CSS variables enhances theming flexibility and maintains consistent styling across navigation elements.


130-130: LGTM

Using a CSS variable for left positioning in &__prev (var(--tv-Image-viewer-prev-left)) enhances flexibility and consistency, allowing for easy adjustments through theming.


135-135: LGTM

Applying a CSS variable for right positioning in &__next (var(--tv-Image-viewer-next-right)) improves maintainability and enables streamlined theme customization.

packages/theme/src/image/index.less Show resolved Hide resolved
--tv-Image-viewer-next-font-size: calc(var(--tv-size-base) * 6);
--tv-Image-viewer-next-width: var(--tv-size-height-lg);
--tv-Image-viewer-next-height: var(--tv-size-height-lg);
--tv-Image-viewer-btn-opacity: 1;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider Using a Variable for Opacity

The opacity value is set directly to 1. If you anticipate needing different opacity levels for theming purposes, consider defining a CSS variable for the opacity value.

Example:

- --tv-Image-viewer-btn-opacity: 1;
+ --tv-Image-viewer-btn-opacity: var(--tv-button-opacity, 1);
📝 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
--tv-Image-viewer-btn-opacity: 1;
--tv-Image-viewer-btn-opacity: var(--tv-button-opacity, 1);

packages/theme/src/image-viewer/vars.less Outdated Show resolved Hide resolved
packages/theme/src/image-viewer/vars.less Outdated Show resolved Hide resolved
packages/theme/src/image-viewer/index.less Show resolved Hide resolved

&:hover {
cursor: pointer;
background-color: var(--ti-image-viewer-close-bg-color-hover);
background-color: #606266;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use CSS variable instead of hardcoded color in hover state

In the &__close element's :hover state, the background-color is set to a hardcoded value #606266. To maintain consistency with the theming system and facilitate easier customization, consider replacing the hardcoded color with a CSS variable.

Apply this diff to replace the hardcoded color:

 &__close {
     // existing styles
     &:hover {
         cursor: pointer;
-        background-color: #606266;
+        background-color: var(--tv-Image-viewer-close-hover-bg-color);
     }
 }

Committable suggestion was skipped due to low confidence.

packages/theme/src/image-viewer/index.less 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: 5

🧹 Outside diff range and nitpick comments (3)
packages/theme/src/image/vars.less (2)

23-23: LGTM! Consider externalizing the data URL.

The update of --ti-image-error-bg-image-url to --tv-Image-error-bg-image-url is consistent with the other changes. However, the long data URL might impact readability and maintainability of this file.

Consider moving the data URL to a separate file (e.g., a JavaScript module) and importing it here. This would improve the readability of this file and make it easier to update the image in the future.


13-23: Overall, good refactoring towards a more consistent theming system.

The changes in this file represent a significant step towards a more consistent and modular theming system. The new naming conventions and use of shared variables should improve maintainability. However, please ensure that all dependent components are updated accordingly and consider the suggestions for further improvements.

As you continue this refactoring effort, consider creating a style guide or documentation for the new theming system to ensure consistency across the entire project.

packages/theme/src/image-viewer/index.less (1)

38-38: Nitpick: Explicit opacity: 1; may be unnecessary

Since the default value of opacity is 1, explicitly setting opacity: 1; might be redundant unless it's intended to override a previous styling. Consider removing it if it's not necessary.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 277bcae and 6f37c03.

📒 Files selected for processing (4)
  • packages/theme/src/image-viewer/index.less (5 hunks)
  • packages/theme/src/image-viewer/vars.less (1 hunks)
  • packages/theme/src/image/index.less (3 hunks)
  • packages/theme/src/image/vars.less (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/image/index.less
🧰 Additional context used
🔇 Additional comments (6)
packages/theme/src/image/vars.less (3)

15-21: LGTM! Update related components.

The CSS variable updates look good. The new naming convention with the --tv- prefix is more consistent and the use of other --tv- prefixed variables for values suggests a more modular approach. This change improves maintainability and readability of the code.

Please ensure that all components using these variables are updated accordingly. Run the following script to find potential places that need updates:

#!/bin/bash
# Search for any remaining usage of the old variable names
rg --type less "\-\-ti-(image-error-font-size|image-error-text-color|image-error-bg-color|image-error-line-height)"

13-13: LGTM! Verify usage in other files.

The function name change from .component-css-vars-image() to .inject-Image-vars() looks good. It appears to follow a new naming convention, which is more consistent with modern CSS-in-JS practices.

Please run the following script to check for any remaining usages of the old function name:


13-23: Clarify removal of --ti-image-error-display.

The variable --ti-image-error-display has been removed. Can you please clarify the reason for this removal? It's important to ensure that this change doesn't negatively impact the error state handling in the image component.

To help understand the impact, please run the following script to find any remaining usage of this variable:

✅ Verification successful

Re-verify usage of --ti-image-error-display.

To ensure that the variable has been fully removed and is not used elsewhere in the codebase, please run the following script:


Re-verify usage of --ti-image-error-display with corrected search command.

To ensure that the variable has been fully removed and is not used elsewhere in the codebase, please run the following corrected script:


Re-verify usage of --ti-image-error-display with corrected search command.

To ensure that the variable has been fully removed and is not used elsewhere in the codebase, please run the following corrected script:


Confirmed removal of --ti-image-error-display.

No remaining usages of --ti-image-error-display were found in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of the removed variable
rg --type less "\-\-ti-image-error-display"

Length of output: 45


Script:

#!/bin/bash
# Search for any remaining usage of the removed variable across all files
rg '--ti-image-error-display'

Length of output: 456


Script:

#!/bin/bash
# Search for any remaining usage of the removed variable across all files
rg '--ti-image-error-display'

Length of output: 456


Script:

#!/bin/bash
# Search for any remaining usage of the removed variable across all files
rg -- '--ti-image-error-display'

Length of output: 32

packages/theme/src/image-viewer/vars.less (1)

20-20: Verify Unit Usage in Calculation

The calculation calc(var(--tv-size-base) * 6) may not work as expected if --tv-size-base does not include units. In CSS, when using calc() for multiplication, at least one operand must have units.

Please ensure that --tv-size-base includes units (e.g., 1rem, 16px). If it doesn't, you might need to adjust the calculation.

If --tv-size-base is unitless, consider updating the calculation:

--tv-ImageViewer-next-font-size: calc(var(--tv-size-base) * 6);
--tv-ImageViewer-next-font-size: calc(6 * 1rem);

Run the following script to verify the definition of --tv-size-base:

✅ Verification successful

Unit Usage Verified for --tv-size-base

The --tv-size-base variable is defined with units (4px), ensuring that the calculation calc(var(--tv-size-base) * 6) will work as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if `--tv-size-base` includes units.

# Search for the definition of `--tv-size-base` in the codebase.
rg --type less --no-filename --no-line-number --word-regexp --fixed-strings '--tv-size-base:'

Length of output: 511


Script:

#!/bin/bash
# Description: Verify if `--tv-size-base` includes units.

# Corrected command: Ensure the pattern is correctly passed as a search string.
rg --type less --no-filename --no-line-number --word-regexp --fixed-strings '--tv-size-base:' .

Length of output: 513


Script:

#!/bin/bash
# Description: Verify if `--tv-size-base` includes units using the -e flag to specify the pattern.

rg --type less --no-filename --no-line-number --word-regexp --fixed-strings -e '--tv-size-base:' .

Length of output: 121

packages/theme/src/image-viewer/index.less (2)

23-23: Verify that setting background: none; does not impact theming

By replacing the background variable with background: none; in &__wrapper, there might be unintended side effects on theming and customization. Please ensure that this change does not adversely affect the ability to theme or customize the background of the image viewer component.


88-88: Verify that justify-content: space-around; achieves the desired layout

Changing justify-content to space-around may alter the spacing between elements in &__actions-inner. Please confirm that this modification aligns with the intended design and does not negatively impact the user interface.

--tv-ImageViewer-text-color: var(--tv-color-success-text-white);
--tv-ImageViewer-actions-inner-text-color: var(--tv-color-success-text-white);
--tv-ImageViewer-close-font-size: var(--tv-font-size-xxl);
--tv-ImageViewer-close-bg-color: var(--tv-color-bg-control-unactive);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Typo in Variable Name Reference

The variable name --tv-color-bg-control-unactive may contain a typo. The term "unactive" is uncommon in English; perhaps you intended to use "inactive".

Apply this diff to correct the variable name reference:

--tv-ImageViewer-close-bg-color: var(--tv-color-bg-control-unactive);
--tv-ImageViewer-close-bg-color: var(--tv-color-bg-control-inactive);
📝 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
--tv-ImageViewer-close-bg-color: var(--tv-color-bg-control-unactive);
--tv-ImageViewer-close-bg-color: var(--tv-color-bg-control-inactive);

Comment on lines +13 to +26
.inject-ImageViewer-vars() {
--tv-ImageViewer-text-color: var(--tv-color-success-text-white);
--tv-ImageViewer-actions-inner-text-color: var(--tv-color-success-text-white);
--tv-ImageViewer-close-font-size: var(--tv-font-size-xxl);
--tv-ImageViewer-close-bg-color: var(--tv-color-bg-control-unactive);
--tv-ImageViewer-actions-border-radius: var(--tv-border-radius-round);
--tv-ImageViewer-actions-height: var(--tv-size-height-lg);
--tv-ImageViewer-next-font-size: calc(var(--tv-size-base) * 6);
--tv-ImageViewer-next-width: var(--tv-size-height-lg);
--tv-ImageViewer-next-height: var(--tv-size-height-lg);
--tv-ImageViewer-actions-icon-margin-right: var(--tv-space-xl);
--tv-ImageViewer-actions-count-font-size: var(--tv-font-size-md);
--tv-ImageViewer-prev-left: calc(var(--tv-space-base) * 8);
--tv-ImageViewer-next-right: calc(var(--tv-space-base) * 8);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consistent Naming Convention for CSS Variables

The CSS custom properties are using PascalCase with mixed capitalization, e.g., --tv-ImageViewer-text-color. For consistency and to align with standard CSS practices, it's recommended to use all lowercase letters with hyphens.

Consider updating the variable names to use all lowercase letters with hyphens:

- --tv-ImageViewer-text-color: var(--tv-color-success-text-white);
+ --tv-image-viewer-text-color: var(--tv-color-success-text-white);

Apply similar changes to all custom properties within this block.

Committable suggestion was skipped due to low confidence.

Comment on lines +106 to +108
width: 20px;
height: 20px;
line-height: 20px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using CSS variables for dimensions

To enhance theming capabilities and maintain consistency, consider replacing hardcoded values for width, height, and line-height with CSS variables. This will allow for easier customization and scalability.

Example modifications:

-        width: 20px;
+        width: var(--tv-ImageViewer-actions-count-width, 20px);
-        height: 20px;
+        height: var(--tv-ImageViewer-actions-count-height, 20px);
-        line-height: 20px;
+        line-height: var(--tv-ImageViewer-actions-count-line-height, 20px);
📝 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
width: 20px;
height: 20px;
line-height: 20px;
width: var(--tv-ImageViewer-actions-count-width, 20px);
height: var(--tv-ImageViewer-actions-count-height, 20px);
line-height: var(--tv-ImageViewer-actions-count-line-height, 20px);

Comment on lines +75 to +77
width: 248px;
height: var(--tv-ImageViewer-actions-height);
padding: 10px 24px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using CSS variables for width and padding

To maintain consistency with the theming system and allow for greater flexibility, consider replacing the hardcoded width and padding values with CSS variables.

Suggested changes:

-        width: 248px;
+        width: var(--tv-ImageViewer-actions-width, 248px);
-        padding: 10px 24px; 
+        padding: var(--tv-ImageViewer-actions-padding, 10px 24px);
📝 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
width: 248px;
height: var(--tv-ImageViewer-actions-height);
padding: 10px 24px;
width: var(--tv-ImageViewer-actions-width, 248px);
height: var(--tv-ImageViewer-actions-height);
padding: var(--tv-ImageViewer-actions-padding, 10px 24px);

Comment on lines +50 to +53
top: 32px;
right: 32px;
width: 40px;
height: 40px;
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using CSS variables for positioning and dimensions

To enhance theming flexibility and maintain consistency, consider replacing hardcoded pixel values for top, right, width, and height with CSS variables. This allows for easier customization and responsiveness across different screen sizes.

Example changes:

-        top: 32px;
+        top: var(--tv-ImageViewer-close-top, 32px);
-        right: 32px;
+        right: var(--tv-ImageViewer-close-right, 32px);
-        width: 40px;
+        width: var(--tv-ImageViewer-close-width, 40px);
-        height: 40px;
+        height: var(--tv-ImageViewer-close-height, 40px);
📝 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
top: 32px;
right: 32px;
width: 40px;
height: 40px;
top: var(--tv-ImageViewer-close-top, 32px);
right: var(--tv-ImageViewer-close-right, 32px);
width: var(--tv-ImageViewer-close-width, 40px);
height: var(--tv-ImageViewer-close-height, 40px);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Refactoring (重构)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants