Skip to content

feat(accordion): add custom icon support #97

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

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

MGREMY
Copy link
Collaborator

@MGREMY MGREMY commented Dec 16, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Docs have been added/updated (for bug fixes/features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • CI-related changes
  • Documentation content changes
  • Other... Please describe:

Issue Number

Issue Number: #95

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added a demo section for the new accordion component in the documentation.
  • Documentation

    • Updated documentation to include a new "Arrow style" section with code snippets for the accordion component.

@MGREMY MGREMY linked an issue Dec 16, 2024 that may be closed by this pull request
@MGREMY MGREMY self-assigned this Dec 16, 2024
Copy link

vercel bot commented Dec 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-angular ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 16, 2024 2:23pm

Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request introduces a new "Arrow style" feature for the Accordion component in the Flowbite Angular library. The changes include adding a new standalone Angular component FlowbiteArrowStyleComponent that demonstrates custom icon styling for accordion titles. The implementation extends the existing accordion functionality by allowing more flexible icon rendering through a new injection token and template-based icon customization. Documentation is updated to showcase this new feature, including code snippets and a demo in the component documentation.

Changes

File Change Summary
apps/docs/docs/components/accordion/_arrow-style.component.html Added new HTML template with Flowbite accordion components, defining panels with custom icons and content
apps/docs/docs/components/accordion/_arrow-style.component.ts Created new standalone Angular component FlowbiteArrowStyleComponent with accordion imports
apps/docs/docs/components/accordion/index.md Added "Arrow style" section with demo action and code snippets
apps/docs/docs/components/accordion/ng-doc.page.ts Imported and added flowbiteArrowStyleComponent to demos
libs/flowbite-angular/accordion/accordion-title.component.ts Added injection token for icon customization and modified icon rendering logic

Sequence Diagram

sequenceDiagram
    participant User
    participant AccordionComponent
    participant AccordionTitleComponent
    participant IconComponent

    User->>AccordionComponent: Interact with Accordion
    AccordionComponent->>AccordionTitleComponent: Render Title
    alt Custom Icon Defined
        AccordionTitleComponent->>IconComponent: Render Custom Icon
    else Default Icon
        AccordionTitleComponent->>IconComponent: Render Chevron Icon
    end
Loading

Possibly related PRs

Poem

🐰 Hop along, accordion friend,
With icons that twist and bend!
Chevrons dance, templates play,
Flowbite's magic finds its way!
A rabbit's code, both sleek and bright,
Brings UI joy with pure delight! 🎉

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request.


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.

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 (4)
apps/docs/docs/components/accordion/index.md (1)

53-63: Enhance documentation with feature description and usage guidelines

While the section follows the documentation structure, consider adding:

  1. A brief description of the arrow style feature
  2. Use cases or scenarios where custom icons would be beneficial
  3. Configuration options available for customization

Also, the TypeScript snippet range (L1-L7) seems limited and might not show the complete implementation.

Consider expanding the documentation like this:

 ## Arrow style
+
+The arrow style feature allows you to customize the appearance of accordion icons. This is useful when:
+- You need to match your application's design system
+- You want to use custom icons for expanded/collapsed states
+- You need to modify the icon animation behavior
+
 {{ NgDocActions.demo('flowbiteArrowStyleComponent', {container: false}) }}

 ```angular-html file="./_arrow-style.component.html" group="arrow-style" name="html"

-angular-ts file="./_arrow-style.component.ts"#L1-L7 group="arrow-style" name="typescript" +angular-ts file="./_arrow-style.component.ts" group="arrow-style" name="typescript"

apps/docs/docs/components/accordion/_arrow-style.component.html (2)

1-78: Consider enhancing accessibility with ARIA labels

While the structure is semantically correct, consider adding ARIA labels to improve accessibility:

-<flowbite-accordion>
+<flowbite-accordion aria-label="Flowbite FAQ">
   <flowbite-accordion-panel [isOpen]="true">
-    <flowbite-accordion-title [icon]="no_arrow">What is Flowbite ?</flowbite-accordion-title>
+    <flowbite-accordion-title [icon]="no_arrow" aria-level="2">What is Flowbite ?</flowbite-accordion-title>

80-85: Add comments to document icon template usage

Consider adding comments to explain the purpose of each template for better maintainability:

+<!-- Empty template to remove default chevron icon -->
 <ng-template #no_arrow />
+<!-- Custom question mark icon template -->
 <ng-template #question_mark_arrow>
   <flowbite-icon
     svgIcon="outline:question-circle"
     class="h-6 w-6 shrink-0" />
 </ng-template>
libs/flowbite-angular/accordion/accordion-title.component.ts (1)

33-36: Add JSDoc comment to document the provider's purpose

Consider adding documentation to explain the provider's role:

+/**
+ * Provides default value for accordion title icon.
+ * When undefined, the default chevron icon will be used.
+ */
 {
   provide: FLOWBITE_ACCORDION_TITLE_ICON_DEFAULT_VALUE,
   useValue: undefined,
 },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe25ed8 and 5b184dd.

📒 Files selected for processing (5)
  • apps/docs/docs/components/accordion/_arrow-style.component.html (1 hunks)
  • apps/docs/docs/components/accordion/_arrow-style.component.ts (1 hunks)
  • apps/docs/docs/components/accordion/index.md (1 hunks)
  • apps/docs/docs/components/accordion/ng-doc.page.ts (2 hunks)
  • libs/flowbite-angular/accordion/accordion-title.component.ts (4 hunks)
🔇 Additional comments (4)
apps/docs/docs/components/accordion/_arrow-style.component.ts (1)

11-23: Verify the empty component implementation

The component is correctly structured as a standalone component with proper imports. However, the empty class implementation suggests that all the logic might be in the template file.

Let's verify the template implementation:

✅ Verification successful

Empty component implementation is justified by template-driven functionality

The empty component class is appropriate as all the necessary functionality is handled through the template:

  • The template implements a complete accordion structure with three panels
  • Custom arrow styles are managed through template references (#no_arrow and #question_mark_arrow)
  • The component properly demonstrates different arrow styles:
    • First panel uses no arrow ([icon]="no_arrow")
    • Second panel uses a question mark icon ([icon]="question_mark_arrow")
    • Third panel uses default arrow (no icon binding)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the template file exists and contains the necessary accordion structure
if [ -f "apps/docs/docs/components/accordion/_arrow-style.component.html" ]; then
    echo "Template content:"
    cat "apps/docs/docs/components/accordion/_arrow-style.component.html"
else
    echo "Template file missing!"
fi

Length of output: 4020

apps/docs/docs/components/accordion/ng-doc.page.ts (1)

3-3: LGTM! Component registration follows existing patterns

The arrow style demo component is properly imported and registered in the demos object, maintaining consistency with other demo components.

Also applies to: 25-25

libs/flowbite-angular/accordion/accordion-title.component.ts (2)

Line range hint 11-26: LGTM! Clean implementation of the injection token

The injection token is well-defined with proper typing and follows naming conventions.


94-99: LGTM! Well-documented icon property

The icon property is properly implemented using Angular's model() and includes clear documentation.

@MGREMY MGREMY merged commit 2ca1b36 into main Dec 16, 2024
5 checks passed
@MGREMY MGREMY deleted the 95-feature-accordion-possibility-to-change-icon branch December 16, 2024 14:44
@MGREMY
Copy link
Collaborator Author

MGREMY commented Dec 18, 2024

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] {Accordion} - Possibility to change icon
1 participant