Skip to content

feat(text-group): add TextGroupList feature #81#625

Open
airikej wants to merge 2 commits into
rcfrom
fix/81-textgroup-multiple-rows-in-one-dl-element
Open

feat(text-group): add TextGroupList feature #81#625
airikej wants to merge 2 commits into
rcfrom
fix/81-textgroup-multiple-rows-in-one-dl-element

Conversation

@airikej
Copy link
Copy Markdown
Contributor

@airikej airikej commented May 13, 2026

Summary by CodeRabbit

  • New Features
    • Added TextGroup.List component for rendering multiple label/value pairs in a definition list format.
    • Supports both vertical and horizontal layout modes.
    • Enables responsive design through breakpoint-based configuration.
    • Allows per-item customization of label alignment and width settings.

Review Change Stack

@airikej airikej linked an issue May 13, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Warning

Rate limit exceeded

@airikej has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 52 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c64955e6-fd3e-4733-a18c-b2cb3f0a467c

📥 Commits

Reviewing files that changed from the base of the PR and between ff01901 and a8d117d.

📒 Files selected for processing (1)
  • src/tedi/components/content/text-group/text-group.spec.tsx
📝 Walkthrough

Walkthrough

This PR adds TextGroupList, a new subcomponent of TextGroup that renders multiple label/value pairs in a semantic <dl> element. The component supports responsive layout configuration, per-row overrides for label alignment and width, and includes complete styling, test coverage, and Storybook documentation.

Changes

TextGroupList Subcomponent

Layer / File(s) Summary
TextGroupList component types and helpers
src/tedi/components/content/text-group/text-group-list/text-group-list.tsx (lines 1–87)
Introduces TextGroupListItem interface and TextGroupListProps type with responsive breakpoint support for layout type, label alignment, and label width; adds helper functions to wrap string labels in the Label component and normalize label width values into percentages.
TextGroupList component rendering
src/tedi/components/content/text-group/text-group-list/text-group-list.tsx (lines 88–134)
Implements TextGroupList that resolves breakpoint props, computes BEM classes for list and type modifiers, applies --label-width CSS custom property at root and per-row levels, iterates items into <dt>/<dd> pairs with alignment-specific classes, and sets component displayName.
TextGroup base refactoring and subcomponent wiring
src/tedi/components/content/text-group/text-group.tsx (lines 7, 60–94)
Imports TextGroupList, introduces shared renderLabelContent and resolveLabelWidth helpers, refactors TextGroup rendering to apply --label-width CSS variable, and exports TextGroup as Object.assign(TextGroupBase, { List: TextGroupList }) to expose subcomponent access.
CSS styling for list layout and rows
src/tedi/components/content/text-group/text-group.module.scss (lines 29–46)
Adds SCSS for --list modifier that renders content as vertical flex column, __row element as flex container, and combined --list + --horizontal selector that switches rows to horizontal layout with gap spacing and top alignment.
Module re-exports and barrel entries
src/tedi/components/content/text-group/index.ts, src/tedi/index.ts (lines 1–2, 9)
Updates text-group directory index to re-export TextGroup and TextGroupList, and updates main tedi/index.ts to export from text-group directory entry point instead of text-group.tsx directly.
Tests and Storybook documentation
src/tedi/components/content/text-group/text-group.spec.tsx (lines 137–235), src/tedi/components/content/text-group/text-group.stories.tsx (lines 19, 253–317)
Adds comprehensive test suite verifying <dl>/<dt>/<dd> rendering, layout modifiers, per-row label width overrides, and label rendering semantics for string vs JSX labels; registers TextGroupList as Storybook subcomponent and adds WithList story with vertical, horizontal, and per-row override examples.

Sequence Diagram

sequenceDiagram
  participant Consumer
  participant TextGroup
  participant TextGroupBase
  participant TextGroupList
  participant Label
  participant DOM
  Consumer->>TextGroup: import { TextGroup }
  TextGroup->>TextGroupBase: Object.assign reference
  TextGroup->>TextGroupList: List subcomponent attached
  Consumer->>TextGroupList: render with items array
  TextGroupList->>TextGroupList: resolve breakpoint props
  TextGroupList->>Label: wrap string labels
  Label->>DOM: render wrapped label
  TextGroupList->>DOM: render dt/dd pairs in dl
  TextGroupList->>DOM: apply --label-width CSS variable
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • mart-sessman
  • ly-tempel-bitweb
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a new TextGroupList feature to the text-group component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/81-textgroup-multiple-rows-in-one-dl-element

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@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: 2

🧹 Nitpick comments (2)
src/tedi/components/content/text-group/text-group-list/text-group-list.tsx (2)

122-122: 💤 Low value

Consider adding an optional identifier to TextGroupListItem for stable keys.

Using array index as the key prop works for static lists but can cause rendering issues if items are reordered, filtered, or dynamically updated. Consider adding an optional id or key field to the TextGroupListItem interface.

Optional enhancement
 export interface TextGroupListItem {
+  /**
+   * Optional unique identifier for this item. Used as React key if provided.
+   */
+  id?: string | number;
   /**
    * Label rendered as the `<dt>` for this row.

Then in the component:

-        <div key={index} className={styles['tedi-text-group__row']} style={rowStyle}>
+        <div key={item.id ?? index} className={styles['tedi-text-group__row']} style={rowStyle}>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tedi/components/content/text-group/text-group-list/text-group-list.tsx`
at line 122, The list currently uses the array index as the React key which can
break rendering when items change; update the TextGroupListItem interface to
include an optional unique identifier (e.g., id or uid), accept that field in
the component props for TextGroupList (and any parent types), and switch the key
on the rendered div in TextGroupList (the element with className
styles['tedi-text-group__row']) from index to item.id || index so existing
callers remain compatible while enabling stable keys when provided.

82-86: ⚡ Quick win

Extract duplicated helper functions to a shared utility file.

The renderLabelContent and resolveLabelWidth functions are identical to those in text-group.tsx (lines 60-64). This code duplication could lead to maintenance issues if one is updated without the other.

♻️ Refactor suggestion

Create a shared utilities file (e.g., text-group/text-group.utils.ts) and export these helpers:

import React from 'react';
import { Label } from '../label/label';

export const renderLabelContent = (label: React.ReactNode): React.ReactNode =>
  typeof label === 'string' ? <Label>{label}</Label> : label;

export const resolveLabelWidth = (labelWidth: string | number): string =>
  typeof labelWidth === 'number' ? `${labelWidth}%` : labelWidth;

Then import from both text-group.tsx and text-group-list.tsx:

+import { renderLabelContent, resolveLabelWidth } from './text-group.utils';
-
-const renderLabelContent = (label: React.ReactNode): React.ReactNode =>
-  typeof label === 'string' ? <Label>{label}</Label> : label;
-
-const resolveLabelWidth = (labelWidth: string | number): string =>
-  typeof labelWidth === 'number' ? `${labelWidth}%` : labelWidth;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tedi/components/content/text-group/text-group-list/text-group-list.tsx`
around lines 82 - 86, Extract the duplicated helpers renderLabelContent and
resolveLabelWidth into a shared utility module (e.g., create text-group.utils.ts
exporting renderLabelContent and resolveLabelWidth), ensure the utility imports
React and Label for renderLabelContent, then replace the local definitions in
both text-group.tsx and text-group-list.tsx with imports from the new
text-group.utils.ts; verify typings/signatures remain identical and update any
import paths accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tedi/components/content/text-group/text-group.spec.tsx`:
- Around line 138-235: The tests for TextGroup.List are unstable because they
rely on responsive behavior; mock the useBreakpointProps hook at the top of this
spec so the List renders deterministically — import or jest.mock the module that
exports useBreakpointProps (the hook used by TextGroup.List) and have it return
a simple passthrough implementation (props => props) or a fixed object for the
cases under test before any renders, then run the existing assertions; ensure
the mock is applied in this spec file (affecting TextGroup.List) so class and
style assertions are environment-independent.
- Around line 150-161: Replace raw DOM selectors in the test (currently using
container.querySelectorAll('dl'), 'dt', 'dd' and mapping textContent into
labels/values) with RTL semantic queries: use within(container) (or screen) and
getAllByRole('list') to assert there is one list and it has classes
'tedi-text-group' and 'tedi-text-group--list', then use getAllByRole/getByRole
or getAllByText/getByText to find the term labels and definition values (e.g.,
replace the labels mapping with within(list).getAllByText(...) or
within(list).getAllByRole(...) and similarly for values), and update the expect
assertions to compare the returned element textContent via .textContent or .text
to the expected ['Patient','Address','Vaccine'] and ['Mari Maasikas','Tulbi tn
4, Tallinn','COVID-19 mRNA']; do the same replacement for the other test blocks
referenced (lines ~176-179, 192-195, 209-213, 225-229, 233-234).

---

Nitpick comments:
In `@src/tedi/components/content/text-group/text-group-list/text-group-list.tsx`:
- Line 122: The list currently uses the array index as the React key which can
break rendering when items change; update the TextGroupListItem interface to
include an optional unique identifier (e.g., id or uid), accept that field in
the component props for TextGroupList (and any parent types), and switch the key
on the rendered div in TextGroupList (the element with className
styles['tedi-text-group__row']) from index to item.id || index so existing
callers remain compatible while enabling stable keys when provided.
- Around line 82-86: Extract the duplicated helpers renderLabelContent and
resolveLabelWidth into a shared utility module (e.g., create text-group.utils.ts
exporting renderLabelContent and resolveLabelWidth), ensure the utility imports
React and Label for renderLabelContent, then replace the local definitions in
both text-group.tsx and text-group-list.tsx with imports from the new
text-group.utils.ts; verify typings/signatures remain identical and update any
import paths accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 89194050-9f9f-4e9e-b2c6-134753877c36

📥 Commits

Reviewing files that changed from the base of the PR and between 1740b86 and ff01901.

📒 Files selected for processing (7)
  • src/tedi/components/content/text-group/index.ts
  • src/tedi/components/content/text-group/text-group-list/text-group-list.tsx
  • src/tedi/components/content/text-group/text-group.module.scss
  • src/tedi/components/content/text-group/text-group.spec.tsx
  • src/tedi/components/content/text-group/text-group.stories.tsx
  • src/tedi/components/content/text-group/text-group.tsx
  • src/tedi/index.ts

Comment thread src/tedi/components/content/text-group/text-group.spec.tsx
Comment thread src/tedi/components/content/text-group/text-group.spec.tsx Outdated
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.

[TextGroup]: Multiple rows in one <dl> element

1 participant