component-library-mustafa-akagunduz
Version:
Air Command System projesi için geliştirilmiş React component kütüphanesi
3 lines (2 loc) • 2.42 kB
JavaScript
import{jsxs as t,jsx as e}from"react/jsx-runtime";import{useState as s,useEffect as i}from"react";const l=({toast:l,onRemove:a})=>{const[o,n]=s(!1);i(()=>{setTimeout(()=>n(!0),10)},[]);if("success"!==l.type&&"error"!==l.type)return null;const r=l.message&&l.message.length>50;return t("div",{className:`toast-item toast-${l.type} ${o?"toast-visible":""} ${r?"toast-multiline":""}`,children:[(()=>{switch(l.type){case"success":return e("div",{className:"toast-icon",children:e("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e("path",{d:"M10 0C15.523 0 20 4.477 20 10C20 15.523 15.523 20 10 20C4.477 20 0 15.523 0 10C0 4.477 4.477 0 10 0ZM13.535 6.381L8.585 11.331L6.465 9.21C6.37216 9.11709 6.26192 9.04338 6.14059 8.99307C6.01926 8.94276 5.8892 8.91684 5.75785 8.9168C5.49258 8.9167 5.23814 9.02199 5.0505 9.2095C4.86286 9.39701 4.75739 9.65138 4.7573 9.91665C4.7572 10.1819 4.86249 10.4364 5.05 10.624L7.808 13.382C7.91015 13.4842 8.03144 13.5653 8.16493 13.6206C8.29842 13.6759 8.4415 13.7044 8.586 13.7044C8.7305 13.7044 8.87358 13.6759 9.00707 13.6206C9.14056 13.5653 9.26185 13.4842 9.364 13.382L14.95 7.796C15.1376 7.60836 15.2431 7.35386 15.2431 7.0885C15.2431 6.82314 15.1376 6.56864 14.95 6.381C14.7624 6.19336 14.5079 6.08794 14.2425 6.08794C13.9771 6.08794 13.7226 6.19336 13.535 6.381Z",fill:"white"})})});case"error":return e("div",{className:"toast-icon",children:e("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e("path",{d:"M2.09977 18H17.9002C19.5159 18 20.5231 16.2325 19.7153 14.8249L11.8151 1.05571C11.0072 -0.351904 8.9928 -0.351904 8.18494 1.05571L0.284714 14.8249C-0.523145 16.2325 0.484055 18 2.09977 18ZM10 10.5915C9.42296 10.5915 8.95083 10.1152 8.95083 9.53315V7.41643C8.95083 6.83434 9.42296 6.35808 10 6.35808C10.577 6.35808 11.0492 6.83434 11.0492 7.41643V9.53315C11.0492 10.1152 10.577 10.5915 10 10.5915ZM11.0492 14.8249H8.95083V12.7082H11.0492V14.8249Z",fill:"white"})})});default:return null}})(),t("div",{className:"toast-content",children:[e("div",{className:"toast-title",children:l.title}),l.message&&e("div",{className:"toast-message",children:l.message})]}),e("button",{className:"toast-close",onClick:()=>{n(!1),setTimeout(()=>a(l.id),300)},"aria-label":"Close notification",children:"×"})]})};export{l as ToastItem};
//# sourceMappingURL=ToastItem.js.map