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

fixed the status boxes on screen to be more responsive and better align with UI #1985

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Owaiseimdad
Copy link
Contributor

Describe your changes

The design of status boxes where pretty out of order and due to this the UI looked a bit off, added necessary css in order better align with needs

Please ensure all items are checked off before requesting a review. "Checked off" means you need to add an "x" character between brackets so they turn into checkmarks.

  • (Do not skip this or your PR will be closed) I deployed the application locally.
  • (Do not skip this or your PR will be closed) I have performed a self-review and testing of my code.
  • [] I have included the issue # in the PR.
  • I have added i18n support to visible strings (instead of <div>Add</div>, use):
const { t } = useTranslation();
<div>{t('add')}</div>
  • The issue I am working on is assigned to me.
  • [] I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • [x ] I made sure font sizes, color choices etc are all referenced from the theme. I have no hardcoded dimensions.
  • My PR is granular and targeted to one specific feature.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

Before:
https://github.com/user-attachments/assets/e09fd92e-3939-4c74-863b-b90bd098fd36

After:
https://github.com/user-attachments/assets/073378ba-576b-4e7c-8c62-ba09312e5676

@Owaiseimdad Owaiseimdad requested a review from ajhollid March 22, 2025 04:36
Copy link

@llamapreview llamapreview bot left a comment

Choose a reason for hiding this comment

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

Auto Pull Request Review from LlamaPReview

1. Overview

1.1 Core Changes

  • Primary purpose and scope: Improve responsiveness and visual alignment of status boxes across different screen sizes
  • Key components modified: StatBox and StatusBoxes layout components
  • Cross-component impacts: Affects all instances using StatusBoxes component
  • Business value alignment: Enhances user experience through improved visual consistency and responsive design

1.2 Technical Architecture

  • System design modifications: Implemented responsive width calculations using theme breakpoints
  • Component interaction changes: Modified flex container properties for better space distribution
  • Integration points impact: Maintains existing prop interfaces for backward compatibility
  • Dependency changes: No new dependencies introduced

2. Critical Findings

2.1 Must Fix (P0🔴)

No critical must-fix issues identified

2.2 Should Fix (P1🟡)

Issue: Magic number in responsive width calculation

  • Analysis Confidence: High
  • Impact: Reduces code maintainability and makes future adjustments difficult
  • Suggested Solution: Extract 95% value to named constant with explanation

Issue: Ambiguous width/minWidth combination

  • Analysis Confidence: Medium
  • Impact: Potential layout inconsistencies and code clarity issues
  • Suggested Solution: Clarify purpose of minWidth through comments

2.3 Consider (P2🟢)

Area: Redundant display property

  • Analysis Confidence: High
  • Improvement Opportunity: Code simplification by removing unnecessary flex declaration

Area: Issue linking

  • Analysis Confidence: Medium
  • Improvement Opportunity: Better traceability by linking to original issue

2.4 Summary of Action Items

  1. Address magic number and width clarification (P1 - immediate)
  2. Remove redundant display property (P2 - before merge)
  3. Add issue reference (P2 - optional)

3. Technical Analysis

3.1 Code Logic Analysis

📁 src/Components/StatBox/index.jsx - StatBox component

  • Submitted PR Code:
    const responsiveWidths = {
        default: "calc(95% / 4)",
        xl: "calc(95% / 3)",
        md: "calc(95% / 2)",
    };
    
    // In Stack component sx prop:
    minWidth: 200,
    width: responsiveWidths.default,
    [theme.breakpoints.down("xl")]: {
        width: responsiveWidths.xl,
    },
    [theme.breakpoints.down("md")]: {
        width: responsiveWidths.md,
    },
  • Analysis:
    • Current logic uses magic number 95% without clear explanation
    • Combined minWidth/width usage needs documentation
    • Breakpoint values hardcoded but aligned with Material-UI standards
  • LlamaPReview Suggested Improvements:
    const containerWidthPercentage = 95; // Accounts for parent container padding
    const responsiveWidths = {
        default: `calc(${containerWidthPercentage}% / 4)`,
        xl: `calc(${containerWidthPercentage}% / 3)`,
        md: `calc(${containerWidthPercentage}% / 2)`,
    };
    
    // In Stack styles:
    minWidth: 200, // Ensures readability on small screens
    width: responsiveWidths.default,
  • Improvement rationale:
    • Explicit percentage constant improves maintainability
    • Clear comment explains minWidth purpose

📁 src/Components/StatusBoxes/index.jsx - StatusBoxes component

  • Submitted PR Code:
    <Stack
        direction="row"
        flexWrap={flexWrap}
        gap={theme.spacing(8)}
        justifyContent="space-between"
        display="flex"
    >
  • Analysis:
    • display="flex" is redundant with Stack component behavior
    • justifyContent improves layout distribution
  • LlamaPReview Suggested Improvements:
    <Stack
        direction="row"
        flexWrap={flexWrap}
        gap={theme.spacing(8)}
        justifyContent="space-between"
    >
  • Improvement rationale:
    • Removes redundant property
    • Maintains identical layout behavior

3.2 Key Quality Aspects

  • Testing strategy: Recommend adding visual regression tests for responsive layouts
  • Documentation needs: Update component style guide with new responsive behavior

4. Overall Evaluation

  • Technical assessment: Well-structured responsive implementation using theme conventions
  • Business impact: Direct UX improvement for monitoring visualization
  • Risk evaluation: Low risk with proper testing verification
  • Notable positive aspects: Excellent use of theme spacing/breakpoints, clear before/after visuals
  • Implementation quality: Good overall with minor maintainability improvements needed
  • Final recommendation: Approve with suggested P1 improvements addressed

💡 LlamaPReview Community
Have feedback on this AI Code review tool? Join our GitHub Discussions to share your thoughts and help shape the future of LlamaPReview.

Copy link

coderabbitai bot commented Mar 22, 2025

Walkthrough

This pull request updates two components. The StatBox component now applies dynamic width values by introducing a responsiveWidths object with default, xl, and md breakpoints to replace the fixed 225 width. Minor spacing adjustments were also made in the styling and Typography components. Additionally, the StatusBoxes component’s layout is enhanced by adding justifyContent="space-between" and display="flex" to its Stack, ensuring a proper flex layout. There are no changes to the exported or public API declarations.

Changes

File Path Change Summary
src/Components/StatBox/index.jsx Introduced responsiveWidths for adaptive widths (default, xl, md) replacing the fixed width; adjusted spacing in spanFixedStyles and Typography.
src/Components/StatusBoxes/index.jsx Added justifyContent="space-between" and display="flex" to the Stack component to improve flex layout alignment.

Possibly related PRs

Suggested reviewers

  • ajhollid
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate docstrings to generate docstrings for this 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.

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

@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

🧹 Nitpick comments (2)
src/Components/StatusBoxes/index.jsx (1)

23-24: The justifyContent property is solid, but display="flex" seems redundant

Yo, the justifyContent="space-between" is a great addition to fix that alignment issue! It'll distribute those status boxes evenly across the container. However, Material-UI's Stack component already uses display: flex by default, so adding display="flex" is like putting an extra sweater on when you're already wearing one - unnecessary, ya know?

<Stack
  direction="row"
  flexWrap={flexWrap}
  gap={theme.spacing(8)}
  justifyContent="space-between"
- display="flex"
>
src/Components/StatBox/index.jsx (1)

95-102: Responsive implementation looks good, but we could leverage theme breakpoints better

This responsive implementation is a major improvement over the previous fixed width approach! Now the status boxes will properly adapt to different screen sizes with 4, 3, or 2 items per row depending on viewport width.

One small suggestion - since you're already using the theme breakpoints system, you could potentially refactor this to use the theme's spacing or grid system for even more consistency:

// this is for status box to be reponsive on diff screens
-width: responsiveWidths.default, // Default: 4 items per row
-[theme.breakpoints.down("xl")]: {
-  width: responsiveWidths.xl, // 3 items per row
-},
-[theme.breakpoints.down("md")]: {
-  width: responsiveWidths.md, // 2 items per row
-},
+width: `calc(${theme.spacing(95)} / 4)`, // Default: 4 items per row
+[theme.breakpoints.down("xl")]: {
+  width: `calc(${theme.spacing(95)} / 3)`, // 3 items per row
+},
+[theme.breakpoints.down("md")]: {
+  width: `calc(${theme.spacing(95)} / 2)`, // 2 items per row
+},

Also, there's still that TODO comment on line 93 about using both width and minWidth. That situation hasn't changed and might be worth addressing in a future update.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88bf086 and 7247f6d.

📒 Files selected for processing (2)
  • src/Components/StatBox/index.jsx (3 hunks)
  • src/Components/StatusBoxes/index.jsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/Components/StatBox/index.jsx (5)
src/Components/StatusBoxes/index.jsx (1) (1)
  • theme (8-8)
src/Components/Charts/CustomGauge/index.jsx (1) (1)
  • theme (31-31)
src/Pages/Infrastructure/Details/Components/GaugeBoxes/Gauge.jsx (1) (1)
  • theme (10-10)
src/Pages/Infrastructure/Details/index.jsx (1) (1)
  • theme (31-31)
src/Pages/Infrastructure/Details/Hooks/useHardwareUtils.jsx (1) (1)
  • theme (12-12)
🔇 Additional comments (2)
src/Components/StatBox/index.jsx (2)

82-86: The responsive width approach looks great!

The introduction of this responsiveWidths object is a smart move for organizing your breakpoint calculations. It makes the code easier to maintain since all width values are defined in one place. This will definitely help with making the UI more organized as mentioned in the PR objectives.


136-136: Typography styling looks good

The addition of fontWeight styling to the Typography component for the subHeading improves the visual hierarchy. Nice touch!

@ajhollid
Copy link
Collaborator

@gorkem-bwl can you weigh in on which design you prefer here? I'm not qualified to make a judemgent 😂

Copy link
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

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

Seems fine to me, just wondering why 95% is the base value used for responsive width calculations?

const responsiveWidths = {
default: "calc(95% / 4)",
xl: "calc(95% / 3)",
md: "calc(95% / 2)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is 95% the value to use here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Owaiseimdad your thoughts on the 95%?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ajhollid the reason for 95% is because, is to the other 5% to the outer part of the card. 94 was very small and 96 made it scatter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats the only reason
or else we have to minus it with some px then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we good with this @ajhollid ?

@Owaiseimdad Owaiseimdad requested a review from ajhollid March 29, 2025 21:16
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