hds-web 1.23.7 → 1.23.8
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/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useState } from "react";
|
1
|
+
import React, { useState, useEffect } from "react";
|
2
2
|
import { Typography } from "../../../foundation/Typography";
|
3
3
|
import { HDSColor } from "../../../foundation/ColorPalette";
|
4
4
|
import { Icon } from '../../../components/common-components/Icon';
|
@@ -12,13 +12,41 @@ const tagColorVariants = {
|
|
12
12
|
green: 'bg-neutral-0 tb:bg-green-500 text-green-500 tb:text-neutral-0',
|
13
13
|
}
|
14
14
|
|
15
|
+
const isBrowser = typeof window !== "undefined";
|
16
|
+
|
15
17
|
export default function AnnouncementMd(props) {
|
16
18
|
const [isBannerActive, toggleBanner] = useState(true);
|
17
19
|
const bgClass = props.bgColorClass ? HDSColor(props.bgColorClass) : 'bg-neutral-0';
|
18
20
|
const linkTextClass = props.linkTextColorClass ? HDSColor(props.linkTextColorClass) : 'text-neutral-600';
|
19
21
|
const tagClass = props.tagColor ? props.tagColor : 'purple';
|
20
22
|
const iconBgClass = props.iconBgColor ? HDSColor(props.iconBgColor) : 'bg-blue-200'
|
21
|
-
|
23
|
+
|
24
|
+
const [isConsentForm, setIsConsentForm] = useState(false);
|
25
|
+
const onCloseBanner = () => {
|
26
|
+
toggleBanner(false);
|
27
|
+
if (isBrowser) {
|
28
|
+
window.sessionStorage.setItem("announcementConsent", "true");
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
useEffect(() => {
|
33
|
+
if (isBrowser) {
|
34
|
+
if (
|
35
|
+
"sessionStorage" in window &&
|
36
|
+
window.sessionStorage &&
|
37
|
+
"getItem" in window.sessionStorage
|
38
|
+
) {
|
39
|
+
const localSessionStorage = window.sessionStorage.getItem(
|
40
|
+
"announcementConsent"
|
41
|
+
);
|
42
|
+
if (localSessionStorage) {
|
43
|
+
setIsConsentForm(true);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}, []);
|
48
|
+
|
49
|
+
if (isBannerActive && !isConsentForm) {
|
22
50
|
return (
|
23
51
|
<div className="py-6">
|
24
52
|
<div className={`${bgClass} flex justify-between relative rounded-2xl tb:rounded-full shadow p-4 tb:justify-center tb:items-center`}>
|
@@ -49,7 +77,7 @@ export default function AnnouncementMd(props) {
|
|
49
77
|
</Typography>
|
50
78
|
</a>
|
51
79
|
</div>
|
52
|
-
<div className="static mt-[2px] tb:mt-0 ml-3 tb:ml-0 tb:absolute top-1/2 tb:-translate-y-1/2 tb:left-6 cursor-pointer w-5 h-5 min-w-[20px] tb:w-8 tb:min-w-[32px] tb:h-8 rounded-full bg-neutral-100 flex items-center justify-center" onClick={()=>
|
80
|
+
<div className="static mt-[2px] tb:mt-0 ml-3 tb:ml-0 tb:absolute top-1/2 tb:-translate-y-1/2 tb:left-6 cursor-pointer w-5 h-5 min-w-[20px] tb:w-8 tb:min-w-[32px] tb:h-8 rounded-full bg-neutral-100 flex items-center justify-center" onClick={()=>onCloseBanner()}>
|
53
81
|
<Icon height={'block w-4 h-4 tb:w-6 tb:h-6 stroke-[2px] transition ease-in-out'} variant='xclose' strokeClass='stroke-neutral-800' />
|
54
82
|
</div>
|
55
83
|
</div>
|