pvincent 4 months ago
parent
commit
af2594124c
  1. 50
      app/views/layouts/_notification.html.erb
  2. 2
      config/importmap.rb
  3. 13
      vendor/javascript/notyf.js

50
app/views/layouts/_notification.html.erb

@ -1,44 +1,10 @@
<h2>NOTIFICATION BAR</h2>
<nav class='relative w-full'>
<% if alert.present? %>
<div class="absolute inset-x-0 top-10">
<div class="flex max-w-sm w-full bg-white shadow-md rounded-lg mx-auto">
<div class="w-2 bg-red-600">
</div>
<div class="w-full flex justify-between items-start px-2 py-2">
<div class="flex flex-col ml-2">
<label class="text-gray-800">Alert</label>
<p class="text-gray-500 "><%= alert %></p>
</div>
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
</div>
</div>
<% end %>
<% if notice.present? %>
<div class="absolute inset-x-0 top-50">
<div class="flex max-w-sm w-full bg-white shadow-md rounded-lg overflow-hidden mx-auto">
<div class="w-2 bg-green-600">
</div>
<div class="w-full flex justify-between items-start px-2 py-2">
<div class="flex flex-col ml-2">
<label class="text-gray-800">Notice</label>
<p class="text-gray-500 "><%= notice %></p>
</div>
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
</div>
</div>
<% end %>
</nav>
<% if flash %>
<script type="module">
import { Notyf } from 'notyf';
const notyf=new Notyf
notyf.success('<%=notice%>')
notyf.error('<%=alert%>')
</script>
<%end%>

2
config/importmap.rb

@ -5,3 +5,5 @@ pin '@hotwired/turbo-rails', to: 'turbo.min.js', preload: true
pin '@hotwired/stimulus', to: 'stimulus.min.js'
pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js'
pin_all_from 'app/javascript/controllers', under: 'controllers'
pin 'notyf' # @3.10.0

13
vendor/javascript/notyf.js
File diff suppressed because it is too large
View File

Loading…
Cancel
Save