mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 09:41:01 +08:00
552cf56afe
- more subtle animation when showing a toast - resumes auto close when removing the mouse from the toast - correctly follows reduced motion - uses output with role status as element: https://web.dev/articles/building/a-toast-component - shows toasts inside a section element - prevents toast to all have the same width - fixes a bug on mobile where we would limit the width and the close button wouldn't show correctly aligned I would prefer to have tests for this, but the conjunction of css/animations and our helper changing `discourseLater` to 0 in tests is making it quite challenging for a rather low value. We have system specs using toasts ensuring they show when they should.
60 lines
1.0 KiB
SCSS
60 lines
1.0 KiB
SCSS
@keyframes d-toast-opening {
|
|
from {
|
|
transform: translateY(var(--transform-y, 10px));
|
|
}
|
|
}
|
|
|
|
.fk-d-toasts {
|
|
--transform-y: 0;
|
|
|
|
position: fixed;
|
|
top: 5px;
|
|
right: 5px;
|
|
z-index: z("max");
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 5px 0;
|
|
flex: 1 1 auto;
|
|
|
|
.mobile-view & {
|
|
left: 5px;
|
|
}
|
|
|
|
.fk-d-toast {
|
|
box-sizing: border-box;
|
|
opacity: 1;
|
|
transition: opacity 0.5s;
|
|
border-radius: var(--d-border-radius);
|
|
overflow: hidden;
|
|
background-color: var(--secondary);
|
|
border: 1px solid var(--primary-low);
|
|
box-shadow: var(--shadow-menu-panel);
|
|
overflow-wrap: break-word;
|
|
display: flex;
|
|
animation: d-toast-opening 0.3s ease-in-out;
|
|
will-change: transform;
|
|
|
|
.desktop-view & {
|
|
margin-left: auto;
|
|
}
|
|
|
|
&:hover {
|
|
border-color: var(--primary-300);
|
|
}
|
|
|
|
&.-fade-out {
|
|
opacity: 0;
|
|
}
|
|
|
|
& + .d-toast {
|
|
margin-top: 0.25rem;
|
|
}
|
|
}
|
|
}
|
|
|
|
@media (prefers-reduced-motion: no-preference) {
|
|
.fk-d-toasts {
|
|
--transform-y: 2vh;
|
|
}
|
|
}
|