What is this?
I saw the Isotope filter and I just had to write a rebuild using modern web standards. This filter uses a grid layout and animates using view transition. It is silky smooth, blazing fast and has graceful degredation. The code consists of only 63 lines of vanilla JS, while the old version required an astonishing 3500+ lines. If you choose to leave the sorting out, you can even reduce the code to 37 lines. Yup… the web has come a long way.
How to use it?
Just set id="filter" on any container and give its children classes that represent categories, like class="metal". Then create some buttons with data attributes, like data-filter=".metal" or data-sortby="symbol". Load the JS from this demo in the footer and it works. You don’t need ANY of the CSS. That is all just fancy stuff.
<div>
<button data-filter="*">show all</button>
<button data-filter=".metal">metal</button>
...
</div>
<div>
<button data-sortby="order">original order</button>
<button data-sortby="name">name</button>
...
</div>
<div id="filter">
<div class="metal">
<h3 class="name">Mercury</h3>
<p class="symbol">Hg</p>
<p class="number">80</p>
<p class="weight">200.59</p>
</div>
....
</div>
<link rel="stylesheet" href="filter.css" />
<script src="filter.js"></script>
Caveats
Note that this version only supports basic filtering and sorting. Also note that the animation might not show in older browsers. Finally, be aware that you can not use this Isotope filter twice on the same page, as it lacks abstraction for that.
License
The original Isotope code was licensed GPLv3 and was not free for commercial use ($25/dev). That made sense. However, this code is so basic, you can’t license it. You would license modern web standards, which is crazy. So, if anything, it should be WTFPL.