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: adjust design in StudioDisplayTile to align with StudioToggleableTextfield design #14401

Merged
merged 6 commits into from
Jan 15, 2025

Conversation

standeren
Copy link
Contributor

@standeren standeren commented Jan 10, 2025

Description

Adjust design in StudioDisplayTile to align with StudioToggleableTextfield design.
In this PR the label and title for StudioDisplayTile will align vertically instead of horizontally, as it is today.
The reason for this change is to make it look more like the StudioToggleableTextfield which we use across the solution.
This change is "critical" when working on disabling the codeListId-change in the content library since these fields will be placed in the same view.

Today it looks like this:
Skjermbilde 2025-01-10 kl  15 06 05

In this PR it will look like this:
Skjermbilde 2025-01-10 kl  15 08 43

(It will look the same in SelectDataModelBinding`)

⚠️ I have also prepared a PR that will clean up the StudioToggleableTextfield to have a consistent design by removing the children prop and pass the value and label directly.

Related Issue(s)

  • #{issue number}

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Summary by CodeRabbit

  • Style Updates

    • Redesigned layout for Studio Display Tile component using CSS Grid.
    • Improved text overflow handling for labels and values.
    • Removed unnecessary CSS classes and updated styling rules.
    • Introduced a new flexbox layout for the Config Viewer Panel.
    • Adjusted padding for display tiles.
  • Layout Improvements

    • Simplified component structure for better rendering.
    • Enhanced icon and label positioning with new layout rules.
  • Testing Enhancements

    • Added new test cases for rendering scenarios of the Studio Display Tile component.
    • Improved maintainability of test code by using constants for properties.
  • Localization Update

    • Simplified Norwegian language string for ID display.

These changes enhance the visual presentation, text handling, and test coverage of the Studio Display Tile component across the application, along with improvements in the Config Viewer Panel layout and localization.

@standeren standeren added skip-releasenotes Issues that do not make sense to list in our release notes ux/accessebility Related to WCAG, accessebilty and UU frontend skip-documentation Issues where updating documentation is not relevant labels Jan 10, 2025
@github-actions github-actions bot added area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution. labels Jan 10, 2025
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.66%. Comparing base (3598858) to head (2b444ea).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14401   +/-   ##
=======================================
  Coverage   95.66%   95.66%           
=======================================
  Files        1880     1880           
  Lines       24446    24447    +1     
  Branches     2810     2810           
=======================================
+ Hits        23386    23387    +1     
  Misses        800      800           
  Partials      260      260           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@standeren standeren marked this pull request as ready for review January 10, 2025 14:31
@standeren standeren linked an issue Jan 13, 2025 that may be closed by this pull request
@ErlingHauan ErlingHauan self-assigned this Jan 13, 2025
Copy link
Contributor

@ErlingHauan ErlingHauan left a comment

Choose a reason for hiding this comment

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

Fin oppdatering 😊
Har noen kommentarer under.

@ErlingHauan ErlingHauan assigned standeren and unassigned ErlingHauan Jan 14, 2025
Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

📝 Walkthrough

Walkthrough

The pull request introduces layout and styling changes to the StudioDisplayTile component across multiple files. The modifications primarily focus on transitioning from a flexbox to a grid-based layout, updating CSS classes, and improving text overflow handling. The changes affect the component's visual structure and rendering logic while maintaining its core functionality. The updates span CSS modules and the React component implementation, with adjustments to how icons, labels, and values are displayed.

Changes

File Change Summary
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.module.css - Switched from flexbox to grid layout for .container
- Added conditional grid template for third child
- Removed .innerContainer and .iconLabelContainer
- Introduced .prefixIcon class
- Updated text overflow handling for .label and .ellipsis
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.tsx - Added hasPrefixIcon boolean variable
- Simplified JSX structure
- Conditionally applied prefixIcon class
- Modified icon and label/value rendering
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.module.css - Removed .displayTileContainer class and associated styles
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.test.tsx - Defined label and value properties as constants
- Added new test cases for rendering scenarios and icon behavior
frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.tsx - Removed className prop from StudioDisplayTile component
frontend/language/src/nb.json - Modified configuration view panel ID label from dynamic to static
frontend/packages/process-editor/src/components/ConfigPanel/ConfigContent/ConfigContent.module.css - Updated .displayTile padding-inline from var(--fds-spacing-5) to var(--fds-spacing-4)
frontend/packages/process-editor/src/components/ConfigViewerPanel/ConfigViewerPanel.module.css - Added new .container class with flexbox layout
frontend/packages/process-editor/src/components/ConfigViewerPanel/ConfigViewerPanel.tsx - Added import for ConfigViewerPanel.module.css and applied .container class to a <div>

Possibly related PRs

  • feat: Subform table - enable editing of column title #14318: The changes in the main PR involve modifications to the CSS and JSX structure of the StudioDisplayTile component, which may relate to the overall layout and styling adjustments in the subform table editing functionality introduced in this PR.
  • feat: add StudioSearch component #14348: The introduction of the StudioSearch component and its integration into various parts of the application may relate to the layout changes in the StudioDisplayTile, as both involve updates to component structures and styling.
  • fix: remove duplicated action identifier in label #14393: The modifications to the labels and error messages in this PR may connect to the overall user interface improvements, including those in the StudioDisplayTile, as both aim to enhance user experience through clearer labeling.

Suggested labels

quality/testing

Suggested reviewers

  • Konrad-Simso

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 949fb46 and 2b444ea.

📒 Files selected for processing (1)
  • frontend/language/src/nb.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/language/src/nb.json
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: CodeQL
  • GitHub Check: Testing
  • GitHub Check: Typechecking and linting

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.

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.

@standeren standeren assigned ErlingHauan and unassigned standeren Jan 14, 2025
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 (1)
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.tsx (1)

31-38: Consider adding a11y improvements.

While the structure looks good, consider adding aria-label to improve accessibility for screen readers, especially for the icon and value sections.

-        {icon}
+        {icon && <span aria-hidden="true">{icon}</span>}
         <div className={classes.ellipsis}>
           <Paragraph size='small' className={classes.label}>
             {label}
           </Paragraph>
-          <Paragraph size='small' className={classes.ellipsis}>
+          <Paragraph size='small' className={classes.ellipsis} aria-label={`${label} value`}>
             {value}
           </Paragraph>
         </div>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 683992b and 2b7d3c8.

📒 Files selected for processing (3)
  • frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.module.css (1 hunks)
  • frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.tsx (1 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.module.css (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Typechecking and linting
  • GitHub Check: CodeQL
  • GitHub Check: Testing
🔇 Additional comments (6)
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.tsx (1)

26-27: LGTM: Clean implementation of prefix icon handling.

The addition of hasPrefixIcon and its usage in className composition is well-structured and maintainable.

frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.module.css (1)

8-8: Verify text overflow handling with the new padding.

The padding change looks good, but based on previous feedback, we should verify that text overflow is handled correctly in edge cases, especially with longer content.

frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.module.css (4)

2-3: LGTM: Clean transition to grid layout.

The switch from flexbox to grid with 1fr auto columns provides better control over the layout structure.


9-11: LGTM: Well-structured prefix icon handling.

The .prefixIcon class elegantly handles the additional column for the icon.


21-25: LGTM: Comprehensive text overflow handling.

The text overflow properties are well-implemented and consistently applied to both label and ellipsis classes.


13-14: Consider browser compatibility for :has selector.

The :has selector might not be supported in all browsers. Consider adding a fallback for better browser compatibility.

Run the following to check browser support in your target environments:

✅ Verification successful

:has selector usage aligns with project's browser requirements

The project's browserslist configuration explicitly targets modern browsers (>0.2% market share, not dead). The :has selector is well-supported in all major modern browsers since 2022 and is consistently used across multiple components in the codebase. No fallback is necessary.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check browser support for :has selector
curl -s "https://raw.githubusercontent.com/mdn/browser-compat-data/main/css/selectors/has.json" | jq '.browsers'

Length of output: 115


Script:

#!/bin/bash
# Check for browserslist config in package.json files
fd package.json --exec cat {} \; | jq 'select(.browserslist != null) | .browserslist'

# Look for other uses of :has selector and potential fallbacks
rg ":has\(" --type css -C 2

# Check for any browser support related comments
rg -i "browser.?support|fallback|compatibility" --type css -C 2

Length of output: 4727

Copy link
Contributor

@ErlingHauan ErlingHauan left a comment

Choose a reason for hiding this comment

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

Supert at du tok inn overflow-håndtering i selve komponenten 🥳

Jeg har testet PR-en også, så den er snart klar til merge. Men ser at CodeCov klager over manglende dekning på klassenavnet.

@ErlingHauan ErlingHauan added the skip-manual-testing PRs that do not need to be tested manually label Jan 14, 2025
@ErlingHauan ErlingHauan assigned standeren and unassigned ErlingHauan Jan 14, 2025
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)
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.test.tsx (2)

15-23: Consider adding layout-specific tests.

While the basic rendering tests are good, consider adding tests to verify the new vertical alignment layout, as this is a key change mentioned in the PR objectives.

Example test to consider:

it('should render label and value in vertical alignment', () => {
  render(<StudioDisplayTile {...defaultProps} />);
  const container = screen.getByLabelText(label).closest('.container');
  expect(container).toHaveStyle({ display: 'grid' });
  // Add more specific layout assertions based on your CSS implementation
});

40-48: Enhance test descriptions for clarity.

While the tests correctly verify the prefix icon styling, the descriptions could be more specific about the styling context.

Consider these more descriptive test names:

-  it('should not assign prefix icon className by default', () => {
+  it('should not apply prefix icon spacing when no icon is provided', () => {
-  it('should assign prefix icon className when prefix icon is set', () => {
+  it('should apply prefix icon spacing when an icon is provided', () => {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b7d3c8 and 3b47175.

📒 Files selected for processing (2)
  • frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.test.tsx (2 hunks)
  • frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.tsx
🔇 Additional comments (2)
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.test.tsx (2)

7-11: LGTM! Good refactoring of test constants.

Extracting label and value as constants improves maintainability and follows the DRY principle.


25-28: LGTM! Good coverage of padlock icon behavior.

The test properly verifies the default visibility of the padlock icon, complementing the existing visibility tests.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b47175 and f71cc5e.

📒 Files selected for processing (3)
  • frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.module.css (1 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.module.css (0 hunks)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.tsx (0 hunks)
💤 Files with no reviewable changes (2)
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.module.css
  • frontend/packages/ux-editor/src/components/config/editModal/EditDataModelBinding/EditBinding/SelectDataModelBinding.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build environment and run e2e test
🔇 Additional comments (3)
frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.module.css (3)

2-3: LGTM! Base grid layout handles most cases well.

The switch to grid layout with 1fr auto columns effectively handles cases where content needs to be right-aligned (like the lock icon) while allowing the main content to take remaining space.


20-24: LGTM! Text overflow handling follows best practices.

The implementation properly handles text truncation with ellipsis, preventing layout breaks from long text while maintaining readability.


12-13: Consider browser compatibility for :has() selector.

The :has() selector is not supported in all browsers. Consider adding a fallback layout for older browsers.

Run this script to check current browser support:

✅ Verification successful

:has() selector implementation is correctly handled

The current implementation already provides graceful degradation. The default 2-column grid layout serves as a natural fallback for browsers that don't support the :has() selector, while modern browsers will enhance to the 3-column layout when needed. No changes required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check browser support for :has() selector
curl -s "https://caniuse.com/api/features/css-has" | jq '.data."css-has".support'

Length of output: 81


Script:

#!/bin/bash
# Get the complete CSS module file content
cat frontend/libs/studio-components/src/components/StudioDisplayTile/StudioDisplayTile.module.css

# Search for any @supports rules in CSS files related to StudioDisplayTile
rg "@supports" frontend/libs/studio-components/src/components/StudioDisplayTile/

Length of output: 551

Copy link
Contributor

@ErlingHauan ErlingHauan left a comment

Choose a reason for hiding this comment

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

Dette er flisespikkeri, men hvis man endrer .displayTile-klassen i ConfigContent.module.css fra

.displayTile {
  padding-inline: var(--fds-spacing-5);
}

til

.displayTile {
  padding-inline: var(--fds-spacing-4);
  padding-bottom: var(--fds-spacing-1);
}

så synes jeg at det ser litt mer balansert ut (mer på linje med elementene over, pluss at vi får litt mer rom før boksen slutter).

Før:
Before
Etter:
After

@ErlingHauan
Copy link
Contributor

ErlingHauan commented Jan 14, 2025

ConfigViewerPanel ble ikke helt happy når paddingen forsvant fra komponenten 😬
(Men vet ikke om den egentlig er i bruk?)

bilde

@standeren
Copy link
Contributor Author

ConfigViewerPanel ble ikke helt happy når paddingen forsvant fra komponenten 😬 (Vet ikke om den egentlig er i bruk?)

bilde

Ouf, ja, jeg fryktet det 😅 Bra du sjekket! Vanskelig å si om noen bruker den. Det vil jo være synlig for de appene som har >v7 av App backend. Så må sikkert ta hensyn til det og!

@github-actions github-actions bot added the area/process Area: Related to app process (e.g. signing, receipt, fill inn, payment, etc). label Jan 14, 2025
@ErlingHauan
Copy link
Contributor

Så bra ut! Bare å merge for min del 😊

@standeren standeren merged commit 15bd10a into main Jan 15, 2025
12 checks passed
@standeren standeren deleted the adapt-studio-display-tile-for-consistent-design branch January 15, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/process Area: Related to app process (e.g. signing, receipt, fill inn, payment, etc). area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. frontend skip-documentation Issues where updating documentation is not relevant skip-manual-testing PRs that do not need to be tested manually skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain1 ux/accessebility Related to WCAG, accessebilty and UU
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Improve design of Studio components
2 participants