Skip to content

Commit

Permalink
feat: add button postion option (#305)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Filippov <socket.someone@gmail.com>
  • Loading branch information
NedcloarBR and SocketSomeone authored Sep 1, 2024
1 parent 724683b commit b49e7a5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ import { AppService } from './app.service';
// Add buttons for skip to first and last page
allowSkip: true,
// Add buttons for search page
allowTraversal: true
allowTraversal: true,
// Define the buttons position (start / end)
buttonsPosition: 'end'
})
],
providers: [AppService]
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/pagination-builder.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ export class PaginationBuilder {
const buttons = this.generateButtons(page);

const row = new ActionRowBuilder<ButtonBuilder>().addComponents(buttons);

return {
...pageOptions,
components: [row, ...pageOptions.components]
components: this.options.buttonsPosition === 'end'
? [...pageOptions.components, row]
: [row, ...pageOptions.components]
};
}

Expand Down
1 change: 1 addition & 0 deletions src/interfaces/necord-pagination-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export interface NecordPaginationOptions {
modal?: ModalAppearance;
allowSkip?: boolean;
allowTraversal?: boolean;
buttonsPosition?: 'start' | 'end';
}
1 change: 1 addition & 0 deletions src/necord-pagination.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class NecordPaginationService {
private static readonly DEFAULT_OPTIONS: NecordPaginationOptions = {
allowTraversal: false,
allowSkip: false,
buttonsPosition: 'end',
buttons: {
[PaginationAction.First]: {
label: 'First',
Expand Down

0 comments on commit b49e7a5

Please sign in to comment.