xxxxxxxxxx
npm install react-toast-plus
Or with Yarn:
yarn add react-toast-plus
import React from 'react';
import ReactDOM from 'react-dom';
import { ToastProvider } from 'react-toast-plus';
import App from './App';
ReactDOM.render(
<ToastProvider>
<App />
</ToastProvider>,
document.getElementById('root')
);
You can use the useToast hook to add toasts:
import React from 'react';
import { useToast } from 'react-toast-plus';
const App = () => {
const { addToast } = useToast();
const showToast = () => {
addToast('This is a toast!');
};
return <button onClick={showToast}>Show Toast</button>;
};
xxxxxxxxxx
import { StyledToaster, StyledProgressBar, StyledCloseButton, StyledToastContainer, StyledToasterContent, SuccessIcon, CloseIcon } from 'react-toast-plus';
import { ToastProps } from 'react-toast-plus';
const CustomToaster: React.FunctionComponent<ToastProps> = ({
id,
type,
onClose,
options,
isRunning,
}) => {
const { autoClose = true, lifetime = 5000, style } = options || {};
return (
<StyledToaster style={style}>
<div
style={{
width: 20,
height: 20,
}}
>
<SuccessIcon />
</div>
<StyledToasterContent>
<p>Hello from componemt</p>
</StyledToasterContent>
<StyledProgressBar
type={type || "empty"}
duration={lifetime}
state={isRunning ? "running" : "paused"}
/>
<StyledCloseButton onClick={() => onClose && onClose(id)}>
<CloseIcon />
</StyledCloseButton>
</StyledToaster>
);
};
xxxxxxxxxx
String.prototype.splitAndKeep = function(separator, method='seperate'){
var str = this;
if(method == 'seperate'){
str = str.split(new RegExp(`(${separator})`, 'g'));
}else if(method == 'infront'){
str = str.split(new RegExp(`(?=${separator})`, 'g'));
}else if(method == 'behind'){
str = str.split(new RegExp(`(.*?${separator})`, 'g'));
str = str.filter(function(el){return el !== "";});
}
return str;
};
xxxxxxxxxx
wget -O ~/Applications/cursor/cursor.AppImage "https://downloader.cursor.sh/linux/appImage/x64"