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

fix(site): official website adapts to the dark mode. #2956

Merged
merged 5 commits into from
Feb 25, 2025

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Feb 25, 2025

PR

官网适配暗色模式

以下2处,待组件的暗色适配 ------ Tabs , Grid

image

image

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

    • Refined color schemes and background settings to boost contrast and readability across both dark and light modes.
    • Updated hover effects and border styles for a more cohesive look in documentation, headers, API sections, and layout components.
    • Enhanced styling for buttons and markdown elements, including new border-radius properties and background color adjustments.
  • New Features

    • Introduced dedicated dark mode styling for key interface areas, including app containers and navigation panels.
    • Added new CSS classes for improved semantic meaning in documentation.
  • Refactor

    • Harmonized class naming and theming conventions to provide a consistent, modern user interface.

Copy link

coderabbitai bot commented Feb 25, 2025

Walkthrough

The pull request updates the theming approach across various assets and components. CSS selectors are modified, replacing legacy classes (e.g., .theme-light and .theme-dark) with new selectors (body and .dark) and adjusting color variables. Redundant or deprecated CSS blocks are removed, and the dynamic theme update logic (via watchEffect) is eliminated. Several Vue components have updated class names and styling to better support dark mode, with minor adjustments to external CSS imports.

Changes

File(s) Change Summary
examples/.../assets/custom-block.less
examples/.../assets/custom-markdown.css
Updated theme selectors: replaced .theme-light with body and .theme-dark with .dark; adjusted dark theme color for canvas background.
examples/.../assets/index.less Removed the entire .theme-dark class definition, eliminating its related custom properties.
examples/.../main.js Changed import: replaced github-markdown-light.css with the standard github-markdown.css.
examples/.../style.css Added new CSS rules for #app: sets background to white in light mode and black in dark mode; fixed formatting for html selector.
examples/.../tools/appData.js Removed watchEffect import and its usage, discontinuing automatic DOM theme updates.
examples/.../views/components-doc/components/api-docs.vue
examples/.../views/components-doc/components/demo.vue
examples/.../views/components-doc/components/float-settings.vue
examples/.../views/components-doc/components/header.vue
examples/.../views/docs/docs.vue
examples/.../views/layout/layout.vue
examples/.../views/overview.vue
Updated component class names and incorporated new CSS rules to better support variable-based theming and dark mode styling.
packages/theme/src/button/index.less Removed lines that set the fill and color on .tiny-svg, altering button icon styling.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • zzcr

Poem

I'm a rabbit with a hop so light,
Digging through code from day to night,
CSS selectors all spruced and new,
Dark and light themes now shining through,
With tweaks and hops, the styles align,
Carrot cheers for code so fine!

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/docs/docs.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.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ffe2570 and 0cc9922.

📒 Files selected for processing (2)
  • examples/sites/src/assets/custom-block.less (3 hunks)
  • examples/sites/src/views/docs/docs.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/sites/src/views/docs/docs.vue
  • examples/sites/src/assets/custom-block.less

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. (Beta)
  • @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 25, 2025
Copy link

Walkthrough

此PR修改了官网的样式以适配暗色模式,涉及多个样式文件的调整和主题切换逻辑的更新。主要是通过引入新的CSS变量和修改现有样式来实现暗色模式的适配。

Changes

文件 概要
examples/sites/src/assets/custom-block.less, examples/sites/src/assets/custom-markdown.css, examples/sites/src/assets/index.less 修改样式以支持暗色模式,使用CSS变量替代硬编码颜色值。
examples/sites/src/main.js 更新Markdown样式的导入路径以支持暗色模式。
examples/sites/src/style.css 增加对暗色模式下背景色的支持。
examples/sites/src/tools/appData.js 注释掉不再需要的主题切换逻辑代码。
examples/sites/src/views/components-doc/components/api-docs.vue, examples/sites/src/views/components-doc/components/demo.vue 调整组件样式以适配暗色模式。
examples/sites/src/views/components-doc/components/float-settings.vue 修改设置按钮样式以支持暗色模式。
examples/sites/src/views/components-doc/components/header.vue 增加暗色模式下的头部样式。
examples/sites/src/views/docs/docs.vue 增加暗色模式下的文档样式。
examples/sites/src/views/layout/layout.vue 增加暗色模式下的布局样式。
examples/sites/src/views/overview.vue 调整概览页面样式以适配暗色模式。
packages/theme/src/button/index.less 移除不必要的颜色定义。

@@ -1,4 +1,4 @@
import { reactive, computed, watchEffect } from 'vue'
import { reactive, computed } from 'vue'

Choose a reason for hiding this comment

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

The watchEffect function has been commented out. Ensure that this change does not affect the theme switching functionality if it was previously required for dynamic updates.

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

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Walkthrough

This PR has modified the style of the official website to adapt to dark mode, involving adjustments to multiple style files and updates to the theme switching logic. The main purpose is to implement dark mode adaptation by introducing new CSS variables and modifying existing styles.

Changes

Documents Summary
examples/sites/src/assets/custom-block.less, examples/sites/src/assets/custom-markdown.css, examples/sites/src/assets/index.less Modify the style to support dark mode, use CSS Variables replace hard-coded color values.
examples/sites/src/main.js Update the Markdown style import path to support dark mode.
examples/sites/src/style.css Add support for background colors in dark mode.
examples/sites/src/tools/appData.js Comment out the no longer needed topic switching logic code.
examples/sites/src/views/components-doc/components/api-docs.vue, examples/sites/src/views/components-doc/components/demo.vue Adjust the component style to suit dark mode.
examples/sites/src/views/components-doc/components/float-settings.vue Modify the setting button style to support dark mode.
examples/sites/src/views/components-doc/components/header.vue Add head style in dark mode.
examples/sites/src/views/docs/docs.vue Add document style in dark mode.
examples/sites/src/views/layout/layout.vue Add layout style in dark mode.
examples/sites/src/views/overview.vue Adjust the overview page style to suit dark mode.
packages/theme/src/button/index.less Remove unnecessary color definitions.

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

🧹 Nitpick comments (3)
examples/sites/src/style.css (1)

4-5: Minor whitespace inconsistency.

The closing brace has inconsistent spacing compared to the rest of the file.

-  font-size: 16px;
- }
+  font-size: 16px;
+}
examples/sites/src/views/layout/layout.vue (1)

405-407: Good sidebar border styling for dark mode.

The addition of a dark border for the sidebar in dark mode enhances visual separation. Consider using a CSS variable instead of a hardcoded color.

 .dark #layoutSider {
-  border-right: 1px solid #1a1a1a; // 没有常用变量
+  border-right: 1px solid var(--tv-border-color-dark, #1a1a1a);
 }
examples/sites/src/views/components-doc/components/demo.vue (1)

350-352: Consider using CSS variables for hardcoded colors.

While the global dark mode selector works correctly, it uses a hardcoded color value (#1a1a1a) instead of a CSS variable like the other changes.

:global(.dark .pc-demo-container.pc-demo-container) {
-  background-color: #1a1a1a;
+  background-color: var(--tv-color-bg-dark);
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cd1ea6e and ffe2570.

📒 Files selected for processing (14)
  • examples/sites/src/assets/custom-block.less (2 hunks)
  • examples/sites/src/assets/custom-markdown.css (3 hunks)
  • examples/sites/src/assets/index.less (0 hunks)
  • examples/sites/src/main.js (1 hunks)
  • examples/sites/src/style.css (1 hunks)
  • examples/sites/src/tools/appData.js (1 hunks)
  • examples/sites/src/views/components-doc/components/api-docs.vue (3 hunks)
  • examples/sites/src/views/components-doc/components/demo.vue (4 hunks)
  • examples/sites/src/views/components-doc/components/float-settings.vue (1 hunks)
  • examples/sites/src/views/components-doc/components/header.vue (1 hunks)
  • examples/sites/src/views/docs/docs.vue (1 hunks)
  • examples/sites/src/views/layout/layout.vue (1 hunks)
  • examples/sites/src/views/overview.vue (6 hunks)
  • packages/theme/src/button/index.less (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/theme/src/button/index.less
  • examples/sites/src/assets/index.less
✅ Files skipped from review due to trivial changes (1)
  • examples/sites/src/main.js
🔇 Additional comments (27)
examples/sites/src/views/components-doc/components/header.vue (1)

36-38: Good dark mode implementation for the header component.

The addition of a dark background color for the .docs-header in dark mode complements the existing light background, providing proper contrast for users in dark mode.

examples/sites/src/views/docs/docs.vue (2)

70-72: Good dark mode background for markdown content.

Setting a black background for markdown content in dark mode provides proper contrast with the content.


74-81: Appropriate code block styling for dark mode.

The changes properly adjust code block styling for dark mode by:

  1. Removing text shadow (which would be hard to read on dark backgrounds)
  2. Using a CSS variable for text color
  3. Making operator tokens have a transparent background

These adjustments will ensure code remains readable in dark mode.

examples/sites/src/style.css (1)

6-11: Good application-level dark mode implementation.

Setting appropriate background colors at the app level is essential for a proper dark mode implementation. The use of #fff for light mode and #000 for dark mode ensures consistent backgrounds throughout the application.

examples/sites/src/assets/custom-block.less (2)

64-86: Good improvement in light theme selector implementation.

Changing from .theme-light to body as the base selector is a solid approach for the default light theme. This makes the light theme the default and doesn't require an explicit class to be added to the body element.


87-109: Clean implementation of dark mode styles.

The change from .theme-dark to .dark aligns with modern dark mode implementation practices. The color variables are well-defined with appropriate contrasts for dark mode readability.

examples/sites/src/tools/appData.js (1)

1-1: Verify theme switching still works properly.

The watchEffect import has been removed from the Vue imports. This likely means the automatic theme class application on theme changes has been removed as well.

#!/bin/bash
# Check if there are other files handling theme switching
rg -l "toggleTheme|theme.*switch" --type js --type vue
examples/sites/src/views/components-doc/components/float-settings.vue (2)

278-280: Good addition of dark mode styles for settings button.

Adding specific styles for .dark .settings-btn ensures proper contrast and visibility when the site is in dark mode.


282-317: Improved theming with CSS variables.

Replacing hardcoded colors with CSS variables (var(--tv-color-border)) improves maintainability and consistency across themes. The hover states and spacing are well-structured.

examples/sites/src/assets/custom-markdown.css (3)

6-7: Clear documentation and proper dark mode implementation.

The added comment explains the color source, and changing from .theme-dark .markdown-body to .dark .markdown-body ensures consistency with the rest of the dark mode implementation.


42-42: Improved dark mode background color.

Changing the canvas default color from #0d1117 to #1a1a1a provides a slightly lighter dark mode background, which can improve readability while still reducing eye strain in low-light conditions.


53-53: Consistent light theme selector.

Changing from .theme-light .markdown-body to body .markdown-body makes the light theme the default, consistent with changes in other files.

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

7-12: Good semantic naming for better dark mode support.

The addition of descriptive class names like api-groupname and api-groupname-tag improves the semantic structure while enabling proper dark mode styling.


16-18: Clear semantic naming with API key headers.

Adding the api-groupname-key class to the API key heading ensures consistent styling in both light and dark modes.


176-191: Well-implemented theming with CSS variables.

The CSS classes effectively use CSS variables for theming, with appropriate selectors for both light and dark modes. The .dark selector properly overrides styles for dark mode.


232-233: Good use of CSS variables for code element styling.

Replacing hardcoded colors with CSS variables (--tv-color-text-secondary and --tv-color-bg-header) enables proper dark mode support for code elements.

examples/sites/src/views/overview.vue (7)

4-7: Enhanced semantic structure with descriptive class names.

Adding the overview-title class improves semantic meaning while enabling proper theming support.


9-11: Improved semantic naming for description element.

The overview-desc class provides better semantics and enables consistent dark mode styling.


31-33: Clear semantic structure for group names.

Adding the overview-groupname class enhances the semantic structure while enabling proper dark mode support.


50-53: Improved component name styling with semantic class.

The overview-componentname class provides clear semantic meaning and enables consistent theming across modes.


174-181: Well-structured CSS variables for text colors.

The CSS implementation properly uses variables for text colors, ensuring consistent styling across light and dark modes. The selector structure follows best practices for theming.


215-219: Good hover effect for dark mode.

The special hover effect for dark mode creates a subtle visual distinction using appropriate shadow opacity values.


230-232: Proper background color for dark mode cards.

Setting the background color for dark mode cards ensures proper contrast and visibility in dark mode.

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

51-51: Simplified class structure for markdown component.

Removing the markdown-body class and using only demo-desc streamlines the styling hierarchy while maintaining dark mode support.


306-307: Good use of CSS variables for code background.

Replacing the hardcoded background color with var(--tv-color-bg-header) enables proper dark mode styling for code elements.


356-358: Well-implemented variable-based theming.

Using CSS variables for text and background colors ensures consistent styling across light and dark modes.


372-373: Good use of CSS variables for title color.

Replacing the hardcoded color with var(--tv-color-text) enables proper dark mode styling for demo titles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants