metafizzy / isotope

:revolving_hearts: Filter & sort magical layouts
https://isotope.metafizzy.co
11.05k stars 1.41k forks source link

inclusive and exclusive filters for multiple checkboxes #1613

Open rrrrpppp opened 2 years ago

rrrrpppp commented 2 years ago

Hi, I made a new fork of "Combination inclusive and exclusive filters with selects and checkboxes" (https://codepen.io/desandro/pen/GFbAs) here: https://codepen.io/rrrppp/pen/LYjLXvq

My goal is to have several checkbox groups where i can define whether they act inclusively or exclusively. I have tried to define the former select options as input fields, but they do not react as desired.

The following selection should generate the following:

isotope

.medium.price20.green.blue, .large.price20.green.blue

I hope someone has some advice for me. Thanks!

thesublimeobject commented 2 years ago

@rrrrpppp — First, you need to clear the filters whenever you're changing them. As it is, the filters I am receiving on the Pen you posted are accumulating indefinitely, it seems. Otherwise, you just need to run some sort of permutation/combination filter over the fields depending on which is which; I think I have an example of this somewhere in my own code, but I'll have to look for it. I will post it if I can find it.

rrrrpppp commented 2 years ago

@thesublimeobject thank you! I have made some progress and updated the pen: https://codepen.io/rrrppp/pen/LYjLXvq

The colours are provided as AND condition. So all conditions must apply. The other two (price and size) are with the OR condition. I now get the following:

filter-output

I would still like the two OR conditions to be grouped and then clustered together so that I get the following result at the end:

.medium.price20.blue.orange, .medium.price30.blue.orange, .large.price20.blue.orange, .large.price30.blue.orange

So how can I first bundle the two OR conditions together so that I get something like this first?

.medium.price20, .medium.price30, .large.price20, .large.price30

And then add the colours afterwards? Do you have a tip or an example for this? I would be very grateful for that.