@stack-spot/portal-layout 2.19.3 → 2.20.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 +19 -0
- package/dist/components/Rate/FeedbackModal.d.ts +1 -1
- package/dist/components/Rate/FeedbackModal.d.ts.map +1 -1
- package/dist/components/Rate/FeedbackModal.js +7 -5
- package/dist/components/Rate/FeedbackModal.js.map +1 -1
- package/dist/components/Rate/on-nps-submit.d.ts.map +1 -1
- package/dist/components/Rate/on-nps-submit.js +3 -2
- package/dist/components/Rate/on-nps-submit.js.map +1 -1
- package/dist/components/Rate/show-rate-us-modals.d.ts +1 -1
- package/dist/components/Rate/show-rate-us-modals.js +1 -1
- package/dist/components/Rate/utils.d.ts +1 -1
- package/dist/components/Rate/utils.d.ts.map +1 -1
- package/dist/components/Rate/utils.js +2 -8
- package/dist/components/Rate/utils.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/layout.css +10 -0
- package/package.json +3 -3
- package/src/components/Rate/FeedbackModal.tsx +10 -8
- package/src/components/Rate/on-nps-submit.ts +3 -2
- package/src/components/Rate/show-rate-us-modals.tsx +1 -1
- package/src/components/Rate/utils.ts +2 -7
- package/src/index.ts +1 -1
- package/src/layout.css +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.20.0](https://github.com/stack-spot/portal-commons/compare/portal-layout@v2.19.4...portal-layout@v2.20.0) (2024-12-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* update libs banner ([#604](https://github.com/stack-spot/portal-commons/issues/604)) ([f2bc440](https://github.com/stack-spot/portal-commons/commit/f2bc440db6c65461a2b1228d0efc08ed3d883d67))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Bump lib ([#612](https://github.com/stack-spot/portal-commons/issues/612)) ([2aca501](https://github.com/stack-spot/portal-commons/commit/2aca501e9d117c149e72acd8786a8de95dafabb1))
|
|
14
|
+
|
|
15
|
+
## [2.19.4](https://github.com/stack-spot/portal-commons/compare/portal-layout@v2.19.3...portal-layout@v2.19.4) (2024-12-20)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* Improve nps flow ([#599](https://github.com/stack-spot/portal-commons/issues/599)) ([5af32a3](https://github.com/stack-spot/portal-commons/commit/5af32a3a714dff206180c63c4fad74d731902d87))
|
|
21
|
+
|
|
3
22
|
## [2.19.3](https://github.com/stack-spot/portal-commons/compare/portal-layout@v2.19.2...portal-layout@v2.19.3) (2024-12-20)
|
|
4
23
|
|
|
5
24
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedbackModal.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/FeedbackModal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeedbackModal.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/FeedbackModal.tsx"],"names":[],"mappings":"AAuBA,eAAO,MAAM,aAAa,wBAAyB;IAAE,OAAO,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,KAAK,GAAG,IAAI,CAAA;CAAE,mDA0C/F,CAAA"}
|
|
@@ -4,7 +4,8 @@ import { ArrowRight, TimesMini } from '@citric/icons';
|
|
|
4
4
|
import { IconButton } from '@citric/ui';
|
|
5
5
|
import { theme } from '@stack-spot/portal-theme';
|
|
6
6
|
import { useTranslate } from '@stack-spot/portal-translate';
|
|
7
|
-
import { useEffect } from 'react';
|
|
7
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
8
|
+
import { shouldShowNpsModal } from './hook.js';
|
|
8
9
|
import { checkVisibility } from './utils.js';
|
|
9
10
|
const style = {
|
|
10
11
|
box: {
|
|
@@ -21,19 +22,20 @@ const style = {
|
|
|
21
22
|
};
|
|
22
23
|
export const FeedbackModal = ({ onClick, portal }) => {
|
|
23
24
|
const t = useTranslate(dictionary);
|
|
25
|
+
const [isNpsVisible, setIsNpsVisible] = useState(shouldShowNpsModal());
|
|
24
26
|
const handleClose = () => {
|
|
25
27
|
localStorage.setItem('RATED_US_IN', Date.now().toString());
|
|
26
|
-
|
|
28
|
+
setIsNpsVisible(false);
|
|
27
29
|
};
|
|
30
|
+
const visibilityCheck = useCallback((event) => checkVisibility(event, setIsNpsVisible), []);
|
|
28
31
|
useEffect(() => {
|
|
29
|
-
checkVisibility({ key: 'RATED_US_IN' });
|
|
30
|
-
const visibilityCheck = (event) => checkVisibility(event);
|
|
32
|
+
checkVisibility({ key: 'RATED_US_IN' }, setIsNpsVisible);
|
|
31
33
|
window.addEventListener('storage', visibilityCheck);
|
|
32
34
|
return () => {
|
|
33
35
|
window.removeEventListener('storage', visibilityCheck);
|
|
34
36
|
};
|
|
35
37
|
}, []);
|
|
36
|
-
return (_jsxs(Box, { sx: style.box, id: "feedback-modal", children: [_jsxs(Flex, { justifyContent: "space-between", flexWrap: "nowrap", children: [_jsxs(Text, { appearance: "h5", mb: 6, children: [t.title, portal, "?"] }), _jsx(IconButton, { onClick: handleClose, children: _jsx(TimesMini, {}) })] }), _jsx(Text, { sx: { lineHeight: '24px' }, children: t.description }), _jsx(Flex, { flexDirection: "row-reverse", mt: 7, mb: 4, children: _jsxs(Button, { onClick: onClick, size: "md", children: [t.buttonText, _jsx(IconBox, { colorIcon: "inverse.contrastText", ml: 2, children: _jsx(ArrowRight, {}) })] }) })] }));
|
|
38
|
+
return isNpsVisible ? (_jsxs(Box, { sx: style.box, id: "feedback-modal", children: [_jsxs(Flex, { justifyContent: "space-between", flexWrap: "nowrap", children: [_jsxs(Text, { appearance: "h5", mb: 6, children: [t.title, portal, "?"] }), _jsx(IconButton, { onClick: handleClose, id: "feedback-modal-close-icon", children: _jsx(TimesMini, {}) })] }), _jsx(Text, { sx: { lineHeight: '24px' }, children: t.description }), _jsx(Flex, { flexDirection: "row-reverse", mt: 7, mb: 4, children: _jsxs(Button, { onClick: onClick, size: "md", children: [t.buttonText, _jsx(IconBox, { colorIcon: "inverse.contrastText", ml: 2, children: _jsx(ArrowRight, {}) })] }) })] })) : null;
|
|
37
39
|
};
|
|
38
40
|
const dictionary = {
|
|
39
41
|
en: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeedbackModal.js","sourceRoot":"","sources":["../../../src/components/Rate/FeedbackModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAU,IAAI,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"FeedbackModal.js","sourceRoot":"","sources":["../../../src/components/Rate/FeedbackModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAU,IAAI,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAc,YAAY,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,KAAK,GAAW;IACpB,GAAG,EAAE;QACH,KAAK,EAAE,OAAO;QACd,EAAE,EAAE,WAAW;QACf,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,CAAC;QACN,KAAK,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;QACJ,MAAM,EAAE,CAAC;QACT,YAAY,EAAE,MAAM;QACpB,SAAS,EAAE,oBAAoB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;KACxD;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAiD,EAAE,EAAE;IAClG,MAAM,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC,CAAA;IAClC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAA;IAEtE,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC1D,eAAe,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC,CAAA;IAED,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,KAAmB,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,EAAE,CAAC,CAAA;IAEzG,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,EAAE,GAAG,EAAE,aAAa,EAAkB,EAAE,eAAe,CAAC,CAAA;QAExE,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;QAEnD,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;QACxD,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,YAAY,CAAC,CAAC,CAAC,CACpB,MAAC,GAAG,IAAC,EAAE,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,EAAC,gBAAgB,aACrC,MAAC,IAAI,IAAC,cAAc,EAAC,eAAe,EAAC,QAAQ,EAAC,QAAQ,aACpD,MAAC,IAAI,IAAC,UAAU,EAAC,IAAI,EAAC,EAAE,EAAE,CAAC,aAAG,CAAC,CAAC,KAAK,EAAE,MAAM,SAAS,EACtD,KAAC,UAAU,IAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAC,2BAA2B,YAC9D,KAAC,SAAS,KAAG,GACF,IACR,EACP,KAAC,IAAI,IAAC,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,YAC7B,CAAC,CAAC,WAAW,GACT,EACP,KAAC,IAAI,IAAC,aAAa,EAAC,aAAa,EAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,YAC5C,MAAC,MAAM,IAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,IAAI,aAChC,CAAC,CAAC,UAAU,EACb,KAAC,OAAO,IAAC,SAAS,EAAC,sBAAsB,EAAC,EAAE,EAAE,CAAC,YAC7C,KAAC,UAAU,KAAG,GACN,IACH,GACJ,IACH,CACP,CAAC,CAAC,CAAC,IAAI,CAAA;AACV,CAAC,CAAA;AAED,MAAM,UAAU,GAAG;IACjB,EAAE,EAAE;QACF,KAAK,EAAE,uCAAuC;QAC9C,WAAW,EAAE,0GAA0G;QACvH,UAAU,EAAE,qBAAqB;KAClC;IACD,EAAE,EAAE;QACF,KAAK,EAAE,0CAA0C;QACjD,WAAW,EAAE,2GAA2G;QACxH,UAAU,EAAE,0BAA0B;KACvC;CACmB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-nps-submit.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/on-nps-submit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"on-nps-submit.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/on-nps-submit.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAA;AAGT,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,EAAE,MAAM,IAAI,CAAC;KACzB;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { overlay } from '../../LayoutOverlayManager.js';
|
|
2
2
|
function onNpsSubmit() {
|
|
3
3
|
localStorage.setItem('RATED_US_IN', Date.now().toString());
|
|
4
|
-
|
|
4
|
+
overlay.closeModal();
|
|
5
|
+
document.getElementById('feedback-modal-close-icon')?.click();
|
|
5
6
|
}
|
|
6
7
|
window.onNpsSubmit = onNpsSubmit;
|
|
7
8
|
//# sourceMappingURL=on-nps-submit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-nps-submit.js","sourceRoot":"","sources":["../../../src/components/Rate/on-nps-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"on-nps-submit.js","sourceRoot":"","sources":["../../../src/components/Rate/on-nps-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,SAAS,WAAW;IAClB,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC1D,OAAO,CAAC,UAAU,EAAE,CAAA;IACpB,QAAQ,CAAC,cAAc,CAAC,2BAA2B,CAAC,EAAE,KAAK,EAAE,CAAA;AAC/D,CAAC;AAWD,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { overlay } from '../../LayoutOverlayManager.js';
|
|
3
3
|
import { FeedbackModal } from './FeedbackModal.js';
|
|
4
4
|
import { RateComponent } from './index.js';
|
|
5
|
-
export const
|
|
5
|
+
export const ShowFeedbackModal = ({ onClick, portal }) => (_jsx(FeedbackModal, { onClick: onClick, portal: portal }));
|
|
6
6
|
export const showRateUsModal = ({ title, ...props }) => {
|
|
7
7
|
const { formIdentifier, sub, tenant, portal } = props;
|
|
8
8
|
overlay.showModal({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const checkVisibility: (event: StorageEvent) => void;
|
|
1
|
+
export declare const checkVisibility: (event: StorageEvent, fnUpdateState: React.Dispatch<React.SetStateAction<boolean>>) => void;
|
|
2
2
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,UAAW,YAAY,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Rate/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,UAAW,YAAY,iBAAiB,MAAM,QAAQ,CAAC,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC,SAOhH,CAAA"}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { shouldShowNpsModal } from './hook.js';
|
|
2
|
-
export const checkVisibility = (event) => {
|
|
2
|
+
export const checkVisibility = (event, fnUpdateState) => {
|
|
3
3
|
if (event.key === 'RATED_US_IN') {
|
|
4
4
|
const shouldShow = shouldShowNpsModal();
|
|
5
5
|
if (!shouldShow) {
|
|
6
|
-
|
|
7
|
-
document.getElementById('feedback-modal')?.remove();
|
|
8
|
-
}
|
|
9
|
-
catch {
|
|
10
|
-
// eslint-disable-next-line no-console
|
|
11
|
-
console.warn('Error removing');
|
|
12
|
-
}
|
|
6
|
+
fnUpdateState(false);
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Rate/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Rate/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,aAA4D,EAAE,EAAE;IACnH,IAAI,KAAK,CAAC,GAAG,KAAK,aAAa,EAAE,CAAC;QAChC,MAAM,UAAU,GAAG,kBAAkB,EAAE,CAAA;QACvC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,aAAa,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { PortalSwitcher } from './components/PortalSwitcher.js';
|
|
|
10
10
|
export { usePrivacyPolicyEffect } from './components/PrivacyPolicyMessage/hooks.js';
|
|
11
11
|
export { RateComponent } from './components/Rate/index.js';
|
|
12
12
|
export { shouldShowNpsModal, useRatingEffect } from './components/Rate/hook.js';
|
|
13
|
-
export {
|
|
13
|
+
export { ShowFeedbackModal, showRateUsModal } from './components/Rate/show-rate-us-modals.js';
|
|
14
14
|
export * from './components/tour/index.js';
|
|
15
15
|
export * from './elements.js';
|
|
16
16
|
export * from './errors.js';
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ export { PortalSwitcher } from './components/PortalSwitcher.js';
|
|
|
10
10
|
export { usePrivacyPolicyEffect } from './components/PrivacyPolicyMessage/hooks.js';
|
|
11
11
|
export { RateComponent } from './components/Rate/index.js';
|
|
12
12
|
export { shouldShowNpsModal, useRatingEffect } from './components/Rate/hook.js';
|
|
13
|
-
export {
|
|
13
|
+
export { ShowFeedbackModal, showRateUsModal } from './components/Rate/show-rate-us-modals.js';
|
|
14
14
|
export * from './components/tour/index.js';
|
|
15
15
|
export * from './elements.js';
|
|
16
16
|
export * from './errors.js';
|
package/dist/layout.css
CHANGED
|
@@ -94,6 +94,16 @@ body {
|
|
|
94
94
|
transition: left ease-in-out var(--menu-animation-duration);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
#page.home-banner-visible {
|
|
98
|
+
padding: 0 !important;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#banner-warning {
|
|
102
|
+
width: 90.7vw;
|
|
103
|
+
margin-left: calc(-0.6 * var(--menu-sections-width));
|
|
104
|
+
margin-right: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
97
107
|
#layout.menu-content-visible #page {
|
|
98
108
|
left: calc(var(--menu-sections-width) + var(--menu-content-width));
|
|
99
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/portal-layout",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"@citric/icons": "^5.9.0",
|
|
15
15
|
"@citric/ui": "^6.1.1",
|
|
16
16
|
"@stack-spot/portal-theme": "^1.0.0",
|
|
17
|
-
"@stack-spot/portal-translate": "^1.
|
|
18
|
-
"@stack-spot/portal-components": "^2.
|
|
17
|
+
"@stack-spot/portal-translate": "^1.1.0",
|
|
18
|
+
"@stack-spot/portal-components": "^2.11.0",
|
|
19
19
|
"react": "^18.2.0",
|
|
20
20
|
"react-dom": "^18.2.0",
|
|
21
21
|
"styled-components": "^6.1.10"
|
|
@@ -3,7 +3,8 @@ import { ArrowRight, TimesMini } from '@citric/icons'
|
|
|
3
3
|
import { IconButton } from '@citric/ui'
|
|
4
4
|
import { theme } from '@stack-spot/portal-theme'
|
|
5
5
|
import { Dictionary, useTranslate } from '@stack-spot/portal-translate'
|
|
6
|
-
import { useEffect } from 'react'
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react'
|
|
7
|
+
import { shouldShowNpsModal } from './hook'
|
|
7
8
|
import { checkVisibility } from './utils'
|
|
8
9
|
|
|
9
10
|
const style: Styles = {
|
|
@@ -22,16 +23,17 @@ const style: Styles = {
|
|
|
22
23
|
|
|
23
24
|
export const FeedbackModal = ({ onClick, portal }: { onClick: () => void, portal: 'EDP' | 'AI' }) => {
|
|
24
25
|
const t = useTranslate(dictionary)
|
|
26
|
+
const [isNpsVisible, setIsNpsVisible] = useState(shouldShowNpsModal())
|
|
25
27
|
|
|
26
28
|
const handleClose = () => {
|
|
27
29
|
localStorage.setItem('RATED_US_IN', Date.now().toString())
|
|
28
|
-
|
|
30
|
+
setIsNpsVisible(false)
|
|
29
31
|
}
|
|
32
|
+
|
|
33
|
+
const visibilityCheck = useCallback((event: StorageEvent) => checkVisibility(event, setIsNpsVisible), [])
|
|
30
34
|
|
|
31
35
|
useEffect(() => {
|
|
32
|
-
checkVisibility({ key: 'RATED_US_IN' } as StorageEvent)
|
|
33
|
-
|
|
34
|
-
const visibilityCheck = (event: StorageEvent) => checkVisibility(event)
|
|
36
|
+
checkVisibility({ key: 'RATED_US_IN' } as StorageEvent, setIsNpsVisible)
|
|
35
37
|
|
|
36
38
|
window.addEventListener('storage', visibilityCheck)
|
|
37
39
|
|
|
@@ -40,11 +42,11 @@ export const FeedbackModal = ({ onClick, portal }: { onClick: () => void, portal
|
|
|
40
42
|
}
|
|
41
43
|
}, [])
|
|
42
44
|
|
|
43
|
-
return (
|
|
45
|
+
return isNpsVisible ? (
|
|
44
46
|
<Box sx={style.box} id="feedback-modal">
|
|
45
47
|
<Flex justifyContent="space-between" flexWrap="nowrap">
|
|
46
48
|
<Text appearance="h5" mb={6}>{t.title}{portal}?</Text>
|
|
47
|
-
<IconButton onClick={handleClose}>
|
|
49
|
+
<IconButton onClick={handleClose} id="feedback-modal-close-icon">
|
|
48
50
|
<TimesMini />
|
|
49
51
|
</IconButton>
|
|
50
52
|
</Flex>
|
|
@@ -60,7 +62,7 @@ export const FeedbackModal = ({ onClick, portal }: { onClick: () => void, portal
|
|
|
60
62
|
</Button>
|
|
61
63
|
</Flex>
|
|
62
64
|
</Box>
|
|
63
|
-
)
|
|
65
|
+
) : null
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
const dictionary = {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { overlay } from '../../LayoutOverlayManager'
|
|
2
2
|
|
|
3
3
|
function onNpsSubmit(): void {
|
|
4
4
|
localStorage.setItem('RATED_US_IN', Date.now().toString())
|
|
5
|
-
|
|
5
|
+
overlay.closeModal()
|
|
6
|
+
document.getElementById('feedback-modal-close-icon')?.click()
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
export {}
|
|
@@ -2,7 +2,7 @@ import { overlay } from '../../LayoutOverlayManager'
|
|
|
2
2
|
import { FeedbackModal } from './FeedbackModal'
|
|
3
3
|
import { RateComponent } from '.'
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const ShowFeedbackModal = ({ onClick, portal }: { onClick: () => void, portal: 'EDP' | 'AI' }) => (
|
|
6
6
|
<FeedbackModal onClick={onClick} portal={portal} />
|
|
7
7
|
)
|
|
8
8
|
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { shouldShowNpsModal } from './hook'
|
|
2
2
|
|
|
3
|
-
export const checkVisibility = (event: StorageEvent) => {
|
|
3
|
+
export const checkVisibility = (event: StorageEvent, fnUpdateState: React.Dispatch<React.SetStateAction<boolean>>) => {
|
|
4
4
|
if (event.key === 'RATED_US_IN') {
|
|
5
5
|
const shouldShow = shouldShowNpsModal()
|
|
6
6
|
if (!shouldShow) {
|
|
7
|
-
|
|
8
|
-
document.getElementById('feedback-modal')?.remove()
|
|
9
|
-
} catch {
|
|
10
|
-
// eslint-disable-next-line no-console
|
|
11
|
-
console.warn('Error removing')
|
|
12
|
-
}
|
|
7
|
+
fnUpdateState(false)
|
|
13
8
|
}
|
|
14
9
|
}
|
|
15
10
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { PortalSwitcher } from './components/PortalSwitcher'
|
|
|
10
10
|
export { usePrivacyPolicyEffect } from './components/PrivacyPolicyMessage/hooks'
|
|
11
11
|
export { RateComponent } from './components/Rate'
|
|
12
12
|
export { shouldShowNpsModal, useRatingEffect } from './components/Rate/hook'
|
|
13
|
-
export {
|
|
13
|
+
export { ShowFeedbackModal, showRateUsModal } from './components/Rate/show-rate-us-modals'
|
|
14
14
|
export * from './components/tour'
|
|
15
15
|
export * from './elements'
|
|
16
16
|
export * from './errors'
|
package/src/layout.css
CHANGED
|
@@ -94,6 +94,16 @@ body {
|
|
|
94
94
|
transition: left ease-in-out var(--menu-animation-duration);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
#page.home-banner-visible {
|
|
98
|
+
padding: 0 !important;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#banner-warning {
|
|
102
|
+
width: 90.7vw;
|
|
103
|
+
margin-left: calc(-0.6 * var(--menu-sections-width));
|
|
104
|
+
margin-right: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
97
107
|
#layout.menu-content-visible #page {
|
|
98
108
|
left: calc(var(--menu-sections-width) + var(--menu-content-width));
|
|
99
109
|
}
|