@arche-mc2/arche-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
78 lines • 3.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var react_1 = require("react");
var withTheme_1 = require("../../../Common/theming/withTheme");
var colorMap_1 = require("../../../Common/theming/colorMap");
var Box_1 = require("../Box");
var Button_1 = require("../../Inputs/Button");
function setCookie(name, value, days) {
var expires = '';
if (days) {
var date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || '') + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) === ' ')
c = c.substring(1, c.length);
if (c.indexOf(nameEQ) === 0)
return c.substring(nameEQ.length, c.length);
}
return null;
}
var UpCookiesConsent = function (props) {
var children = props.children, cookieKey = props.cookieKey, cookieValue = props.cookieValue, moreDetailsPage = props.moreDetailsPage, closeButtonLabel = props.closeButtonLabel, cookiesConsentMessage = props.cookiesConsentMessage, knowMoreLabel = props.knowMoreLabel;
var _a = react_1.useState(false), cookiesNotAllowed = _a[0], setCookiesNotAllowed = _a[1];
var updateCookies = function () {
if (!getCookie(cookieKey) || getCookie(cookieKey) !== cookieValue) {
setCookiesNotAllowed(true);
}
};
react_1.useEffect(function () {
updateCookies();
});
return (React.createElement(Box_1.default, { style: {
display: 'flex',
flexDirection: 'column',
height: 'calc(100vh)',
width: '100%',
} },
React.createElement(Box_1.default, { flexDirection: 'row', justifyContent: 'center', alignItems: 'center', style: {
height: cookiesNotAllowed ? 80 : 0,
transform: cookiesNotAllowed ? 'scaleY(1)' : 'scaleY(0)',
width: '100%',
backgroundColor: '#424C4A',
paddingRight: 50,
paddingLeft: 50,
transition: 'height 0.5s, transform 0.5s',
} },
React.createElement("span", { style: {
marginRight: 100,
color: colorMap_1.colors.white,
fontFamily: 'Roboto',
fontSize: '14px',
lineHeight: '16px',
display: 'flex',
flexDirection: 'column',
} },
React.createElement("span", null, cookiesConsentMessage),
moreDetailsPage && (React.createElement("span", { style: {
textDecoration: 'underline',
cursor: 'pointer',
}, onClick: function () { return window.open(moreDetailsPage, '_blank'); } }, knowMoreLabel))),
React.createElement(Button_1.default, { width: 'normal', intent: 'primary', onClick: function () {
setCookiesNotAllowed(false);
setCookie(cookieKey, cookieValue);
} }, closeButtonLabel)),
children));
};
exports.UpCookiesConsent = UpCookiesConsent;
exports.default = withTheme_1.default(UpCookiesConsent);
//# sourceMappingURL=UpCookiesConsent.js.map