Skip to content

Feat/template accordion - #178

Merged
BleedingDev merged 5 commits into
masterfrom
feat/template-accordion-1
Nov 22, 2025
Merged

BleedingDev merged 5 commits into
masterfrom
feat/template-accordion-1

Conversation

@KaiUweCZE

@KaiUweCZE KaiUweCZE commented Oct 24, 2025 •

Copy link
Copy Markdown
Collaborator

Create AccordionTemplate with props-based API
Add AccordionItem interface for item configuration
Support all Accordion variants and behaviors
Add comprehensive Storybook stories with FAQ content

Summary by CodeRabbit

  • New Features

    • Added a reusable AccordionTemplate for configurable accordions (multiple items, indicators, disabled states, styling).
  • API

    • Made the AccordionProps type publicly available for external use.
  • Documentation

    • Added Storybook stories: Default example and an interactive Playground demonstrating usage and controls.

- Create AccordionTemplate with props-based API
- Add AccordionItem interface for item configuration
- Support all Accordion variants and behaviors
- Add comprehensive Storybook stories with FAQ content
@semanticdiff-com

semanticdiff-com Bot commented Oct 24, 2025 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  libs/ui/src/molecules/accordion.tsx  15% smaller
  libs/ui/src/templates/accordion.tsx  0% smaller
  libs/ui/stories/templates/accordion.stories.tsx  0% smaller

@vercel

vercel Bot commented Oct 24, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
new-engine-ui-storybook Ready Ready Preview Comment Nov 22, 2025 7:16pm

@coderabbitai

coderabbitai Bot commented Oct 24, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Exports the previously internal AccordionProps, introduces a new AccordionTemplate component with AccordionItem/AccordionTemplateProps types that maps items into Accordion.Item/Header/Content, and adds Storybook stories (Default and Playground) demonstrating the template and controls.

Changes

Cohort / File(s) Summary
Accordion molecule export
libs/ui/src/molecules/accordion.tsx
Made AccordionProps public by changing interface AccordionProps to export interface AccordionProps without altering its members.
AccordionTemplate component
libs/ui/src/templates/accordion.tsx
Added AccordionItem and AccordionTemplateProps interfaces and the AccordionTemplate function component. Renders an Accordion by mapping items to Accordion.Item with Accordion.Header (optional Accordion.Indicator) and Accordion.Content; passes through remaining AccordionProps.
Storybook stories
libs/ui/stories/templates/accordion.stories.tsx
New Storybook meta and stories: Default and Playground. Adds defaultItems, story argTypes and controls for items, variant, size, shadow, showIndicator, collapsible, multiple, and onChange.

Sequence Diagram(s)

sequenceDiagram
    %%{init: {"themeVariables":{"actorBorder":"#2b6cb0","actorBg":"#ebf8ff","noteBorder":"#a0aec0","noteBg":"#f7fafc"}}}%%
    participant User
    participant Template as AccordionTemplate
    participant Accordion
    participant Item as Accordion.Item
    participant Header as Accordion.Header
    participant Indicator as Accordion.Indicator
    participant Content as Accordion.Content

    User->>Template: Render(props: items, showIndicator, ...)
    Template->>Accordion: Mount with passed props
    loop for each item
        Accordion->>Item: Create(value, disabled)
        Item->>Header: Render(title)
        alt showIndicator == true
            Header->>Indicator: Render indicatorIcon
        end
        Item->>Content: Render(item.content)
    end
    Content-->>User: Display expanded/collapsed content
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to type compatibility between the newly exported AccordionProps and the AccordionTemplateProps (uses Omit<AccordionProps, 'children'>).
  • Verify Storybook controls (argTypes) and sample data (defaultItems) match the component prop shapes.
  • Confirm no unintended API breaking changes caused by exporting AccordionProps (visibility only).

Possibly related PRs

Suggested reviewers

  • BleedingDev

Poem

🎪 Accordion unveiled on a tidy little stage,
Items in a line, each title takes the page,
Indicators nod when asked to show,
Stories spin the scene — a playful UI show! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Feat/template accordion" is directly related to the main changeset, which creates a new AccordionTemplate component along with supporting interfaces (AccordionItem, AccordionTemplateProps) and Storybook stories. The title clearly conveys that the primary change involves introducing a template-based accordion feature. Whilst the formatting uses a branch-naming convention rather than a standard sentence structure, the title remains concise and specific enough for teammates scanning the history to understand that an accordion template is being introduced. The title successfully captures the essence of the work without unnecessary noise.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/template-accordion-1

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da9c327 and 8f9ce46.

📒 Files selected for processing (3)
  • libs/ui/src/molecules/accordion.tsx (1 hunks)
  • libs/ui/src/templates/accordion.tsx (1 hunks)
  • libs/ui/stories/templates/accordion.stories.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
libs/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Implement UI library components using Zag.js for React and Tailwind CSS for styling

Files:

  • libs/ui/src/molecules/accordion.tsx
  • libs/ui/stories/templates/accordion.stories.tsx
  • libs/ui/src/templates/accordion.tsx
libs/ui/src/{atoms,molecules}/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

libs/ui/src/{atoms,molecules}/**/*.tsx: React 19 components must not use forwardRef; pass ref as a prop instead
Do not use useCallback in components
Component implementations should use tv() with token-based classes (no raw Tailwind arbitrary values)
Use data attributes for state-based styling (e.g., data-[state=open], data-[disabled])
Do not use arbitrary Tailwind values in class names (e.g., bg-[#ff0000], bg-[var(--...)]); use token classes instead
Do not use direct semantic tokens like bg-primary; use component-specific token classes (e.g., bg-button-bg-primary)
Exported React components should be PascalCase (e.g., ComponentName)
Do not use abbreviations in component names (e.g., btn, pc)
When using Zag.js, derive styles from data attributes (e.g., data-state) rather than imperative styling

Files:

  • libs/ui/src/molecules/accordion.tsx
libs/ui/src/molecules/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Interactive components must use Zag.js patterns (machine, useMachine, normalizeProps, connect)

Files:

  • libs/ui/src/molecules/accordion.tsx
libs/ui/src/{atoms,molecules}/[a-z0-9-]*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Component files must be placed under src/atoms or src/molecules and named in kebab-case (component-name.tsx)

Files:

  • libs/ui/src/molecules/accordion.tsx
libs/ui/stories/**/*.stories.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

libs/ui/stories/**/*.stories.tsx: Storybook stories must exist for components and cover all variants and states
Use Storybook title hierarchy matching the layer (e.g., Atoms/ComponentName)

Files:

  • libs/ui/stories/templates/accordion.stories.tsx
🧠 Learnings (3)
📚 Learning: 2025-10-03T08:38:48.431Z
Learnt from: KaiUweCZE
PR: NMIT-WR/new-engine#151
File: libs/ui/stories/molecules/product-card.stories.tsx:214-227
Timestamp: 2025-10-03T08:38:48.431Z
Learning: Story files in libs/ui/stories/**/*.tsx can use semantic tokens (e.g., bg-accent, text-accent-fg, hover:bg-accent-hover) for demonstration purposes, unlike component implementation files which should use component-specific token classes.

Applied to files:

  • libs/ui/stories/templates/accordion.stories.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
PR: NMIT-WR/new-engine#0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/stories/**/*.stories.tsx : Storybook stories must exist for components and cover all variants and states

Applied to files:

  • libs/ui/stories/templates/accordion.stories.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
PR: NMIT-WR/new-engine#0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/stories/**/*.stories.tsx : Use Storybook title hierarchy matching the layer (e.g., Atoms/ComponentName)

Applied to files:

  • libs/ui/stories/templates/accordion.stories.tsx
🧬 Code graph analysis (2)
libs/ui/stories/templates/accordion.stories.tsx (1)
libs/ui/src/templates/accordion.tsx (1)
  • AccordionTemplate (20-65)
libs/ui/src/templates/accordion.tsx (2)
libs/ui/src/molecules/accordion.tsx (2)
  • AccordionProps (136-148)
  • Accordion (150-199)
libs/ui/src/atoms/icon.tsx (1)
  • IconType (5-5)
🔇 Additional comments (5)
libs/ui/src/templates/accordion.tsx (2)

1-3: LGTM! Clean imports.

All necessary types and components are correctly imported.


20-65: LGTM! Well-structured template component.

The implementation correctly:

  • Maps items to Accordion.Item elements with proper keys and prop forwarding
  • Conditionally renders the indicator based on showIndicator
  • Forwards all AccordionProps to the underlying Accordion component
  • Uses React 19 patterns (ref as a prop, no forwardRef)
  • Provides sensible defaults for all optional props
libs/ui/src/molecules/accordion.tsx (1)

136-136: LGTM! Correct visibility change.

Exporting AccordionProps is necessary to support the new AccordionTemplate and follows best practices for public API design.

libs/ui/stories/templates/accordion.stories.tsx (2)

4-82: LGTM! Comprehensive Storybook configuration.

The Meta configuration correctly:

  • Uses the proper title hierarchy Templates/AccordionTemplate for the templates layer
  • Provides complete argTypes with appropriate controls and categorisation
  • Includes helpful descriptions for documentation

As per coding guidelines.


87-118: LGTM! Well-structured default items.

The FAQ content is realistic and demonstrates the accordion template effectively. The use of text-fg-muted semantic token is acceptable in story files for demonstration purposes.

Based on learnings.

Comment thread libs/ui/src/templates/accordion.tsx
Comment thread libs/ui/stories/templates/accordion.stories.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8f9ce46 and a539208.

📒 Files selected for processing (1)
  • libs/ui/src/templates/accordion.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Implement UI library components using Zag.js for React and Tailwind CSS for styling

Files:

  • libs/ui/src/templates/accordion.tsx
🧬 Code graph analysis (1)
libs/ui/src/templates/accordion.tsx (2)
libs/ui/src/molecules/accordion.tsx (2)
  • AccordionProps (136-148)
  • Accordion (150-199)
libs/ui/src/atoms/icon.tsx (1)
  • IconType (5-5)
🔇 Additional comments (4)
libs/ui/src/templates/accordion.tsx (4)

1-2: LGTM!

The imports are properly structured and all imported entities are utilised in the component.


11-16: LGTM! Previous ref handling issue resolved.

The interface now correctly inherits ref from AccordionProps without redundant omission or re-declaration, addressing the feedback from the previous review.


18-33: LGTM!

The function signature correctly destructures all props with sensible defaults. The explicit defaults for variant, size, and shadow provide clear API expectations for the template.


34-62: LGTM!

The implementation correctly composes the Accordion primitives, properly forwards all props, and cleanly maps items to Accordion.Item components. The conditional indicator rendering provides the expected flexibility whilst maintaining a consistent layout.

Comment thread libs/ui/src/templates/accordion.tsx
@NaucMeIT

Copy link
Copy Markdown

@CodeRabbit full review

@coderabbitai

coderabbitai Bot commented Oct 29, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
libs/ui/src/templates/accordion.tsx (1)

4-9: Document the uniqueness requirement for value.

The value field is used as the React key (line 50), which requires uniqueness. Adding JSDoc documentation or runtime validation would help prevent developer errors.

Consider adding documentation:

+/**
+ * Configuration for an individual accordion item.
+ * @property value - Unique identifier for the accordion item (used as React key)
+ * @property title - The header text displayed for the item
+ * @property content - The content displayed when the item is expanded
+ * @property disabled - Whether the item is disabled
+ */
 export interface AccordionItem {
   value: string
   title: string
   content: React.ReactNode
   disabled?: boolean
 }
libs/ui/stories/templates/accordion.stories.tsx (1)

120-162: Add dedicated stories for all variants and states.

Whilst the Default and Playground stories provide good baseline coverage, the coding guidelines require stories to "cover all variants and states". Consider adding dedicated stories for each variant (borderless, child), size (sm, lg), and shadow option to ensure comprehensive documentation.

For example:

export const Borderless: Story = {
  args: {
    items: defaultItems,
    variant: 'borderless',
    showIndicator: true,
  },
}

export const SmallSize: Story = {
  args: {
    items: defaultItems,
    size: 'sm',
    showIndicator: true,
  },
}

export const WithShadow: Story = {
  args: {
    items: defaultItems,
    shadow: 'md',
    showIndicator: true,
  },
}

As per coding guidelines.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da9c327 and 8a879b2.

📒 Files selected for processing (3)
  • libs/ui/src/molecules/accordion.tsx (1 hunks)
  • libs/ui/src/templates/accordion.tsx (1 hunks)
  • libs/ui/stories/templates/accordion.stories.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
libs/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Implement UI library components using Zag.js for React and Tailwind CSS for styling

Files:

  • libs/ui/stories/templates/accordion.stories.tsx
  • libs/ui/src/molecules/accordion.tsx
  • libs/ui/src/templates/accordion.tsx
libs/ui/stories/**/*.stories.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

libs/ui/stories/**/*.stories.tsx: Storybook stories must exist for components and cover all variants and states
Use Storybook title hierarchy matching the layer (e.g., Atoms/ComponentName)

Files:

  • libs/ui/stories/templates/accordion.stories.tsx
libs/ui/src/{atoms,molecules}/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

libs/ui/src/{atoms,molecules}/**/*.tsx: React 19 components must not use forwardRef; pass ref as a prop instead
Do not use useCallback in components
Component implementations should use tv() with token-based classes (no raw Tailwind arbitrary values)
Use data attributes for state-based styling (e.g., data-[state=open], data-[disabled])
Do not use arbitrary Tailwind values in class names (e.g., bg-[#ff0000], bg-[var(--...)]); use token classes instead
Do not use direct semantic tokens like bg-primary; use component-specific token classes (e.g., bg-button-bg-primary)
Exported React components should be PascalCase (e.g., ComponentName)
Do not use abbreviations in component names (e.g., btn, pc)
When using Zag.js, derive styles from data attributes (e.g., data-state) rather than imperative styling

Files:

  • libs/ui/src/molecules/accordion.tsx
libs/ui/src/molecules/**/*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Interactive components must use Zag.js patterns (machine, useMachine, normalizeProps, connect)

Files:

  • libs/ui/src/molecules/accordion.tsx
libs/ui/src/{atoms,molecules}/[a-z0-9-]*.tsx

📄 CodeRabbit inference engine (libs/ui/CLAUDE.md)

Component files must be placed under src/atoms or src/molecules and named in kebab-case (component-name.tsx)

Files:

  • libs/ui/src/molecules/accordion.tsx
🧠 Learnings (3)
📚 Learning: 2025-10-03T08:38:48.431Z
Learnt from: KaiUweCZE
PR: NMIT-WR/new-engine#151
File: libs/ui/stories/molecules/product-card.stories.tsx:214-227
Timestamp: 2025-10-03T08:38:48.431Z
Learning: Story files in libs/ui/stories/**/*.tsx can use semantic tokens (e.g., bg-accent, text-accent-fg, hover:bg-accent-hover) for demonstration purposes, unlike component implementation files which should use component-specific token classes.

Applied to files:

  • libs/ui/stories/templates/accordion.stories.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
PR: NMIT-WR/new-engine#0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/stories/**/*.stories.tsx : Storybook stories must exist for components and cover all variants and states

Applied to files:

  • libs/ui/stories/templates/accordion.stories.tsx
📚 Learning: 2025-09-07T21:30:50.058Z
Learnt from: CR
PR: NMIT-WR/new-engine#0
File: libs/ui/CLAUDE.md:0-0
Timestamp: 2025-09-07T21:30:50.058Z
Learning: Applies to libs/ui/stories/**/*.stories.tsx : Use Storybook title hierarchy matching the layer (e.g., Atoms/ComponentName)

Applied to files:

  • libs/ui/stories/templates/accordion.stories.tsx
🔇 Additional comments (5)
libs/ui/src/molecules/accordion.tsx (1)

136-136: LGTM! Clean public API exposure.

Exporting AccordionProps enables the template layer to extend it properly. This follows good practice for building composable component architectures.

libs/ui/src/templates/accordion.tsx (2)

11-16: LGTM! Clean interface extension.

The interface correctly extends AccordionProps by omitting only children and adding template-specific props. The ref is properly inherited without redundancy.


34-62: LGTM! Clean template implementation.

The component correctly maps items to the compound Accordion structure, conditionally renders the indicator, and forwards all props appropriately.

libs/ui/stories/templates/accordion.stories.tsx (2)

4-82: LGTM! Comprehensive Storybook configuration.

The meta configuration follows best practices with proper title hierarchy, thorough argTypes with categories, and clear documentation. Well done!


87-118: LGTM! Good demo content with appropriate styling.

The FAQ content provides realistic examples, and the use of semantic tokens like text-fg-muted in story content is appropriate per established patterns.

Based on learnings.

Comment thread libs/ui/src/templates/accordion.tsx
@BleedingDev
BleedingDev merged commit 267d022 into master Nov 22, 2025
4 of 5 checks passed
@BleedingDev
BleedingDev deleted the feat/template-accordion-1 branch November 22, 2025 19:18

This branch was successfully deployed

1 active deployment
Preview — 58bea46e Deployed Nov 22, 2025 by vercel[bot]
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.

3 participants