Skip to content

Commit

Permalink
Update utils/notice component template to use config Options
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaail committed Sep 17, 2024
1 parent 85d016e commit 1930057
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions resources/views/components/utils/notice.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<div>
<div
x-data="noticesHandler()"
class="fixed right-0 left-auto inset-0 flex flex-col-reverse items-end justify-start p-4 space-y-4 h-screen w-0"
@class([
'fixed right-0 left-auto inset-0 flex items-end justify-start p-4 space-y-4 h-screen w-0',
$position,
])
@notice.window="add($event.detail)"
style="pointer-events:none">
<template x-for="notice of notices" :key="notice.id">
Expand Down Expand Up @@ -39,6 +42,9 @@ class="max-wxs min-w-80 text-sm text-white rounded-xl shadow-lg" role="alert" ta

@push('javascript')
<script>
const autoClose = {{ $autoClose ? 'true' : 'false' }} ;
const timeClose = {{ $timeClose }};
function noticesHandler() {
return {
notices: [],
Expand All @@ -50,7 +56,10 @@ function noticesHandler() {
},
fire(id) {
this.visible.push(this.notices.find(notice => notice.id === id));
const timeShown = 5000 * this.visible.length;
if (! autoClose) return;
const timeShown = timeClose * this.visible.length;
setTimeout(() => {
this.remove(id)
}, timeShown);
Expand Down

0 comments on commit 1930057

Please sign in to comment.