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(ui): info card grid #17391

Merged
merged 7 commits into from
Jan 4, 2025
Merged

fix(ui): info card grid #17391

merged 7 commits into from
Jan 4, 2025

Conversation

thorkellmani
Copy link
Member

@thorkellmani thorkellmani commented Jan 2, 2025

What

  • Use css grid
  • Add storybook

Why

  • Better responsiveness
  • Must have storybook

Screenshots / Gifs

image
image

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 InfoCardGrid component with more flexible layout options
    • Added customizable card backgrounds and border colors
    • Improved responsive design for card sizes across different column configurations
  • Refactor

    • Simplified component structure for InfoCard and SimpleInfoCard
    • Removed unnecessary state management
    • Updated grid styling to support more dynamic layouts
  • Documentation

    • Added Storybook stories to showcase different InfoCardGrid configurations

Copy link
Contributor

coderabbitai bot commented Jan 2, 2025

Walkthrough

The pull request introduces significant modifications to the InfoCardGrid component and its related files. The changes focus on enhancing the layout flexibility, simplifying the component structure, and improving the rendering of information cards. Key updates include removing GridContainer, updating text variants, introducing new grid-based styling, and adding more configurable props for background and border colors. The modifications aim to create a more responsive and customizable information card grid system.

Changes

File Change Summary
libs/island-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx - Removed GridContainer
- Updated Text component variants
- Modified text rendering and layout
libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.css.ts - Removed individual card styles
- Added grid container styles for one, two, and three columns
- Introduced gridContainerBase style
libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.tsx - Removed isMobile state management
- Updated BaseProps interface
- Added optional background and borderColor props
libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.stories.tsx - Added Storybook configuration
- Created card generation functions
- Defined stories for different grid configurations
libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.tsx - Updated imports and types
- Added cardsBackground and cardsBorder props
- Implemented dynamic card size mapping
libs/island-ui/core/src/lib/InfoCardGrid/SimpleInfoCard.tsx - Removed GridContainer
- Simplified large size rendering

Sequence Diagram

sequenceDiagram
    participant User
    participant InfoCardGrid
    participant InfoCard
    participant DetailedInfoCard/SimpleInfoCard

    User->>InfoCardGrid: Render with props
    InfoCardGrid->>InfoCardGrid: Determine card size
    InfoCardGrid->>InfoCard: Create cards with background/border
    InfoCard->>DetailedInfoCard/SimpleInfoCard: Render with specific variant
    DetailedInfoCard/SimpleInfoCard-->>InfoCardGrid: Display card content
Loading

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • oddsson

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.

@datadog-island-is
Copy link

datadog-island-is bot commented Jan 2, 2025

Datadog Report

All test runs 4bef244 🔗

10 Total Test Services: 0 Failed, 10 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.08%), 7 increased, 140 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 6.47s 1 no change Link
api 0 0 0 4 0 2.38s 1 no change Link
application-api-files 0 0 0 2 0 4.41s 1 no change Link
application-core 0 0 0 97 0 15.41s 1 no change Link
application-system-api 0 0 0 46 0 2m 14.84s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 4.47s 1 increased (+0.01%) Link
application-templates-accident-notification 0 0 0 140 0 12.94s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 9.5s 1 no change Link
application-templates-driving-license 0 0 0 13 0 13.09s 1 no change Link
application-templates-example-payment 0 0 0 2 0 10.05s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • island-ui-core - jest 31.23% (-0.08%) - Details

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 5.40541% with 35 lines in your changes missing coverage. Please review.

Project coverage is 35.68%. Comparing base (9e9b475) to head (77ff742).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...land-ui/core/src/lib/InfoCardGrid/InfoCardGrid.tsx 10.00% 18 Missing ⚠️
...core/src/lib/InfoCardGrid/InfoCardGrid.stories.tsx 0.00% 9 Missing ⚠️
...s/island-ui/core/src/lib/InfoCardGrid/InfoCard.tsx 0.00% 4 Missing ⚠️
...-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx 0.00% 2 Missing ⚠️
...nd-ui/core/src/lib/InfoCardGrid/SimpleInfoCard.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17391   +/-   ##
=======================================
  Coverage   35.67%   35.68%           
=======================================
  Files        6932     6932           
  Lines      148824   148796   -28     
  Branches    42520    42504   -16     
=======================================
  Hits        53098    53098           
+ Misses      95726    95698   -28     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.33% <ø> (ø)
application-api-files 61.90% <ø> (ø)
application-core 75.72% <ø> (ø)
application-system-api 38.72% <ø> (-0.02%) ⬇️
application-template-api-modules 27.68% <ø> (+0.02%) ⬆️
application-templates-accident-notification 27.61% <ø> (ø)
application-templates-driving-license 18.15% <ø> (ø)
application-templates-estate 13.67% <7.14%> (+<0.01%) ⬆️
application-templates-example-payment 24.69% <ø> (ø)
application-templates-general-petition 23.12% <ø> (ø)
application-templates-inheritance-report 6.59% <ø> (ø)
application-templates-marriage-conditions 15.18% <ø> (ø)
application-templates-mortgage-certificate 43.68% <ø> (ø)
application-templates-parental-leave 29.92% <ø> (-0.03%) ⬇️
application-types 6.51% <ø> (ø)
application-ui-components 1.22% <ø> (ø)
application-ui-shell 22.26% <7.14%> (+<0.01%) ⬆️
clients-charge-fjs-v2 28.88% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
financial-aid-backend 51.42% <ø> (ø)
financial-aid-shared 17.88% <ø> (ø)
island-ui-core 30.34% <0.00%> (-0.09%) ⬇️
judicial-system-web 27.75% <7.14%> (-0.01%) ⬇️
portals-admin-regulations-admin 1.80% <ø> (ø)
portals-core 19.58% <7.14%> (+<0.01%) ⬆️
shared-components 29.49% <7.14%> (-0.01%) ⬇️
shared-form-fields 33.37% <7.14%> (-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% <0.00%> (ø)
...nd-ui/core/src/lib/InfoCardGrid/SimpleInfoCard.tsx 11.76% <0.00%> (ø)
...s/island-ui/core/src/lib/InfoCardGrid/InfoCard.tsx 16.66% <0.00%> (+10.41%) ⬆️
...core/src/lib/InfoCardGrid/InfoCardGrid.stories.tsx 0.00% <0.00%> (ø)
...land-ui/core/src/lib/InfoCardGrid/InfoCardGrid.tsx 7.40% <10.00%> (-0.29%) ⬇️

... and 11 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 9e9b475...77ff742. Read the comment docs.

@thorkellmani thorkellmani marked this pull request as ready for review January 3, 2025 11:51
@thorkellmani thorkellmani requested a review from a team as a code owner January 3, 2025 11:51
@thorkellmani thorkellmani requested a review from disaerna January 3, 2025 11:51
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 (3)
libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.tsx (1)

62-70: Dynamic CSS class assignments for grid layouts.
You may want to consider building a map-based approach (e.g., const containerClassBySize = {...}), but the existing conditional works.

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

33-34: Defaulting background and borderColor to white.
Consider whether you want a no-border scenario or a different fallback for borderColor.

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

100-105: Use semantic cues to avoid confusion for disabled tags.
If the tag is non-interactive and purely informational, disabling it might imply that it should not be clickable. Consider removing disabled if you don’t intend any interactive behavior, or if you want to visually differentiate it, use styling props or a variant.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dd1b223 and 3d4bf1c.

📒 Files selected for processing (6)
  • libs/island-ui/core/src/lib/InfoCardGrid/DetailedInfoCard.tsx (4 hunks)
  • libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.css.ts (1 hunks)
  • libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.tsx (2 hunks)
  • libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.stories.tsx (1 hunks)
  • libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.tsx (1 hunks)
  • libs/island-ui/core/src/lib/InfoCardGrid/SimpleInfoCard.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
libs/island-ui/core/src/lib/InfoCardGrid/SimpleInfoCard.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."
libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.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."
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."
libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.stories.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."
libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.css.ts (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."
libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.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 (37)
libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.tsx (13)

4-4: Good import of Box and BoxProps.
This centralizes styling in a single component, promoting consistent usage of the design system.


7-7: Importing the CSS module is appropriate.
This approach keeps the styles well-organized in one location.


10-13: Excluding background from InfoCardItemProps looks correct.
You're ensuring that background is handled at the grid level rather than at the individual card level, which can ease overall styling consistency.


19-20: Optional background and border props are a nice addition.
Allowing customization of cardsBackground and cardsBorder improves the component’s reusability and configurability.


23-23: Explicit card sizing enum is clean.
Defining 'small' | 'medium' | 'large' clarifies the supported size options.


25-40: Check for edge cases in mapColumnCountToCardSize.
If columns is something other than 1–3, the function defaults to 'small'. That might be unexpected in certain layouts. Consider validating or logging a warning if columns is out of range.


42-48: Destructuring added props nicely.
This enhancement keeps your code clear and ensures new props (cardsBackground, cardsBorder) remain optional.


53-53: Breakpoint adjustment requires verification.
Switching from md to sm changes the threshold for mobile layout. Confirm that this aligns with the new design requirements.


59-59: Leverages the new size-mapping function correctly.
mapColumnCountToCardSize usage is straightforward and keeps consistent sizing logic in one place.


74-74: Propagating cardsBackground.
This is a clean way to apply a unified background to all cards.


75-75: Propagating cardsBorder.
Good approach—gives consistent theming control across all items in the grid.


77-77: Potentially conflicting with mapColumnCountToCardSize.
Here, isMobile forces 'medium', while mapColumnCountToCardSize returns 'large' if isMobile is true. Reassess the desired mobile size to avoid confusion.


81-81: End of the grid container.
No further action needed.

libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.css.ts (4)

4-8: Base grid container styling.
Centralizing grid definitions here fosters maintainability and consistent spacing across columns.


10-12: One-column grid layout.
Straightforward usage, aligning with the new InfoCardGrid logic.


15-17: Two-column grid layout.
Looks good—ensures consistent column structure for moderate layouts.


20-22: Three-column grid layout.
Implementation is consistent with the one- and two-column styles.

libs/island-ui/core/src/lib/InfoCardGrid/InfoCard.tsx (6)

3-3: Importing BoxProps and FocusableBox.
This aligns the component with the new design system approach.


10-10: Optional background prop.
Expanding the base props for dynamic styling is beneficial for adaptability.


12-12: Optional borderColor prop.
Matches the new InfoCardGrid usage for consistent border theming.


40-40: Wrapping content in a padded Box.
Maintains layout consistency; no immediate concerns.


42-42: Using DetailedInfoCard with a passed size.
This is in line with the simplified component architecture.


44-44: Using SimpleInfoCard with a passed size.
Good consistency with the detailed variant.

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

35-46: Refactored content rendering for large size.
By removing the GridContainer, you simplify the layout. Verify that losing the container does not break any padding or alignment that was previously handled.

libs/island-ui/core/src/lib/InfoCardGrid/InfoCardGrid.stories.tsx (10)

1-3: Essential imports for the Storybook file.
No issues—this is a standard approach.


4-8: Utility imports help with expanded coverage.
withFigma integration can make UX reviews more streamlined.


9-33: Metadata definition for the Storybook component.
Provides a clear structure for controlling args.


35-35: Default export meta.
Adheres to Storybook guidelines for naming and structuring stories.


37-38: Declared type alias for the story.
This is a neat approach for strongly typed story definitions.


39-48: generateSimpleCard function.
Keeps sample data DRY for story generation.


50-90: generateDetailedCard function.
Comprehensive placeholder data ensures robust visual testing in Storybook.


92-97: generateCards utility.
Console logging variant is okay, though consider removing it if it's purely for debugging.


99-108: Detailed example story.
Demonstrates a one-column layout with the new background and border props.


109-116: Simple example story with three columns.
Offers good coverage of multi-column usage in Storybook.

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

78-78: Ensure visual consistency of text size.
Switching the variant to small might be intentional to highlight detail lines in a smaller font. Double-check that this aligns with the rest of the design to maintain balance and readability.
[approve]


145-159: Validate responsiveness with the new grid layout.
You’re using an 8/12 and 4/12 split for large sizes. Confirm that this still displays correctly on smaller breakpoints. Also, verify that the new column structure is compatible with the updated InfoCardGrid CSS changes for consistent spacing.


169-171: Keep text weight and size consistent.
The medium variant with a light weight here may differ from other paragraphs in the component. Confirm that this is intentional for a more delicate look.

@thorkellmani thorkellmani added the automerge Merge this PR as soon as all checks pass label Jan 3, 2025
@kodiakhq kodiakhq bot merged commit dd4c6fb into main Jan 4, 2025
126 checks passed
@kodiakhq kodiakhq bot deleted the fix/info-card-grid branch January 4, 2025 07:19
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.

2 participants