From 336462b31fce0dcb8630fd34874dab1684c15a69 Mon Sep 17 00:00:00 2001 From: Pratik Galoria Date: Thu, 9 Feb 2023 21:43:12 +0530 Subject: [PATCH] fix(pagination): accessibility improvements (#408) Co-authored-by: Pratik Galoria --- src/components/pagination/bl-pagination.css | 1 + src/components/pagination/bl-pagination.test.ts | 10 +++++----- src/components/pagination/bl-pagination.ts | 12 ++++++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/pagination/bl-pagination.css b/src/components/pagination/bl-pagination.css index 07a5ae4f..c9e5a853 100644 --- a/src/components/pagination/bl-pagination.css +++ b/src/components/pagination/bl-pagination.css @@ -22,6 +22,7 @@ align-items: center; list-style: none; user-select: none; + gap: var(--bl-size-3xs); } .dots { diff --git a/src/components/pagination/bl-pagination.test.ts b/src/components/pagination/bl-pagination.test.ts index b64a4511..cc62be48 100644 --- a/src/components/pagination/bl-pagination.test.ts +++ b/src/components/pagination/bl-pagination.test.ts @@ -14,17 +14,17 @@ describe('bl-pagination', () => { assert.shadowDom.equal( el, ` - + ` ); }); diff --git a/src/components/pagination/bl-pagination.ts b/src/components/pagination/bl-pagination.ts index 90a7119d..9839343d 100644 --- a/src/components/pagination/bl-pagination.ts +++ b/src/components/pagination/bl-pagination.ts @@ -1,5 +1,6 @@ import { CSSResultGroup, html, LitElement, TemplateResult, PropertyValues } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { event, EventDispatcher } from '../../utilities/event'; import '../button/bl-button'; import '../input/bl-input'; @@ -185,13 +186,16 @@ export default class BlPagination extends LitElement { private _renderSinglePage(page: number | string) { if (typeof page === 'string') { - return html``; + return html`
  • `; } + const ariaCurrent = this.currentPage === page ? 'page' : undefined; return html`
  • ${page} @@ -207,6 +211,7 @@ export default class BlPagination extends LitElement { kind="neutral" icon="arrow_left" class="previous" + label="Previous" ?disabled=${this.currentPage === 1} >
      @@ -220,6 +225,7 @@ export default class BlPagination extends LitElement { kind="neutral" icon="arrow_right" class="next" + label="Next" ?disabled=${this.currentPage === this._getLastPage()} > @@ -256,7 +262,9 @@ export default class BlPagination extends LitElement { return html`
      ${selectEl} ${jumperEl}
      `; }; - return html` `; + return html` `; } }