1.0.2 • Published 2 years ago

mui-snack-stack v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mui-snack-stack

Shows snackbars one after the other with each disappearing after a timeout.

timeout

Installation

npm install --save mui-snack-stack

or

yarn add mui-snack-stack

Usage

import MuiSnackStack from 'mui-snack-stack';
...

Put <MuiSnackStack /> in a root component.

Use queue from anywhere within your application to show a snackbar or queue a snackbar behind one that is already running.

MuiSnackStack.queue(message, timeout=3000, severity='info', snackbarOrigin={vertical: 'top', horizontal: 'right'})
nametype
messagestring
timeoutnumber
severity'success'|'info'|'warning'|'error'
snackbarOrigin{vertical: 'top'|'bottom; horizontal: 'left'|'center'|'right'}

Single Component Example

import MuiSnackStack from 'mui-snack-stack';
export default () => (
	<>
		<MuiSnackStack />
		<button onClick={() => MuiSnackStack.queue('Layout')}>Show Snackbar</button>
	</>
)

Once MuiSnackStack has been initialized, we can show snackbars from anywhere in the application.

Multiple Components Example

// Layout.jsx
import MuiSnackStack from 'mui-snack-stack';
import Content from './Content';
import Sidebar from './Sidebar';
export default () => (
	<>
		<MuiSnackStack />
		<Sidebar />
		<Content />
	</>
);
// Content.jsx
import MuiSnackStack from 'mui-snack-stack';
export default () => (
	<button onClick={() => MuiSnackStack.queue('content')}>Show Snackbar</button>
);
// Sidebar.jsx
import MuiSnackStack from 'mui-snack-stack';
export default () => (
	<button onClick={() => MuiSnackStack.queue('sidebar')}>Show Snackbar</button>
);
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-7

2 years ago

1.0.0-6

2 years ago

1.0.0-5

2 years ago