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 feature: reversible sort links #290

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

neilmcguigan
Copy link

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

@PanderMusubi PanderMusubi requested a review from greyli August 22, 2023 07:23
@PanderMusubi PanderMusubi added the enhancement New feature or request label Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants