@servosinformatica/resources
Version:
Resources to Servos Informatica's apps
168 lines (157 loc) • 4.58 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
var reactResponsive = require('react-responsive');
var reactBootstrap = require('react-bootstrap');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
const SplashScreen = ({
videoSrc,
onEnd,
background
}) => {
const isMobile = reactResponsive.useMediaQuery({
maxWidth: 480
});
const isTablet = reactResponsive.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__default["default"].createElement("div", {
style: styleOverlay
}, /*#__PURE__*/React__default["default"].createElement("video", {
style: styleVideo,
autoPlay: true,
muted: true,
playsInline: true,
onEnded: onEnd
}, /*#__PURE__*/React__default["default"].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__default["default"].createElement(reactBootstrap.Button, {
onClick: onClick,
disabled: disabled ? disabled : isLoading,
variant: variant,
className: className,
type: type,
href: href
}, isLoading ? /*#__PURE__*/React__default["default"].createElement("span", {
className: "spinner-border spinner-border-sm",
role: "status"
}) : /*#__PURE__*/React__default["default"].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__default["default"].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);
};
exports.LoginButton = LoginButton;
exports.OrdinaryButton = OrdinaryButton;
exports.ShowError = ShowError;
exports.SplashScreen = SplashScreen;