Skip to content

Instantly share code, notes, and snippets.

@mficzel
Last active October 22, 2018 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mficzel/7b14eee4ad0fdebc1665440b993b412b to your computer and use it in GitHub Desktop.
Save mficzel/7b14eee4ad0fdebc1665440b993b412b to your computer and use it in GitHub Desktop.
AFX Pagination
#
# simple pagination with parameter appending to a uri
#
prototype(Vendor.Site:Components.Molecules.Pagination) < prototype(PackageFactory.AtomicFusion:Component) {
@styleguide {
title = 'Pagination'
props {
current = 12
start = 8
end = 16
last = 25
baseUri = 'http://www.example.com'
}
}
# first number to be rendererd (if greater than 1 "first" is shown)
start = 1
# last page number to be rendered
end = 1
# number to highlight as current
current = 1
# last possible number (used for "last" if greater than end)
last = 1
# prototype to render the link, the prototype gets the attribute "page" passed
baseUri = null
renderer = afx`
<div class="page-navigation"
@if.isPaginationNeeded={props.last > 1}
>
<ul class="neos-widget-paginator">
<li class="prev" @if.shall={props.current > 1} >
<a href={props.baseUri + '?page=' + (props.current - 1)}>prev</a>
</li>
<li class="first" @if.shall={props.start > 1}>
<a href={props.baseUri + '?page=1'}>1</a>
</li>
<li @if.shall={props.start > 2}>...</li>
<Neos.Fusion:Collection collection={Array.range(props.start, props.end)} itemName="page" @children="itemRenderer">
<li class={(props.current == page) ? 'current': ''}>
<a href={props.baseUri + '?page=' + page}>next</a>
</li>
</Neos.Fusion:Collection>
<li @if.shall={props.end < (props.last - 1)}>...</li>
<li class="last" @if.shall={props.end < props.last}>
<a href={props.baseUri + '?page=' + props.last}>1</a>
</li>
<li class="next" @if.shall={props.current < props.last} >
<a href={props.baseUri + '?page=' + (props.current + 1)}>next</a>
</li>
</ul>
</div>
`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment