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: improve the layout of tables offline on the mobile #4573

Merged
merged 1 commit into from
Oct 5, 2024
Merged

Conversation

anncwb
Copy link
Collaborator

@anncwb anncwb commented Oct 5, 2024

Description

fixed #4570

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.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Enhanced mobile responsiveness for the pagination component.
    • Added a new class for improved layout of the pager component.
  • Bug Fixes

    • Simplified localization strings for better clarity in the Chinese language interface.
  • Style

    • Updated styles for the pager component to improve alignment and interaction states.
  • Refactor

    • Adjusted control flow in the query form styling logic to enhance layout conditions.

@anncwb anncwb added the bug Something isn't working label Oct 5, 2024
Copy link

changeset-bot bot commented Oct 5, 2024

⚠️ No Changeset found

Latest commit: 6e07c18

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 Oct 5, 2024

Walkthrough

The pull request introduces several changes across multiple components, including modifications to the form-actions.vue, theme.css, use-vxe-grid.vue, and a localization file. Key changes involve the removal of a computed property in form-actions.vue, the addition of new CSS rules in theme.css, and enhancements to mobile responsiveness in use-vxe-grid.vue. Additionally, a localization string was simplified in the Chinese language JSON file. These changes collectively aim to refine the user interface and improve component adaptability.

Changes

File Path Change Summary
packages/@core/ui-kit/form-ui/src/components/form-actions.vue Removed isQueryForm computed property; modified queryFormStyle logic to check actionWrapperClass.
packages/effects/plugins/src/vxe-table/theme.css Added new class .vxe-pager--wrapper; organized existing styles for .vxe-pager.
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue Added usePreferences import; updated layout logic for mobile responsiveness; modified class bindings.
playground/src/locales/langs/zh-CN.json Modified string for "form" key from "开启搜索表单" to "搜索表单".

Assessment against linked issues

Objective Addressed Explanation
Enable hiding of the collapse/expand button based on query form elements (#[4570])
Ensure proper layout on small screens for query forms (#[4570])

Possibly related PRs

Suggested reviewers

  • vince292007

🐇 In the meadow where bunnies play,
Changes made to brighten the day.
Forms now dance with style so neat,
Mobile views are quite a treat!
With CSS spruced and strings refined,
A joyful hop for all aligned! 🌼


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

🧹 Outside diff range and nitpick comments (4)
packages/effects/plugins/src/vxe-table/theme.css (3)

Line range hint 69-78: Improved pager layout structure. Consider adding responsive behavior.

The changes to the .vxe-pager class enhance the layout structure by using flexbox, which improves alignment and potentially responsiveness. The .vxe-pager--sizes class pushing to the left side is a good touch for layout control.

Consider adding responsive behavior to the .vxe-pager--sizes margin. For example:

.vxe-pager--sizes {
  margin-right: auto;
  @media (max-width: 768px) {
    margin-right: 0;
    margin-bottom: 10px;
  }
}

This would stack the elements vertically on smaller screens, potentially improving the mobile layout further.


80-82: Responsive justification added. Consider using Tailwind throughout for consistency.

The addition of the .vxe-pager--wrapper class with responsive justification is a good improvement for mobile layouts. It centers content on smaller screens and aligns to the end on medium screens and up.

For consistency, consider using Tailwind utilities throughout the file where applicable. For example, you could refactor the .vxe-pager--sizes rule to use Tailwind:

.vxe-pager {
  &--wrapper {
    @apply flex items-center justify-center md:justify-end;
  }

  &--sizes {
    @apply mr-auto;
  }
}

This would maintain a consistent styling approach across the component.


Line range hint 1-82: Overall improvements align with PR objectives. Consider standardizing CSS approach.

The changes in this file successfully address the layout issues for mobile devices as outlined in the PR objectives. The use of flexbox and responsive justification in the pager component will significantly improve the mobile experience.

To further enhance the maintainability and consistency of the codebase:

  1. Consider standardizing the CSS approach throughout the file. You're currently mixing traditional CSS with Tailwind utilities. Choosing one approach (preferably Tailwind, given its use in the new code) could improve readability and maintainability.

  2. Review the commented-out CSS variables at the top of the file. If they're no longer needed, consider removing them to keep the file clean and up-to-date.

  3. Ensure that these changes are thoroughly tested on various mobile devices and screen sizes to confirm that the layout improvements work as intended across different contexts.

These suggestions will help maintain a consistent and efficient codebase as the project evolves.

packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (1)

165-166: Consider including collapseTriggerResize in finalFormOptions

Adding collapseTriggerResize separately might be inconsistent. Consider including it within finalFormOptions for consistency.

Apply this diff to include collapseTriggerResize in finalFormOptions:

   const finalFormOptions: VbenFormProps = mergeWithArrayOverride(
     {},
     formOptions.value,
     defaultFormProps,
+    {
+      collapseTriggerResize: !!defaultFormProps.showCollapseButton,
+    },
   );
-  return {
-    ...finalFormOptions,
-    collapseTriggerResize: !!finalFormOptions.showCollapseButton,
-  };
+  return finalFormOptions;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d37e2f5 and 6e07c18.

📒 Files selected for processing (4)
  • packages/@core/ui-kit/form-ui/src/components/form-actions.vue (1 hunks)
  • packages/effects/plugins/src/vxe-table/theme.css (1 hunks)
  • packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (6 hunks)
  • playground/src/locales/langs/zh-CN.json (1 hunks)
🔇 Additional comments (7)
packages/@core/ui-kit/form-ui/src/components/form-actions.vue (1)

Line range hint 33-44: Reconsider the changes to form layout logic

The modifications to the isQueryForm computed property and queryFormStyle raise concerns:

  1. Commenting out isQueryForm (lines 33-35) removes the logic for determining when to show the collapse button. This doesn't align with the PR objective of improving mobile layout and the linked issue's discussion about hiding the query button under certain conditions.

  2. The change in queryFormStyle (line 38) now relies on the absence of actionWrapperClass rather than isQueryForm. This may not accurately represent whether it's a query form and could lead to unexpected layout issues.

Consider the following improvements:

  1. Instead of commenting out isQueryForm, modify it to incorporate the conditions discussed in the linked issue (e.g., number of form elements).
  2. Update queryFormStyle to use both isQueryForm and actionWrapperClass for more precise control over the layout.
  3. Ensure these changes improve the layout on mobile devices as per the PR objective.

Example refactor:

const isQueryForm = computed(() => {
  const { showCollapseButton, formItems } = unref(rootProps);
  return showCollapseButton && formItems.length > 2; // Adjust the condition as needed
});

const queryFormStyle = computed(() => {
  if (unref(isQueryForm) && !unref(rootProps).actionWrapperClass) {
    return {
      'grid-column': `-2 / -1`,
      marginLeft: 'auto',
    };
  }
  return {};
});

To ensure these changes align with the PR objectives, please run the following verification:

This will help us understand the broader context and ensure our changes don't introduce regressions.

playground/src/locales/langs/zh-CN.json (1)

95-95: Approved, but clarification needed on relevance to PR objectives

The change from "开启搜索表单" (Open Search Form) to "搜索表单" (Search Form) is a valid simplification of the UI text. However, it's not clear how this change relates to the PR objectives of improving table layout on mobile devices or the linked issue (#4570) about hiding query buttons and table layout problems.

Could you please clarify how this localization change contributes to the stated objectives of the PR? Are there other changes in different files that work in conjunction with this text modification to address the mobile layout issues?

To verify if there are related changes, let's check for modifications in other localization files and any components that might use this text:

packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (5)

22-22: Import of usePreferences is appropriate

The addition of usePreferences import aligns with its usage in the component.


52-53: Destructuring isMobile from usePreferences

Correctly obtaining isMobile for responsive design adjustments.


158-163: Review the order of merging form options

In mergeWithArrayOverride, the default form properties are merged after formOptions.value, which may override user-provided values. Ensure this is intentional and that default properties should take precedence over formOptions.value.


259-259: Validate Tailwind CSS classes for consistency

The class string includes responsive classes like md:bottom-2 and md:h-3. Ensure these classes achieve the desired styling across different screen sizes.


119-119: Ensure reactivity of isMobile.value in computed properties

Verify that isMobile.value is reactive so that layouts in pagerConfig update accordingly when the device type changes.

Run the following script to check if isMobile is a reactive property:

@anncwb anncwb merged commit 47d162e into main Oct 5, 2024
14 checks passed
@anncwb anncwb deleted the bugfix/4570 branch October 5, 2024 14:00
@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FEATURE: 表单组件,查询按钮 收起/展开,能否单独隐藏
1 participant