feat: added server and web base code
This commit is contained in:
2
packages/web/src/components/mod.rs
Normal file
2
packages/web/src/components/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
// AUTOGENERATED Components module
|
||||
pub mod toast;
|
||||
15
packages/web/src/components/toast/component.rs
Normal file
15
packages/web/src/components/toast/component.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_primitives::toast::{self, ToastProviderProps};
|
||||
|
||||
#[component]
|
||||
pub fn ToastProvider(props: ToastProviderProps) -> Element {
|
||||
rsx! {
|
||||
document::Link { rel: "stylesheet", href: asset!("./style.css") }
|
||||
toast::ToastProvider {
|
||||
default_duration: props.default_duration,
|
||||
max_toasts: props.max_toasts,
|
||||
render_toast: props.render_toast,
|
||||
{props.children}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
packages/web/src/components/toast/mod.rs
Normal file
2
packages/web/src/components/toast/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
mod component;
|
||||
pub use component::*;
|
||||
185
packages/web/src/components/toast/style.css
Normal file
185
packages/web/src/components/toast/style.css
Normal file
@@ -0,0 +1,185 @@
|
||||
.toast-container {
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
right: 20px;
|
||||
bottom: 20px;
|
||||
max-width: 350px;
|
||||
}
|
||||
|
||||
.toast-list {
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.toast-item {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.toast {
|
||||
z-index: calc(var(--toast-count) - var(--toast-index));
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
width: 18rem;
|
||||
height: 4rem;
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--light, var(--primary-color-6))
|
||||
var(--dark, var(--primary-color-7));
|
||||
border-radius: 0.5rem;
|
||||
margin-top: -4rem;
|
||||
box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
|
||||
filter: var(--light, none)
|
||||
var(
|
||||
--dark,
|
||||
brightness(calc(0.5 + 0.5 * (1 - ((var(--toast-index) + 1) / 4))))
|
||||
);
|
||||
opacity: calc(1 - var(--toast-hidden));
|
||||
transform: scale(
|
||||
calc(100% - var(--toast-index) * 5%),
|
||||
calc(100% - var(--toast-index) * 2%)
|
||||
);
|
||||
transition: transform 0.2s ease, margin-top 0.2s ease, opacity 0.2s ease;
|
||||
|
||||
--toast-hidden: calc(min(max(0, var(--toast-index) - 2), 1));
|
||||
}
|
||||
|
||||
.toast-container:not(:hover, :focus-within)
|
||||
.toast[data-toast-even]:not([data-top]) {
|
||||
animation: slide-up-even 0.2s ease-out;
|
||||
}
|
||||
|
||||
.toast-container:not(:hover, :focus-within)
|
||||
.toast[data-toast-odd]:not([data-top]) {
|
||||
animation: slide-up-odd 0.2s ease-out;
|
||||
}
|
||||
|
||||
@keyframes slide-up-even {
|
||||
from {
|
||||
transform: translateY(0.5rem)
|
||||
scale(
|
||||
calc(100% - var(--toast-index) * 5%),
|
||||
calc(100% - var(--toast-index) * 2%)
|
||||
);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: translateY(0)
|
||||
scale(
|
||||
calc(100% - var(--toast-index) * 5%),
|
||||
calc(100% - var(--toast-index) * 2%)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slide-up-odd {
|
||||
from {
|
||||
transform: translateY(0.5rem)
|
||||
scale(
|
||||
calc(100% - var(--toast-index) * 5%),
|
||||
calc(100% - var(--toast-index) * 2%)
|
||||
);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: translateY(0)
|
||||
scale(
|
||||
calc(100% - var(--toast-index) * 5%),
|
||||
calc(100% - var(--toast-index) * 2%)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
.toast[data-top] {
|
||||
animation: slide-in 0.2s ease-out;
|
||||
}
|
||||
|
||||
.toast-container:hover .toast[data-top],
|
||||
.toast-container:focus-within .toast[data-top] {
|
||||
animation: slide-in 0 ease-out;
|
||||
}
|
||||
|
||||
@keyframes slide-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(100%)
|
||||
scale(
|
||||
calc(110% - var(--toast-index) * 5%),
|
||||
calc(110% - var(--toast-index) * 2%)
|
||||
);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0)
|
||||
scale(
|
||||
calc(100% - var(--toast-index) * 5%),
|
||||
calc(100% - var(--toast-index) * 2%)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
.toast-container:hover .toast,
|
||||
.toast-container:focus-within .toast {
|
||||
margin-top: var(--toast-padding);
|
||||
filter: brightness(1);
|
||||
opacity: 1;
|
||||
transform: scale(calc(100%));
|
||||
}
|
||||
|
||||
.toast[data-type="success"] {
|
||||
background-color: var(--primary-success-color);
|
||||
color: var(--secondary-success-color);
|
||||
}
|
||||
|
||||
.toast[data-type="error"] {
|
||||
background-color: var(--primary-error-color);
|
||||
color: var(--contrast-error-color);
|
||||
}
|
||||
|
||||
.toast[data-type="warning"] {
|
||||
background-color: var(--primary-warning-color);
|
||||
color: var(--secondary-warning-color);
|
||||
}
|
||||
|
||||
.toast[data-type="info"] {
|
||||
background-color: var(--primary-info-color);
|
||||
color: var(--secondary-info-color);
|
||||
}
|
||||
|
||||
.toast-content {
|
||||
flex: 1;
|
||||
margin-right: 8px;
|
||||
transition: filter 0.2s ease;
|
||||
}
|
||||
|
||||
.toast-title {
|
||||
margin-bottom: 4px;
|
||||
color: var(--secondary-color-4);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.toast-description {
|
||||
color: var(--secondary-color-3);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.toast-close {
|
||||
align-self: flex-start;
|
||||
padding: 0;
|
||||
border: none;
|
||||
margin: 0;
|
||||
background: none;
|
||||
color: var(--secondary-color-3);
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.toast-close:hover {
|
||||
color: var(--secondary-color-1);
|
||||
}
|
||||
Reference in New Issue
Block a user