Skip to content

fix(site): fix source code's highlight color #2968

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 7 commits into from
Feb 26, 2025

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Feb 26, 2025

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

  • Style

    • Enhanced code snippet readability with refined text and highlight colors.
    • Updated contributor and settings appearances for a more consistent, theme-driven look.
    • Improved tooltip visuals with optimized text and background colors across light and dark themes.
  • Refactor

    • Streamlined tooltip interactions in demo components for a cleaner, more intuitive user experience.

Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

This pull request updates several Vue components and theme styles. The component changes primarily refactor CSS styles to utilize CSS variables for text colors and icon theming. The demo component now employs a directive (v-auto-tip) in place of multiple tooltip components for streamlined tooltip functionality. Additionally, the theme files have been modified to introduce a new CSS variable and update tooltip color references, ensuring visual consistency across light and dark themes. No public API or exported entity declarations have been altered.

Changes

File(s) Change Summary
examples/sites/src/views/components-doc/components/async-highlight.vue,
examples/sites/src/views/components-doc/components/contributor.vue,
examples/sites/src/views/components-doc/components/demo.vue,
examples/sites/src/views/components-doc/components/float-settings.vue
Updated various CSS styles: switched hardcoded color values to CSS variables; in async-highlight.vue, adjusted code snippet text and highlight colors; in contributor.vue, removed font-weight and replaced fixed color with variable; in demo.vue, replaced multiple <tiny-tooltip> components with <i> elements using the v-auto-tip directive and updated styling; in float-settings.vue, refined icon, title, and popover styles.
packages/theme/src/base/dark-theme.less,
packages/theme/src/base/vars.less,
packages/theme/src/tooltip/vars.less
Theme updates: added a new CSS variable --tv-color-text-inverse-black in both dark-theme and vars files, and updated the tooltip light text color in tooltip/vars.less to use this new variable.

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • zzcr

Poem

Hop, hop—I'm a rabbit so keen,
Styling changes in CSS now seen.
Colors dance in theme's embrace,
Directives streamline tooltip's grace.
With variables leading the parade,
I cheer these changes—truly well-made! 🐇

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/src/views/components-doc/components/async-highlight.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/src/views/components-doc/components/contributor.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/src/views/components-doc/components/demo.vue

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 1 others

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 generate docstrings to generate docstrings for this 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 bug Something isn't working label Feb 26, 2025
Copy link

Walkthrough

This PR addresses the issue of source code highlight color in the project. It involves updating various components and styles to ensure consistent color theming using CSS variables. The changes include modifying color values and replacing hardcoded colors with theme variables.

Changes

Files Summary
examples/sites/src/assets/images/leftMenu/*.svg Minor adjustments to SVG files.
examples/sites/src/views/components-doc/components/async-highlight.vue Updated color values for syntax highlighting.
examples/sites/src/views/components-doc/components/contributor.vue Replaced hardcoded text color with theme variable.
examples/sites/src/views/components-doc/components/demo.vue Replaced tooltip implementation with v-auto-tip directive and updated styles.
examples/sites/src/views/components-doc/components/float-settings.vue Updated icon colors and background colors to use theme variables.
packages/theme/src/base/dark-theme.less Added new theme variable for tooltip text color.
packages/theme/src/base/vars.less Added new theme variable for tooltip text color.
packages/theme/src/tooltip/vars.less Updated tooltip text color variable.

>
<i class="i-ti-playground ml8 h:c-success ti-w16 ti-h16 ti-cur-hand" @click="openPlayground(demo)" />
</tiny-tooltip>
<i

Choose a reason for hiding this comment

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

The removal of tiny-tooltip and replacement with v-auto-tip should be carefully tested to ensure that the new directive behaves as expected in all scenarios, especially regarding tooltip positioning and display logic.

Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

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: 1

🧹 Nitpick comments (1)
examples/sites/src/views/components-doc/components/contributor.vue (1)

59-61: Consider using theme variable for tooltip text color.

While you've updated the title's color to use a theme variable, the tooltip text color is still hardcoded as #191919. For better theme consistency, consider using the appropriate CSS variable here as well.

.cmp-contributor-tip {
  font-size: 14px;
-  color: #191919;
+  color: var(--tv-color-text-inverse-black);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 985be78 and 8735845.

⛔ Files ignored due to path filters (2)
  • examples/sites/src/assets/images/leftMenu/cmp-business-components.svg is excluded by !**/*.svg
  • examples/sites/src/assets/images/leftMenu/directives-custom-instruction.svg is excluded by !**/*.svg
📒 Files selected for processing (7)
  • examples/sites/src/views/components-doc/components/async-highlight.vue (3 hunks)
  • examples/sites/src/views/components-doc/components/contributor.vue (1 hunks)
  • examples/sites/src/views/components-doc/components/demo.vue (4 hunks)
  • examples/sites/src/views/components-doc/components/float-settings.vue (3 hunks)
  • packages/theme/src/base/dark-theme.less (1 hunks)
  • packages/theme/src/base/vars.less (1 hunks)
  • packages/theme/src/tooltip/vars.less (1 hunks)
🔇 Additional comments (15)
packages/theme/src/base/vars.less (1)

303-303: Good addition of theming variable for tooltip text.

Adding the --tv-color-text-inverse-black variable for tooltip light text improves theme consistency and makes it easier to manage text colors across different themes.

packages/theme/src/base/dark-theme.less (1)

312-312: Good parallel implementation for dark theme.

Adding the same variable --tv-color-text-inverse-black in the dark theme with appropriate value maintains consistency between themes. This ensures proper text color for tooltips in dark mode.

examples/sites/src/views/components-doc/components/contributor.vue (1)

35-35: Good use of theme variable for title color.

Replacing hardcoded color with the CSS variable var(--tv-color-text) improves theme consistency across the application.

packages/theme/src/tooltip/vars.less (1)

66-66: Good update to tooltip text color variable.

Updating the light tooltip text color to use the new --tv-color-text-inverse-black variable improves visual consistency across the application and helps fix the source code highlight color issue mentioned in the PR title.

examples/sites/src/views/components-doc/components/async-highlight.vue (3)

71-71: Good theming improvement!

Adding the color variable var(--tv-color-text) ensures consistent text coloring in code previews across different themes. This change aligns with the PR objective to fix source code highlighting colors.


84-84: Improved contrast for attribute highlighting.

Changing the color from #00c to rgb(20, 20, 219) provides better visibility while maintaining a similar blue hue. The RGB format also offers more precision for this particular shade.


98-98: Changed title highlight from blue to green.

The title highlight color has been changed from blue (#00f) to green (#170), which better differentiates titles from attributes in code snippets. This improves readability and visual hierarchy in the code preview.

examples/sites/src/views/components-doc/components/float-settings.vue (4)

295-298: Good icon theming implementation.

Adding CSS variables for icon colors helps maintain consistent styling across themes. This change supports the theming system by using var(--tv-color-icon) instead of hardcoded values.


304-305: Improved hover state with theming variables.

Replacing hardcoded hover colors with the CSS variable var(--tv-color-icon-hover) ensures consistent interactive behavior across different themes.


341-341: Consistent text theming.

Changing the title color to use var(--tv-color-text) maintains consistency with other themed text elements and improves theme adaptability.


364-367: Enhanced theme support for popover backgrounds.

Adding theme-specific background colors using CSS variables ensures the popover looks consistent in both light and dark modes. This is especially important for UI elements that appear on top of other content.

examples/sites/src/views/components-doc/components/demo.vue (4)

76-76: Updated imports to support the tooltip directive change.

Correctly updated imports to replace the Tooltip component with the AutoTip directive, aligning with the implementation changes in the template.


340-341: Improved dark theme container styling.

Removing the border in dark mode provides a cleaner look that better aligns with dark theme design principles where borders are typically less pronounced.


346-348: Enhanced light theme container styling.

Adding a white background and border to the container improves visual definition in light mode, providing better separation from the surrounding content.


379-384: Added themed icon styling.

The new styling for icons ensures they inherit theme colors and provides appropriate hover behavior, improving accessibility and visual feedback. Using CSS variables ensures consistency with the overall theming system.

Comment on lines +13 to +35
<i
v-auto-tip="{ content: state.copyTip, effect: 'light', always: true }"
:class="state.copyIcon"
class="ti-w16 ti-h16 ti-cur-hand"
@click="copyCode(demo)"
@mouseout="resetTip()"
/>
<i
v-auto-tip="{
content: demo.isOpen ? i18nByKey('hideCode') : i18nByKey('showCode'),
effect: 'light',
always: true
}"
:class="!!demo.isOpen ? 'i-ti-codeslash' : 'i-ti-code'"
class="ti-ml8 ti-w16 ti-h16 ti-cur-hand"
@click="toggleDemoCode(demo)"
/>

<i
v-auto-tip="{ content: i18nByKey('playground'), effect: 'light', always: true }"
class="i-ti-playground ml8 ti-w16 ti-h16 ti-cur-hand"
@click="openPlayground(demo)"
/>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improved tooltip implementation with v-auto-tip directive.

Replacing multiple <tiny-tooltip> components with <i> elements using the v-auto-tip directive simplifies the markup and likely improves performance. The directive-based approach is more concise while maintaining the same functionality.

@zzcr zzcr merged commit 6131002 into opentiny:dev Feb 26, 2025
7 checks passed
@shenjunjian shenjunjian deleted the dev-fix-site-dark-theme branch March 10, 2025 11:35
@coderabbitai coderabbitai bot mentioned this pull request Mar 27, 2025
13 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants