@cloud-ru/uikit-product-site-cookie-policy 1.1.0 → 1.2.0
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/CHANGELOG.md +11 -0
- package/README.md +7 -1
- package/dist/cjs/components/CookiePolicy.d.ts +8 -1
- package/dist/cjs/components/CookiePolicy.js +12 -4
- package/dist/cjs/components/styles.module.css +14 -17
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/esm/components/CookiePolicy.d.ts +8 -1
- package/dist/esm/components/CookiePolicy.js +13 -5
- package/dist/esm/components/styles.module.css +14 -17
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/package.json +4 -3
- package/src/components/CookiePolicy.tsx +28 -8
- package/src/components/styles.module.scss +13 -18
- package/src/constants.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 1.2.0 (2025-12-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **SITE-10433:** update component site-cookie ([6471e9e](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/6471e9ec8830b2dbdac7b77c87c53980159626cd))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 1.1.0 (2025-12-17)
|
|
7
18
|
|
|
8
19
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,13 @@ CookiePolicy — баннер для информирования пользов
|
|
|
10
10
|
|
|
11
11
|
[//]: DOCUMENTATION_SECTION_START
|
|
12
12
|
[//]: THIS_SECTION_IS_AUTOGENERATED_PLEASE_DONT_EDIT_IT
|
|
13
|
-
|
|
13
|
+
## CookiePolicy
|
|
14
|
+
### Props
|
|
15
|
+
| name | type | default value | description |
|
|
16
|
+
|------|------|---------------|-------------|
|
|
17
|
+
| layoutType* | enum LayoutType: `"mobile"`, `"tablet"`, `"desktop"`, `"desktopSmall"` | - | |
|
|
18
|
+
| className | `string` | - | Дополнительный className root элемента |
|
|
19
|
+
| onClick | `() => void` | - | Событие клика на кнопку |
|
|
14
20
|
|
|
15
21
|
|
|
16
22
|
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
|
|
2
|
+
export type CookiePolicyProps = WithLayoutType<{
|
|
3
|
+
/** Дополнительный className root элемента */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** Событие клика на кнопку */
|
|
6
|
+
onClick?(): void;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function CookiePolicy({ className, onClick, layoutType }: CookiePolicyProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -5,18 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CookiePolicy = CookiePolicy;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const uikit_product_utils_1 = require("@cloud-ru/uikit-product-utils");
|
|
10
11
|
const button_1 = require("@snack-uikit/button");
|
|
11
12
|
const constants_1 = require("../constants");
|
|
12
13
|
const CookiePolicyDescription_1 = require("./CookiePolicyDescription");
|
|
13
14
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
14
|
-
function CookiePolicy() {
|
|
15
|
+
function CookiePolicy({ className, onClick, layoutType }) {
|
|
15
16
|
const [skipWidget, setSkipWidget] = (0, uikit_product_utils_1.useLocalStorage)(constants_1.COOKIE_POLICY_STORAGE_KEY, 'false');
|
|
17
|
+
const [showCookiePolicy, setShowCookiePolicy] = (0, react_1.useState)(false);
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
if (skipWidget === 'false')
|
|
20
|
+
setShowCookiePolicy(true);
|
|
21
|
+
}, [skipWidget]);
|
|
16
22
|
const handleClickSubmit = (0, react_1.useCallback)(() => {
|
|
17
23
|
setSkipWidget('true');
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
setShowCookiePolicy(false);
|
|
25
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
26
|
+
}, [setSkipWidget, onClick]);
|
|
27
|
+
if (!showCookiePolicy)
|
|
20
28
|
return null;
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.cookiePolicyWrapper, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.cookiePolicyDescriptionWithButton, children: [(0, jsx_runtime_1.jsx)(CookiePolicyDescription_1.CookiePolicyDescription, {}), (0, jsx_runtime_1.jsx)(button_1.ButtonFilled, { onClick: handleClickSubmit, label: constants_1.COOKIE_POLICY_RIGHT_SECTION_TEXT, size: 'm' })] }) }));
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.cookiePolicyWrapper, className), "data-layout-type": layoutType, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.cookiePolicyDescriptionWithButton, "data-layout-type": layoutType, children: [(0, jsx_runtime_1.jsx)(CookiePolicyDescription_1.CookiePolicyDescription, {}), (0, jsx_runtime_1.jsx)(button_1.ButtonFilled, { onClick: handleClickSubmit, label: constants_1.COOKIE_POLICY_RIGHT_SECTION_TEXT, size: 'm', fullWidth: layoutType === 'mobile' })] }) }));
|
|
22
30
|
}
|
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
padding:24px;
|
|
6
6
|
display:flex;
|
|
7
7
|
overflow:hidden;
|
|
8
|
+
border-radius:4px;
|
|
9
|
+
}
|
|
10
|
+
.cookiePolicyWrapper[data-layout-type=tablet]{
|
|
11
|
+
padding:16px;
|
|
12
|
+
max-width:704px;
|
|
13
|
+
}
|
|
14
|
+
.cookiePolicyWrapper[data-layout-type=mobile]{
|
|
15
|
+
padding:16px;
|
|
16
|
+
max-width:328px;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
.cookiePolicyDescription{
|
|
@@ -17,22 +26,10 @@
|
|
|
17
26
|
justify-content:space-between;
|
|
18
27
|
gap:80px;
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.cookiePolicyWrapper{
|
|
23
|
-
padding:16px;
|
|
24
|
-
max-width:704px;
|
|
25
|
-
}
|
|
26
|
-
.cookiePolicyDescriptionWithButton{
|
|
27
|
-
gap:24px;
|
|
28
|
-
}
|
|
29
|
+
.cookiePolicyDescriptionWithButton[data-layout-type=tablet]{
|
|
30
|
+
gap:24px;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
.cookiePolicyDescriptionWithButton{
|
|
35
|
-
flex-direction:column;
|
|
36
|
-
gap:16px;
|
|
37
|
-
}
|
|
32
|
+
.cookiePolicyDescriptionWithButton[data-layout-type=mobile]{
|
|
33
|
+
flex-direction:column;
|
|
34
|
+
gap:16px;
|
|
38
35
|
}
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const COOKIE_POLICY_RIGHT_SECTION_TEXT = "\u041F\
|
|
1
|
+
export declare const COOKIE_POLICY_RIGHT_SECTION_TEXT = "\u041F\u043E\u043D\u044F\u0442\u043D\u043E";
|
|
2
2
|
export declare const COOKIE_POLICY_STORAGE_KEY = "userAgreeWithCookie";
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.COOKIE_POLICY_STORAGE_KEY = exports.COOKIE_POLICY_RIGHT_SECTION_TEXT = void 0;
|
|
4
|
-
exports.COOKIE_POLICY_RIGHT_SECTION_TEXT = '
|
|
4
|
+
exports.COOKIE_POLICY_RIGHT_SECTION_TEXT = 'Понятно';
|
|
5
5
|
exports.COOKIE_POLICY_STORAGE_KEY = 'userAgreeWithCookie';
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { WithLayoutType } from '@cloud-ru/uikit-product-utils';
|
|
2
|
+
export type CookiePolicyProps = WithLayoutType<{
|
|
3
|
+
/** Дополнительный className root элемента */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** Событие клика на кнопку */
|
|
6
|
+
onClick?(): void;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function CookiePolicy({ className, onClick, layoutType }: CookiePolicyProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
4
|
import { useLocalStorage } from '@cloud-ru/uikit-product-utils';
|
|
4
5
|
import { ButtonFilled } from '@snack-uikit/button';
|
|
5
6
|
import { COOKIE_POLICY_RIGHT_SECTION_TEXT, COOKIE_POLICY_STORAGE_KEY } from '../constants';
|
|
6
7
|
import { CookiePolicyDescription } from './CookiePolicyDescription';
|
|
7
8
|
import s from './styles.module.css';
|
|
8
|
-
export function CookiePolicy() {
|
|
9
|
+
export function CookiePolicy({ className, onClick, layoutType }) {
|
|
9
10
|
const [skipWidget, setSkipWidget] = useLocalStorage(COOKIE_POLICY_STORAGE_KEY, 'false');
|
|
11
|
+
const [showCookiePolicy, setShowCookiePolicy] = useState(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (skipWidget === 'false')
|
|
14
|
+
setShowCookiePolicy(true);
|
|
15
|
+
}, [skipWidget]);
|
|
10
16
|
const handleClickSubmit = useCallback(() => {
|
|
11
17
|
setSkipWidget('true');
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
setShowCookiePolicy(false);
|
|
19
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
20
|
+
}, [setSkipWidget, onClick]);
|
|
21
|
+
if (!showCookiePolicy)
|
|
14
22
|
return null;
|
|
15
|
-
return (_jsx("div", { className: s.cookiePolicyWrapper, children: _jsxs("div", { className: s.cookiePolicyDescriptionWithButton, children: [_jsx(CookiePolicyDescription, {}), _jsx(ButtonFilled, { onClick: handleClickSubmit, label: COOKIE_POLICY_RIGHT_SECTION_TEXT, size: 'm' })] }) }));
|
|
23
|
+
return (_jsx("div", { className: cn(s.cookiePolicyWrapper, className), "data-layout-type": layoutType, children: _jsxs("div", { className: s.cookiePolicyDescriptionWithButton, "data-layout-type": layoutType, children: [_jsx(CookiePolicyDescription, {}), _jsx(ButtonFilled, { onClick: handleClickSubmit, label: COOKIE_POLICY_RIGHT_SECTION_TEXT, size: 'm', fullWidth: layoutType === 'mobile' })] }) }));
|
|
16
24
|
}
|
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
padding:24px;
|
|
6
6
|
display:flex;
|
|
7
7
|
overflow:hidden;
|
|
8
|
+
border-radius:4px;
|
|
9
|
+
}
|
|
10
|
+
.cookiePolicyWrapper[data-layout-type=tablet]{
|
|
11
|
+
padding:16px;
|
|
12
|
+
max-width:704px;
|
|
13
|
+
}
|
|
14
|
+
.cookiePolicyWrapper[data-layout-type=mobile]{
|
|
15
|
+
padding:16px;
|
|
16
|
+
max-width:328px;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
.cookiePolicyDescription{
|
|
@@ -17,22 +26,10 @@
|
|
|
17
26
|
justify-content:space-between;
|
|
18
27
|
gap:80px;
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.cookiePolicyWrapper{
|
|
23
|
-
padding:16px;
|
|
24
|
-
max-width:704px;
|
|
25
|
-
}
|
|
26
|
-
.cookiePolicyDescriptionWithButton{
|
|
27
|
-
gap:24px;
|
|
28
|
-
}
|
|
29
|
+
.cookiePolicyDescriptionWithButton[data-layout-type=tablet]{
|
|
30
|
+
gap:24px;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
.cookiePolicyDescriptionWithButton{
|
|
35
|
-
flex-direction:column;
|
|
36
|
-
gap:16px;
|
|
37
|
-
}
|
|
32
|
+
.cookiePolicyDescriptionWithButton[data-layout-type=mobile]{
|
|
33
|
+
flex-direction:column;
|
|
34
|
+
gap:16px;
|
|
38
35
|
}
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const COOKIE_POLICY_RIGHT_SECTION_TEXT = "\u041F\
|
|
1
|
+
export declare const COOKIE_POLICY_RIGHT_SECTION_TEXT = "\u041F\u043E\u043D\u044F\u0442\u043D\u043E";
|
|
2
2
|
export declare const COOKIE_POLICY_STORAGE_KEY = "userAgreeWithCookie";
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const COOKIE_POLICY_RIGHT_SECTION_TEXT = '
|
|
1
|
+
export const COOKIE_POLICY_RIGHT_SECTION_TEXT = 'Понятно';
|
|
2
2
|
export const COOKIE_POLICY_STORAGE_KEY = 'userAgreeWithCookie';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloud-ru/uikit-product-site-cookie-policy",
|
|
3
3
|
"title": "Site Cookie Policy",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"@cloud-ru/uikit-product-utils": "8.1.0",
|
|
40
40
|
"@snack-uikit/button": "0.19.7",
|
|
41
41
|
"@snack-uikit/link": "0.17.12",
|
|
42
|
-
"@snack-uikit/typography": "0.8.7"
|
|
42
|
+
"@snack-uikit/typography": "0.8.7",
|
|
43
|
+
"classnames": "2.5.1"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "6974dbef2c07e14bc62de04868a85f7a931b48b0"
|
|
45
46
|
}
|
|
@@ -1,26 +1,46 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
3
|
|
|
3
|
-
import { useLocalStorage } from '@cloud-ru/uikit-product-utils';
|
|
4
|
+
import { useLocalStorage, WithLayoutType } from '@cloud-ru/uikit-product-utils';
|
|
4
5
|
import { ButtonFilled } from '@snack-uikit/button';
|
|
5
6
|
|
|
6
7
|
import { COOKIE_POLICY_RIGHT_SECTION_TEXT, COOKIE_POLICY_STORAGE_KEY } from '../constants';
|
|
7
8
|
import { CookiePolicyDescription } from './CookiePolicyDescription';
|
|
8
9
|
import s from './styles.module.scss';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
+
export type CookiePolicyProps = WithLayoutType<{
|
|
12
|
+
/** Дополнительный className root элемента */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Событие клика на кнопку */
|
|
15
|
+
onClick?(): void;
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
export function CookiePolicy({ className, onClick, layoutType }: CookiePolicyProps) {
|
|
11
19
|
const [skipWidget, setSkipWidget] = useLocalStorage<'true' | 'false'>(COOKIE_POLICY_STORAGE_KEY, 'false');
|
|
20
|
+
const [showCookiePolicy, setShowCookiePolicy] = useState(false);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (skipWidget === 'false') setShowCookiePolicy(true);
|
|
24
|
+
}, [skipWidget]);
|
|
12
25
|
|
|
13
26
|
const handleClickSubmit = useCallback(() => {
|
|
14
27
|
setSkipWidget('true');
|
|
15
|
-
|
|
28
|
+
setShowCookiePolicy(false);
|
|
29
|
+
onClick?.();
|
|
30
|
+
}, [setSkipWidget, onClick]);
|
|
16
31
|
|
|
17
|
-
if (
|
|
32
|
+
if (!showCookiePolicy) return null;
|
|
18
33
|
|
|
19
34
|
return (
|
|
20
|
-
<div className={s.cookiePolicyWrapper}>
|
|
21
|
-
<div className={s.cookiePolicyDescriptionWithButton}>
|
|
35
|
+
<div className={cn(s.cookiePolicyWrapper, className)} data-layout-type={layoutType}>
|
|
36
|
+
<div className={s.cookiePolicyDescriptionWithButton} data-layout-type={layoutType}>
|
|
22
37
|
<CookiePolicyDescription />
|
|
23
|
-
<ButtonFilled
|
|
38
|
+
<ButtonFilled
|
|
39
|
+
onClick={handleClickSubmit}
|
|
40
|
+
label={COOKIE_POLICY_RIGHT_SECTION_TEXT}
|
|
41
|
+
size='m'
|
|
42
|
+
fullWidth={layoutType === 'mobile'}
|
|
43
|
+
/>
|
|
24
44
|
</div>
|
|
25
45
|
</div>
|
|
26
46
|
);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
@use '@sbercloud/figma-tokens-web/build/scss/styles-theme-variables' as ds;
|
|
2
2
|
|
|
3
|
-
$breakpoint-mobile: 767px;
|
|
4
|
-
$breakpoint-tablet: 1023px;
|
|
5
|
-
|
|
6
3
|
.cookiePolicyWrapper {
|
|
7
4
|
background: ds.$sys-graphite-accent-default;
|
|
8
5
|
width: 100%;
|
|
@@ -10,6 +7,17 @@ $breakpoint-tablet: 1023px;
|
|
|
10
7
|
padding: 24px;
|
|
11
8
|
display: flex;
|
|
12
9
|
overflow: hidden;
|
|
10
|
+
border-radius: 4px;
|
|
11
|
+
|
|
12
|
+
&[data-layout-type='tablet'] {
|
|
13
|
+
padding: 16px;
|
|
14
|
+
max-width: 704px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&[data-layout-type='mobile'] {
|
|
18
|
+
padding: 16px;
|
|
19
|
+
max-width: 328px;
|
|
20
|
+
}
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
.cookiePolicyDescription {
|
|
@@ -21,25 +29,12 @@ $breakpoint-tablet: 1023px;
|
|
|
21
29
|
align-items: center;
|
|
22
30
|
justify-content: space-between;
|
|
23
31
|
gap: 80px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@media (max-width: $breakpoint-tablet) {
|
|
27
|
-
.cookiePolicyWrapper {
|
|
28
|
-
padding: 16px;
|
|
29
|
-
max-width: 704px;
|
|
30
|
-
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
&[data-layout-type='tablet'] {
|
|
33
34
|
gap: 24px;
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@media (max-width: $breakpoint-mobile) {
|
|
38
|
-
.cookiePolicyWrapper {
|
|
39
|
-
max-width: 328px;
|
|
40
|
-
}
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
&[data-layout-type='mobile'] {
|
|
43
38
|
flex-direction: column;
|
|
44
39
|
gap: 16px;
|
|
45
40
|
}
|
package/src/constants.ts
CHANGED