Skip to content

Commit

Permalink
Merge pull request #195 from OnroerendErfgoed/feature/105_no_rows_ove…
Browse files Browse the repository at this point in the history
…rlay_component

Feature/105 no rows overlay component
  • Loading branch information
wouter-adriaens authored Jan 12, 2024
2 parents 48af99b + 66b7953 commit 624b26d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/__tests__/NoRowsOverlay.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { defineComponent } from 'vue';
import NoRowsOverlay from '@/components/dumb/NoRowsOverlay.vue';

describe('NoRowsOverlay', () => {
const TestComponent = defineComponent({
components: { NoRowsOverlay },
data: () => {
return {
params: {
noRowsMessage: 'No rows available',
},
};
},
template: '<no-rows-overlay :params="params"/>',
});

beforeEach(() => {
cy.mount(TestComponent);
});

it('has a wrapper with class ag-overlay-loading-center', () => {
cy.dataCy('ag-overlay').should('have.class', 'ag-overlay-loading-center');
});

it('renders a warning icon', () => {
cy.dataCy('warning-icon').should('exist').should('have.attr', 'data-icon', 'circle-exclamation');
});

it('renders the given no rows message', () => {
cy.dataCy('ag-overlay').invoke('text').should('contain', 'No rows available');
});
});
12 changes: 12 additions & 0 deletions src/components/dumb/NoRowsOverlay.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<div data-cy="ag-overlay" class="ag-overlay-loading-center">
<font-awesome-icon data-cy="warning-icon" :icon="['fas', 'circle-exclamation']" />
{{ props.params.noRowsMessage }}
</div>
</template>

<script setup lang="ts">
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
const props = defineProps<{ params: { noRowsMessage: string } }>();
</script>
2 changes: 2 additions & 0 deletions src/components/dumb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import FilterRadio from './FilterRadio.vue';
import FilterSelect from './FilterSelect.vue';
import FilterText from './FilterText.vue';
import InputPhone from './InputPhone.vue';
import NoRowsOverlay from './NoRowsOverlay.vue';
import OeAutocomplete from './OeAutocomplete.vue';
import OeButton from './OeButton.vue';
import OeContainer from './OeContainer.vue';
Expand All @@ -24,6 +25,7 @@ export {
FilterSelect,
FilterText,
InputPhone,
NoRowsOverlay,
OeAutocomplete,
OeButton,
OeContainer,
Expand Down
21 changes: 21 additions & 0 deletions src/stories/dumb-components/no-rows-overlay.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import NoRowsOverlay from '@components/dumb/NoRowsOverlay.vue';
import type { Meta, StoryObj } from '@storybook/vue3';

const meta: Meta<typeof NoRowsOverlay> = {
title: 'Dumb components/NoRowsOverlay',
component: NoRowsOverlay,
tags: ['autodocs'],
argTypes: {
params: { control: 'object' },
},
args: {
params: {
noRowsMessage: 'No rows available',
},
},
};

export default meta;
type Story = StoryObj<typeof NoRowsOverlay>;

export const Default: Story = {};

0 comments on commit 624b26d

Please sign in to comment.