@propellerads/cookie-message 3.0.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +19 -4
- package/dist/index.js +49 -7
- package/dist/index.js.map +1 -0
- package/package.json +29 -24
- package/dist/cookie-message.cjs.development.js +0 -61
- package/dist/cookie-message.cjs.development.js.map +0 -1
- package/dist/cookie-message.cjs.production.min.js +0 -2
- package/dist/cookie-message.cjs.production.min.js.map +0 -1
- package/dist/cookie-message.esm.js +0 -52
- package/dist/cookie-message.esm.js.map +0 -1
- package/dist/style.d.ts +0 -9
- package/dist/types.d.ts +0 -13
- package/src/index.tsx +0 -39
- package/src/style.tsx +0 -41
- package/src/types.tsx +0 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const Position: {
|
|
5
|
+
readonly LeftBottom: "left_bottom";
|
|
6
|
+
readonly RightBottom: "right_bottom";
|
|
7
|
+
};
|
|
8
|
+
type Position = (typeof Position)[keyof typeof Position];
|
|
9
|
+
type CookieMessageProps = {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
title?: ReactNode;
|
|
12
|
+
cookieKey?: string;
|
|
13
|
+
position?: Position;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const CookieMessage: ({ title, children, position, cookieKey, }: CookieMessageProps) => react_jsx_runtime.JSX.Element | null;
|
|
17
|
+
|
|
18
|
+
export { Position, CookieMessage as default };
|
|
19
|
+
export type { CookieMessageProps };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,50 @@
|
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as p } from "react";
|
|
3
|
+
import h, { ButtonType as f } from "@propellerads/button";
|
|
4
|
+
import i from "styled-components";
|
|
5
|
+
import { borderRadius as x, white as g, baseShadow as b, spacing as o } from "@propellerads/stylevariables";
|
|
6
|
+
const n = {
|
|
7
|
+
LeftBottom: "left_bottom",
|
|
8
|
+
RightBottom: "right_bottom"
|
|
9
|
+
}, u = {
|
|
10
|
+
[n.LeftBottom]: {
|
|
11
|
+
left: `${o * 5}px`
|
|
12
|
+
},
|
|
13
|
+
[n.RightBottom]: {
|
|
14
|
+
right: `${o * 5}px`
|
|
15
|
+
}
|
|
16
|
+
}, $ = i.div`
|
|
17
|
+
width: 320px;
|
|
18
|
+
border-radius: ${x}px;
|
|
19
|
+
background-color: ${g};
|
|
20
|
+
box-shadow: ${b};
|
|
21
|
+
position: fixed;
|
|
22
|
+
z-index: 99999;
|
|
23
|
+
bottom: ${o * 5}px;
|
|
24
|
+
padding: ${o * 5}px;
|
|
1
25
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
26
|
+
${({ $position: e }) => u[e]}
|
|
27
|
+
`, k = i.div`
|
|
28
|
+
margin-bottom: ${o * 3}px;
|
|
29
|
+
`, w = i.div`
|
|
30
|
+
margin-bottom: ${o * 3}px;
|
|
31
|
+
`, C = i.div``, S = "accept_cookie_policy", L = ({
|
|
32
|
+
title: e = "Cookies",
|
|
33
|
+
children: s,
|
|
34
|
+
position: d = n.LeftBottom,
|
|
35
|
+
cookieKey: r = S
|
|
36
|
+
}) => {
|
|
37
|
+
const [c, m] = p(!window.localStorage.getItem(r)), l = () => {
|
|
38
|
+
window.localStorage.setItem(r, "true"), m(!1);
|
|
39
|
+
};
|
|
40
|
+
return c ? /* @__PURE__ */ a($, { $position: d, children: [
|
|
41
|
+
/* @__PURE__ */ t(w, { children: /* @__PURE__ */ t("b", { children: e }) }),
|
|
42
|
+
/* @__PURE__ */ t(k, { children: s }),
|
|
43
|
+
/* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(h, { elementId: "cookie-consent", type: f.Primary, onClick: l, children: "Got it" }) })
|
|
44
|
+
] }) : null;
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
n as Position,
|
|
48
|
+
L as default
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import type {ReactNode} from 'react';\n\nexport const Position = {\n LeftBottom: 'left_bottom',\n RightBottom: 'right_bottom',\n} as const;\nexport type Position = (typeof Position)[keyof typeof Position];\n\nexport type CookieMessageProps = {\n children: ReactNode;\n title?: ReactNode;\n cookieKey?: string;\n position?: Position;\n};\n","import styled, {CSSObject} from 'styled-components';\nimport {white, borderRadius, baseShadow, spacing} from '@propellerads/stylevariables';\nimport type {Position} from './types';\nimport {Position as CookieMessagePosition} from './types';\n\ntype StyledCookieCardProps = {\n $position: Position;\n};\n\nconst positionStylesMap = {\n [CookieMessagePosition.LeftBottom]: {\n left: `${spacing * 5}px`,\n },\n [CookieMessagePosition.RightBottom]: {\n right: `${spacing * 5}px`,\n },\n} as const satisfies Record<Position, CSSObject>;\n\nconst StyledCookieCard = styled.div<StyledCookieCardProps>`\n width: 320px;\n border-radius: ${borderRadius}px;\n background-color: ${white};\n box-shadow: ${baseShadow};\n position: fixed;\n z-index: 99999;\n bottom: ${spacing * 5}px;\n padding: ${spacing * 5}px;\n\n ${({$position}) => positionStylesMap[$position]}\n`;\n\nconst CookieInfo = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\nconst CookieTitle = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\n\nconst CookieAction = styled.div``;\n\nexport {StyledCookieCard, CookieInfo, CookieTitle, CookieAction};\n","import {useState} from 'react';\nimport Button, {ButtonType} from '@propellerads/button';\nimport type {CookieMessageProps} from './types';\nimport {Position} from './types';\nimport {StyledCookieCard, CookieAction, CookieInfo, CookieTitle} from './style';\n\nconst DEFAULT_COOKIE_KEY = 'accept_cookie_policy';\n\nconst CookieMessage = ({\n title = 'Cookies',\n children,\n position = Position.LeftBottom,\n cookieKey = DEFAULT_COOKIE_KEY,\n}: CookieMessageProps) => {\n const [isShow, setShow] = useState(!window.localStorage.getItem(cookieKey));\n\n const handleClick = () => {\n window.localStorage.setItem(cookieKey, 'true');\n setShow(false);\n };\n\n if (!isShow) {\n return null;\n }\n\n return (\n <StyledCookieCard $position={position}>\n <CookieTitle>\n <b>{title}</b>\n </CookieTitle>\n\n <CookieInfo>{children}</CookieInfo>\n\n <CookieAction>\n <Button elementId=\"cookie-consent\" type={ButtonType.Primary} onClick={handleClick}>\n Got it\n </Button>\n </CookieAction>\n </StyledCookieCard>\n );\n};\n\nexport default CookieMessage;\n\nexport {Position};\nexport type {CookieMessageProps};\n"],"names":["Position","positionStylesMap","CookieMessagePosition","spacing","StyledCookieCard","styled","borderRadius","white","baseShadow","$position","CookieInfo","CookieTitle","CookieAction","DEFAULT_COOKIE_KEY","CookieMessage","title","children","position","cookieKey","isShow","setShow","useState","handleClick","jsxs","jsx","Button","ButtonType"],"mappings":";;;;;AAEO,MAAMA,IAAW;AAAA,EACtB,YAAY;AAAA,EACZ,aAAa;AACf,GCIMC,IAAoB;AAAA,EACxB,CAACC,EAAsB,UAAU,GAAG;AAAA,IAClC,MAAM,GAAGC,IAAU,CAAC;AAAA,EAAA;AAAA,EAEtB,CAACD,EAAsB,WAAW,GAAG;AAAA,IACnC,OAAO,GAAGC,IAAU,CAAC;AAAA,EAAA;AAEzB,GAEMC,IAAmBC,EAAO;AAAA;AAAA,mBAEbC,CAAY;AAAA,sBACTC,CAAK;AAAA,gBACXC,CAAU;AAAA;AAAA;AAAA,YAGdL,IAAU,CAAC;AAAA,aACVA,IAAU,CAAC;AAAA;AAAA,IAEpB,CAAC,EAAC,WAAAM,QAAeR,EAAkBQ,CAAS,CAAC;AAAA,GAG3CC,IAAaL,EAAO;AAAA,mBACPF,IAAU,CAAC;AAAA,GAExBQ,IAAcN,EAAO;AAAA,mBACRF,IAAU,CAAC;AAAA,GAGxBS,IAAeP,EAAO,OChCtBQ,IAAqB,wBAErBC,IAAgB,CAAC;AAAA,EACrB,OAAAC,IAAQ;AAAA,EACR,UAAAC;AAAA,EACA,UAAAC,IAAWjB,EAAS;AAAA,EACpB,WAAAkB,IAAYL;AACd,MAA0B;AACxB,QAAM,CAACM,GAAQC,CAAO,IAAIC,EAAS,CAAC,OAAO,aAAa,QAAQH,CAAS,CAAC,GAEpEI,IAAc,MAAM;AACxB,WAAO,aAAa,QAAQJ,GAAW,MAAM,GAC7CE,EAAQ,EAAK;AAAA,EACf;AAEA,SAAKD,IAKH,gBAAAI,EAACnB,GAAA,EAAiB,WAAWa,GAC3B,UAAA;AAAA,IAAA,gBAAAO,EAACb,GAAA,EACC,UAAA,gBAAAa,EAAC,KAAA,EAAG,UAAAT,EAAA,CAAM,GACZ;AAAA,IAEA,gBAAAS,EAACd,KAAY,UAAAM,GAAS;AAAA,IAEtB,gBAAAQ,EAACZ,GAAA,EACC,UAAA,gBAAAY,EAACC,GAAA,EAAO,WAAU,kBAAiB,MAAMC,EAAW,SAAS,SAASJ,GAAa,UAAA,SAAA,CAEnF,EAAA,CACF;AAAA,EAAA,GACF,IAhBO;AAkBX;"}
|
package/package.json
CHANGED
|
@@ -1,37 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@propellerads/cookie-message",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
9
12
|
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
"src"
|
|
13
|
+
"dist"
|
|
12
14
|
],
|
|
15
|
+
"repository": "https://github.com/propellerads/ui-components.git",
|
|
13
16
|
"author": "i.pasyuk@propellerads.net",
|
|
14
|
-
"
|
|
15
|
-
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/propellerads/ui-components/issues"
|
|
16
20
|
},
|
|
17
21
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
|
|
22
|
+
"build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/propellerads/ui-components#readme",
|
|
25
|
+
"private": false,
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@propellerads/button": "^9.0.2",
|
|
28
|
+
"@propellerads/stylevariables": "^2.0.2"
|
|
20
29
|
},
|
|
21
30
|
"peerDependencies": {
|
|
22
|
-
"react": "
|
|
23
|
-
"styled-components": "5.1.1"
|
|
24
|
-
"@types/styled-components": "5.1.34"
|
|
31
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
32
|
+
"styled-components": "^5.1.1 || ^6.0.0"
|
|
25
33
|
},
|
|
26
|
-
"module": "dist/cookie-message.esm.js",
|
|
27
34
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"@propellerads/button": "^9.0.0",
|
|
35
|
-
"@propellerads/stylevariables": "^2.0.2"
|
|
35
|
+
"@types/react": "^19.2.14",
|
|
36
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
37
|
+
"rollup": "^4.58.0",
|
|
38
|
+
"rollup-plugin-dts": "^6.3.0",
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"vite": "^7.3.1"
|
|
36
41
|
}
|
|
37
42
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var React__default = _interopDefault(React);
|
|
9
|
-
var Button = require('@propellerads/button');
|
|
10
|
-
var Button__default = _interopDefault(Button);
|
|
11
|
-
var styled = require('styled-components');
|
|
12
|
-
var styled__default = _interopDefault(styled);
|
|
13
|
-
var stylevariables = require('@propellerads/stylevariables');
|
|
14
|
-
|
|
15
|
-
function _taggedTemplateLiteralLoose(e, t) {
|
|
16
|
-
return t || (t = e.slice(0)), e.raw = t, e;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var POSITION;
|
|
20
|
-
(function (POSITION) {
|
|
21
|
-
POSITION["LEFT_BOTTOM"] = "left_bottom";
|
|
22
|
-
POSITION["RIGHT_BOTTOM"] = "right_bottom";
|
|
23
|
-
})(POSITION || (POSITION = {}));
|
|
24
|
-
|
|
25
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
26
|
-
var StyledCookieCard = /*#__PURE__*/styled__default.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 320px;\n border-radius: ", "px;\n background-color: ", ";\n box-shadow: ", ";\n position: fixed;\n z-index: 99999;\n bottom: ", "px;\n padding: ", "px;\n\n ", ";\n\n ", ";\n"])), stylevariables.borderRadius, stylevariables.white, stylevariables.baseShadow, stylevariables.spacing * 5, stylevariables.spacing * 5, function (props) {
|
|
27
|
-
return props.position === POSITION.RIGHT_BOTTOM && styled.css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n right: ", "px;\n "])), stylevariables.spacing * 5);
|
|
28
|
-
}, function (props) {
|
|
29
|
-
return props.position === POSITION.LEFT_BOTTOM && styled.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n left: ", "px;\n "])), stylevariables.spacing * 5);
|
|
30
|
-
});
|
|
31
|
-
var CookieInfo = /*#__PURE__*/styled__default.div(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: ", "px;\n"])), stylevariables.spacing * 3);
|
|
32
|
-
var CookieTitle = /*#__PURE__*/styled__default.div(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: ", "px;\n"])), stylevariables.spacing * 3);
|
|
33
|
-
var CookieAction = /*#__PURE__*/styled__default.div(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
|
|
34
|
-
|
|
35
|
-
var DEFAULT_COOKIE_KEY = 'accept_cookie_policy';
|
|
36
|
-
var CookieMessage = function CookieMessage(_ref) {
|
|
37
|
-
var _ref$title = _ref.title,
|
|
38
|
-
title = _ref$title === void 0 ? 'Cookies' : _ref$title,
|
|
39
|
-
children = _ref.children,
|
|
40
|
-
_ref$position = _ref.position,
|
|
41
|
-
position = _ref$position === void 0 ? POSITION.LEFT_BOTTOM : _ref$position,
|
|
42
|
-
_ref$cookieKey = _ref.cookieKey,
|
|
43
|
-
cookieKey = _ref$cookieKey === void 0 ? DEFAULT_COOKIE_KEY : _ref$cookieKey;
|
|
44
|
-
var _useState = React.useState(!window.localStorage.getItem(cookieKey)),
|
|
45
|
-
isShow = _useState[0],
|
|
46
|
-
setShow = _useState[1];
|
|
47
|
-
var handleClick = function handleClick() {
|
|
48
|
-
window.localStorage.setItem(cookieKey, 'true');
|
|
49
|
-
setShow(false);
|
|
50
|
-
};
|
|
51
|
-
return isShow ? React__default.createElement(StyledCookieCard, {
|
|
52
|
-
position: position
|
|
53
|
-
}, React__default.createElement(CookieTitle, null, React__default.createElement("b", null, title)), React__default.createElement(CookieInfo, null, children), React__default.createElement(CookieAction, null, React__default.createElement(Button__default, {
|
|
54
|
-
elementId: "cookie-consent",
|
|
55
|
-
type: Button.ButtonType.Primary,
|
|
56
|
-
onClick: handleClick
|
|
57
|
-
}, "Got it"))) : null;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.CookieMessage = CookieMessage;
|
|
61
|
-
//# sourceMappingURL=cookie-message.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-message.cjs.development.js","sources":["../src/types.tsx","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\n\nexport enum POSITION {\n LEFT_BOTTOM = 'left_bottom',\n RIGHT_BOTTOM = 'right_bottom',\n}\n\nexport interface CookieMessageProps {\n children: ReactNode;\n title?: ReactNode;\n cookieKey?: string;\n position?: POSITION;\n}\n\nexport class CookieMessage extends React.Component<CookieMessageProps> {}\n","import styled, {css} from 'styled-components';\nimport {white, borderRadius, baseShadow, spacing} from '@propellerads/stylevariables';\nimport {POSITION} from './types';\n\ninterface StyledCookieCardProps {\n position: POSITION;\n}\n\nconst StyledCookieCard = styled.div`\n width: 320px;\n border-radius: ${borderRadius}px;\n background-color: ${white};\n box-shadow: ${baseShadow};\n position: fixed;\n z-index: 99999;\n bottom: ${spacing * 5}px;\n padding: ${spacing * 5}px;\n\n ${(props: StyledCookieCardProps) =>\n props.position === POSITION.RIGHT_BOTTOM &&\n css`\n right: ${spacing * 5}px;\n `};\n\n ${(props: StyledCookieCardProps) =>\n props.position === POSITION.LEFT_BOTTOM &&\n css`\n left: ${spacing * 5}px;\n `};\n`;\n\nconst CookieInfo = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\nconst CookieTitle = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\n\nconst CookieAction = styled.div``;\n\nexport {StyledCookieCard, CookieInfo, CookieTitle, CookieAction};\n","import React, {useState} from 'react';\nimport Button, {ButtonType} from '@propellerads/button';\n\nimport {CookieMessageProps, POSITION} from './types';\nimport {StyledCookieCard, CookieAction, CookieInfo, CookieTitle} from './style';\n\nconst DEFAULT_COOKIE_KEY = 'accept_cookie_policy';\n\nconst CookieMessage = ({\n title = 'Cookies',\n children,\n position = POSITION.LEFT_BOTTOM,\n cookieKey = DEFAULT_COOKIE_KEY,\n}: CookieMessageProps) => {\n const [isShow, setShow] = useState<boolean>(!window.localStorage.getItem(cookieKey));\n\n const handleClick = () => {\n window.localStorage.setItem(cookieKey, 'true');\n setShow(false);\n };\n\n return isShow ? (\n <StyledCookieCard position={position}>\n <CookieTitle>\n <b>{title}</b>\n </CookieTitle>\n\n <CookieInfo>{children}</CookieInfo>\n\n <CookieAction>\n <Button elementId=\"cookie-consent\" type={ButtonType.Primary} onClick={handleClick}>\n Got it\n </Button>\n </CookieAction>\n </StyledCookieCard>\n ) : null;\n};\n\nexport {CookieMessage};\n"],"names":["POSITION","StyledCookieCard","styled","div","_templateObject","_taggedTemplateLiteralLoose","borderRadius","white","baseShadow","spacing","props","position","RIGHT_BOTTOM","css","_templateObject2","LEFT_BOTTOM","_templateObject3","CookieInfo","_templateObject4","CookieTitle","_templateObject5","CookieAction","_templateObject6","DEFAULT_COOKIE_KEY","CookieMessage","_ref","title","_ref$title","children","_ref$position","_ref$cookieKey","cookieKey","_useState","useState","window","localStorage","getItem","isShow","setShow","handleClick","setItem","React","Button","elementId","type","ButtonType","Primary","onClick"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,IAAYA,QAGX;AAHD,WAAYA,QAAQ;EAClBA,uCAA2B;EAC3BA,yCAA6B;AAC/B,CAAC,EAHWA,QAAQ,KAARA,QAAQ;;;ACFpB,AAQA,IAAMC,gBAAgB,gBAAGC,eAAM,CAACC,GAAG,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,0MAEhBC,2BAAY,EACTC,oBAAK,EACXC,yBAAU,EAGdC,sBAAO,GAAG,CAAC,EACVA,sBAAO,GAAG,CAAC,EAEpB,UAACC,KAA4B;EAAA,OAC7BA,KAAK,CAACC,QAAQ,KAAKX,QAAQ,CAACY,YAAY,IACxCC,UAAG,CAAAC,gBAAA,KAAAA,gBAAA,GAAAT,2BAAA,qCACQI,sBAAO,GAAG,CAAC,CACrB;AAAA,GAED,UAACC,KAA4B;EAAA,OAC7BA,KAAK,CAACC,QAAQ,KAAKX,QAAQ,CAACe,WAAW,IACvCF,UAAG,CAAAG,gBAAA,KAAAA,gBAAA,GAAAX,2BAAA,oCACOI,sBAAO,GAAG,CAAC,CACpB;AAAA,EACJ;AAED,IAAMQ,UAAU,gBAAGf,eAAM,CAACC,GAAG,CAAAe,gBAAA,KAAAA,gBAAA,gBAAAb,2BAAA,qCACVI,sBAAO,GAAG,CAAC,CAC7B;AACD,IAAMU,WAAW,gBAAGjB,eAAM,CAACC,GAAG,CAAAiB,gBAAA,KAAAA,gBAAA,gBAAAf,2BAAA,qCACXI,sBAAO,GAAG,CAAC,CAC7B;AAED,IAAMY,YAAY,gBAAGnB,eAAM,CAACC,GAAG,CAAAmB,gBAAA,KAAAA,gBAAA,gBAAAjB,2BAAA,QAAE;;AChCjC,IAAMkB,kBAAkB,GAAG,sBAAsB;AAEjD,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA;wBACjBC,KAAK;IAALA,KAAK,GAAAC,UAAA,cAAG,SAAS,GAAAA,UAAA;IACjBC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IAAAC,aAAA,GAAAJ,IAAA,CACRd,QAAQ;IAARA,QAAQ,GAAAkB,aAAA,cAAG7B,QAAQ,CAACe,WAAW,GAAAc,aAAA;IAAAC,cAAA,GAAAL,IAAA,CAC/BM,SAAS;IAATA,SAAS,GAAAD,cAAA,cAAGP,kBAAkB,GAAAO,cAAA;EAE9B,IAAAE,SAAA,GAA0BC,cAAQ,CAAU,CAACC,MAAM,CAACC,YAAY,CAACC,OAAO,CAACL,SAAS,CAAC,CAAC;IAA7EM,MAAM,GAAAL,SAAA;IAAEM,OAAO,GAAAN,SAAA;EAEtB,IAAMO,WAAW,GAAG,SAAdA,WAAWA;IACfL,MAAM,CAACC,YAAY,CAACK,OAAO,CAACT,SAAS,EAAE,MAAM,CAAC;IAC9CO,OAAO,CAAC,KAAK,CAAC;GACf;EAED,OAAOD,MAAM,GACXI,6BAACxC,gBAAgB;IAACU,QAAQ,EAAEA;KAC1B8B,6BAACtB,WAAW,QACVsB,wCAAIf,KAAK,CAAK,CACF,EAEde,6BAACxB,UAAU,QAAEW,QAAQ,CAAc,EAEnCa,6BAACpB,YAAY,QACXoB,6BAACC,eAAM;IAACC,SAAS,EAAC,gBAAgB;IAACC,IAAI,EAAEC,iBAAU,CAACC,OAAO;IAAEC,OAAO,EAAER;cAE7D,CACI,CACE,GACjB,IAAI;AACV,CAAC;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n,t,o,i,r,a,c,l=require("react"),s=e(l),p=require("@propellerads/button"),u=e(p),d=require("styled-components"),m=e(d),g=require("@propellerads/stylevariables");function T(e,n){return n||(n=e.slice(0)),e.raw=n,e}!function(e){e.LEFT_BOTTOM="left_bottom",e.RIGHT_BOTTOM="right_bottom"}(n||(n={}));var b=m.div(t||(t=T(["\n width: 320px;\n border-radius: ","px;\n background-color: ",";\n box-shadow: ",";\n position: fixed;\n z-index: 99999;\n bottom: ","px;\n padding: ","px;\n\n ",";\n\n ",";\n"])),g.borderRadius,g.white,g.baseShadow,5*g.spacing,5*g.spacing,(function(e){return e.position===n.RIGHT_BOTTOM&&d.css(o||(o=T(["\n right: ","px;\n "])),5*g.spacing)}),(function(e){return e.position===n.LEFT_BOTTOM&&d.css(i||(i=T(["\n left: ","px;\n "])),5*g.spacing)})),f=m.div(r||(r=T(["\n margin-bottom: ","px;\n"])),3*g.spacing),x=m.div(a||(a=T(["\n margin-bottom: ","px;\n"])),3*g.spacing),v=m.div(c||(c=T([""])));exports.CookieMessage=function(e){var t=e.title,o=void 0===t?"Cookies":t,i=e.children,r=e.position,a=void 0===r?n.LEFT_BOTTOM:r,c=e.cookieKey,d=void 0===c?"accept_cookie_policy":c,m=l.useState(!window.localStorage.getItem(d)),g=m[1];return m[0]?s.createElement(b,{position:a},s.createElement(x,null,s.createElement("b",null,o)),s.createElement(f,null,i),s.createElement(v,null,s.createElement(u,{elementId:"cookie-consent",type:p.ButtonType.Primary,onClick:function(){window.localStorage.setItem(d,"true"),g(!1)}},"Got it"))):null};
|
|
2
|
-
//# sourceMappingURL=cookie-message.cjs.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-message.cjs.production.min.js","sources":["../src/types.tsx","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\n\nexport enum POSITION {\n LEFT_BOTTOM = 'left_bottom',\n RIGHT_BOTTOM = 'right_bottom',\n}\n\nexport interface CookieMessageProps {\n children: ReactNode;\n title?: ReactNode;\n cookieKey?: string;\n position?: POSITION;\n}\n\nexport class CookieMessage extends React.Component<CookieMessageProps> {}\n","import styled, {css} from 'styled-components';\nimport {white, borderRadius, baseShadow, spacing} from '@propellerads/stylevariables';\nimport {POSITION} from './types';\n\ninterface StyledCookieCardProps {\n position: POSITION;\n}\n\nconst StyledCookieCard = styled.div`\n width: 320px;\n border-radius: ${borderRadius}px;\n background-color: ${white};\n box-shadow: ${baseShadow};\n position: fixed;\n z-index: 99999;\n bottom: ${spacing * 5}px;\n padding: ${spacing * 5}px;\n\n ${(props: StyledCookieCardProps) =>\n props.position === POSITION.RIGHT_BOTTOM &&\n css`\n right: ${spacing * 5}px;\n `};\n\n ${(props: StyledCookieCardProps) =>\n props.position === POSITION.LEFT_BOTTOM &&\n css`\n left: ${spacing * 5}px;\n `};\n`;\n\nconst CookieInfo = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\nconst CookieTitle = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\n\nconst CookieAction = styled.div``;\n\nexport {StyledCookieCard, CookieInfo, CookieTitle, CookieAction};\n","import React, {useState} from 'react';\nimport Button, {ButtonType} from '@propellerads/button';\n\nimport {CookieMessageProps, POSITION} from './types';\nimport {StyledCookieCard, CookieAction, CookieInfo, CookieTitle} from './style';\n\nconst DEFAULT_COOKIE_KEY = 'accept_cookie_policy';\n\nconst CookieMessage = ({\n title = 'Cookies',\n children,\n position = POSITION.LEFT_BOTTOM,\n cookieKey = DEFAULT_COOKIE_KEY,\n}: CookieMessageProps) => {\n const [isShow, setShow] = useState<boolean>(!window.localStorage.getItem(cookieKey));\n\n const handleClick = () => {\n window.localStorage.setItem(cookieKey, 'true');\n setShow(false);\n };\n\n return isShow ? (\n <StyledCookieCard position={position}>\n <CookieTitle>\n <b>{title}</b>\n </CookieTitle>\n\n <CookieInfo>{children}</CookieInfo>\n\n <CookieAction>\n <Button elementId=\"cookie-consent\" type={ButtonType.Primary} onClick={handleClick}>\n Got it\n </Button>\n </CookieAction>\n </StyledCookieCard>\n ) : null;\n};\n\nexport {CookieMessage};\n"],"names":["POSITION","StyledCookieCard","styled","div","_templateObject","_taggedTemplateLiteralLoose","borderRadius","white","baseShadow","spacing","props","position","RIGHT_BOTTOM","css","_templateObject2","LEFT_BOTTOM","_templateObject3","CookieInfo","_templateObject4","CookieTitle","_templateObject5","CookieAction","_templateObject6","_ref","title","_ref$title","children","_ref$position","_ref$cookieKey","cookieKey","_useState","useState","window","localStorage","getItem","setShow","React","Button","elementId","type","ButtonType","Primary","onClick","setItem"],"mappings":"8IAEYA,qNAAZ,SAAYA,GACVA,4BACAA,8BAFF,CAAYA,IAAAA,OCFZ,IAQMC,EAAmBC,EAAOC,IAAGC,IAAAA,EAAAC,mMAEhBC,eACGC,QACNC,aAGM,EAAVC,UACW,EAAVA,WAET,SAACC,GAA4B,OAC7BA,EAAMC,WAAaX,EAASY,cAC5BC,MAAGC,IAAAA,EAAAT,oCACkB,EAAVI,cAGX,SAACC,GAA4B,OAC7BA,EAAMC,WAAaX,EAASe,aAC5BF,MAAGG,IAAAA,EAAAX,mCACiB,EAAVI,cAIRQ,EAAaf,EAAOC,IAAGe,IAAAA,EAAAb,oCACA,EAAVI,WAEbU,EAAcjB,EAAOC,IAAGiB,IAAAA,EAAAf,oCACD,EAAVI,WAGbY,EAAenB,EAAOC,IAAGmB,IAAAA,EAAAjB,gCC9BT,SAAHkB,WACjBC,MAAAA,WAAKC,EAAG,UAASA,EACjBC,EAAQH,EAARG,SAAQC,EAAAJ,EACRZ,SAAAA,WAAQgB,EAAG3B,EAASe,YAAWY,EAAAC,EAAAL,EAC/BM,UAAAA,WAASD,EANgB,uBAMKA,EAE9BE,EAA0BC,YAAmBC,OAAOC,aAAaC,QAAQL,IAA1DM,EAAOL,KAOtB,OAPaA,KAQXM,gBAACnC,GAAiBU,SAAUA,GAC1ByB,gBAACjB,OACCiB,yBAAIZ,IAGNY,gBAACnB,OAAYS,GAEbU,gBAACf,OACCe,gBAACC,GAAOC,UAAU,iBAAiBC,KAAMC,aAAWC,QAASC,QAd/C,WAClBV,OAAOC,aAAaU,QAAQd,EAAW,QACvCM,GAAQ,iBAiBN"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import Button, { ButtonType } from '@propellerads/button';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { borderRadius, white, baseShadow, spacing } from '@propellerads/stylevariables';
|
|
5
|
-
|
|
6
|
-
function _taggedTemplateLiteralLoose(e, t) {
|
|
7
|
-
return t || (t = e.slice(0)), e.raw = t, e;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
var POSITION;
|
|
11
|
-
(function (POSITION) {
|
|
12
|
-
POSITION["LEFT_BOTTOM"] = "left_bottom";
|
|
13
|
-
POSITION["RIGHT_BOTTOM"] = "right_bottom";
|
|
14
|
-
})(POSITION || (POSITION = {}));
|
|
15
|
-
|
|
16
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
17
|
-
var StyledCookieCard = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 320px;\n border-radius: ", "px;\n background-color: ", ";\n box-shadow: ", ";\n position: fixed;\n z-index: 99999;\n bottom: ", "px;\n padding: ", "px;\n\n ", ";\n\n ", ";\n"])), borderRadius, white, baseShadow, spacing * 5, spacing * 5, function (props) {
|
|
18
|
-
return props.position === POSITION.RIGHT_BOTTOM && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n right: ", "px;\n "])), spacing * 5);
|
|
19
|
-
}, function (props) {
|
|
20
|
-
return props.position === POSITION.LEFT_BOTTOM && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n left: ", "px;\n "])), spacing * 5);
|
|
21
|
-
});
|
|
22
|
-
var CookieInfo = /*#__PURE__*/styled.div(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: ", "px;\n"])), spacing * 3);
|
|
23
|
-
var CookieTitle = /*#__PURE__*/styled.div(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: ", "px;\n"])), spacing * 3);
|
|
24
|
-
var CookieAction = /*#__PURE__*/styled.div(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose([""])));
|
|
25
|
-
|
|
26
|
-
var DEFAULT_COOKIE_KEY = 'accept_cookie_policy';
|
|
27
|
-
var CookieMessage = function CookieMessage(_ref) {
|
|
28
|
-
var _ref$title = _ref.title,
|
|
29
|
-
title = _ref$title === void 0 ? 'Cookies' : _ref$title,
|
|
30
|
-
children = _ref.children,
|
|
31
|
-
_ref$position = _ref.position,
|
|
32
|
-
position = _ref$position === void 0 ? POSITION.LEFT_BOTTOM : _ref$position,
|
|
33
|
-
_ref$cookieKey = _ref.cookieKey,
|
|
34
|
-
cookieKey = _ref$cookieKey === void 0 ? DEFAULT_COOKIE_KEY : _ref$cookieKey;
|
|
35
|
-
var _useState = useState(!window.localStorage.getItem(cookieKey)),
|
|
36
|
-
isShow = _useState[0],
|
|
37
|
-
setShow = _useState[1];
|
|
38
|
-
var handleClick = function handleClick() {
|
|
39
|
-
window.localStorage.setItem(cookieKey, 'true');
|
|
40
|
-
setShow(false);
|
|
41
|
-
};
|
|
42
|
-
return isShow ? React.createElement(StyledCookieCard, {
|
|
43
|
-
position: position
|
|
44
|
-
}, React.createElement(CookieTitle, null, React.createElement("b", null, title)), React.createElement(CookieInfo, null, children), React.createElement(CookieAction, null, React.createElement(Button, {
|
|
45
|
-
elementId: "cookie-consent",
|
|
46
|
-
type: ButtonType.Primary,
|
|
47
|
-
onClick: handleClick
|
|
48
|
-
}, "Got it"))) : null;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { CookieMessage };
|
|
52
|
-
//# sourceMappingURL=cookie-message.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-message.esm.js","sources":["../src/types.tsx","../src/style.tsx","../src/index.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\n\nexport enum POSITION {\n LEFT_BOTTOM = 'left_bottom',\n RIGHT_BOTTOM = 'right_bottom',\n}\n\nexport interface CookieMessageProps {\n children: ReactNode;\n title?: ReactNode;\n cookieKey?: string;\n position?: POSITION;\n}\n\nexport class CookieMessage extends React.Component<CookieMessageProps> {}\n","import styled, {css} from 'styled-components';\nimport {white, borderRadius, baseShadow, spacing} from '@propellerads/stylevariables';\nimport {POSITION} from './types';\n\ninterface StyledCookieCardProps {\n position: POSITION;\n}\n\nconst StyledCookieCard = styled.div`\n width: 320px;\n border-radius: ${borderRadius}px;\n background-color: ${white};\n box-shadow: ${baseShadow};\n position: fixed;\n z-index: 99999;\n bottom: ${spacing * 5}px;\n padding: ${spacing * 5}px;\n\n ${(props: StyledCookieCardProps) =>\n props.position === POSITION.RIGHT_BOTTOM &&\n css`\n right: ${spacing * 5}px;\n `};\n\n ${(props: StyledCookieCardProps) =>\n props.position === POSITION.LEFT_BOTTOM &&\n css`\n left: ${spacing * 5}px;\n `};\n`;\n\nconst CookieInfo = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\nconst CookieTitle = styled.div`\n margin-bottom: ${spacing * 3}px;\n`;\n\nconst CookieAction = styled.div``;\n\nexport {StyledCookieCard, CookieInfo, CookieTitle, CookieAction};\n","import React, {useState} from 'react';\nimport Button, {ButtonType} from '@propellerads/button';\n\nimport {CookieMessageProps, POSITION} from './types';\nimport {StyledCookieCard, CookieAction, CookieInfo, CookieTitle} from './style';\n\nconst DEFAULT_COOKIE_KEY = 'accept_cookie_policy';\n\nconst CookieMessage = ({\n title = 'Cookies',\n children,\n position = POSITION.LEFT_BOTTOM,\n cookieKey = DEFAULT_COOKIE_KEY,\n}: CookieMessageProps) => {\n const [isShow, setShow] = useState<boolean>(!window.localStorage.getItem(cookieKey));\n\n const handleClick = () => {\n window.localStorage.setItem(cookieKey, 'true');\n setShow(false);\n };\n\n return isShow ? (\n <StyledCookieCard position={position}>\n <CookieTitle>\n <b>{title}</b>\n </CookieTitle>\n\n <CookieInfo>{children}</CookieInfo>\n\n <CookieAction>\n <Button elementId=\"cookie-consent\" type={ButtonType.Primary} onClick={handleClick}>\n Got it\n </Button>\n </CookieAction>\n </StyledCookieCard>\n ) : null;\n};\n\nexport {CookieMessage};\n"],"names":["POSITION","StyledCookieCard","styled","div","_templateObject","_taggedTemplateLiteralLoose","borderRadius","white","baseShadow","spacing","props","position","RIGHT_BOTTOM","css","_templateObject2","LEFT_BOTTOM","_templateObject3","CookieInfo","_templateObject4","CookieTitle","_templateObject5","CookieAction","_templateObject6","DEFAULT_COOKIE_KEY","CookieMessage","_ref","title","_ref$title","children","_ref$position","_ref$cookieKey","cookieKey","_useState","useState","window","localStorage","getItem","isShow","setShow","handleClick","setItem","React","Button","elementId","type","ButtonType","Primary","onClick"],"mappings":";;;;;;;;;AAEA,IAAYA,QAGX;AAHD,WAAYA,QAAQ;EAClBA,uCAA2B;EAC3BA,yCAA6B;AAC/B,CAAC,EAHWA,QAAQ,KAARA,QAAQ;;;ACFpB,AAQA,IAAMC,gBAAgB,gBAAGC,MAAM,CAACC,GAAG,CAAAC,eAAA,KAAAA,eAAA,gBAAAC,2BAAA,0MAEhBC,YAAY,EACTC,KAAK,EACXC,UAAU,EAGdC,OAAO,GAAG,CAAC,EACVA,OAAO,GAAG,CAAC,EAEpB,UAACC,KAA4B;EAAA,OAC7BA,KAAK,CAACC,QAAQ,KAAKX,QAAQ,CAACY,YAAY,IACxCC,GAAG,CAAAC,gBAAA,KAAAA,gBAAA,GAAAT,2BAAA,qCACQI,OAAO,GAAG,CAAC,CACrB;AAAA,GAED,UAACC,KAA4B;EAAA,OAC7BA,KAAK,CAACC,QAAQ,KAAKX,QAAQ,CAACe,WAAW,IACvCF,GAAG,CAAAG,gBAAA,KAAAA,gBAAA,GAAAX,2BAAA,oCACOI,OAAO,GAAG,CAAC,CACpB;AAAA,EACJ;AAED,IAAMQ,UAAU,gBAAGf,MAAM,CAACC,GAAG,CAAAe,gBAAA,KAAAA,gBAAA,gBAAAb,2BAAA,qCACVI,OAAO,GAAG,CAAC,CAC7B;AACD,IAAMU,WAAW,gBAAGjB,MAAM,CAACC,GAAG,CAAAiB,gBAAA,KAAAA,gBAAA,gBAAAf,2BAAA,qCACXI,OAAO,GAAG,CAAC,CAC7B;AAED,IAAMY,YAAY,gBAAGnB,MAAM,CAACC,GAAG,CAAAmB,gBAAA,KAAAA,gBAAA,gBAAAjB,2BAAA,QAAE;;AChCjC,IAAMkB,kBAAkB,GAAG,sBAAsB;AAEjD,IAAMC,aAAa,GAAG,SAAhBA,aAAaA,CAAAC,IAAA;wBACjBC,KAAK;IAALA,KAAK,GAAAC,UAAA,cAAG,SAAS,GAAAA,UAAA;IACjBC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IAAAC,aAAA,GAAAJ,IAAA,CACRd,QAAQ;IAARA,QAAQ,GAAAkB,aAAA,cAAG7B,QAAQ,CAACe,WAAW,GAAAc,aAAA;IAAAC,cAAA,GAAAL,IAAA,CAC/BM,SAAS;IAATA,SAAS,GAAAD,cAAA,cAAGP,kBAAkB,GAAAO,cAAA;EAE9B,IAAAE,SAAA,GAA0BC,QAAQ,CAAU,CAACC,MAAM,CAACC,YAAY,CAACC,OAAO,CAACL,SAAS,CAAC,CAAC;IAA7EM,MAAM,GAAAL,SAAA;IAAEM,OAAO,GAAAN,SAAA;EAEtB,IAAMO,WAAW,GAAG,SAAdA,WAAWA;IACfL,MAAM,CAACC,YAAY,CAACK,OAAO,CAACT,SAAS,EAAE,MAAM,CAAC;IAC9CO,OAAO,CAAC,KAAK,CAAC;GACf;EAED,OAAOD,MAAM,GACXI,oBAACxC,gBAAgB;IAACU,QAAQ,EAAEA;KAC1B8B,oBAACtB,WAAW,QACVsB,+BAAIf,KAAK,CAAK,CACF,EAEde,oBAACxB,UAAU,QAAEW,QAAQ,CAAc,EAEnCa,oBAACpB,YAAY,QACXoB,oBAACC,MAAM;IAACC,SAAS,EAAC,gBAAgB;IAACC,IAAI,EAAEC,UAAU,CAACC,OAAO;IAAEC,OAAO,EAAER;cAE7D,CACI,CACE,GACjB,IAAI;AACV,CAAC;;;;"}
|
package/dist/style.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { POSITION } from './types';
|
|
2
|
-
interface StyledCookieCardProps {
|
|
3
|
-
position: POSITION;
|
|
4
|
-
}
|
|
5
|
-
declare const StyledCookieCard: import("styled-components").StyledComponent<"div", any, StyledCookieCardProps, never>;
|
|
6
|
-
declare const CookieInfo: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
-
declare const CookieTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
-
declare const CookieAction: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
-
export { StyledCookieCard, CookieInfo, CookieTitle, CookieAction };
|
package/dist/types.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
export declare enum POSITION {
|
|
3
|
-
LEFT_BOTTOM = "left_bottom",
|
|
4
|
-
RIGHT_BOTTOM = "right_bottom"
|
|
5
|
-
}
|
|
6
|
-
export interface CookieMessageProps {
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
title?: ReactNode;
|
|
9
|
-
cookieKey?: string;
|
|
10
|
-
position?: POSITION;
|
|
11
|
-
}
|
|
12
|
-
export declare class CookieMessage extends React.Component<CookieMessageProps> {
|
|
13
|
-
}
|
package/src/index.tsx
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, {useState} from 'react';
|
|
2
|
-
import Button, {ButtonType} from '@propellerads/button';
|
|
3
|
-
|
|
4
|
-
import {CookieMessageProps, POSITION} from './types';
|
|
5
|
-
import {StyledCookieCard, CookieAction, CookieInfo, CookieTitle} from './style';
|
|
6
|
-
|
|
7
|
-
const DEFAULT_COOKIE_KEY = 'accept_cookie_policy';
|
|
8
|
-
|
|
9
|
-
const CookieMessage = ({
|
|
10
|
-
title = 'Cookies',
|
|
11
|
-
children,
|
|
12
|
-
position = POSITION.LEFT_BOTTOM,
|
|
13
|
-
cookieKey = DEFAULT_COOKIE_KEY,
|
|
14
|
-
}: CookieMessageProps) => {
|
|
15
|
-
const [isShow, setShow] = useState<boolean>(!window.localStorage.getItem(cookieKey));
|
|
16
|
-
|
|
17
|
-
const handleClick = () => {
|
|
18
|
-
window.localStorage.setItem(cookieKey, 'true');
|
|
19
|
-
setShow(false);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return isShow ? (
|
|
23
|
-
<StyledCookieCard position={position}>
|
|
24
|
-
<CookieTitle>
|
|
25
|
-
<b>{title}</b>
|
|
26
|
-
</CookieTitle>
|
|
27
|
-
|
|
28
|
-
<CookieInfo>{children}</CookieInfo>
|
|
29
|
-
|
|
30
|
-
<CookieAction>
|
|
31
|
-
<Button elementId="cookie-consent" type={ButtonType.Primary} onClick={handleClick}>
|
|
32
|
-
Got it
|
|
33
|
-
</Button>
|
|
34
|
-
</CookieAction>
|
|
35
|
-
</StyledCookieCard>
|
|
36
|
-
) : null;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export {CookieMessage};
|
package/src/style.tsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import styled, {css} from 'styled-components';
|
|
2
|
-
import {white, borderRadius, baseShadow, spacing} from '@propellerads/stylevariables';
|
|
3
|
-
import {POSITION} from './types';
|
|
4
|
-
|
|
5
|
-
interface StyledCookieCardProps {
|
|
6
|
-
position: POSITION;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const StyledCookieCard = styled.div`
|
|
10
|
-
width: 320px;
|
|
11
|
-
border-radius: ${borderRadius}px;
|
|
12
|
-
background-color: ${white};
|
|
13
|
-
box-shadow: ${baseShadow};
|
|
14
|
-
position: fixed;
|
|
15
|
-
z-index: 99999;
|
|
16
|
-
bottom: ${spacing * 5}px;
|
|
17
|
-
padding: ${spacing * 5}px;
|
|
18
|
-
|
|
19
|
-
${(props: StyledCookieCardProps) =>
|
|
20
|
-
props.position === POSITION.RIGHT_BOTTOM &&
|
|
21
|
-
css`
|
|
22
|
-
right: ${spacing * 5}px;
|
|
23
|
-
`};
|
|
24
|
-
|
|
25
|
-
${(props: StyledCookieCardProps) =>
|
|
26
|
-
props.position === POSITION.LEFT_BOTTOM &&
|
|
27
|
-
css`
|
|
28
|
-
left: ${spacing * 5}px;
|
|
29
|
-
`};
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
const CookieInfo = styled.div`
|
|
33
|
-
margin-bottom: ${spacing * 3}px;
|
|
34
|
-
`;
|
|
35
|
-
const CookieTitle = styled.div`
|
|
36
|
-
margin-bottom: ${spacing * 3}px;
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
const CookieAction = styled.div``;
|
|
40
|
-
|
|
41
|
-
export {StyledCookieCard, CookieInfo, CookieTitle, CookieAction};
|
package/src/types.tsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, {ReactNode} from 'react';
|
|
2
|
-
|
|
3
|
-
export enum POSITION {
|
|
4
|
-
LEFT_BOTTOM = 'left_bottom',
|
|
5
|
-
RIGHT_BOTTOM = 'right_bottom',
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface CookieMessageProps {
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
title?: ReactNode;
|
|
11
|
-
cookieKey?: string;
|
|
12
|
-
position?: POSITION;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class CookieMessage extends React.Component<CookieMessageProps> {}
|