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(Accordion): new component #301

Merged
merged 28 commits into from
Jun 27, 2023

Conversation

Haythamasalama
Copy link
Contributor

@Haythamasalama Haythamasalama commented Jun 17, 2023

Accordion

✨ Introducing a new component for the NuxtLabs UI : Toggleable Accordion Panels! πŸŽ‰

πŸ“ This pull request introduces the Disclosure component from the Headless UI library. It enables the display of interactive accordion panels for hiding and revealing content.

image
image

πŸš€ Key features of this component include:

  • Customizable labels, leading icons, and content for each panel.
  • Options to enable/disable individual panels.
  • Control over the initial open/closed state of the panels.
  • Ability to change the color and size of the accordion panels.
  • Flexible icon customization for opening and closing the panels.
  • Support for disabling specific panels.
  • Option to open all panels by default.
  • Slots for customizing the button and content items.

❀️ Please review the changes in this PR and provide feedback.

Resolves #156

@nuxt-studio-dev
Copy link

nuxt-studio-dev bot commented Jun 17, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
ui Edit on Studio β†—οΈŽ View Live Preview f80b996

@vercel
Copy link

vercel bot commented Jun 17, 2023

@Haythamasalama is attempting to deploy a commit to the Nuxt Labs Team on Vercel.

A member of the Team first needs to authorize it.

@nuxt-studio
Copy link

nuxt-studio bot commented Jun 17, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
ui Edit on Studio β†—οΈŽ View Live Preview dcb4502

Copy link
Member

I had a quick look and I would rather call this component Accordion :)

Also, what would you think of using the UButton for the triggers? It would allow to handle all the styling and the props like here https://github.com/nuxtlabs/ui/blob/dev/src/runtime/components/overlays/Notification.vue#L83 without configuring everything like the sizes, icons, etc.

@Haythamasalama
Copy link
Contributor Author

Haythamasalama commented Jun 20, 2023

I had a quick look and I would rather call this component Accordion :)

You're right, I don't like the Disclosure name It's nice to be accordion.Β I will work on these changes.

@Haythamasalama Haythamasalama changed the title feat(Disclosure): new component feat(Accordion): new component Jun 20, 2023
@Haythamasalama
Copy link
Contributor Author

@benjamincanac done

Do you think we need to add as props for the content of the accordion?

@Haythamasalama
Copy link
Contributor Author

@benjamincanac
Can we review this to work on new components like breadcrumbs ?

@vercel
Copy link

vercel bot commented Jun 27, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
ui πŸ”„ Building (Inspect) Jun 27, 2023 7:53pm

@benjamincanac
Copy link
Member

I've taken the liberty to make a few changes to your PR. Let me know what you think!

@benjamincanac
Copy link
Member

I just have an issue with the disabled field on an item that doesn't get forwarded to the Button.

@Haythamasalama
Copy link
Contributor Author

Haythamasalama commented Jun 27, 2023

@benjamincanac
Nice changes. But what if we make the default variant soft and add this example of the default slot to showcase an alternative accordion design or style ?

image

I just have an issue with the disabled field on an item that doesn't get forwarded to the Button.

I will check it

@Haythamasalama
Copy link
Contributor Author

Haythamasalama commented Jun 27, 2023

@benjamincanac

Changing the as property from template to div in <HDisclosureButton as="div"> makes it work correctly

image

Copy link
Member

I fixed it by passing the disabled prop to the DisclosureButton which works with as="template".

Do you still see an issue?

Copy link
Member

I've updated the default slot example from your proposal.

@Haythamasalama
Copy link
Contributor Author

Haythamasalama commented Jun 27, 2023

@benjamincanac

disabled It's working well. I updated the default slot example and added the default variant soft. I think it looks very nice, rather than solid.

Copy link
Member

I agree, just pushed some changes too. Let me know 😊

@Haythamasalama
Copy link
Contributor Author

Haythamasalama commented Jun 27, 2023

I agree, just pushed some changes too. Let me know 😊

Nice tweak! ❀️

@benjamincanac
Copy link
Member

Let's merge this then!

@benjamincanac benjamincanac merged commit e50f377 into nuxt:dev Jun 27, 2023
1 of 2 checks passed
@Haythamasalama Haythamasalama deleted the feat/ements-disclosure branch June 27, 2023 19:56
@mathieunicolas
Copy link

mathieunicolas commented Jun 27, 2023

Nice component !
Is it possible to add an option that would let us choose if opening a panel should close the others ?
I have a usecase in which that would be helpful.

btw, thanks a lot for this amazing UI module !!! you guys are amazing

@Haythamasalama
Copy link
Contributor Author

Haythamasalama commented Jun 27, 2023

@mathieunicolas

Yes, it's existied!

  • You can open all items by enabling default-open props.

Check it here: https://ui.nuxtlabs.com/elements/accordion#open

  • Or open a specific item by passing defaultOpen in the items array.

Check it here: https://ui.nuxtlabs.com/elements/accordion#usage

@mathieunicolas
Copy link

Hi @Haythamasalama thanks for your quick reply !
My question was about the behaviour of the accordion when you click on a panel to open it : it would be nice to have the previously opened one automatically closing, so you always have one panel opened !

For example :

  • all panels are closed
  • you click panel 2, it opens
  • you click panel 3, it opens, and panel 2 closes

@Haythamasalama
Copy link
Contributor Author

@mathieunicolas
Open issue with this description

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.

[Component] Accordion
5 participants