primevue-mirror/components/lib/toast/style/ToastStyle.js

287 lines
8.4 KiB
JavaScript
Raw Normal View History

import BaseStyle from 'primevue/base/style';
const theme = ({ dt }) => `
.p-toast {
2024-05-09 15:22:29 +00:00
width: ${dt('toast.width')};
white-space: pre-line;
word-break: break-word;
}
.p-toast-message {
backdrop-filter: blur(${dt('toast.blur')});
margin: 0 0 1rem 0;
2024-05-09 15:22:29 +00:00
border-radius: ${dt('toast.border.radius')};
2024-05-09 15:48:00 +00:00
border-width: ${dt('toast.border.width')};
border-style: solid;
}
.p-toast-message-icon {
flex-shrink: 0;
2024-05-09 15:22:29 +00:00
font-size: ${dt('toast.icon.size')};
width: ${dt('toast.icon.size')};
height: ${dt('toast.icon.size')};
}
.p-toast-message-content {
display: flex;
align-items: flex-start;
2024-05-09 15:22:29 +00:00
padding: ${dt('toast.content.padding')};
gap: ${dt('toast.content.gap')};
}
.p-toast-message-text {
flex: 1 1 auto;
2024-05-09 15:22:29 +00:00
display: flex;
flex-direction: column;
gap: ${dt('toast.text.gap')};
}
2024-05-14 22:14:43 +00:00
.p-toast-summary {
2024-05-09 15:22:29 +00:00
font-weight: ${dt('toast.summary.font.weight')};
font-size: ${dt('toast.summary.font.size')};
}
2024-05-09 15:22:29 +00:00
.p-toast-detail {
2024-05-09 15:22:29 +00:00
font-weight: ${dt('toast.detail.font.weight')};
font-size: ${dt('toast.detail.font.size')};
}
.p-toast-close-button {
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
position: relative;
cursor: pointer;
background: transparent;
2024-05-09 15:22:29 +00:00
transition: background ${dt('transition.duration')}, color ${dt('transition.duration')}, outline-color ${dt('transition.duration')}, box-shadow ${dt('transition.duration')};
outline-color: transparent;
color: inherit;
2024-05-09 15:22:29 +00:00
width: ${dt('toast.close.button.width')};
height: ${dt('toast.close.button.height')};
border-radius: ${dt('toast.close.button.border.radius')};
margin: -25% 0 0 0;
right: -25%;
padding: 0;
border: none;
user-select: none;
}
2024-05-09 15:22:29 +00:00
.p-toast-close-icon {
font-size: ${dt('toast.close.icon.size')};
width: ${dt('toast.close.icon.size')};
height: ${dt('toast.close.icon.size')};
}
.p-toast-close-button:focus-visible {
outline-width: ${dt('focus.ring.width')};
outline-style: ${dt('focus.ring.style')};
outline-offset: ${dt('focus.ring.offset')};
}
.p-toast-message-info {
background: ${dt('toast.info.background')};
2024-05-09 15:48:00 +00:00
border-color: ${dt('toast.info.border.color')};
color: ${dt('toast.info.color')};
2024-05-06 21:23:42 +00:00
box-shadow: ${dt('toast.info.shadow')};
}
.p-toast-message-info .p-toast-detail {
color: ${dt('toast.info.detail.color')};
}
.p-toast-message-info .p-toast-close-button:focus-visible {
2024-05-09 15:22:29 +00:00
outline-color: ${dt('toast.info.close.button.focus.ring.color')};
box-shadow: ${dt('toast.info.close.button.focus.ring.shadow')};
}
.p-toast-message-info .p-toast-close-button:hover {
2024-05-04 12:23:26 +00:00
background: ${dt('toast.info.close.button.hover.background')};
}
.p-toast-message-success {
background: ${dt('toast.success.background')};
2024-05-09 15:48:00 +00:00
border-color: ${dt('toast.success.border.color')};
color: ${dt('toast.success.color')};
2024-05-06 21:23:42 +00:00
box-shadow: ${dt('toast.success.shadow')};
}
.p-toast-message-success .p-toast-detail {
color: ${dt('toast.success.detail.color')};
}
.p-toast-message-success .p-toast-close-button:focus-visible {
2024-05-09 15:22:29 +00:00
outline-color: ${dt('toast.success.close.button.focus.ring.color')};
box-shadow: ${dt('toast.success.close.button.focus.ring.shadow')};
}
.p-toast-message-success .p-toast-close-button:hover {
2024-05-04 12:23:26 +00:00
background: ${dt('toast.success.close.button.hover.background')};
}
.p-toast-message-warn {
background: ${dt('toast.warn.background')};
2024-05-09 15:48:00 +00:00
border-color: ${dt('toast.warn.border.color')};
color: ${dt('toast.warn.color')};
2024-05-06 21:23:42 +00:00
box-shadow: ${dt('toast.warn.shadow')};
}
.p-toast-message-warn .p-toast-detail {
color: ${dt('toast.warn.detail.color')};
}
.p-toast-message-warn .p-toast-close-button:focus-visible {
2024-05-09 15:22:29 +00:00
outline-color: ${dt('toast.warn.close.button.focus.ring.color')};
box-shadow: ${dt('toast.warn.close.button.focus.ring.shadow')};
}
.p-toast-message-warn .p-toast-close-button:hover {
2024-05-04 12:23:26 +00:00
background: ${dt('toast.warn.close.button.hover.background')};
}
.p-toast-message-error {
background: ${dt('toast.error.background')};
2024-05-09 15:48:00 +00:00
border-color: ${dt('toast.error.border.color')};
color: ${dt('toast.error.color')};
2024-05-06 21:23:42 +00:00
box-shadow: ${dt('toast.error.shadow')};
}
.p-toast-message-error .p-toast-detail {
color: ${dt('toast.error.detail.color')};
}
.p-toast-message-error .p-toast-close-button:focus-visible {
2024-05-09 15:22:29 +00:00
outline-color: ${dt('toast.error.close.button.focus.ring.color')};
box-shadow: ${dt('toast.error.close.button.focus.ring.shadow')};
}
.p-toast-message-error .p-toast-close-button:hover {
2024-05-04 12:23:26 +00:00
background: ${dt('toast.error.close.button.hover.background')};
}
.p-toast-message-secondary {
background: ${dt('toast.secondary.background')};
2024-05-09 15:48:00 +00:00
border-color: ${dt('toast.secondary.border.color')};
color: ${dt('toast.secondary.color')};
2024-05-06 21:23:42 +00:00
box-shadow: ${dt('toast.secondary.shadow')};
}
.p-toast-message-secondary .p-toast-detail {
color: ${dt('toast.secondary.detail.color')};
}
.p-toast-message-secondary .p-toast-close-button:focus-visible {
2024-05-09 15:22:29 +00:00
outline-color: ${dt('toast.secondary.close.button.focus.ring.color')};
box-shadow: ${dt('toast.secondary.close.button.focus.ring.shadow')};
}
.p-toast-message-secondary .p-toast-close-button:hover {
2024-05-04 12:23:26 +00:00
background: ${dt('toast.secondary.close.button.hover.background')};
}
.p-toast-message-contrast {
background: ${dt('toast.contrast.background')};
2024-05-09 15:48:00 +00:00
border-color: ${dt('toast.contrast.border.color')};
color: ${dt('toast.contrast.color')};
2024-05-06 21:23:42 +00:00
box-shadow: ${dt('toast.contrast.shadow')};
}
.p-toast-message-contrast .p-toast-detail {
color: ${dt('toast.contrast.detail.color')};
}
.p-toast-message-contrast .p-toast-close-button:focus-visible {
2024-05-09 15:22:29 +00:00
outline-color: ${dt('toast.contrast.close.button.focus.ring.color')};
box-shadow: ${dt('toast.contrast.close.button.focus.ring.shadow')};
}
.p-toast-message-contrast .p-toast-close-button:hover {
2024-05-04 12:23:26 +00:00
background: ${dt('toast.contrast.close.button.hover.background')};
}
.p-toast-top-center {
transform: translateX(-50%);
}
.p-toast-bottom-center {
transform: translateX(-50%);
}
.p-toast-center {
min-width: 20vw;
transform: translate(-50%, -50%);
}
.p-toast-message-enter-from {
opacity: 0;
transform: translateY(50%);
}
.p-toast-message-leave-from {
max-height: 1000px;
}
.p-toast .p-toast-message.p-toast-message-leave-to {
max-height: 0;
opacity: 0;
margin-bottom: 0;
overflow: hidden;
}
.p-toast-message-enter-active {
transition: transform 0.3s, opacity 0.3s;
}
.p-toast-message-leave-active {
transition: max-height 0.45s cubic-bezier(0, 1, 0, 1), opacity 0.3s, margin-bottom 0.3s;
}
`;
// Position
const inlineStyles = {
root: ({ position }) => ({
position: 'fixed',
top: position === 'top-right' || position === 'top-left' || position === 'top-center' ? '20px' : position === 'center' ? '50%' : null,
right: (position === 'top-right' || position === 'bottom-right') && '20px',
bottom: (position === 'bottom-left' || position === 'bottom-right' || position === 'bottom-center') && '20px',
left: position === 'top-left' || position === 'bottom-left' ? '20px' : position === 'center' || position === 'top-center' || position === 'bottom-center' ? '50%' : null
})
};
const classes = {
root: ({ props }) => ['p-toast p-component p-toast-' + props.position],
2024-04-30 08:15:34 +00:00
message: ({ props }) => [
'p-toast-message',
{
'p-toast-message-info': props.message.severity === 'info' || props.message.severity === undefined,
'p-toast-message-warn': props.message.severity === 'warn',
'p-toast-message-error': props.message.severity === 'error',
'p-toast-message-success': props.message.severity === 'success',
'p-toast-message-secondary': props.message.severity === 'secondary',
'p-toast-message-contrast': props.message.severity === 'contrast'
}
],
2024-04-30 08:15:34 +00:00
messageContent: 'p-toast-message-content',
messageIcon: ({ props }) => [
'p-toast-message-icon',
{
[props.infoIcon]: props.message.severity === 'info',
[props.warnIcon]: props.message.severity === 'warn',
[props.errorIcon]: props.message.severity === 'error',
[props.successIcon]: props.message.severity === 'success'
}
],
2024-04-30 08:15:34 +00:00
messageText: 'p-toast-message-text',
summary: 'p-toast-summary',
detail: 'p-toast-detail',
2024-04-09 09:05:34 +00:00
closeButton: 'p-toast-close-button',
closeIcon: 'p-toast-close-icon'
};
export default BaseStyle.extend({
name: 'toast',
theme,
classes,
inlineStyles
});