toasts container styles applied through props

This commit is contained in:
nklhrstv 2020-01-31 23:28:19 +02:00
parent a20f6a4e24
commit c2db27d938
5 changed files with 21 additions and 14 deletions

View file

@ -51,7 +51,7 @@ const App = () => {
<ServicesProvider services={services}>
{
shellInitialized && coreInitialized ?
<ToastsContainerProvider>
<ToastsContainerProvider className={styles['toasts-container']}>
<Router
className={styles['router']}
homePath={'/'}

View file

@ -72,6 +72,22 @@ html {
width: 100%;
height: 100%;
.toasts-container {
position: absolute;
top: calc(1.2 * var(--nav-bar-size));
right: var(--nav-bar-size);
bottom: calc(1.2 * var(--nav-bar-size));
left: auto;
z-index: 0;
overflow-y: auto;
scrollbar-width: none;
pointer-events: none;
&::-webkit-scrollbar {
width: var(--scroll-bar-width);
}
}
.router {
width: 100%;
height: 100%;

View file

@ -1,6 +1,6 @@
const React = require('react');
const { Modal } = require('stremio-router');
const ModalsContainerContext = require('stremio-router/ModalsContainerContext/ModalsContainerContext');
const { ModalsContainerContext } = require('stremio-router');
const { useToastsContainer } = require('./ToastsContainerContext');
const Toast = require('./Toast');

View file

@ -1,19 +1,19 @@
const React = require('react');
const PropTypes = require('prop-types');
const ToastsContainerContext = require('./ToastsContainerContext');
const styles = require('./styles');
const ToastsContainerProvider = ({ children }) => {
const ToastsContainerProvider = ({ className, children }) => {
const [container, setContainer] = React.useState(null);
return (
<ToastsContainerContext.Provider value={container}>
{container instanceof HTMLElement ? children : null}
<div ref={setContainer} className={styles['toasts-container']} />
<div ref={setContainer} className={className} />
</ToastsContainerContext.Provider>
);
};
ToastsContainerProvider.propTypes = {
className: PropTypes.string,
children: PropTypes.node
};

View file

@ -1,9 +0,0 @@
.toasts-container {
position: absolute;
top: var(--nav-bar-size);
right: 0;
bottom: 0;
left: auto !important;
z-index: 0;
pointer-events: none;
}