Skip to content

feat: adds localization to uui-pagination #1069

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

Merged
merged 8 commits into from
May 6, 2025
Merged
55 changes: 39 additions & 16 deletions packages/uui-pagination/lib/uui-pagination.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,37 @@ export class UUIPaginationElement extends LitElement {
@property({ reflect: true, attribute: 'aria-label' })
ariaLabel = '';

/**
* This property is used to generate the name of the first button
* @type {string}
* @attr
*/
@property({ type: String })
firstLabel: string = 'First';

/**
* This property is used to generate the name of the previous button
* @type {string}
* @attr
*/
@property({ type: String })
previousLabel: string = 'Previous';

/**
* This property is used to generate the name of the next button
* @type {string}
* @attr
*/
@property({ type: String })
nextLabel: string = 'Next';
/**
* This property is used to generate the name of the last button
* @type {string}
* @attr
*/
@property({ type: String })
lastLabel: string = 'Last';

private _total = 100;

/**
Expand Down Expand Up @@ -214,11 +245,9 @@ export class UUIPaginationElement extends LitElement {
look="outline"
class="nav"
role="listitem"
label="Go to first page"
label=${this.firstLabel}
?disabled=${this._current === 1}
@click=${() => this.goToPage(1)}>
First
</uui-button>`;
@click=${() => this.goToPage(1)}></uui-button>`;
}

protected renderPrevious() {
Expand All @@ -227,11 +256,9 @@ export class UUIPaginationElement extends LitElement {
look="outline"
class="nav"
role="listitem"
label="Go to previous page"
label=${this.previousLabel}
?disabled=${this._current === 1}
@click=${this.goToPreviousPage}>
Previous
</uui-button>`;
@click=${this.goToPreviousPage}></uui-button>`;
}

protected renderNext() {
Expand All @@ -240,11 +267,9 @@ export class UUIPaginationElement extends LitElement {
look="outline"
role="listitem"
class="nav"
label="Go to next page"
label=${this.nextLabel}
?disabled=${this._current === this.total}
@click=${this.goToNextPage}>
Next
</uui-button>`;
@click=${this.goToNextPage}></uui-button>`;
}

protected renderLast() {
Expand All @@ -254,11 +279,9 @@ export class UUIPaginationElement extends LitElement {
look="outline"
role="listitem"
class="nav"
label="Go to last page"
label=${this.lastLabel}
?disabled=${this.total === this._current}
@click=${() => this.goToPage(this.total)}>
Last
</uui-button>
@click=${() => this.goToPage(this.total)}></uui-button>
`;
}

Expand Down
Loading