Skip to content

Commit

Permalink
fix: #177 export visible/autohide
Browse files Browse the repository at this point in the history
  • Loading branch information
jjagielka committed Jul 22, 2022
1 parent 57ad677 commit 2127151
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/toasts/Toast.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Absolute position
export let position: 'tl' | 'tr' | 'bl' | 'br' = undefined; // default not set
let visible = true;
export let visible = true;
const colors = {
blue: 'text-blue-500 bg-blue-100 dark:bg-blue-800 dark:text-blue-200',
Expand Down
52 changes: 52 additions & 0 deletions src/routes/toasts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ layout: toastLayout

let divClass='w-full relative overflow-x-auto shadow-md sm:rounded-lg py-4'
let theadClass ='text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-white'

let show = true;
let counter = 6;

function trigger() {
show = true;
counter = 6;
timeout();
}

function timeout() {
if (--counter > 0)
return setTimeout(timeout, 1000);
show = false;
}
</script>

<Breadcrumb>
Expand Down Expand Up @@ -117,6 +132,43 @@ that if you want no color at all set property to empty string.</p>
<Toast> No icon at all. </Toast>
```

<Htwo label="Autohide example" />

<ExampleDiv>
<div class="flex gap-10">
<Button on:click={trigger} class="my-3">Restart</Button>

<Toast simple transition="slide" bind:visible={show}>
<CheckCircle slot="icon"/> Autohide in {counter}s.
</Toast>
</div>
</ExampleDiv>

```html
<script>
let show = true;
let counter = 6;
function trigger() {
show = true;
counter = 6;
timeout();
}
function timeout() {
if (--counter > 0)
return setTimeout(timeout, 1000);
show = false;
}
</script>

<Button on:click={trigger} class="my-3">Restart</Button>

<Toast simple transition="slide" bind:visible={show}>
<CheckCircle slot="icon"/> Autohide in {counter}s.
</Toast>
```

<Htwo label="Transitions" />

<p>You can use one of <a href="https://svelte.dev/docs#run-time-svelte-easing" target="_blank" >Svelte/easing</a>.</p>
Expand Down

2 comments on commit 2127151

@vercel
Copy link

@vercel vercel bot commented on 2127151 Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 2127151 Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.