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(web): Grant - spacing and empty containers #17330

Merged
merged 2 commits into from
Dec 21, 2024
Merged

Conversation

disaerna
Copy link
Member

@disaerna disaerna commented Dec 20, 2024

Web - Grant

What

  • Fix spacing on sidmenu for Grant
  • Fix alignment for Infocard tags

Checklist:

  • I have performed a self-review of my own code
  • 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
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Enhanced conditional rendering in the ExtraPanel to prevent empty displays when no files are available.
    • Improved layout structure in the DetailedInfoCard for better presentation of header, content, and tags.
  • Bug Fixes

    • Resolved layout issues in the DetailedInfoCard by implementing a flexbox structure.

@disaerna disaerna requested review from a team as code owners December 20, 2024 13:41
@disaerna disaerna requested a review from snaerth December 20, 2024 13:41
Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Walkthrough

The pull request introduces modifications to two components: ExtraPanel in the web application and DetailedInfoCard in the island-ui core library. The ExtraPanel component now conditionally renders its content based on the length of filesPanelData, returning null when no files are present. The DetailedInfoCard component has been restructured with a new Box component, changing the layout to use flexbox and improve the vertical arrangement of its elements.

Changes

File Change Summary
apps/web/screens/Grants/Grant/GrantSidebar/ExtraPanel.tsx Conditional rendering added to only display panel when filesPanelData is not empty
libs/island-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx Replaced fragment with Box component, restructured layout using flexbox for vertical alignment

Sequence Diagram

sequenceDiagram
    participant Component as ExtraPanel
    participant Data as filesPanelData
    
    Component->>Data: Check length
    alt Data length > 0
        Component->>Component: Render Box with Stack
    else Data length = 0
        Component->>Component: Return null
    end
Loading

Possibly related PRs

Suggested Labels

automerge

Suggested Reviewers

  • thorkellmani
  • Toti91

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

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

LGTM

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

🧹 Nitpick comments (2)
apps/web/screens/Grants/Grant/GrantSidebar/ExtraPanel.tsx (1)

73-77: Consider using a more semantic background color

The red100 background color seems unusual for a sidebar panel. Consider using a more appropriate semantic color that aligns with the UI design system, such as blue100 or white.

-    <Box background={'red100'} padding={3} borderRadius="large">
+    <Box background="blue100" padding={3} borderRadius="large">
libs/island-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx (1)

174-187: Consider extracting layout constants

For better maintainability and reusability, consider extracting the common layout values into constants.

+const LAYOUT_CONSTANTS = {
+  marginTop: 3,
+  height: 'full',
+} as const;

 return (
   <Box
     display="flex"
     justifyContent="spaceBetween"
     flexDirection="column"
-    height="full"
+    height={LAYOUT_CONSTANTS.height}
   >
     <div>
       {renderHeader()}
       {renderContent()}
     </div>
-    <Box marginTop={3} display="flex" justifyContent="spaceBetween">
+    <Box marginTop={LAYOUT_CONSTANTS.marginTop} display="flex" justifyContent="spaceBetween">
       {renderTags()}
     </Box>
   </Box>
 )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fa5f279 and ca3deb6.

📒 Files selected for processing (2)
  • apps/web/screens/Grants/Grant/GrantSidebar/ExtraPanel.tsx (1 hunks)
  • libs/island-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
apps/web/screens/Grants/Grant/GrantSidebar/ExtraPanel.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/island-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (2)
apps/web/screens/Grants/Grant/GrantSidebar/ExtraPanel.tsx (1)

73-77: Verify empty state handling across the application

The conditional rendering to prevent empty containers aligns with the PR objectives. However, we should ensure this pattern is consistently applied across similar components.

✅ Verification successful

Based on the search results, I can see that empty state handling through conditional rendering is a common pattern across the codebase, with many components using similar length checks and Box containers. The implementation in ExtraPanel.tsx follows this established pattern. Let me verify the specific Box styling pattern to ensure full consistency.


Based on the search results, I can now provide a definitive response about the empty state handling and Box styling pattern:

Empty state handling and Box styling are consistent with codebase patterns

The implementation in ExtraPanel.tsx follows the established patterns in the codebase where:

  • The conditional rendering using length check (filesPanelData.length > 0) is consistent with other components
  • The Box component styling with background, padding, and borderRadius props matches similar patterns seen across the codebase, particularly in sidebar and panel components
  • The use of Stack with space prop for content spacing is also consistent with other implementations

The specific use of red100 background color is appropriate as it's used in other components to highlight important or warning content, like in the air-discount-scheme components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for similar patterns in other sidebar components
ast-grep --pattern 'return $data.length > 0 ? (<Box>$$$</Box>) : null'

Length of output: 72


Script:

#!/bin/bash
# Search for conditional rendering patterns with length checks
rg "\.length\s*>\s*0\s*\?" -A 2

# Also search for similar patterns with empty array checks
rg "\.length\s*===?\s*0" -A 2

# Look for Box components with conditional rendering
ast-grep --pattern 'return $_ ? <Box $$$>$$$</Box> : $_'

Length of output: 85202


Script:

#!/bin/bash
# Search for Box components with background and padding props
rg '<Box\s+background.*padding.*>' -A 2

# Also look for similar patterns with Stack components
rg '<Stack\s+space={[^}]*}>\s*{[^}]*}\s*</Stack>' -A 2

Length of output: 15045

libs/island-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx (1)

174-187: LGTM! Improved layout structure

The new Box wrapper with flexbox layout improves the spacing and alignment issues:

  • Uses proper flex properties for vertical spacing
  • Maintains component reusability
  • Follows TypeScript best practices

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 20, 2024

Datadog Report

All test runs a540525 🔗

10 Total Test Services: 0 Failed, 10 Passed
➡️ Test Sessions change in coverage: 148 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 7.54s 1 no change Link
api 0 0 0 4 0 3.17s 1 no change Link
application-api-files 0 0 0 2 0 4.52s 1 no change Link
application-core 0 0 0 97 0 18.79s 1 no change Link
application-system-api 0 0 0 46 0 2m 19.7s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 19.24s 1 no change Link
application-templates-accident-notification 0 0 0 140 0 15.75s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 10.95s 1 no change Link
application-templates-driving-license 0 0 0 13 0 15.33s 1 no change Link
application-templates-example-payment 0 0 0 2 0 10.28s 1 no change Link

@disaerna disaerna added the automerge Merge this PR as soon as all checks pass label Dec 20, 2024
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 35.68%. Comparing base (8d0e092) to head (41515a1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...b/screens/Grants/Grant/GrantSidebar/ExtraPanel.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17330      +/-   ##
==========================================
- Coverage   35.68%   35.68%   -0.01%     
==========================================
  Files        6928     6928              
  Lines      148750   148751       +1     
  Branches    42499    42501       +2     
==========================================
- Hits        53088    53086       -2     
- Misses      95662    95665       +3     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
application-api-files 61.90% <ø> (ø)
application-core 75.72% <ø> (ø)
application-system-api 38.73% <ø> (+<0.01%) ⬆️
application-template-api-modules 27.66% <ø> (-0.01%) ⬇️
application-templates-accident-notification 27.61% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.74% <ø> (ø)
application-templates-driving-license 18.15% <ø> (ø)
application-templates-estate 13.69% <ø> (ø)
application-templates-example-payment 24.69% <ø> (ø)
application-templates-financial-aid 14.45% <ø> (ø)
application-templates-general-petition 23.12% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 15.18% <ø> (ø)
application-templates-mortgage-certificate 43.62% <ø> (ø)
application-templates-parental-leave 29.93% <ø> (ø)
application-types 6.51% <ø> (ø)
application-ui-components 1.22% <ø> (ø)
application-ui-shell 22.28% <ø> (ø)
clients-charge-fjs-v2 28.35% <ø> (ø)
contentful-apps 4.71% <ø> (ø)
financial-aid-backend 51.42% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
island-ui-core 30.40% <ø> (ø)
judicial-system-web 27.72% <ø> (ø)
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.61% <ø> (ø)
shared-components 29.64% <ø> (ø)
shared-form-fields 33.36% <ø> (ø)
web 2.40% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx 5.88% <ø> (ø)
...b/screens/Grants/Grant/GrantSidebar/ExtraPanel.tsx 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d0e092...41515a1. Read the comment docs.

Copy link
Member

@Tryggvig Tryggvig left a comment

Choose a reason for hiding this comment

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

🚀

@kodiakhq kodiakhq bot merged commit e0a1eec into main Dec 21, 2024
126 checks passed
@kodiakhq kodiakhq bot deleted the fix/web-grant-sidemenu branch December 21, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants