Skip to content

Commit

Permalink
fix(addon-table): TablePagination show checkmark for selected `[siz…
Browse files Browse the repository at this point in the history
…e]` (#1780)
  • Loading branch information
nsbarsukov authored May 19, 2022
1 parent 0950f8e commit 4a26fac
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TuiDataListModule,
TuiHostedDropdownModule,
TuiLinkModule,
TuiSvgModule,
} from '@taiga-ui/core';

import {TuiTablePaginationComponent} from './table-pagination.component';
Expand All @@ -16,6 +17,7 @@ import {TuiTablePaginationComponent} from './table-pagination.component';
TuiLinkModule,
TuiHostedDropdownModule,
TuiDataListModule,
TuiSvgModule,
],
declarations: [TuiTablePaginationComponent],
exports: [TuiTablePaginationComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
}

.t-item {
width: 5.5rem;
min-width: 5.5rem;
box-sizing: border-box;
}

.t-checkmark {
min-width: 1.5rem;
border-left: 5px solid transparent;
}

.t-back {
margin: 0 0.25rem 0 1.5rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ texts.pages }}
<strong class="t-strong">{{ pages }}</strong>
</span>
<span>
<span automation-id="tui-table-pagination__lines-per-page-wrapper">
{{ texts.linesPerPage }}
<tui-hosted-dropdown
[content]="content"
Expand All @@ -16,13 +16,21 @@
<tui-data-list>
<ng-container *ngFor="let item of items">
<button
*ngIf="item !== size"
tuiOption
size="s"
class="t-item"
(click)="onItem(item)"
>
{{ item }}
<tui-svg
*ngIf="item === size; else fakeIcon"
src="tuiIconCheckLarge"
class="t-checkmark"
></tui-svg>

<ng-template #fakeIcon>
<span class="t-checkmark"></span>
</ng-template>
</button>
</ng-container>
</tui-data-list>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
describe('TablePagination', () => {
beforeEach(() => {
cy.viewport('macbook-13');
});

describe('Dropdown with `[size]`-options (amount items per page)', () => {
it('Basic case', () => {
cy.tuiVisit('/components/table-pagination/API');
initializeAliases('#demoContent');

cy.get('@linesPerPageSelect').click();
waitForCheckmarkIcon();
cy.get('@tablePagination').matchImageSnapshot('0-[size]-dropdown-base', {
padding: [0, 0, 150, 0],
});
});

it('With very long option name', () => {
const LONG_NUMBER = 10000000000000000000;

cy.tuiVisit(
encodeURI(
`/components/table-pagination/API?items=[0, ${LONG_NUMBER}]&size=${LONG_NUMBER}&total=${LONG_NUMBER}&page=0`,
),
);
initializeAliases('#demoContent');

cy.get('@linesPerPageSelect').click();
waitForCheckmarkIcon();
cy.get('@tablePagination').matchImageSnapshot(
'1-[size]-dropdown-long-option-name',
{
padding: [0, 0, 100, 0],
},
);
});
});
});

function initializeAliases(selectorToTablePagination: string): void {
cy.get(`${selectorToTablePagination} tui-table-pagination`)
.should('be.visible')
.as('tablePagination');

cy.get('@tablePagination')
.find(
'[automation-id=tui-table-pagination__lines-per-page-wrapper] tui-hosted-dropdown',
)
.should('be.visible')
.as('linesPerPageSelect');
}

function waitForCheckmarkIcon(): void {
cy.get('tui-dropdown-box')
.find('tui-svg[src=tuiIconCheckLarge] use')
.should('be.visible')
.invoke('height')
.should('be.greaterThan', 0);
}

0 comments on commit 4a26fac

Please sign in to comment.