@servosinformatica/resources
Version:
Resources to Servos Informatica's apps
157 lines (150 loc) • 4.04 kB
JavaScript
import React from 'react';
import { useMediaQuery } from 'react-responsive';
import { Button } from 'react-bootstrap';
const SplashScreen = ({
videoSrc,
onEnd,
background
}) => {
const isMobile = useMediaQuery({
maxWidth: 480
});
const isTablet = useMediaQuery({
minWidth: 481,
maxWidth: 768
});
const percentage = isMobile ? '80%' : isTablet ? '70%' : '50%';
const styleOverlay = {
position: 'fixed',
top: '0',
left: '0',
width: '100%',
height: '100%',
backgroundColor: background,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: '9999',
overflow: 'hidden'
};
const styleVideo = {
maxWidth: percentage,
maxHeight: percentage
};
return /*#__PURE__*/React.createElement("div", {
style: styleOverlay
}, /*#__PURE__*/React.createElement("video", {
style: styleVideo,
autoPlay: true,
muted: true,
playsInline: true,
onEnded: onEnd
}, /*#__PURE__*/React.createElement("source", {
src: videoSrc,
type: "video/mp4"
}), "Your browser does not support videos."));
};
const OrdinaryButton = ({
disabled = false,
isLoading = false,
icon,
onClick,
children,
variant,
type = 'button',
href,
className
}) => {
return /*#__PURE__*/React.createElement(Button, {
onClick: onClick,
disabled: disabled ? disabled : isLoading,
variant: variant,
className: className,
type: type,
href: href
}, isLoading ? /*#__PURE__*/React.createElement("span", {
className: "spinner-border spinner-border-sm",
role: "status"
}) : /*#__PURE__*/React.createElement("i", {
className: `bi bi-${icon}`
}), children);
};
const LoginButton = ({
isLoading = false,
onClick,
provedor = 'github'
}) => {
let icon;
let vari;
let text;
switch (provedor) {
case "google":
icon = "google";
vari = "primary";
text = "Entrar com Google";
break;
case "mail":
icon = "envelope";
vari = "warning";
text = "Entrar com Email";
break;
case "logout":
icon = "power";
vari = "danger";
text = "Logout";
break;
default:
icon = "github";
vari = "dark";
text = "Entrar com Github";
}
return /*#__PURE__*/React.createElement(OrdinaryButton, {
icon: icon,
isLoading: isLoading,
onClick: onClick,
variant: vari,
className: "d-flex align-items-center justify-content-center gap-2 w-100"
}, text);
};
const ShowError = message => {
const styleElement = document.createElement('style');
styleElement.type = 'text/css';
// Define os @keyframes
styleElement.innerHTML = `
@keyframes snackIn {
from { bottom: 0; opacity: 0; }
to { bottom: 30px; opacity: 1; }
}
@keyframes snackOut {
from { bottom: 30px; opacity: 1; }
to { bottom: 0; opacity: 0; }
}
`;
document.head.appendChild(styleElement);
// Cria novo snackbar
const existing = document.getElementById('global-snackbar');
if (existing) existing.remove();
const snackbar = document.createElement('div');
snackbar.id = 'global-snackbar';
snackbar.innerHTML = message;
snackbar.style.minWidth = '210px';
snackbar.style.backgroundColor = '#630d03';
snackbar.style.color = 'white';
snackbar.style.textAlign = 'center';
snackbar.style.padding = '16px';
snackbar.style.position = 'fixed';
snackbar.style.zIndex = '9999';
snackbar.style.bottom = '30px';
snackbar.style.left = '50%';
snackbar.style.fontSize = '0.9em';
snackbar.style.boxShadow = '0 3px 5px rgba(0,0,0,0.2)';
snackbar.style.visibility = 'visible';
snackbar.style.transform = 'translateX(-50%)';
snackbar.style.borderRadius = '4px';
snackbar.style.animation = 'snackIn 0.5s, snackOut 0.5s 3.5s';
document.body.appendChild(snackbar);
setTimeout(() => {
snackbar.style.visibility = 'hidden';
}, 4000);
};
export { LoginButton, OrdinaryButton, ShowError, SplashScreen };