hoda-react
Version:
<div align="center"> <h1>:construction: flowbite-react (unreleased) :construction:</h1> <p> <a href="https://flowbite-react.com"> <img alt="Flowbite - Tailwind CSS components" width="350" src=".github/assets/flowbite-react-github.png"> <
28 lines (27 loc) • 1.23 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import classNames from 'classnames';
import { useState } from 'react';
import { useTheme } from '../Flowbite/ThemeContext';
import { ToastContext } from './ToastContext';
import { ToastToggle } from './ToastToggle';
const durationClasses = {
75: 'duration-75',
100: 'duration-100',
150: 'duration-150',
200: 'duration-200',
300: 'duration-300',
500: 'duration-500',
700: 'duration-700',
1000: 'duration-1000',
};
const ToastComponent = ({ children, duration = 300, className, ...props }) => {
const [isClosed, setIsClosed] = useState(false);
const [isRemoved, setIsRemoved] = useState(false);
const theme = useTheme().theme.toast;
return (_jsx(ToastContext.Provider, { value: { duration, isClosed, isRemoved, setIsClosed, setIsRemoved }, children: _jsx("div", { "data-testid": "flowbite-toast", className: classNames(theme.base, durationClasses[duration], { [theme.closed]: isClosed }, { [theme.removed]: isRemoved }, className), ...props, children: children }) }));
};
ToastComponent.displayName = 'Toast';
ToastToggle.displayName = 'Toast.Toggle';
export const Toast = Object.assign(ToastComponent, {
Toggle: ToastToggle,
});