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

New pattern proposal: reveal/collapse elements #1139

Open
gforcada opened this issue Mar 9, 2023 · 3 comments
Open

New pattern proposal: reveal/collapse elements #1139

gforcada opened this issue Mar 9, 2023 · 3 comments

Comments

@gforcada
Copy link

gforcada commented Mar 9, 2023

The idea

I have a list of say tags of a document, but there are way too many, applying this pattern, given a data-reveal-amount number, that number of tags are shown, the others are hidden behind a button that reveals them 🎉

Extra nice would be if elements are sorted given a data-reveal-key that is sortable within the elements of the list.

This way, if each tag has a relevance number, the most relevant could be sorted, so by automatically hiding the other elements, the most relevant tags would be shown.

Implementation

Is there any pattern that provides this functionality? I could not find any, the sortable allows manual sorting, not automatic sorting, AFAIU

Are there guidelines on how to create a new pattern and submit it? 🤔

@thet
Copy link
Member

thet commented Mar 10, 2023

Hi, sounds like an interesting idea!

I could imagine to add automatic sorting as a feature to pat-sortable. But that would need to run through an internal specification process.

A related pattern to this idea is pat-collapsible - however, it does not support something like the reveal amount idea.
Instead of pat-collabpsible you can also use pat-toggle to toggle a class on an element.

In any case, you might be able to get what you want with pure CSS.
For example, if you toggle the .closed class on a div containing li elements:

.closed  li:nth-child[n+5] {
  display: none;
}

and then do a animation on the height of the div if you want.
Sorting in that case would have to be done server side.

If you decide to go for a Pattern:

The pattern template repo should get you quickly started.

Please don't read anything except "module federation" or "styleguide" from https://github.com/Patternslib/Patterns/tree/master/docs/developer - this is still outdated.

@gforcada
Copy link
Author

@thet thanks! 🙇🏾 I will have a look and decide 😄

@thet
Copy link
Member

thet commented Mar 10, 2023

@gforcada let me know if I can help bootstrapping a new pattern or getting this done

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

No branches or pull requests

2 participants