skeletonlabs / skeleton

A complete design system and component solution, built on Tailwind.
https://skeleton.dev
MIT License
5.15k stars 322 forks source link

Collapse component #2002

Closed bartcuijpers closed 1 year ago

bartcuijpers commented 1 year ago

Describe the feature in detail (code, mocks, or screenshots encouraged)

In addition to the accordeon, I would love to see a collapse component.

What type of pull request would this be?

New Feature

Provide relevant links or additional information.

Similar to Bootstraps Collapse component

Mahmoud-zino commented 1 year ago

@bartcuijpers what would the collapse component be able to do, that the accordion can't do? can you give some more explanation or examples for how you are planning to use it?

endigo9740 commented 1 year ago

@Mahmoud-zino in other UI libraries, it's essentially the <AccordionItem> component, but standalone. It doesn't work in conjunction with a group of siblings.

Mahmoud-zino commented 1 year ago

@endigo9740 I would like to work on this feature. if this is ok and you have some expectations, please let me know.

endigo9740 commented 1 year ago

@Mahmoud-zino the main thing is I want to try to reduce redundancy. There's a lot of overlap with <AccordionItem>, but at the same time it's not 1:1 since it doesn't have the overhead of needing to work within a group.

For now I say we treat it as a brand new standalone component, similar to how other libraries separate Accordion and Collapse:

Feel free to base it off the AccordionItem though. The API and structure for that is fairly simple and obvious.

Mahmoud-zino commented 1 year ago

After further discussion on Discord, we found out that the component is too trivial to include in the library.

Here is a simple example on how to implement it (using svelte only): https://svelte.dev/repl/d8a84263d60d4c5e9100df1f6d896b15?version=4.2.1