Skip to content

feat: Add Accordion component#85

Open
BIA3IA wants to merge 4 commits intomainfrom
bianca/accordion
Open

feat: Add Accordion component#85
BIA3IA wants to merge 4 commits intomainfrom
bianca/accordion

Conversation

@BIA3IA
Copy link
Copy Markdown
Contributor

@BIA3IA BIA3IA commented Apr 14, 2026

Introduce an Accordion component

Closes #82

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Walkthrough

Introduces a Radix UI-based accordion component with wrapper abstractions, CSS animations for expand/collapse transitions, and a FAQ page demonstrating the accordion. Also adds the required @radix-ui/react-accordion dependency to package.json.

Changes

Cohort / File(s) Summary
Accordion UI Component
src/components/ui/accordion.tsx, src/styles/animations.css
New accordion component wrapping Radix UI primitives with styled subcomponents (Accordion, AccordionItem, AccordionTrigger, AccordionContent). Accompanying CSS animations define keyframes for accordion expand (accordion-down) and collapse (accordion-up) with height/opacity transitions, plus utility classes for animation application.
Global Styling
src/styles/globals.css
Added import for new animations stylesheet to extend global styling pipeline.
FAQ Page
src/app/faqs/page.tsx
New page component rendering a FAQ section with five accordion entries, each configured with a trigger and content. Accordion initialized with type="single", collapsible, and defaultValue="item-1".
Dependencies
package.json
Added @radix-ui/react-accordion at ^1.2.12 as a new dependency.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: Add Accordion component' clearly and concisely summarizes the main change—introducing an Accordion UI component. It is fully related to the changeset.
Linked Issues check ✅ Passed The PR successfully implements an Accordion component meeting the visual requirement from issue #82, with a fully functional accordion UI component, FAQ page demonstration, animations, and styling.
Out of Scope Changes check ✅ Passed All changes are in scope: the Accordion component and supporting UI elements directly address issue #82's requirement for an Accordion component. The FAQ page demonstrates the component usage as intended.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@BIA3IA
Copy link
Copy Markdown
Contributor Author

BIA3IA commented Apr 14, 2026

Pensate sia meglio spostare il css dell'animazione dell'accordion in un animation.css o in un file per l'accordion tipo accordion.css?

@BIA3IA BIA3IA marked this pull request as ready for review April 15, 2026 09:02
Copy link
Copy Markdown
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.

🧹 Nitpick comments (6)
package.json (2)

52-53: Missing newline at end of file.

The file is missing a trailing newline character. Most editors and formatters expect files to end with a newline.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 52 - 53, The package.json is missing a trailing
newline at end-of-file; open package.json and add a single newline character at
the end so the file ends with a newline (ensure the final closing brace '}' is
followed by a newline).

20-20: @radix-ui/react-accordion version 1.2.12 is available and valid.

The dependency version exists on npm with appropriate peer dependencies. Consider grouping all @radix-ui/* packages together alphabetically in package.json for consistency—currently this entry is placed between react-slot and @t3-oss/env-nextjs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 20, The `@radix-ui/react-accordion` dependency line is
placed out of alphabetical grouping; move the "@radix-ui/react-accordion":
"^1.2.12" entry so that all "@radix-ui/*" packages are grouped together and
sorted alphabetically in package.json (ensure it sits near other `@radix-ui`
entries and not between "react-slot" and "@t3-oss/env-nextjs"), updating the
dependencies block accordingly and preserving commas/JSON validity.
src/components/ui/accordion.tsx (1)

23-41: Consider adding visible focus indicator for accessibility.

The trigger has outline-none which removes the default focus outline. For keyboard accessibility, ensure there's a visible focus state. Consider adding a focus-visible style.

♻️ Proposed fix
         className={cn(
           "flex w-full items-center justify-between gap-4 p-6 text-left",
-          "typo-title-medium text-blue-secondary outline-none",
+          "typo-title-medium text-blue-secondary outline-none focus-visible:ring-2 focus-visible:ring-blue-secondary focus-visible:ring-offset-2",
           "[&[data-state=open]>svg]:rotate-90",
           className
         )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/ui/accordion.tsx` around lines 23 - 41, The AccordionTrigger
component removes the default focus outline via "outline-none", which breaks
keyboard visibility; update AccordionTrigger (the AccordionPrimitive.Trigger
element) to replace "outline-none" with an accessible focus style (e.g., add a
focus-visible class like "focus-visible:ring-2 focus-visible:ring-blue-secondary
focus-visible:outline-none" or similar) so keyboard users get a visible focus
indicator while preserving design; ensure the new classes are merged into the
existing cn(...) call so className prop and other props remain applied.
src/app/faqs/page.tsx (2)

36-36: Rename the component to reflect its purpose.

The function is named Home but this is the FAQs page (/faqs). Consider renaming it to FAQsPage or FAQPage for clarity and consistency with the route.

♻️ Proposed fix
-export default function Home() {
+export default function FAQsPage() {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/faqs/page.tsx` at line 36, Rename the default-exported React
component function from Home to a descriptive name like FAQsPage (or FAQPage) to
match the /faqs route; update the declaration export default function Home() to
export default function FAQsPage() and adjust any internal/local references or
imports that might reference Home so the file exports and usage remain
consistent.

3-34: Placeholder data with identical entries and trailing spaces.

All five accordion items have identical trigger and content text, which appears to be placeholder data. Additionally, there are trailing spaces in the trigger strings (e.g., "Per le lauree le lezioni sono sospese? "). If this is intended as demo content, consider either:

  • Adding a comment indicating these are placeholders
  • Removing the trailing spaces for consistency
♻️ Proposed fix for trailing spaces
   {
     value: "item-1",
-    trigger: "Per le lauree le lezioni sono sospese? ",
+    trigger: "Per le lauree le lezioni sono sospese?",
     content:
       "Spesso, la prima settimana, i Professori utilizzano le ore destinate alle esercitazioni per qualche ora di lezione in più: saranno quindi i docenti a specificare come verranno utilizzate queste ore. Dunque, le esercitazioni non sono da considerarsi annullate, salvo diversa comunicazione da parte del docente o dell'esercitatore.",
   },

Apply the same fix to items 2-5.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/faqs/page.tsx` around lines 3 - 34, The accordionItems array contains
placeholder entries with identical trigger/content and trailing spaces in the
trigger strings (e.g., items with value "item-1" through "item-5"); remove the
trailing space from each trigger (e.g., change "Per le lauree le lezioni sono
sospese? " to "Per le lauree le lezioni sono sospese?") and either replace
duplicated content with real FAQ text or add a clear inline comment above the
accordionItems declaration stating these are placeholders so reviewers know it’s
intentional; ensure you update all entries (value "item-1" .. "item-5")
consistently.
src/styles/animations.css (1)

1-29: Consider adding fill-mode: forwards to prevent content flash.

The animations don't specify a fill mode, which means the element reverts to its pre-animation state after the animation completes. For the close animation (accordion-up), this could cause a brief flash where the content is visible before being hidden. Adding forwards fill mode ensures the final state persists.

♻️ Proposed fix
 `@utility` animate-accordion-down {
-  animation: accordion-down 0.2s ease-out;
+  animation: accordion-down 0.2s ease-out forwards;
 }

 `@utility` animate-accordion-up {
-  animation: accordion-up 0.2s ease-out;
+  animation: accordion-up 0.2s ease-out forwards;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/styles/animations.css` around lines 1 - 29, The accordion animations
(keyframes accordion-down and accordion-up) lack an animation-fill-mode, causing
the element to revert and flash after the animation; update the utility rules
animate-accordion-down and animate-accordion-up to include animation-fill-mode:
forwards (or include "forwards" in the animation shorthand) so the final state
of accordion-down/up persists after the animation completes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@package.json`:
- Around line 52-53: The package.json is missing a trailing newline at
end-of-file; open package.json and add a single newline character at the end so
the file ends with a newline (ensure the final closing brace '}' is followed by
a newline).
- Line 20: The `@radix-ui/react-accordion` dependency line is placed out of
alphabetical grouping; move the "@radix-ui/react-accordion": "^1.2.12" entry so
that all "@radix-ui/*" packages are grouped together and sorted alphabetically
in package.json (ensure it sits near other `@radix-ui` entries and not between
"react-slot" and "@t3-oss/env-nextjs"), updating the dependencies block
accordingly and preserving commas/JSON validity.

In `@src/app/faqs/page.tsx`:
- Line 36: Rename the default-exported React component function from Home to a
descriptive name like FAQsPage (or FAQPage) to match the /faqs route; update the
declaration export default function Home() to export default function FAQsPage()
and adjust any internal/local references or imports that might reference Home so
the file exports and usage remain consistent.
- Around line 3-34: The accordionItems array contains placeholder entries with
identical trigger/content and trailing spaces in the trigger strings (e.g.,
items with value "item-1" through "item-5"); remove the trailing space from each
trigger (e.g., change "Per le lauree le lezioni sono sospese? " to "Per le
lauree le lezioni sono sospese?") and either replace duplicated content with
real FAQ text or add a clear inline comment above the accordionItems declaration
stating these are placeholders so reviewers know it’s intentional; ensure you
update all entries (value "item-1" .. "item-5") consistently.

In `@src/components/ui/accordion.tsx`:
- Around line 23-41: The AccordionTrigger component removes the default focus
outline via "outline-none", which breaks keyboard visibility; update
AccordionTrigger (the AccordionPrimitive.Trigger element) to replace
"outline-none" with an accessible focus style (e.g., add a focus-visible class
like "focus-visible:ring-2 focus-visible:ring-blue-secondary
focus-visible:outline-none" or similar) so keyboard users get a visible focus
indicator while preserving design; ensure the new classes are merged into the
existing cn(...) call so className prop and other props remain applied.

In `@src/styles/animations.css`:
- Around line 1-29: The accordion animations (keyframes accordion-down and
accordion-up) lack an animation-fill-mode, causing the element to revert and
flash after the animation; update the utility rules animate-accordion-down and
animate-accordion-up to include animation-fill-mode: forwards (or include
"forwards" in the animation shorthand) so the final state of accordion-down/up
persists after the animation completes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 837ca0f3-6a41-47e9-98d7-02ca0ea53d80

📥 Commits

Reviewing files that changed from the base of the PR and between 998b219 and 8f92448.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • package.json
  • src/app/faqs/page.tsx
  • src/components/ui/accordion.tsx
  • src/styles/animations.css
  • src/styles/globals.css

@BIA3IA BIA3IA self-assigned this Apr 15, 2026
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.

Accordion

1 participant