Skip to content

Commit

Permalink
fix(DataTable): external pagination, and sticky table header
Browse files Browse the repository at this point in the history
  • Loading branch information
lukicenturi committed Jan 2, 2024
1 parent f4e0edf commit adaf47c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
20 changes: 12 additions & 8 deletions example/cypress/e2e/data-table.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,37 @@ describe('DataTable', () => {
});

it.only('checks for data tables with sticky header', () => {
cy.get('div[data-cy=table-expandable-0]').as('sticky');
cy.get('div[data-cy="table-expandable-0"]').as('sticky');

cy.get('@sticky')
.find('> div > table > tbody > tr:nth-child(5)')
.as('row4');

cy.get('@sticky')
.find('> div > table thead[data-id=head-clone]')
.find('> div > table > thead[data-id=head-clone]')
.should('exist');

cy.get('@sticky')
.find('> div > table > thead[data-id=head-main]')
.as('mainHead')
.should('exist');

cy.get('@row4')
.scrollIntoView()
.get('@sticky')
.find('> div > table thead[data-id=head-main]')
.get('@mainHead')
.should((thead) => {
const classes = Cypress.$(thead).attr('class');
expect(classes).to.contain('_sticky__header_');
expect(classes).to.contain('_stick__top_');
expect(classes).not.to.contain('_stick__top_');
});

cy.window()
.get('body')
.scrollTo('top')
.get('@sticky')
.find('> div > table thead[data-id=head-main][class*=_sticky__header_]')
.get('@mainHead')
.should((thead) => {
const classes = Cypress.$(thead).attr('class');
expect(classes).to.contain('_stick__top_');
expect(classes).not.to.contain('_stick__top_');
});
});
});
6 changes: 5 additions & 1 deletion example/src/assets/main.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
@import './style.css';

@layer base {
html {
@apply overflow-hidden;
}

body {
@apply bg-white text-black;
@apply bg-white text-black h-screen overflow-y-auto overflow-x-hidden;
}

.dark body {
Expand Down
13 changes: 11 additions & 2 deletions example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@rotki/ui-library/style.css';
import '@fontsource/roboto/latin.css';

import { createApp } from 'vue';
import { createPinia } from 'pinia';
import { createPinia, storeToRefs } from 'pinia';
import {
RiAddFill,
RiAlertLine,
Expand All @@ -30,8 +30,12 @@ import {
} from '@rotki/ui-library';
import App from '@/App.vue';
import router from '@/router';
import { useCounterStore } from '@/stores/counter';

const app = createApp(App);

app.use(createPinia());
const { itemsPerPage } = storeToRefs(useCounterStore());
const RuiPlugin = createRui({
theme: {
icons: [
Expand All @@ -58,9 +62,14 @@ const RuiPlugin = createRui({
RiArrowDownCircleLine,
],
},
defaults: {
table: {
itemsPerPage,
globalItemsPerPage: false,
},
},
});

app.use(createPinia());
app.use(router);
app.use(RuiPlugin);

Expand Down
4 changes: 3 additions & 1 deletion example/src/stores/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ export const useCounterStore = defineStore('counter', () => {
count.value++;
}

return { count, doubleCount, increment };
const itemsPerPage = ref(15);

return { count, doubleCount, increment, itemsPerPage };
});

0 comments on commit adaf47c

Please sign in to comment.