fix(pagination): extract nav list template to reuse in derived component
This commit is contained in:
parent
b06c85bbb4
commit
bcc809b6bb
2 changed files with 29 additions and 15 deletions
5
.changeset/lucky-otters-appear.md
Normal file
5
.changeset/lucky-otters-appear.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/pagination': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(pagination): extract nav list template to reuse in derived component
|
||||||
|
|
@ -264,6 +264,29 @@ export class LionPagination extends LocalizeMixin(LitElement) {
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render navigation list
|
||||||
|
* @returns {TemplateResult} nav list template
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
_renderNavList() {
|
||||||
|
return this.__calculateNavList().map(page =>
|
||||||
|
page === '...'
|
||||||
|
? html` <li><span>${page}</span></li> `
|
||||||
|
: html`
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
aria-label="${this.msgLit('lion-pagination:page', { page })}"
|
||||||
|
aria-current=${page === this.current}
|
||||||
|
@click=${() => this.__fire(page)}
|
||||||
|
>
|
||||||
|
${page}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return html`
|
return html`
|
||||||
<nav role="navigation" aria-label="${this.msgLit('lion-pagination:label')}">
|
<nav role="navigation" aria-label="${this.msgLit('lion-pagination:label')}">
|
||||||
|
|
@ -271,21 +294,7 @@ export class LionPagination extends LocalizeMixin(LitElement) {
|
||||||
${this.current > 1
|
${this.current > 1
|
||||||
? this._prevNextButtonTemplate('previous', this.current - 1)
|
? this._prevNextButtonTemplate('previous', this.current - 1)
|
||||||
: this._disabledButtonTemplate('previous')}
|
: this._disabledButtonTemplate('previous')}
|
||||||
${this.__calculateNavList().map(page =>
|
${this._renderNavList()}
|
||||||
page === '...'
|
|
||||||
? html` <li><span>${page}</span></li> `
|
|
||||||
: html`
|
|
||||||
<li>
|
|
||||||
<button
|
|
||||||
aria-label="${this.msgLit('lion-pagination:page', { page })}"
|
|
||||||
aria-current=${page === this.current}
|
|
||||||
@click=${() => this.__fire(page)}
|
|
||||||
>
|
|
||||||
${page}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
`,
|
|
||||||
)}
|
|
||||||
${this.current < this.count
|
${this.current < this.count
|
||||||
? this._prevNextButtonTemplate('next', this.current + 1)
|
? this._prevNextButtonTemplate('next', this.current + 1)
|
||||||
: this._disabledButtonTemplate('next')}
|
: this._disabledButtonTemplate('next')}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue