bootstrap-flask
bootstrap-flask copied to clipboard
New feature: reversible sort links
Added a new macro: render_sortlink. This renders hyperlinks to sort by a given field in a given direction, and its reverse
{{ render_sortlink('foo') }}
will render HTML:
<span class="text-nowrap">
<a href="/?sort=foo,asc">Foo</a>
</span>
when clicked again, will render:
<span class="text-nowrap">
<a href="/?sort=foo,desc">Foo</a>
<svg class="bi" width="1em" height="1em" fill="currentColor">
<use xlink:href="/bootstrap/static/icons/bootstrap-icons.svg#caret-up"></use>
</svg>
</span>
when clicked again will render:
<span class="text-nowrap">
<a href="/?sort=foo,asc">Foo</a>
<svg class="bi" width="1em" height="1em" fill="currentColor">
<use xlink:href="/bootstrap/static/icons/bootstrap-icons.svg#caret-down"></use>
</svg>
</span>
maintains state with respect to other query string parameters
configurable to use different icons, or sort "styles", like ?sort=foo,asc
vs ?field=foo&asc=1