pvincent 7 months ago
parent
commit
283572d1dc
  1. 4
      app/views/layouts/_notification.html.erb
  2. 2
      app/views/layouts/application.html.erb
  3. 68
      app/views/layouts/toaster/_toaster.html.erb
  4. 4
      lib/formatters/basic_formatter.rb

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

@ -9,8 +9,8 @@
offset: { y: '1em' },
close: true
}
const notice={ className: 'toastify-notice text-black', ...common }
const alert={ className: 'text-black toastify-alert', ...common }
const notice={ className: 'toastify-notice', ...common }
const alert={ className: 'toastify-alert', ...common }
<% if flash.notice%>
Toastify({ text: '<%=flash.notice%>', ...notice}).showToast();

2
app/views/layouts/application.html.erb

@ -19,7 +19,7 @@
<body>
<%=render '/layouts/notification' %>
<%=render 'layouts/notification' %>
<main class="m-8 flex flex-col">
<%= yield %>

68
app/views/layouts/toaster/_toaster.html.erb

@ -1,68 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#snackbar {
visibility: hidden;
min-width: 250px;
margin-left: -125px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 2px;
padding: 16px;
position: fixed;
z-index: 1;
left: 50%;
top: 30px;
font-size: 17px;
}
#snackbar.show {
visibility: visible;
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
animation: fadein 0.5s, fadeout 0.5s 2.5s;
}
@-webkit-keyframes fadein {
from {top: 0; opacity: 0;}
to {top: 30px; opacity: 1;}
}
@keyframes fadein {
from {top: 0; opacity: 0;}
to {top: 30px; opacity: 1;}
}
@-webkit-keyframes fadeout {
from {top: 30px; opacity: 1;}
to {top: 0; opacity: 0;}
}
@keyframes fadeout {
from {top: 30px; opacity: 1;}
to {top: 0; opacity: 0;}
}
</style>
</head>
<body>
<h2>Snackbar / Toast</h2>
<p>Snackbars are often used as a tooltips/popups to show a message at the bottom of the screen.</p>
<p>Click on the button to show the snackbar. It will disappear after 3 seconds.</p>
<button onclick="myFunction()">Show Snackbar</button>
<div id="snackbar">Some text some message..</div>
<script>
function myFunction() {
var x = document.getElementById("snackbar");
x.className = "show";
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
}
</script>
</body>
</html>

4
lib/formatters/basic_formatter.rb

@ -210,7 +210,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri
def wrap_message(message)
message, space_prefix = split_spaces_in_front(message)
message = Wrapper.wrap("#{CONTENT_COLOR_MAP[log.level]}#{message}",
before_message(wrapped: true) + space_prefix.to_s,
before_message(true) + space_prefix.to_s,
compute_useful_length - space_prefix.length)
"#{space_prefix}#{message}"
end
@ -226,7 +226,7 @@ class BasicFormatter < SemanticLogger::Formatters::Color # rubocop:disable Metri
100 # FIXME: CONSTANTIZE, only useful in DEBUGGER, no IO.console detected!
end
def before_message(wrapped: false)
def before_message(wrapped = false)
[name, wrapped ? continuation : level, tags, named_tags, duration].compact.join(' ') + CONTENT_PREFIX
end

Loading…
Cancel
Save