Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@edx/cookie-policy-banner

Package Overview
Dependencies
Maintainers
13
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edx/cookie-policy-banner - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

12

build/constants.js

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", {

});
exports.getPolicyHTML = exports.LANGUAGE_CODES = exports.DEFAULT_IETF_TAG = void 0;
var ENGLISH_IETF_TAG = 'en';
var SPANISH_IETF_TAG = 'es-419';
var DEFAULT_IETF_TAG = ENGLISH_IETF_TAG;
exports.DEFAULT_IETF_TAG = DEFAULT_IETF_TAG;
var LANGUAGE_CODES = Object.freeze([ENGLISH_IETF_TAG, SPANISH_IETF_TAG]);
exports.LANGUAGE_CODES = LANGUAGE_CODES;

@@ -20,9 +18,11 @@ var getPolicyHTML = function getPolicyHTML(tag) {

var _linkOpen = '<a href="https://edx.org/es/privacy-policy" class="policy-link">';
return "By using the website, you consent to our use of cookies in accordance with the terms of the edX ".concat(_linkOpen, " Privacy Policy ").concat(linkClose, ".");
return 'By using the website, you consent to our use of cookies in accordance with the terms of the edX ' + _linkOpen + ' Privacy Policy ' + linkClose + '.';
}
var linkOpen = '<a href="https://edx.org/privacy-policy" class="policy-link">';
return "By using the website, you consent to our use of cookies in accordance with the terms of the edX ".concat(linkOpen, " Privacy Policy ").concat(linkClose, ".");
return 'By using the website, you consent to our use of cookies in accordance with the terms of the edX ' + linkOpen + ' Privacy Policy ' + linkClose + '.';
};
exports.DEFAULT_IETF_TAG = DEFAULT_IETF_TAG;
exports.LANGUAGE_CODES = LANGUAGE_CODES;
exports.getPolicyHTML = getPolicyHTML;

@@ -1,15 +0,19 @@

"use strict";
'use strict';
var _react = _interopRequireDefault(require("react"));
var _react = require('react');
var _react2 = require("@storybook/react");
var _react2 = _interopRequireDefault(_react);
var _addonInfo = require("@storybook/addon-info");
var _react3 = require('@storybook/react');
var _index = _interopRequireDefault(require("./index"));
var _addonInfo = require('@storybook/addon-info');
var _index = require('./index');
var _index2 = _interopRequireDefault(_index);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
(0, _react2.storiesOf)('Cookie Banner', _index.default).add('basic usage', function () {
return _react.default.createElement(_index.default, null);
(0, _react3.storiesOf)('Cookie Banner', _index2.default).add('basic usage', function () {
return _react2.default.createElement(_index2.default, null);
});

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -6,48 +6,42 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _paragon = require("@edx/paragon");
var _react = require('react');
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react2 = _interopRequireDefault(_react);
var _constants = require("../constants");
var _paragon = require('@edx/paragon');
var _utilities = require("../utilities");
var _propTypes = require('prop-types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
var _constants = require('../constants');
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _utilities = require('../utilities');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable react/no-danger */
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// import styles from './CookieBanner.scss';
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
// import styles from './CookieBanner.scss';
var CookieBanner =
/*#__PURE__*/
function (_Component) {
var CookieBanner = function (_Component) {
_inherits(CookieBanner, _Component);
function CookieBanner(props) {
var _this;
_classCallCheck(this, CookieBanner);
_this = _possibleConstructorReturn(this, (CookieBanner.__proto__ || Object.getPrototypeOf(CookieBanner)).call(this, props));
_this.onClose = _this.onClose.bind(_assertThisInitialized(_this));
_this.state = {
open: false
};
var _this = _possibleConstructorReturn(this, (CookieBanner.__proto__ || Object.getPrototypeOf(CookieBanner)).call(this, props));
_this.onClose = _this.onClose.bind(_this);
// this.state = { open: false };
_this.state = { open: true };
return _this;

@@ -57,39 +51,50 @@ }

_createClass(CookieBanner, [{
key: "componentDidMount",
key: 'componentDidMount',
value: function componentDidMount() {
if ((0, _utilities.hasViewedCookieBanner)()) {
this.setState({
open: false
});
this.toggleDisplay(false);
} else {
(0, _utilities.createHasViewedCookieBanner)();
this.setState({
open: true
});
this.toggleDisplay(true);
}
}
}, {
key: "onClose",
key: 'onClose',
value: function onClose(event) {
this.setState({
open: false
});
this.setState({ open: false });
this.props.onClose(event);
}
}, {
key: "render",
key: 'toggleDisplay',
value: function toggleDisplay(open) {
// this.setState({ open });
}
}, {
key: 'render',
value: function render() {
return _react.default.createElement("div", {
className: "edx-cookie-banner-wrapper",
"aria-live": "polite"
}, _react.default.createElement(_paragon.StatusAlert, {
className: ['edx-cookie-banner'],
open: this.state.open,
dialog: _react.default.createElement("span", {
dangerouslySetInnerHTML: {
__html: (0, _constants.getPolicyHTML)((0, _utilities.getLanguageCode)())
}
}),
onClose: this.onClose
}));
var bannerStyle = {
display: 'flex',
justifyContent: 'space-between',
maxWidth: '1200px',
margin: '0 auto',
background: 'inherit',
border: 'none'
};
return _react2.default.createElement(
'div',
{
className: 'edx-cookie-banner-wrapper',
style: { background: '#f2f8fd' },
'aria-live': 'polite'
},
_react2.default.createElement(_paragon.StatusAlert, {
className: ['edx-cookie-banner'],
style: bannerStyle,
open: this.state.open,
dialog: _react2.default.createElement('span', { dangerouslySetInnerHTML: { __html: (0, _constants.getPolicyHTML)((0, _utilities.getLanguageCode)()) } }),
onClose: this.onClose
})
);
}

@@ -104,6 +109,7 @@ }]);

};
CookieBanner.propTypes = {
onClose: _propTypes.default.func
onClose: _propTypes2.default.func
};
var _default = CookieBanner;
exports.default = _default;
exports.default = CookieBanner;

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _CookieBanner = _interopRequireDefault(require("./CookieBanner"));
var _CookieBanner = require('./CookieBanner');
var _CookieBanner2 = _interopRequireDefault(_CookieBanner);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = _CookieBanner.default;
exports.default = _default;
exports.default = _CookieBanner2.default;

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {

});
exports.hasViewedCookieBanner = exports.createHasViewedCookieBanner = exports.getLanguageCode = void 0;
exports.hasViewedCookieBanner = exports.createHasViewedCookieBanner = exports.getLanguageCode = undefined;
var _universalCookie = _interopRequireDefault(require("universal-cookie"));
var _universalCookie = require('universal-cookie');
var _constants = require("./constants");
var _universalCookie2 = _interopRequireDefault(_universalCookie);
var _constants = require('./constants');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var getLanguageCode = function getLanguageCode() {
var cookie = new _universalCookie.default('edx.org');
var cookie = new _universalCookie2.default('edx.org');
var languageCode = cookie.get('prod-edx-language-preference');

@@ -26,14 +28,12 @@

exports.getLanguageCode = getLanguageCode;
var createHasViewedCookieBanner = function createHasViewedCookieBanner() {
return new _universalCookie.default('edx.org').set('has-viewed-cookie', true);
return new _universalCookie2.default('edx.org').set('has-viewed-cookie', true, { domain: '.edx.org' });
};
exports.createHasViewedCookieBanner = createHasViewedCookieBanner;
var hasViewedCookieBanner = function hasViewedCookieBanner() {
return !!new _universalCookie.default('edx.org').get('has-viewed-cookie');
return !!new _universalCookie2.default('edx.org').get('has-viewed-cookie');
};
exports.getLanguageCode = getLanguageCode;
exports.createHasViewedCookieBanner = createHasViewedCookieBanner;
exports.hasViewedCookieBanner = hasViewedCookieBanner;
{
"name": "@edx/cookie-policy-banner",
"version": "0.0.1",
"version": "0.0.2",
"description": "The edX cookie policy banner component implemented in React.",

@@ -35,6 +35,6 @@ "main": "build/index.js",

"devDependencies": {
"@babel/cli": "^7.0.0-beta.42",
"@babel/core": "^7.0.0-beta.42",
"@babel/preset-env": "^7.0.0-beta.42",
"@babel/preset-react": "^7.0.0-beta.44",
"babel-cli": "6.26.0",
"babel-core": "6.24.0",
"babel-preset-env": "1.6.1",
"babel-preset-react": "6.24.1",
"@commitlint/cli": "^6.1.3",

@@ -41,0 +41,0 @@ "@commitlint/config-angular": "^6.1.3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc