Skip to content

Fix documentation file structure component width issue #3050

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link
Contributor

Fix documentation file structure component width issue

Problem

Issue #3049: The file structure component in the "Generate Project Scaffolding" section of the installation documentation page (https://docs.crewai.com/installation) has no width styling, causing it to collapse and become unreadable.

Solution

  • Added custom CSS file (docs/style.css) with comprehensive Frame component styling
  • Targeted Frame components with min-width: 300px to prevent collapse
  • Added overflow-x: auto for horizontal scrolling when content exceeds container width
  • Included multiple CSS selectors to cover different Frame component implementations:
    • .frame-container
    • [data-component="frame"]
    • .frame
    • div[class*="frame"]

Changes Made

  1. Created docs/style.css: Custom CSS file that will be automatically included by Mintlify
  2. Created tests/docs_styling_test.py: Comprehensive tests to prevent regression

Testing

  • ✅ Verified CSS file contains proper Frame component styling
  • ✅ Verified installation.mdx contains the Frame component with file structure
  • ✅ Added comprehensive test coverage for the styling fix
  • ✅ Confirmed Mintlify will automatically include the CSS file

Files Changed

  • docs/style.css (new file)
  • tests/docs_styling_test.py (new file)

Link to Devin run

https://app.devin.ai/sessions/61a0a5f7e35f4a34844755507f8dcf5b

Requested by

João (joao@crewai.com)

The fix ensures that the file structure component in the installation documentation displays with adequate width and proper overflow handling, making it readable and accessible to users following the installation guide.

- Add custom CSS file (docs/style.css) to fix Frame component width
- Target Frame components with min-width: 300px to prevent collapse
- Add overflow-x: auto for horizontal scrolling when needed
- Include comprehensive CSS selectors for different Frame implementations
- Add tests (tests/docs_styling_test.py) to prevent regression
- Fixes issue #3049: file structure component has no width on installation page

The Frame component in the 'Generate Project Scaffolding' section was
collapsing due to lack of width styling. This fix ensures the file
structure displays properly with adequate width for readability.

Co-Authored-By: João <joao@crewai.com>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@joaomdmoura
Copy link
Collaborator

Disclaimer: This review was made by a crew of AI Agents.

Code Review Comment for PR #3050

Overview

This pull request introduces new CSS styles to address a width issue with the Frame component in the documentation, accompanied by corresponding tests in tests/docs_styling_test.py. The implementation is mostly solid, but there are opportunities to enhance maintainability, performance, and browser compatibility.

CSS File Review (docs/style.css)

Strengths:

  • Comprehensive coverage for Frame components is achieved through diligent use of multiple selectors.
  • The overflow-x: auto specification enhances user experience by allowing horizontal scrolling when necessary.
  • The code is well-commented, providing clarity on styling intentions.

Issues and Recommendations:

  1. Redundant Selectors:
    The current implementation duplicates CSS properties across multiple selectors. Instead, consolidate these to minimize redundancy:

    /* Recommended */
    .frame-container,
    [data-component="frame"],
    .frame,
    div[class*="frame"] {
      min-width: 300px;
      width: 100%;
      overflow-x: auto;
    }
  2. Vendor Prefixes Missing:
    Ensure that styles cater to various browsers by adding vendor prefixes where necessary:

    /* Recommended Addition */
    .frame-container {
      -webkit-overflow-scrolling: touch; /* Ensure smooth scrolling on iOS */
    }
  3. Media Queries:
    Responsive design is vital. It would help if you considered adding media queries to adapt to smaller screens:

    /* Recommended Addition */
    @media screen and (max-width: 768px) {
      .frame-container,
      [data-component="frame"] {
        min-width: 100%;
      }
    }

Additional Suggestions:

  • CSS Custom Properties: Use CSS variables for repeated values to enhance maintainability:
    :root {
      --frame-min-width: 300px;
      --frame-width: 100%;
    }

Test File Review (tests/docs_styling_test.py)

Strengths:

  • The test suite provides thoughtful coverage regarding file existence and checks for various content properties in the CSS.
  • Clear naming conventions are upheld, enhancing the readability of the test cases.

Issues and Recommendations:

  1. Test Setup Improvement:
    Introduce fixture setups to avoid repetitive code within multiple tests:

    @pytest.fixture(scope="module")
    def css_content():
        css_file = Path(__file__).parent.parent / "docs" / "style.css"
        with open(css_file, 'r') as f:
            return f.read()
  2. Error Messaging:
    Improve existing assertions by making error messages more descriptive:

    assert css_file.exists(), (
        f"Custom CSS file not found at {css_file}. "
        "Please ensure style.css is present in the docs directory."
    )
  3. Edge Case Testing:
    Consider adding tests to handle potential CSS edge cases, ensuring robust validation:

    def test_css_values_are_valid():
        """Validate that critical CSS values are as expected."""
        assert '300px' in css_content, "Min-width should be 300px"
  4. File Encoding Specification:
    Adding a coding specification at the file’s top can prevent potential encoding issues in some environments:

    # -*- coding: utf-8 -*-

Conclusion:

The changes in PR #3050 provide a solid foundation for enhancing the documentation's styling. However, addressing the feedback regarding CSS redundancy, vendor prefixes, and test robustness would greatly improve the implementation. Given these enhancements, the changes are deemed safe for merging.

For additional context, look back on any related pull requests that dealt with UI improvements to see how similar styling and testing concerns were resolved, ensuring consistency in approach across the project.

Thank you for your efforts on this PR, and I look forward to your thoughts on the suggestions!

@mplachta
Copy link
Contributor

Disclaimer: This review was made by a crew of AI Agents.

Thank you for the PR that addresses issue #3049 by fixing the Frame component width problem in the documentation's installation page. Below is a detailed review synthesizing the key findings, historical context, and specific improvement recommendations to strengthen this contribution for long-term maintainability and quality.


Code Review for PR #3050: Fix Documentation Frame Component Width Issue

Summary of Key Findings

  • Problem Addressed: The Frame component inside the "Generate Project Scaffolding" section of installation.mdx was collapsing due to lack of width styling, making the file structure unreadable.
  • Solution Overview: Introduced a new CSS file at docs/style.css applying minimum width, full width, and horizontal scrolling (overflow-x: auto) to multiple selectors targeting Frame components and their nested pre elements. Added tests (tests/docs_styling_test.py) ensuring presence and content of CSS, presence of Frame in docs, and correctness of styling properties.
  • Tests: Tests provide good coverage on static file existence and CSS content assertions, plus verify documentation contains Frame usage. They act as a regression safeguard.
  • Documentation Integration: The PR does not show linkage of style.css within the documentation build system or HTML templates, so ensure this CSS file is actually loaded to activate the fixes.

Code Quality and Improvement Suggestions

1. CSS Consolidation and Maintainability

Current CSS repeats the same style properties across multiple selectors (.frame-container, [data-component="frame"], .frame, div[class*="frame"]), increasing maintenance effort and size. Consolidating them reduces duplication and risk of missing future updates.

Suggested improved CSS snippet:

/* Common frame styling */
.frame-container,
[data-component="frame"],
.frame,
div[class*="frame"] {
  min-width: 300px;
  width: 100%;
  max-width: 100vw; /* Add max-width for responsive behavior */
  overflow-x: auto;
}

/* Code block width inside frames */
.frame-container pre,
[data-component="frame"] pre,
div[class*="frame"] pre {
  min-width: 280px;
  white-space: pre;
  overflow-x: auto;
}
  • Add max-width: 100vw; to prevent overly stretched Frames on large screens.
  • Comment usage is excellent — maintain it to keep clarity.
  • Consider vendor prefixes only if legacy browser support is a requirement; modern browsers support these properties well.

2. Testing Enhancements

  • Duplicate CSS file reads: The current tests read style.css multiple times independently. Switching to a pytest fixture that reads CSS once per module reduces overhead and improves clarity.

Example fixture usage:

import pytest
from pathlib import Path

@pytest.fixture(scope="module")
def css_content():
    css_file = Path(__file__).parent.parent / "docs" / "style.css"
    with open(css_file, 'r') as f:
        return f.read()

def test_custom_css_file_exists():
    css_file = Path(__file__).parent.parent / "docs" / "style.css"
    assert css_file.exists()

def test_frame_component_styling(css_content):
    assert 'frame' in css_content.lower()
    assert 'min-width' in css_content
    assert 'overflow-x' in css_content

# Similarly refactor other tests to utilize css_content fixture...
  • Hardcoded relative paths: Although straightforward, consider abstracting file path resolution to accommodate future restructuring and increase robustness.
  • Static vs Dynamic testing: While current static tests are valuable, consider integrating visual regression or UI interaction tests (e.g., with Playwright or Selenium) in the future to verify the actual rendering behavior and prevent UI regressions.
  • Use pytest fixtures for setup: If more tests or more complex setup arise, consider fixtures to handle setup/teardown or shared context.

3. Documentation Build Integration

This PR adds a new CSS file but does not demonstrate how it is included in the documentation build. Please confirm:

  • Is docs/style.css linked or imported into your documentation static site generator (e.g., Docusaurus, MkDocs)?
  • If not, add linking in your documentation theme or layout templates to ensure styles apply. Otherwise, your fix may not be visible to users.

Historical Context and Related PRs

  • This PR continues the pattern of fixing UI/UX anomalies in documentation by targeted CSS patches.
  • Previous PRs addressing UI bugs have sometimes suffered from duplicated CSS rules; consolidating selectors, as suggested here, stems from lessons learned.
  • Testing in the repo currently focuses on file existence and content validation rather than rendered UI behavior, which is common for documentation style fixes, but could be enhanced over time.
  • Co-authorship and clear commit messages in this PR exemplify good collaborative practices.

Implications for Related Files and Future Maintenance

  • The styling changes only affect documentation rendering of Frame components; no impact on runtime code or business logic.
  • If installation.mdx or other docs change their usage of Frame components, CSS selectors and test assertions here may need updates.
  • Consolidating CSS selectors makes future style changes more straightforward and less error-prone.
  • Incorporating UI regression tests would increase confidence in maintaining these visual styles as the codebase evolves.

Summary Table of Recommendations

Area Issue / Observation Recommendation
CSS selectors Repetitive, overlapping selectors Consolidate selectors, add max-width for responsiveness
CSS responsiveness No max-width property set Add max-width: 100vw; to frame selectors
CSS vendor prefixes Not present (minor) Optional based on browser support targets
Tests Multiple redundant CSS reads Use pytest fixture to read once
Tests Hardcoded relative paths Abstract path handling for flexibility
Tests Static content checks only Consider visual/UI tests for layout regressions
Documentation build process Styling file inclusion unverified Confirm style.css is linked in docs build

Final Recommendation

This PR effectively fixes the immediate visual problem with Frame component collapsing in documentation and includes useful regression tests. Prior to merge, if possible:

  • Refactor the CSS file to consolidate selectors and add responsive max-width.
  • Refactor tests to utilize fixtures for better code quality.
  • Verify that the new CSS file is included in the documentation build pipeline.
  • Plan for potential future visual regression testing to ensure ongoing UI stability.

If you address these suggestions, this change will be more maintainable, robust, and effective in improving documentation readability. Excellent work so far—the fix is well scoped and the documentation/testing effort adds good coverage.

Please reach out if you would like clarifications or help implementing any of the improvements mentioned above!


Thank you for your contribution!

devin-ai-integration bot and others added 2 commits June 23, 2025 19:25
- Consolidate redundant CSS selectors into grouped rules
- Add CSS custom properties for better maintainability
- Implement responsive design with media queries for mobile
- Add vendor prefixes (-webkit-overflow-scrolling) for iOS
- Improve test suite with pytest fixtures to reduce redundancy
- Add better error messages and encoding specifications
- Add comprehensive test coverage for new CSS features

This addresses all actionable feedback from the AI crew review
while maintaining the core fix for Frame component width issues.

Co-Authored-By: João <joao@crewai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants