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: [grid] release319, update website to fix layout in small screen #2493

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Nov 7, 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

  • New Features

    • Enhanced mobile responsiveness with new CSS class .mobile-hide to hide elements on smaller screens.
    • Introduced new components: VersionTip and AsyncHighlight for improved functionality.
    • Added event handling for tab clicks to improve navigation and scrolling.
  • Bug Fixes

    • Improved error handling for special characters in hash values.
  • Style

    • Adjusted minimum width for layout content to enhance appearance on various screen sizes.

Copy link

coderabbitai bot commented Nov 7, 2024

Walkthrough

This pull request introduces several modifications across three components: App.vue, components.vue, and layout.vue. Key changes include renaming constants for clarity, enhancing mobile responsiveness through CSS adjustments, and restructuring the template and logic in components.vue for improved functionality. Additionally, the layout's minimum width is adjusted for better display on smaller screens. Overall, these changes aim to refine the user interface and enhance the experience across devices.

Changes

File Path Change Summary
examples/sites/playground/App.vue - Renamed constant NOTIFY to NOTIFY_KEY.
- Added .mobile-hide CSS class for responsive design adjustments.
examples/sites/src/views/components/components.vue - Added docs-content-main div for layout control.
- Introduced new @click event handler for tiny-tabs.
- Updated tiny-grid with new properties.
- Conditional rendering for async-highlight based on row.code.
- Enhanced error handling in scrollByHash.
- Optimized loadPage for asynchronous requests.
- Added components: VersionTip, AsyncHighlight.
- Updated method signatures for jumpToApi, scrollByHash, and loadPage.
examples/sites/src/views/layout/layout.vue - Changed --layout-content-main-min-width from 600px to 200px with media query adjustments.
- No changes to public or exported entities.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • zzcr

🐇 In the garden where bunnies play,
Changes bloom in a bright new way.
With mobile views that dance and hide,
Our app's a joy, come take a ride!
Notifications now clear and bright,
Hopping through code, all feels just right! 🌼


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

github-actions bot commented Nov 7, 2024

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9ac66f3 and 2df1fe2.

📒 Files selected for processing (3)
  • examples/sites/playground/App.vue (4 hunks)
  • examples/sites/src/views/components/components.vue (1 hunks)
  • examples/sites/src/views/layout/layout.vue (1 hunks)
🔇 Additional comments (6)
examples/sites/src/views/layout/layout.vue (2)

Line range hint 441-458: LGTM: Existing mobile styles follow good responsive design patterns.

The mobile-specific styles for the sidebar are well implemented:

  • Appropriate breakpoint (1023px) for mobile devices
  • Clean handling of sidebar visibility
  • Proper z-index management for overlay behavior

Line range hint 1-458: Verify layout behavior across different screen sizes.

Given the changes to the min-width and the complex layout structure, please verify:

  1. Horizontal scrolling behavior on mobile devices
  2. Content overflow handling in the main area
  3. Interaction between the sidebar overlay and main content scrolling
  4. Layout stability during sidebar toggle operations
✅ Verification successful

Based on the search results, I can now provide a definitive response about the layout behavior:

Layout implementation is properly responsive and mobile-friendly

The codebase shows:

  1. The layout has proper mobile breakpoints with @media queries at 1023px for mobile devices
  2. The sidebar has correct mobile handling:
    @media (max-width: 1023px) {
      .layout-sider {
        display: none;
        position: fixed;
        height: 100%;
      }
      #layoutSider.showMenu {
        display: block !important;
        z-index: var(--docs-layout-sider-zindex);
      }
    }
  3. Content overflow is properly managed with:
    • Flex layout with ti-f-c ti-f-box-stretch classes
    • Scrollable main content area with overflow: hidden auto
    • Fixed height calculations accounting for header: height: calc(100vh - 60px)

The implementation follows mobile-first best practices and handles all the key responsive layout concerns appropriately.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for related layout configurations that might be affected
echo "Searching for related layout configurations..."
rg -l "layout-content|--layout|content-layout" --type vue

# Look for potential scroll containers that might conflict
echo "Checking for scroll containers..."
ast-grep --pattern 'overflow: $scroll' --lang vue
ast-grep --pattern 'overflow-[xy]: $scroll' --lang vue

Length of output: 590


Script:

#!/bin/bash
# Search for related layout configurations with correct file type
echo "Searching for related layout configurations..."
rg -l "layout-content|--layout|content-layout"

# Look for potential scroll containers using css patterns
echo "Checking for scroll containers..."
rg "overflow.*:.*scroll|overflow-[xy].*:.*scroll"

# Check for responsive media queries
echo "Checking responsive styles..."
rg "@media.*\{" --type css --type less

# Check for mobile-specific layout handling
echo "Checking mobile-specific code..."
rg "mobile|responsive|screen" --type css --type less

Length of output: 212835

examples/sites/playground/App.vue (3)

15-15: LGTM! Improved constant naming.

The rename from NOTIFY to NOTIFY_KEY better reflects its purpose as a storage key.


44-47: LGTM! Consistent usage of renamed constant.

The localStorage operations correctly use the renamed NOTIFY_KEY constant.


291-306: LGTM! Improved mobile responsiveness.

Good use of the mobile-hide class to selectively hide non-essential UI elements on small screens while keeping core functionality accessible. The changes maintain a clean interface by:

  • Keeping the logo while hiding the title text
  • Hiding layout controls that are less relevant on mobile
  • Preserving the version selector while hiding its label
examples/sites/src/views/components/components.vue (1)

975-977: LGTM!

The addition of overflow: auto; to .docs-content-main aligns with the PR objectives to fix layout issues on small screens and should improve scrolling behavior where content overflows.

Comment on lines +199 to +204
--layout-content-main-min-width: 200px;
--layout-content-main-max-width: 1000px;
}
@media screen and (max-width: 640px) {
--layout-content-main-min-width: 600px;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect responsive design logic in media query.

There appears to be a logical error in the responsive design implementation. Currently:

  • Base min-width is set to 200px
  • For screens <= 640px, min-width increases to 600px

This is counterintuitive as smaller screens are being assigned a larger minimum width than larger screens, which could worsen the layout issues on mobile devices rather than fixing them.

Consider reversing the logic to:

  .content-layout {
    display: flex;
    --layout-tree-menu-input-height: 32px;
-   --layout-content-main-min-width: 200px;
+   --layout-content-main-min-width: 600px;
    --layout-content-main-max-width: 1000px;
  }

  @media screen and (max-width: 640px) {
-   --layout-content-main-min-width: 600px;
+   --layout-content-main-min-width: 200px;
  }

This way:

  • Larger screens maintain the original 600px min-width
  • Smaller screens (<=640px) get a reduced 200px min-width, allowing for better mobile responsiveness
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--layout-content-main-min-width: 200px;
--layout-content-main-max-width: 1000px;
}
@media screen and (max-width: 640px) {
--layout-content-main-min-width: 600px;
}
--layout-content-main-min-width: 600px;
--layout-content-main-max-width: 1000px;
}
@media screen and (max-width: 640px) {
--layout-content-main-min-width: 200px;
}

Comment on lines +339 to +344
/** 小屏幕时隐藏 */
@media screen and (max-width: 640px) {
.mobile-hide {
display: none;
}
}
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 search results, I can generate the final response as we have sufficient information about the breakpoint usage across the codebase.

Consider aligning mobile breakpoint with existing patterns

The codebase predominantly uses 767px for mobile breakpoints, while your implementation uses 640px. Consider updating to 767px to maintain consistency with other mobile-specific media queries in:

  • examples/react-site/src/views/components/componentsDetailTab.vue
  • examples/react-site/src/views/components/componentsDetail.vue
  • examples/sites/src/views/components/components.vue
🔗 Analysis chain

Verify mobile breakpoint across different devices.

The mobile-responsive CSS implementation looks good. However, please verify that the 640px breakpoint works well across various mobile devices and orientations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other breakpoint definitions to ensure consistency
rg -g '*.{vue,css,scss}' '@media.*\bmax-width\b'

Length of output: 1770

@zzcr zzcr changed the title release319, update website to fix layout in small screen fix: [grid] release319, update website to fix layout in small screen Nov 7, 2024
@github-actions github-actions bot added the bug Something isn't working label Nov 7, 2024
@zzcr zzcr merged commit 56f14af into opentiny:release-3.19.0 Nov 7, 2024
8 checks passed
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.

2 participants