fix toast display and auto-dismiss

- Wrap toast message in span for proper text rendering
- Use setTimeout instead of mosis.timer for auto-dismiss
- Remove unsupported CSS animation property
- Add explicit color to toast variants
- Change px to dp units for RmlUi compatibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-20 11:45:02 +01:00
parent 07896959ce
commit 17f605cf5f
2 changed files with 13 additions and 11 deletions

View File

@@ -227,14 +227,13 @@ function showToast(message, type)
class = "toast toast-warning" class = "toast toast-warning"
end end
-- Add toast element -- Clear existing toasts and add new one
local toast_html = '<div class="' .. class .. '">' .. message .. '</div>' local toast_html = '<div class="' .. class .. '"><span>' .. message .. '</span></div>'
container.inner_rml = container.inner_rml .. toast_html container.inner_rml = toast_html
-- Auto-remove after 3 seconds (would need timer API) -- Auto-remove after 3 seconds
if mosis and mosis.timer then if setTimeout then
mosis.timer.setTimeout(function() setTimeout(function()
-- Remove first toast
container.inner_rml = "" container.inner_rml = ""
end, 3000) end, 3000)
end end

View File

@@ -113,24 +113,27 @@
.toast { .toast {
background-color: #323232; background-color: #323232;
color: #FFFFFF; color: #FFFFFF;
padding: 14px 24px; padding: 14dp 24dp;
border-radius: 8px; border-radius: 8dp;
font-size: 14px; font-size: 14dp;
text-align: center; text-align: center;
pointer-events: auto; pointer-events: auto;
animation: toast-in 0.3s ease-out; width: auto;
} }
.toast-success { .toast-success {
background-color: #4CAF50; background-color: #4CAF50;
color: #FFFFFF;
} }
.toast-error { .toast-error {
background-color: #F44336; background-color: #F44336;
color: #FFFFFF;
} }
.toast-warning { .toast-warning {
background-color: #FF9800; background-color: #FF9800;
color: #000000;
} }
@keyframes toast-in { @keyframes toast-in {