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

feat(dept): [dept] Optimize style #2487

Merged
merged 2 commits into from
Nov 7, 2024
Merged

feat(dept): [dept] Optimize style #2487

merged 2 commits into from
Nov 7, 2024

Conversation

Youyou-smiles
Copy link
Collaborator

@Youyou-smiles Youyou-smiles commented Nov 5, 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

Release Notes

  • New Features

    • Added a title attribute with the value "选择权签人" to the tiny-hrapprover component across multiple demo files, enhancing user clarity during the approval process.
  • Style Updates

    • Adjusted margins for the .tiny-popper class to improve positioning.
    • Increased vertical spacing for department component elements to enhance layout.
    • Modified margins for .item-talk, .item-call, and .item-email classes for better item separation.

Copy link

coderabbitai bot commented Nov 5, 2024

Walkthrough

The changes introduce a new title attribute with the value "选择权签人" to the tiny-hrapprover component across multiple Vue files. This addition aims to enhance the component's functionality by providing a clear title for the approval process. Additionally, modifications to the CSS files include adjustments to margins and paddings for various classes, improving the layout and spacing of UI elements. Overall, the structural integrity of the components and styles remains intact.

Changes

File Path Change Summary
examples/sites/demos/pc/app/hrapprover/*.vue Added title attribute with value "选择权签人" to tiny-hrapprover component in the templates of multiple Vue files: custom-service-composition-api.vue, custom-service.vue, basic-usage-composition-api.vue, basic-usage.vue, category-type-composition-api.vue, category-type.vue, disabled-composition-api.vue, disabled.vue.
packages/theme/src/base/reset.less Added margin properties for .tiny-popper class for placements: top, bottom, right, left, each with 4px margin.
packages/theme/src/dept/index.less Increased margin-bottom for &__search and &__item classes from 12px to 24px; set width to 80px for &__text and &__label, and changed text-align of &__label from right to left.
packages/theme/src/dept/vars.less Updated CSS properties for department label text color and font weight: changed --tv-Dept-label-text-color to secondary color and --tv-Dept-label-font-weight to regular.
packages/theme/src/espace/index.less Adjusted margin for .item-talk, .item-call, and .item-email classes from 0 8px 0 0 to 0 24px 0 0.
packages/theme/src/roles/index.less Updated padding for &.@{css-prefix}popover.@{css-prefix}popper from 0 to 8px 0; removed styles for .is-selected state in &__poplist-item.
packages/theme/src/roles/vars.less Removed variable --tv-Roles-poplist-item-selected-bg-color related to selected background color for dropdown panel options.

Suggested reviewers

  • zzcr

🐰 "In a world of code, I hop and play,
With new titles added, brightening the day.
Margins adjusted, layouts refined,
In this rabbit's realm, all's perfectly aligned!
Let's celebrate changes, both big and small,
For in this code garden, there's room for us all!" 🐇✨


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 enhancement New feature or request (功能增强) label Nov 5, 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: 0

🧹 Outside diff range and nitpick comments (6)
packages/theme/src/espace/index.less (1)

25-25: Consider documenting spacing guidelines.

Since this is part of a style optimization effort, it would be valuable to document the spacing system in a design system guide.

Consider adding a comment above the class definitions explaining the spacing rationale:

  .item-talk,
  .item-call,
  .item-email {
+   // Use 24px horizontal spacing for better visual separation of communication items
    margin: 0 24px 0 0;
examples/sites/demos/pc/app/hrapprover/custom-service-composition-api.vue (1)

9-9: Consider extracting the hardcoded title text for internationalization.

While adding a title improves UI clarity, the Chinese text "选择权签人" is hardcoded. Since this appears to be a demo file, consider:

  1. Using an i18n key instead of hardcoded text
  2. Adding a comment explaining the title's meaning in English for non-Chinese speakers

Example modification:

-      title="选择权签人"
+      :title="t('hrapprover.selectApprovalPerson')" <!-- Select Approval Person -->
examples/sites/demos/pc/app/hrapprover/custom-service.vue (1)

9-9: Consider internationalization for the title text.

While the implementation is correct for a demo, consider using an i18n system for the title text "选择权签人" to support multiple languages in a production environment.

Example implementation using Vue i18n:

-      title="选择权签人"
+      :title="$t('hrapprover.selectApprover')"
packages/theme/src/dept/index.less (1)

30-34: Consider responsive design for text width

The fixed width of 80px for text and label elements might cause issues on different screen sizes or with longer text content (though mitigated by text-overflow: ellipsis).

Consider using:

  1. A relative width unit or min/max width constraints
  2. A responsive approach using media queries for different screen sizes
-    width: 80px;
+    min-width: 80px;
+    max-width: 120px;
+    width: fit-content;
packages/theme/src/base/reset.less (1)

180-193: Consider using CSS variables for margin values.

The implementation looks good! However, for better maintainability, consider extracting the margin value to a CSS variable.

+:root {
+  --tv-popper-margin: 4px;
+}
 .tiny-popper {
   &[x-placement^='top'] {
-    margin-bottom: 4px;
+    margin-bottom: var(--tv-popper-margin);
   }
   &[x-placement^='bottom'] {
-    margin-top: 4px;
+    margin-top: var(--tv-popper-margin);
   }
   &[x-placement^='right'] {
-    margin-left: 4px;
+    margin-left: var(--tv-popper-margin);
   }
   &[x-placement^='left'] {
-    margin-right: 4px;
+    margin-right: var(--tv-popper-margin);
   }
 }
packages/vue/src/dept/src/pc.vue (1)

21-21: Consider a more responsive approach for dialog positioning.

While setting top="10vh" provides consistent positioning, it might not be optimal for all viewport sizes. On smaller screens, this fixed position could make the dialog appear too close to the top.

Consider these alternatives:

-      top="10vh"
+      :style="{ top: Math.max(window.innerHeight * 0.1, 50) + 'px' }"

Or use CSS custom properties for better maintainability:

-      top="10vh"
+      class="tiny-dept-dialog"

With corresponding CSS:

.tiny-dept-dialog {
  --min-top-spacing: 50px;
  --preferred-top-ratio: 10vh;
  top: max(var(--min-top-spacing), var(--preferred-top-ratio));
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dce3b6e and b7d006c.

📒 Files selected for processing (10)
  • examples/sites/demos/pc/app/hrapprover/custom-service-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/hrapprover/custom-service.vue (1 hunks)
  • packages/theme/src/base/reset.less (1 hunks)
  • packages/theme/src/dept/index.less (2 hunks)
  • packages/theme/src/dept/vars.less (1 hunks)
  • packages/theme/src/espace/index.less (1 hunks)
  • packages/theme/src/roles/index.less (1 hunks)
  • packages/theme/src/roles/vars.less (0 hunks)
  • packages/vue/src/dept/package.json (1 hunks)
  • packages/vue/src/dept/src/pc.vue (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/theme/src/roles/vars.less
✅ Files skipped from review due to trivial changes (1)
  • packages/vue/src/dept/package.json
🔇 Additional comments (10)
packages/theme/src/dept/vars.less (2)

15-16: Verify accessibility impact of reduced label prominence.

The changes to make labels less prominent (secondary color and regular weight) look good from a visual hierarchy perspective. However, please ensure these changes maintain sufficient contrast ratios for accessibility.

✅ Verification successful

Based on the search results, I can now provide a conclusive response:

The color change to secondary text is consistent with the design system and maintains accessibility.

The search results show that --tv-color-text-secondary (value: #595959) is widely used across the component library for secondary text elements, labels, and descriptions. This color is part of the base theme variables and follows a consistent pattern where:

  • Primary text is used for main content
  • Secondary text (#595959) is specifically designated for "secondary information" and labels
  • The color provides sufficient contrast against light backgrounds

The change aligns with the established design patterns in the codebase where similar components like Tree, NavMenu, and Grid all use this same secondary text color for their labels.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if there are any accessibility-related tests or documentation
# that might need updating with these style changes

# Look for accessibility tests
rg -l "accessibility|a11y|contrast|WCAG" --type md
rg -l "accessibility|a11y|contrast|WCAG" --type vue

Length of output: 318


Script:

#!/bin/bash
# Let's check the actual color values and any existing color contrast guidelines
rg -A 3 "tv-color-text-secondary|tv-color-text-primary" --type less

# Also check for any existing color contrast or accessibility documentation
fd -e md -e mdx . | xargs rg -l "contrast|color|accessibility"

# Check the actual usage of these label styles in components
rg -l "tv-Dept-label" --type vue --type less

Length of output: 13686


15-16: Consider updating style documentation.

Since these changes affect the visual appearance of department labels across the application, consider updating the component's style documentation or design guidelines to reflect these new defaults.

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

25-25: LGTM! Verify spacing consistency across components.

The increased margin improves visual separation between communication items. This aligns well with modern UI practices for better readability.

Let's verify if this spacing is consistent with other similar components:

✅ Verification successful

Spacing pattern is consistent with component-specific requirements

The 24px margin is appropriately used across different components where larger spacing is needed:

  • Vertical spacing for dividers (24px 0)
  • Bottom spacing for popeditor (0 auto 24px)
  • Horizontal spacing for communication items (0 24px 0 0)

While some components use 8px margins for tighter spacing needs, the 24px spacing in the espace component aligns with other instances where prominent separation is desired.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other margin definitions in the theme package
# to ensure consistent spacing across components

# Search for margin definitions in theme files
rg -g '*.less' -g '*.css' 'margin:.*24px' packages/theme/

Length of output: 245


Script:

#!/bin/bash
# Let's check for other margin values in these specific components to understand the spacing patterns
rg -g '*.less' -g '*.css' 'margin:.*\d+px' packages/theme/src/espace/ packages/theme/src/popeditor/ packages/theme/src/divider/

# Also check for any spacing variables that might define these values
rg -g '*.less' -g '*.css' '@space|@margin' packages/theme/src/

Length of output: 857

examples/sites/demos/pc/app/hrapprover/custom-service-composition-api.vue (1)

Line range hint 1-45: LGTM! The changes look good overall.

The addition of the title property to the tiny-hrapprover component enhances the UI by providing clear context to users. The implementation is clean and consistent with Vue's template syntax.

examples/sites/demos/pc/app/hrapprover/custom-service.vue (1)

Line range hint 1-57: LGTM! The demo implementation is well-structured.

The component demonstrates proper usage of TinyHrapprover with:

  • Clear data binding using v-model
  • Mock data service implementation
  • Appropriate event handling
  • Clean and focused styling
packages/theme/src/roles/index.less (2)

Line range hint 30-57: Verify impact of removed selected state styles.

The removal of .is-selected styles and its related variable --tv-Roles-poplist-item-selected-bg-color could affect the user experience. Please ensure:

  1. Selected states are still visually distinguishable
  2. This change is intentional and documented
  3. No other components rely on these styles
#!/bin/bash
# Description: Check usage of removed styles and variables

# Search for any remaining references to the selected state
rg "is-selected" --type vue --type less

# Search for the removed variable
rg "tv-Roles-poplist-item-selected-bg-color"

# Look for similar selected state patterns in other components
rg "selected.*bg-color" --type less

27-27: Verify consistency of popover padding across components.

The padding change from 0 to 8px 0 improves spacing, but let's ensure this aligns with other popovers in the system.

✅ Verification successful

Let's search for padding patterns in popover/popper components to verify consistency.


Padding change is consistent with design patterns

The padding value of 8px 0 aligns with the existing padding patterns across the codebase, particularly in similar components:

  • Autocomplete: padding: 8px 0
  • Date panel: padding: 8px 0
  • Grid menu: padding: 8px 0
  • Pager: padding: 8px 0

This change maintains consistency with the established design system's spacing patterns.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check padding patterns in other popover components
# Look for similar popover/popper class combinations and their padding values

# Search for popover/popper padding definitions
rg -l "\.popover.*\.popper.*padding:" --type less

# Search for specific padding patterns
rg "padding:\s*(8px 0|0);" --type less

Length of output: 1472


Script:

#!/bin/bash
# Search for padding patterns in less files, focusing on popover/popper related styles
rg "\.popover|\.popper" -A 5 -B 5 --type less | grep -E "padding:|margin:"

# Search specifically for padding: 8px patterns
rg "padding:\s*8px" --type less

Length of output: 1761

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

25-25: Verify spacing alignment with design system

The margin-bottom has been doubled from 12px to 24px for both search and item elements. While this increased spacing can improve readability, please ensure this aligns with your design system's spacing scale.

Consider using spacing variables from your design system (if available) instead of hard-coded values for better maintainability:

-    margin-bottom: 24px;
+    margin-bottom: var(--tv-spacing-xl);  // or similar design token

Also applies to: 53-53

packages/theme/src/base/reset.less (1)

180-193: Verify the margin value consistency across popper components.

There seems to be an inconsistency between margin values:

  • .tiny-popper uses 4px margins
  • .tiny-popconfirm-popover and .tiny-tooltip__popper use 12px margins

Please verify if this difference is intentional. If not, consider standardizing the margin values across all popper components.

Also applies to: 196-251

packages/vue/src/dept/src/pc.vue (1)

Line range hint 1-180: Implementation follows Vue.js best practices.

The component is well-structured with:

  • Proper component registration
  • Clear prop and emit definitions
  • Consistent use of the tiny-vue design system
  • TypeScript integration

@@ -18,6 +18,7 @@
@update:visible="state.open = $event"
:close-on-click-modal="false"
width="550px"
top="10vh"
Copy link
Member

Choose a reason for hiding this comment

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

这里为啥要改模板呢?需要评估下对saas主题的影响

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

🧹 Outside diff range and nitpick comments (7)
examples/sites/demos/pc/app/hrapprover/basic-usage-composition-api.vue (2)

5-5: Consider internationalizing the title text.

While adding a title improves accessibility, consider using an i18n key instead of hardcoding the Chinese text "选择权签人", especially if this component is intended for international usage.

Example modification:

-      title="选择权签人"
+      :title="t('hrapprover.selectRightsSigner')"

Line range hint 1-24: Documentation update needed for the title attribute.

Since this is a demo file showcasing the basic usage of the component with Composition API, please update the relevant documentation to explain the purpose and usage of the newly added title attribute.

Would you like me to help draft the documentation update or create a GitHub issue to track this task?

examples/sites/demos/pc/app/hrapprover/basic-usage.vue (1)

5-5: Consider using i18n for the title text.

The hardcoded Chinese text "选择权签人" should ideally be internationalized to support multiple languages and improve maintainability.

Consider using your i18n system, for example:

-      title="选择权签人"
+      :title="t('hrapprover.selectApprover')"
examples/sites/demos/pc/app/hrapprover/category-type.vue (1)

6-6: LGTM! Consider implementing i18n for the title.

The addition of the title improves UI clarity. However, consider implementing internationalization for better maintainability and accessibility.

Example implementation using Vue i18n:

-      title="选择权签人"
+      :title="$t('hrapprover.selectApprover')"

Then in your i18n configuration:

{
  "en": {
    "hrapprover": {
      "selectApprover": "Select Approval Person"
    }
  },
  "zh": {
    "hrapprover": {
      "selectApprover": "选择权签人"
    }
  }
}
examples/sites/demos/pc/app/hrapprover/disabled-composition-api.vue (1)

7-7: Consider internationalizing the title text.

While adding the title improves accessibility, consider using an i18n key instead of hardcoding the Chinese text "选择权签人" to support multiple languages.

-      title="选择权签人"
+      :title="t('hrapprover.approverTitle')"
examples/sites/demos/pc/app/hrapprover/disabled.vue (2)

7-7: Consider internationalizing the title text.

The title addition improves component clarity, but consider extracting "选择权签人" to a localization file for better maintainability and internationalization support.


6-10: Enhance accessibility with aria-label.

Consider adding an aria-label attribute to improve accessibility for screen readers, especially since this is a demo showcasing disabled state functionality.

    <tiny-hrapprover
      :value="value"
      :approval-person="person"
      title="选择权签人"
+     aria-label="Approval person selector"
      @update:approvalPerson="person = $event"
      :disabled="disabled"
    ></tiny-hrapprover>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b7d006c and 83a4205.

📒 Files selected for processing (7)
  • examples/sites/demos/pc/app/hrapprover/basic-usage-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/hrapprover/basic-usage.vue (1 hunks)
  • examples/sites/demos/pc/app/hrapprover/category-type-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/hrapprover/category-type.vue (1 hunks)
  • examples/sites/demos/pc/app/hrapprover/disabled-composition-api.vue (1 hunks)
  • examples/sites/demos/pc/app/hrapprover/disabled.vue (1 hunks)
  • packages/theme/src/dept/index.less (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/sites/demos/pc/app/hrapprover/category-type-composition-api.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/theme/src/dept/index.less
🔇 Additional comments (1)
examples/sites/demos/pc/app/hrapprover/basic-usage.vue (1)

Line range hint 1-33: LGTM! Clean and well-structured demo implementation.

The component demonstrates proper usage of tiny-hrapprover with clear data bindings and event handling. The styling is appropriately scoped and the implementation is consistent with other demo files.

@@ -4,6 +4,7 @@
<tiny-hrapprover
:value="value"
:approval-person="person"
title="选择权签人"
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the git history and documentation review, I can now provide a final response:

The title property is a recent addition and documentation needs to be updated

The git history shows that the title property was added in the most recent commit (83a4205) and checking the component's documentation (both Chinese and English versions) reveals that this property is not documented. The documentation should be updated to include:

  • The new title property
  • Its purpose and usage
  • Default value if any
  • Type information
🔗 Analysis chain

Verify documentation updates for the new title property.

The title property appears to be a new addition across multiple files. Let's verify if the documentation has been updated accordingly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if documentation for the title property exists
# Expected: Documentation files containing information about the new title property

# Search in documentation files
rg -g "*.md" "title.*选择权签人|hrapprover.*title" docs/

Length of output: 99


Script:

#!/bin/bash
# Let's first check if there are any documentation directories in the repository
fd -t d "doc|docs"

# Let's also check the root directory for any markdown files that might contain documentation
fd -e md

# Let's also check if this title property is used in other files to understand its context
rg "title=\"选择权签人\""

Length of output: 60663


Script:

#!/bin/bash
# Let's check the documentation for the hrapprover component
cat examples/sites/demos/pc/app/hrapprover/webdoc/hrapprover.cn.md
cat examples/sites/demos/pc/app/hrapprover/webdoc/hrapprover.en.md

# Let's also check if this title property is a new addition by looking at git history
git log -p examples/sites/demos/pc/app/hrapprover/disabled-composition-api.vue

Length of output: 4692

@zzcr zzcr merged commit 9ac66f3 into release-3.19.0 Nov 7, 2024
6 checks passed
@Youyou-smiles Youyou-smiles deleted the lty/feat-dept branch November 7, 2024 07:00
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2024
13 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 19, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants