1
1
'use client'
2
2
3
+ import ChatBox from '@/components/common/chats/ChatBox'
3
4
import { NavItem } from '@/components/main/NavItem'
4
5
import { NavModal } from '@/components/main/NavModal'
5
- import { CubeIcon , DocumentIcon , FaceSmileIcon } from '@heroicons/react/24/solid'
6
- import Spline from '@splinetool/react-spline'
6
+ import { ChatBubbleLeftEllipsisIcon , DocumentIcon } from '@heroicons/react/24/solid'
7
7
import { Application , SPEObject } from '@splinetool/runtime'
8
8
import { motion } from 'framer-motion'
9
+ import dynamic from 'next/dynamic'
9
10
import { Inter } from 'next/font/google'
10
- import { useEffect , useRef , useState } from 'react'
11
+ import { useRef , useState } from 'react'
11
12
13
+ const Spline = dynamic ( ( ) => import ( '@splinetool/react-spline' ) )
12
14
const inter = Inter ( { variable : '--font-inter' , subsets : [ 'latin' ] } )
13
15
14
16
const navList = [
@@ -18,18 +20,18 @@ const navList = [
18
20
icon : < DocumentIcon className = "text-light" /> ,
19
21
desc : 'Check out my dev blog posts'
20
22
} ,
21
- {
22
- name : 'works' ,
23
- href : '/works' ,
24
- icon : < CubeIcon className = "text-light" /> ,
25
- desc : 'Check out my works'
26
- } ,
27
- {
28
- name : 'about' ,
29
- href : '/about' ,
30
- icon : < FaceSmileIcon className = "text-light" /> ,
31
- desc : 'Get to know more about me'
32
- } ,
23
+ // {
24
+ // name: 'works',
25
+ // href: '/works',
26
+ // icon: <CubeIcon className="text-light" />,
27
+ // desc: 'Check out my works'
28
+ // },
29
+ // {
30
+ // name: 'about',
31
+ // href: '/about',
32
+ // icon: <FaceSmileIcon className="text-light" />,
33
+ // desc: 'Get to know more about me'
34
+ // },
33
35
{
34
36
name : 'github' ,
35
37
href : 'https://www.github.com/henrynoowah' ,
@@ -42,36 +44,24 @@ const navList = [
42
44
}
43
45
]
44
46
47
+ const chat = {
48
+ name : 'chat' ,
49
+ href : 'https://www.github.com/henrynoowah' ,
50
+ icon : < ChatBubbleLeftEllipsisIcon className = "text-light" /> ,
51
+ desc : 'Chat bot!'
52
+ }
53
+
45
54
const SPLINE_SCENE = 'https://prod.spline.design/W83XdmrQbaQnPMlJ/scene.splinecode'
46
55
47
56
const Home = ( ) => {
48
57
const [ selected , setSelected ] = useState < string | null > ( null )
49
-
50
- const sidebar = {
51
- open : ( height = 1000 ) => ( {
52
- clipPath : `circle(${ height * 2 + 200 } px at 40px 40px)` ,
53
- transition : {
54
- type : 'spring' ,
55
- stiffness : 20 ,
56
- restDelta : 2
57
- }
58
- } ) ,
59
- closed : {
60
- clipPath : `circle(30px at 40px 40px)` ,
61
- transition : {
62
- delay : 0.5 ,
63
- type : 'spring' ,
64
- stiffness : 400 ,
65
- damping : 40
66
- }
67
- }
68
- }
58
+ const [ chatToggle , setChatToggle ] = useState < boolean > ( false )
69
59
70
60
const handleNavSelect = ( name : string ) => {
71
61
if ( selected === name ) {
72
62
setSelected ( null )
73
63
} else {
74
- const ref = document . getElementById ( name )
64
+ // const ref = document.getElementById(name)
75
65
setSelected ( name )
76
66
}
77
67
}
@@ -82,19 +72,10 @@ const Home = () => {
82
72
const onLoad = ( spline : Application ) => {
83
73
splineRef . current = spline
84
74
const botObj = spline . findObjectByName ( 'Character' )
75
+ botObj ?. emitEvent ( 'mouseDown' )
85
76
botRef . current = botObj
86
77
}
87
78
88
- const [ toggle , setToggle ] = useState < boolean > ( false )
89
-
90
- function triggerAnimation ( ) {
91
- splineRef . current ?. emitEvent ( 'mouseHover' , 'Camera' )
92
- }
93
-
94
- useEffect ( ( ) => {
95
- console . log ( toggle )
96
- } , [ toggle ] )
97
-
98
79
return (
99
80
< main className = { inter . variable } >
100
81
< div className = "w-full h-[100vh] flex justify-center relative overflow-hidden" >
@@ -109,29 +90,13 @@ const Home = () => {
109
90
scene = { SPLINE_SCENE }
110
91
onLoad = { onLoad }
111
92
onMouseDown = { ( e ) => {
112
- console . log ( e . target )
113
- console . log ( toggle )
114
- setToggle ( ! toggle )
93
+ botRef . current ?. emitEvent ( 'mouseDown' )
94
+ setChatToggle ( ! chatToggle )
115
95
} }
116
96
/>
117
97
</ div >
118
98
119
- { /* {!!toggle && (
120
- <div
121
- className="absolute w-full h-full
122
- flex justify-end items-center z-50 pointer-events-none] pt-[10%] pb-[22%] px-[16px] md:px-[10%] pointer-events-none"
123
- >
124
- <div
125
- className="w-full h-full max-w-full md:max-w-[400px] bg-light end-0 rounded p-4 shadow-xl backdrop-filter backdrop-blur-lg bg-opacity-40"
126
- onClick={() => {}}
127
- >
128
- Test
129
- </div>
130
- </div>
131
- )} */ }
132
- { /* <button className="z-40 pointer-events-auto" type="button" onClick={triggerAnimation}>
133
- Trigger Spline Animation
134
- </button> */ }
99
+ < ChatBox isOpen = { chatToggle } />
135
100
136
101
{ navList . map ( ( nav , i ) => (
137
102
< NavModal selected = { selected === nav . name } { ...nav } key = { `nav-modal-${ nav } -${ i } ` } />
@@ -148,10 +113,33 @@ const Home = () => {
148
113
animate = { { y : 0 , opacity : 100 } }
149
114
transition = { { ease : 'easeInOut' , duration : 0.25 * i } }
150
115
>
151
- < NavItem { ...nav } selected = { selected === nav . name } onClick = { ( ) => handleNavSelect ( nav . name ) } />
116
+ < NavItem
117
+ { ...nav }
118
+ selected = { selected === nav . name }
119
+ onClick = { ( ) => {
120
+ setChatToggle ( false )
121
+ handleNavSelect ( nav . name )
122
+ } }
123
+ />
152
124
</ motion . div >
153
125
</ div >
154
126
) ) }
127
+ < div id = { chat . name } className = "pointer-events-auto" >
128
+ < motion . div
129
+ initial = { { y : 40 , opacity : 0 } }
130
+ animate = { { y : 0 , opacity : 100 } }
131
+ transition = { { ease : 'easeInOut' , duration : 0.25 * navList . length } }
132
+ >
133
+ < NavItem
134
+ { ...chat }
135
+ onClick = { ( ) => {
136
+ setSelected ( null )
137
+ botRef . current ?. emitEventReverse ( 'mouseDown' )
138
+ setChatToggle ( ! chatToggle )
139
+ } }
140
+ />
141
+ </ motion . div >
142
+ </ div >
155
143
</ nav >
156
144
</ div >
157
145
</ div >
0 commit comments