@daeryun/dr_components 1.0.74 → 1.0.75
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.
|
@@ -7,12 +7,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import React, { useCallback, useEffect } from 'react';
|
|
10
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
11
11
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
12
12
|
import useBrowser from '../hook/useBrowser';
|
|
13
13
|
const ChatButton = ({ isOpen, onClick, apiVersion, isMobile = false, hashValue = null, bannerHeight = 0 }) => {
|
|
14
14
|
const { initializeDaeryuntalk, centerCode } = useDaeryuntalk();
|
|
15
15
|
const { width } = useBrowser(true);
|
|
16
|
+
const [isScrollTop, setIsScrollTop] = useState(true);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const handleScroll = () => {
|
|
19
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
20
|
+
setIsScrollTop(scrollTop === 0);
|
|
21
|
+
};
|
|
22
|
+
handleScroll();
|
|
23
|
+
window.addEventListener('scroll', handleScroll);
|
|
24
|
+
return () => {
|
|
25
|
+
window.removeEventListener('scroll', handleScroll);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
16
28
|
const handleClick = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
29
|
onClick();
|
|
18
30
|
if (!isOpen) {
|
|
@@ -39,14 +51,20 @@ const ChatButton = ({ isOpen, onClick, apiVersion, isMobile = false, hashValue =
|
|
|
39
51
|
}
|
|
40
52
|
}, [hashValue, apiVersion, initializeDaeryuntalk]);
|
|
41
53
|
return (<button aria-label="채팅 상담 열기" onClick={handleClick} style={{
|
|
42
|
-
bottom:
|
|
54
|
+
bottom: bannerHeight > 0 && (!isScrollTop || width >= 1024)
|
|
55
|
+
? width >= 1024
|
|
56
|
+
? `${bannerHeight + 20}px`
|
|
57
|
+
: `${bannerHeight + 78}px`
|
|
58
|
+
: width >= 1024
|
|
59
|
+
? '20px'
|
|
60
|
+
: '88px'
|
|
43
61
|
}} className={`
|
|
44
62
|
${isOpen ? 'hidden h-[50px] w-[50px] xs:block ' : 'h-[70px] w-[70px] 5xl:h-[100px] 5xl:w-[100px]'}
|
|
45
63
|
${hashValue ? 'pointer-events-none opacity-0' : ''}
|
|
46
64
|
fixed right-[10px] rounded-[10px] border lg:right-[25px]
|
|
47
65
|
${isOpen ? 'border-gray-200 bg-white' : 'border-[#AA1D36] bg-[#AA1D36]'}
|
|
48
66
|
z-[50] flex transform cursor-pointer items-center justify-center
|
|
49
|
-
p-0 shadow-lg outline-none transition-
|
|
67
|
+
p-0 shadow-lg outline-none transition-all duration-300 ease-in-out
|
|
50
68
|
hover:${isOpen ? 'bg-gray-100' : 'bg-[#8A1729]'}
|
|
51
69
|
`}>
|
|
52
70
|
{!isOpen && (<span style={{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
3
|
import useBrowser from '../hook/useBrowser';
|
|
4
4
|
|
|
@@ -21,6 +21,21 @@ const ChatButton: React.FC<ChatButtonProps> = ({
|
|
|
21
21
|
}) => {
|
|
22
22
|
const { initializeDaeryuntalk, centerCode } = useDaeryuntalk();
|
|
23
23
|
const { width } = useBrowser(true);
|
|
24
|
+
const [isScrollTop, setIsScrollTop] = useState(true);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const handleScroll = () => {
|
|
28
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
29
|
+
setIsScrollTop(scrollTop === 0);
|
|
30
|
+
};
|
|
31
|
+
handleScroll();
|
|
32
|
+
|
|
33
|
+
window.addEventListener('scroll', handleScroll);
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
window.removeEventListener('scroll', handleScroll);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
24
39
|
|
|
25
40
|
const handleClick = useCallback(async () => {
|
|
26
41
|
onClick();
|
|
@@ -51,7 +66,14 @@ const ChatButton: React.FC<ChatButtonProps> = ({
|
|
|
51
66
|
aria-label="채팅 상담 열기"
|
|
52
67
|
onClick={handleClick}
|
|
53
68
|
style={{
|
|
54
|
-
bottom:
|
|
69
|
+
bottom:
|
|
70
|
+
bannerHeight > 0 && (!isScrollTop || width >= 1024)
|
|
71
|
+
? width >= 1024
|
|
72
|
+
? `${bannerHeight + 20}px`
|
|
73
|
+
: `${bannerHeight + 78}px`
|
|
74
|
+
: width >= 1024
|
|
75
|
+
? '20px'
|
|
76
|
+
: '88px'
|
|
55
77
|
}}
|
|
56
78
|
className={`
|
|
57
79
|
${isOpen ? 'hidden h-[50px] w-[50px] xs:block ' : 'h-[70px] w-[70px] 5xl:h-[100px] 5xl:w-[100px]'}
|
|
@@ -59,7 +81,7 @@ const ChatButton: React.FC<ChatButtonProps> = ({
|
|
|
59
81
|
fixed right-[10px] rounded-[10px] border lg:right-[25px]
|
|
60
82
|
${isOpen ? 'border-gray-200 bg-white' : 'border-[#AA1D36] bg-[#AA1D36]'}
|
|
61
83
|
z-[50] flex transform cursor-pointer items-center justify-center
|
|
62
|
-
p-0 shadow-lg outline-none transition-
|
|
84
|
+
p-0 shadow-lg outline-none transition-all duration-300 ease-in-out
|
|
63
85
|
hover:${isOpen ? 'bg-gray-100' : 'bg-[#8A1729]'}
|
|
64
86
|
`}
|
|
65
87
|
>
|
package/dist/styles/globals.css
CHANGED
|
@@ -8387,12 +8387,6 @@ html {
|
|
|
8387
8387
|
transition-duration: 150ms;
|
|
8388
8388
|
}
|
|
8389
8389
|
|
|
8390
|
-
.transition-\[height\2c width\] {
|
|
8391
|
-
transition-property: height,width;
|
|
8392
|
-
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
8393
|
-
transition-duration: 150ms;
|
|
8394
|
-
}
|
|
8395
|
-
|
|
8396
8390
|
.transition-\[left\] {
|
|
8397
8391
|
transition-property: left;
|
|
8398
8392
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|