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

feat: adding new StudioHeading #15064

Merged
merged 16 commits into from
Mar 27, 2025
Merged

feat: adding new StudioHeading #15064

merged 16 commits into from
Mar 27, 2025

Conversation

wrt95
Copy link
Contributor

@wrt95 wrt95 commented Mar 26, 2025

Description

  • Adding the new StudioHeading component

Related Issue(s)

  • PR itself

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

  • New Features

    • Introduced a new heading component that extends standard heading functionality with customizable sizes and styling options.
  • Tests

    • Added a robust suite of tests to verify that the new component renders correctly and applies both default and custom configurations.
  • Chores

    • Updated component exports to replace placeholders, ensuring seamless integration and accessibility of the new heading component.
  • Types

    • Added a new type alias to exclude specific properties from component props, enhancing type safety and flexibility.

Copy link
Contributor

coderabbitai bot commented Mar 26, 2025

Warning

Rate limit exceeded

@wrt95 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 73c8a96 and 7d73263.

📒 Files selected for processing (2)
  • frontend/libs/studio-components/src/components/StudioHeading/StudioHeading.test.tsx (1 hunks)
  • frontend/libs/studio-components/src/components/index.ts (1 hunks)
📝 Walkthrough

Walkthrough

A new StudioHeading component has been added, extending the existing Heading component with customizable attributes. A test suite has been created to validate its rendering and functionality. Additionally, export statements have been updated to include the new component while removing a previous placeholder. A new type alias, WithoutAsChild, has also been introduced to omit a specific property from a generic type.

Changes

Files Change Summary
frontend/libs/studio-components/.../StudioHeading/StudioHeading.tsx, StudioHeading.test.tsx, StudioHeading/index.ts Added a new StudioHeading React component that extends the existing Heading component with default/custom attributes. Introduced a test suite to verify rendering, attribute handling, and export changes.
frontend/libs/studio-components/.../components/index.ts Removed the placeholder export (dummy) and added an export for the new StudioHeading component.
frontend/libs/studio-components/.../types/WithoutAsChild.ts Introduced a new type alias WithoutAsChild that omits the asChild property from the generic type Props.

Suggested labels

area/ui-editor, quality/testing

Suggested reviewers

  • JamalAlabdullah
  • github-actions

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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

🧹 Nitpick comments (2)
frontend/libs/studio-components/src/components/StudioHeading/StudioHeading.test.tsx (1)

24-27: Consider testing default level value

While you test the default data-size and custom level, there's no test to verify the default level is 2 (as implied by your getHeading function default).

  it('applies custom level prop correctly', () => {
    renderStudioHeading({ level: 1 });
    expect(getHeading(mockHeading, 1)).toBeInTheDocument();
  });
  
+  it('applies default level correctly', () => {
+    renderStudioHeading();
+    expect(screen.getByRole('heading', { name: mockHeading, level: 2 })).toBeInTheDocument();
+  });
frontend/libs/studio-components/src/components/StudioHeading/StudioHeading.tsx (1)

4-16: Consider adding JSDoc comments to the component

The component lacks documentation that explains its purpose and usage. Adding JSDoc comments would improve discoverability and help other developers understand how to use this component.

import React from 'react';
import { Heading, HeadingProps } from '@digdir/designsystemet-react';

+/**
+ * Props for the StudioHeading component
+ */
export type StudioHeadingProps = HeadingProps;

+/**
+ * StudioHeading component
+ * 
+ * A wrapper around the Heading component from designsystemet-react
+ * with a default data-size of 'sm' that can be overridden.
+ */
export const StudioHeading = ({
  children,
  'data-size': dataSize = 'sm',
  ...rest
}: StudioHeadingProps) => {
  return (
    <Heading {...rest} data-size={dataSize}>
      {children}
    </Heading>
  );
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2572e15 and aee996b.

📒 Files selected for processing (4)
  • frontend/libs/studio-components/src/components/StudioHeading/StudioHeading.test.tsx (1 hunks)
  • frontend/libs/studio-components/src/components/StudioHeading/StudioHeading.tsx (1 hunks)
  • frontend/libs/studio-components/src/components/StudioHeading/index.ts (1 hunks)
  • frontend/libs/studio-components/src/components/index.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build environment and run e2e test
  • GitHub Check: Testing
🔇 Additional comments (2)
frontend/libs/studio-components/src/components/StudioHeading/index.ts (1)

1-2: LGTM! Index file exports the StudioHeading component correctly

The index file correctly exports the StudioHeading component, following the barrel pattern for component organization.

frontend/libs/studio-components/src/components/index.ts (1)

1-2: LGTM! Component properly exported from the main index file

The StudioHeading component is correctly exported from the main components index file, replacing the previous placeholder export.

@github-actions github-actions bot added solution/studio/designer Issues related to the Altinn Studio Designer solution. frontend labels Mar 26, 2025
Copy link

codecov bot commented Mar 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.93%. Comparing base (c5744f4) to head (7d73263).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15064   +/-   ##
=======================================
  Coverage   95.93%   95.93%           
=======================================
  Files        1995     1996    +1     
  Lines       25864    25869    +5     
  Branches     2920     2921    +1     
=======================================
+ Hits        24812    24817    +5     
  Misses        788      788           
  Partials      264      264           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TomasEng TomasEng self-assigned this Mar 27, 2025
@wrt95 wrt95 requested a review from TomasEng March 27, 2025 12:25
@wrt95 wrt95 added the skip-manual-testing PRs that do not need to be tested manually label Mar 27, 2025
@TomasEng TomasEng assigned wrt95 and unassigned TomasEng Mar 27, 2025
@wrt95 wrt95 removed their assignment Mar 27, 2025
@TomasEng TomasEng merged commit f124a8c into main Mar 27, 2025
9 checks passed
@TomasEng TomasEng deleted the feat--add-new-StudioHeading branch March 27, 2025 13:40
@TomasEng TomasEng removed their assignment Mar 27, 2025
@wrt95 wrt95 self-assigned this Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
added-to-sprint frontend skip-manual-testing PRs that do not need to be tested manually solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-core team/studio-domain1 team/studio-domain2
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants