Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

Commit

Permalink
feat(Alert): can customise transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputerM committed Aug 8, 2020
1 parent d6f84da commit 9f129b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions __tests__/Alert/spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, fireEvent } from '@testing-library/svelte';
import { render, fireEvent, waitFor } from '@testing-library/svelte';
import Alert from '@s/components/Alert';
import html from 'svelte-htm';

Expand Down Expand Up @@ -32,7 +32,8 @@ describe('Alert', () => {
expect(mock).not.toBeCalled();

await fireEvent.click(dismissBtn);
await waitFor(() => expect(alert).not.toBeInTheDocument());

expect(alert).not.toBeInTheDocument();
expect(mock).toHaveBeenCalledTimes(1);
});
});
6 changes: 5 additions & 1 deletion src/components/Alert/Alert.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<script>
import { createEventDispatcher } from 'svelte';
import { fade } from 'svelte/transition';
const dispatch = createEventDispatcher();
import Button from '../Button/Button.svelte';
let classes = '';
export let visible = true;
export let transition = fade;
export let transitionOpts = {};
export let dense = false;
export let outlined = false;
export let text = false;
Expand All @@ -32,6 +35,7 @@
<div
role="alert"
class="s-alert {classes}"
transition:transition={transitionOpts}
class:dense
class:outlined
class:text
Expand All @@ -43,7 +47,7 @@
</div>
{#if dismissible}
<Button icon on:click={dismiss}>
<slot name="closeIcon">✖</slot>
<slot name="close">✖</slot>
</Button>
{/if}
{#if border}
Expand Down

0 comments on commit 9f129b8

Please sign in to comment.