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: stripe table style for element plus, fixed: #4501 #4502

Closed
wants to merge 2 commits into from

Conversation

mynetfan
Copy link
Collaborator

@mynetfan mynetfan commented Sep 25, 2024

Description

修复ElementPlus组件库的表格斑马纹样式在暗黑模式下的问题

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Summary by CodeRabbit

  • New Features

    • Introduced a new UI component with a data table displaying two columns: "测试列1" and "测试列2".
    • Added new CSS variables for a lighter accent color option, enhancing styling flexibility.
  • Bug Fixes

    • Improved visual distinction of table rows with a striped style.
  • Documentation

    • Updated design tokens to include new color variants for better UI customization.

Copy link

changeset-bot bot commented Sep 25, 2024

⚠️ No Changeset found

Latest commit: 2d33f55

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Sep 25, 2024

Walkthrough

This pull request introduces new features and enhancements in a Vue.js application, including a new data structure for a table component, additional CSS variables for design tokens, and updates to the design configuration. The changes involve the addition of a tableData constant for an ElTable component, new CSS properties for lighter accent colors, and modifications to the design token functions to accommodate these new variables.

Changes

File Path Change Summary
apps/web-ele/src/views/demos/element/index.vue Added a constant tableData for an ElTable component displaying two columns.
internal/tailwind-config/src/index.ts Introduced a new property lighter in the shadcnUiColors object for color variants.
packages/@core/base/design/src/design-tokens/dark/index.css Added a CSS variable --accent-lighter for a lighter accent color option.
packages/@core/base/design/src/design-tokens/default/index.css Added a CSS custom property --accent-lighter defined in HSL format.
packages/effects/hooks/src/use-design-tokens.ts Introduced a new CSS variable --el-fill-color-lighter in the useElementPlusDesignTokens function.

Possibly related PRs

Suggested labels

bug, documentation

Suggested reviewers

  • vince292007
  • anncwb

🐇 In the code, I hop and play,
New colors brighten up the day!
Tables now with data shine,
Design tokens, oh so fine!
With every change, we leap ahead,
A vibrant world, where dreams are fed! 🌈


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.

Copy link
Contributor

@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: 2

Outside diff range and nitpick comments (3)
apps/web-ele/src/views/demos/element/index.vue (2)

42-49: Consider adding a type definition for tableData.

The tableData constant is correctly defined with appropriate demo data. However, for better type safety and code maintainability, consider adding a type definition for the table row structure.

Here's a suggested improvement:

interface TableRow {
  prop1: string;
  prop2: string;
}

const tableData: TableRow[] = [
  { prop1: '1', prop2: 'A' },
  // ... rest of the data
];

86-91: Consider internationalizing table column labels.

The ElTable is correctly implemented with the stripe attribute, which addresses the PR objective. The data binding and column definitions are also correct.

For better internationalization support, consider using translation keys for the column labels instead of hardcoded Chinese text. For example:

<ElTable.TableColumn :label="$t('table.column1')" prop="prop1" />
<ElTable.TableColumn :label="$t('table.column2')" prop="prop2" />

Ensure to add corresponding translations in your i18n configuration.

packages/effects/hooks/src/use-design-tokens.ts (1)

260-260: LGTM! Consider adding a dark mode condition for consistency.

The addition of the --el-fill-color-lighter variable is appropriate and aligns with the PR objective of fixing the stripe table style for ElementPlus in dark mode.

For consistency with other color variables, consider adding a dark mode condition similar to the surrounding code. Here's a suggested improvement:

- '--el-fill-color-lighter': getCssVariableValue('--accent-lighter'),
+ '--el-fill-color-lighter': isDark.value
+   ? getCssVariableValue('--accent-lighter')
+   : getCssVariableValue('--accent-50'),

This change would make the variable behave consistently with other color variables in both light and dark modes.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between abbbbfb and 2d33f55.

Files selected for processing (5)
  • apps/web-ele/src/views/demos/element/index.vue (3 hunks)
  • internal/tailwind-config/src/index.ts (1 hunks)
  • packages/@core/base/design/src/design-tokens/dark/index.css (1 hunks)
  • packages/@core/base/design/src/design-tokens/default/index.css (1 hunks)
  • packages/effects/hooks/src/use-design-tokens.ts (1 hunks)
Additional comments not posted (3)
apps/web-ele/src/views/demos/element/index.vue (2)

10-10: LGTM: ElTable import added correctly.

The ElTable component is properly imported from element-plus, which is necessary for its usage in the template.


Line range hint 1-93: Overall implementation looks good and addresses the PR objective.

The changes successfully introduce a striped table using Element Plus, which aligns with the PR objective of fixing the stripe table style. The implementation is correct and functional.

A few minor suggestions were made to improve type safety and internationalization support, but these are not critical for the current PR objective.

To ensure that the stripe style is working correctly in dark mode as mentioned in the PR objectives, please run the following verification:

This script will help identify any potential conflicts or overrides that might affect the stripe style in dark mode.

packages/@core/base/design/src/design-tokens/dark/index.css (1)

56-56: Approved: Addition of --accent-lighter variable for improved table styling

The introduction of the --accent-lighter CSS variable with the value 216 5% 11% is a good approach to address the issue with zebra stripe styling for tables in dark mode. This new variable provides a slightly lighter shade compared to the existing --accent variable, which should create a subtle contrast for alternating table rows.

This change aligns well with the PR objectives and is appropriately categorized as a bug fix and non-breaking change.

To ensure this change fully addresses the reported issue (#4501), please run the following verification:

This script will help verify if the new variable is being used correctly in table styles and if there are any remaining tasks related to this issue.

@@ -29,6 +29,7 @@ const shadcnUiColors = {
DEFAULT: 'hsl(var(--accent))',
foreground: 'hsl(var(--accent-foreground))',
hover: 'hsl(var(--accent-hover))',
lighter: 'has(val(--accent-lighter))',
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Potential Issue with lighter Property Syntax

The lighter property in the shadcnUiColors object uses the value 'has(val(--accent-lighter))', which is inconsistent with other color properties that typically use the hsl(var(--accent-*)) format. Additionally, the has() and val() functions are not standard CSS functions and may cause configuration issues.

Could you please clarify:

  • Is this the intended syntax for defining the lighter accent color?
  • How does this change contribute to the PR's objective of fixing the stripe table style issue in dark mode?
Analysis chain

Clarify the lighter property value and its relation to the PR objective

The addition of the lighter property to the accent color is noted. However, there are a few concerns:

  1. The value 'has(val(--accent-lighter))' doesn't follow the pattern used for other color properties in this file, which typically use the format hsl(var(--accent-*)).
  2. The has() and val() functions are not standard CSS functions, which might cause issues in the Tailwind configuration.
  3. It's unclear how this change relates to the PR's objective of fixing the stripe table style for ElementPlus in dark mode.

Could you please clarify:

  • Is this the intended syntax for defining the lighter accent color?
  • How does this change contribute to fixing the stripe table style issue mentioned in the PR description?

To check if this syntax is used elsewhere in the project:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar syntax in other configuration files
rg --type=typescript "has\(val\(" -g "*.ts"

Length of output: 80


Script:

#!/bin/bash
# Search for similar syntax in other TypeScript configuration files
rg --type ts "has\\(val\\(--accent-lighter\\)\\)" -g "*.ts"

Length of output: 138

@@ -53,6 +53,7 @@

/* Used for accents such as hover effects on <DropdownMenuItem>, <SelectItem>...etc */
--accent: 240 5% 96%;
--accent-lighter: 240 0% 98%;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Unused --accent-lighter Variable Detected

The --accent-lighter custom property has been added in both dark and default design tokens:

  • packages/@core/base/design/src/design-tokens/dark/index.css: --accent-lighter: 216 5% 11%;
  • packages/@core/base/design/src/design-tokens/default/index.css: --accent-lighter: 240 0% 98%;

However, there are no references to --accent-lighter in other parts of the codebase.

Please clarify how this addition contributes to the PR's objective of fixing the stripe table style for ElementPlus in dark mode.

Analysis chain

New custom property added: Clarification needed

The addition of the --accent-lighter custom property is noted. This new variable introduces a very light shade (almost white) to the accent color palette.

However, it's not immediately clear how this addition relates to the PR objective of fixing the stripe table style for ElementPlus in dark mode. Could you please clarify:

  1. How does this new variable contribute to addressing the issue with table styles in dark mode?
  2. Are there other changes in different files that utilize this new variable?

Additionally, consider adding a comment to document the purpose and intended use of this new custom property. This will help maintain clarity for future developers working with these design tokens.

To better understand the usage of this new variable, let's check if it's being used in other files:

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of the new --accent-lighter variable
rg --type css "--accent-lighter"

Length of output: 451


Script:

#!/bin/bash
# Corrected search for usage of the new --accent-lighter variable in CSS files
rg --type css "--accent-lighter"

Length of output: 451


Script:

#!/bin/bash
# Corrected search for usage of the new --accent-lighter variable in CSS files
rg --type css -e "--accent-lighter"

Length of output: 222

@mynetfan
Copy link
Collaborator Author

有多余的合并commit,重新提交PR

@mynetfan mynetfan closed this Sep 25, 2024
@mynetfan mynetfan deleted the fixed/ele-table branch September 25, 2024 02:51
@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant