Skip to content

Commit c0156a5

Browse files
committed
chore: bot interaction update
1 parent 251289d commit c0156a5

File tree

4 files changed

+584
-623
lines changed

4 files changed

+584
-623
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@heroicons/react": "^2.1.1",
1313
"@splinetool/react-spline": "^2.2.6",
14-
"@splinetool/runtime": "^1.2.6",
14+
"@splinetool/runtime": "^1.2.8",
1515
"@uiw/react-md-editor": "^3.20.5",
1616
"eslint": "8.35.0",
1717
"eslint-config-next": "13.2.3",

src/app/(routes)/page.tsx

+16-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { motion } from 'framer-motion'
99
import dynamic from 'next/dynamic'
1010
import { Inter } from 'next/font/google'
1111
import { useRef, useState } from 'react'
12-
1312
const Spline = dynamic(() => import('@splinetool/react-spline'))
1413
const inter = Inter({ variable: '--font-inter', subsets: ['latin'] })
1514

@@ -52,10 +51,11 @@ const chat = {
5251
}
5352

5453
const SPLINE_SCENE = 'https://prod.spline.design/W83XdmrQbaQnPMlJ/scene.splinecode'
54+
const SPLINE_BOT_ID = '7a1937ee-e0ec-4da1-bca9-10b1ff105490'
5555

5656
const Home = () => {
5757
const [selected, setSelected] = useState<string | null>(null)
58-
const [chatToggle, setChatToggle] = useState<boolean>(false)
58+
const [isBotChangeOpened, setIsBotChangeOpened] = useState<boolean>(false)
5959

6060
const handleNavSelect = (name: string) => {
6161
if (selected === name) {
@@ -71,11 +71,17 @@ const Home = () => {
7171

7272
const onLoad = (spline: Application) => {
7373
splineRef.current = spline
74-
const botObj = spline.findObjectByName('Character')
74+
const botObj = spline.findObjectByName(SPLINE_BOT_ID)
7575
botObj?.emitEvent('mouseDown')
7676
botRef.current = botObj
7777
}
7878

79+
const toggleChat = () => {
80+
!!isBotChangeOpened
81+
? splineRef.current?.emitEventReverse('mouseDown', SPLINE_BOT_ID)
82+
: splineRef.current?.emitEvent('mouseDown', SPLINE_BOT_ID)
83+
setIsBotChangeOpened(!isBotChangeOpened)
84+
}
7985
return (
8086
<main className={inter.variable}>
8187
<div className="w-full h-[100vh] flex justify-center relative overflow-hidden">
@@ -86,17 +92,10 @@ const Home = () => {
8692
className="absolute w-full h-full
8793
flex justify-center items-center z-30 pointer-events-auto"
8894
>
89-
<Spline
90-
scene={SPLINE_SCENE}
91-
onLoad={onLoad}
92-
onMouseDown={(e) => {
93-
botRef.current?.emitEvent('mouseDown')
94-
setChatToggle(!chatToggle)
95-
}}
96-
/>
95+
<Spline scene={SPLINE_SCENE} onLoad={onLoad} />
9796
</div>
9897

99-
<ChatBox isOpen={chatToggle} />
98+
<ChatBox isOpen={isBotChangeOpened} />
10099

101100
{navList.map((nav, i) => (
102101
<NavModal selected={selected === nav.name} {...nav} key={`nav-modal-${nav}-${i}`} />
@@ -117,7 +116,9 @@ const Home = () => {
117116
{...nav}
118117
selected={selected === nav.name}
119118
onClick={() => {
120-
setChatToggle(false)
119+
if (!!isBotChangeOpened) {
120+
toggleChat()
121+
}
121122
handleNavSelect(nav.name)
122123
}}
123124
/>
@@ -131,11 +132,11 @@ const Home = () => {
131132
transition={{ ease: 'easeInOut', duration: 0.25 * navList.length }}
132133
>
133134
<NavItem
135+
selected={!!isBotChangeOpened}
134136
{...chat}
135137
onClick={() => {
136138
setSelected(null)
137-
botRef.current?.emitEventReverse('mouseDown')
138-
setChatToggle(!chatToggle)
139+
toggleChat()
139140
}}
140141
/>
141142
</motion.div>

src/components/common/chats/ChatBox.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ChatBox = ({ isOpen, onClose }: Params) => {
99
return (
1010
<motion.div
1111
className={`absolute w-full h-full md:max-h-[80vh] bottom-0 end-0 px-[24px] py-[100px] md:pb-[160px]
12-
flex justify-end items-center z-50 pointer-events-none`}
12+
flex justify-end items-center z-50 pointer-events-auto`}
1313
initial={{ opacity: 0 }}
1414
animate={!!isOpen ? 'open' : 'closed'}
1515
variants={{
@@ -19,9 +19,9 @@ const ChatBox = ({ isOpen, onClose }: Params) => {
1919
transition: { ease: 'easeInOut', duration: 0.5 }
2020
}),
2121
closed: () => ({
22-
y: 40,
22+
y: 80,
2323
opacity: 0,
24-
transition: { ease: 'backInOut', duration: 0.2 }
24+
transition: { ease: 'easeOut', duration: 0.5 }
2525
})
2626
}}
2727
>

0 commit comments

Comments
 (0)