Skip to content

Commit ed6c63a

Browse files
committed
adding the contact page - Day 4
1 parent be09554 commit ed6c63a

File tree

3 files changed

+91
-65
lines changed

3 files changed

+91
-65
lines changed

components/mouse/index.js

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,50 +41,47 @@ const Mouse = () => {
4141
}, [])
4242

4343
useEffect(() => {
44-
if (!(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) {
45-
46-
cursor.current.style.borderWidth = `2px`
47-
const a = document.querySelectorAll('a')
48-
a.forEach(el => {
49-
el.addEventListener("mouseenter", event => {
50-
cursor.current.style.width = cssVar('--cursor-hover-size')
51-
cursor.current.style.height = cssVar('--cursor-hover-size')
52-
cursor.current.style.color = cssVar('--color-active-2')
53-
})
54-
el.addEventListener("mouseleave", event => {
55-
cursor.current.style.width = cssVar('--cursor-size')
56-
cursor.current.style.height = cssVar('--cursor-size')
57-
cursor.current.style.color = 'inherit'
58-
})
44+
cursor.current.style.borderWidth = `2px`
45+
const a = document.querySelectorAll('a')
46+
a.forEach(el => {
47+
el.addEventListener("mouseenter", event => {
48+
cursor.current.style.width = cssVar('--cursor-hover-size')
49+
cursor.current.style.height = cssVar('--cursor-hover-size')
50+
cursor.current.style.color = cssVar('--color-active-2')
51+
})
52+
el.addEventListener("mouseleave", event => {
53+
cursor.current.style.width = cssVar('--cursor-size')
54+
cursor.current.style.height = cssVar('--cursor-size')
55+
cursor.current.style.color = 'inherit'
5956
})
57+
})
6058

61-
//back filter
62-
const filters = document.querySelectorAll('[data-cursor-filter]')
63-
filters.forEach(el => {
64-
el.style.cursor = "none"
65-
el.addEventListener("mouseenter", event => {
66-
cursor.current.style.backdropFilter = el.dataset.cursorFilter
67-
cursor.current.style.borderWidth = 0
68-
})
69-
el.addEventListener("mouseleave", event => {
70-
cursor.current.style.backdropFilter = ''
71-
cursor.current.style.borderWidth = `2px`
72-
})
59+
//back filter
60+
const filters = document.querySelectorAll('[data-cursor-filter]')
61+
filters.forEach(el => {
62+
el.style.cursor = "none"
63+
el.addEventListener("mouseenter", event => {
64+
cursor.current.style.backdropFilter = el.dataset.cursorFilter
65+
cursor.current.style.borderWidth = 0
66+
})
67+
el.addEventListener("mouseleave", event => {
68+
cursor.current.style.backdropFilter = ''
69+
cursor.current.style.borderWidth = `2px`
7370
})
71+
})
7472

75-
//size
76-
const sizes = document.querySelectorAll('[data-cursor-size]')
77-
sizes.forEach(el => {
78-
el.addEventListener("mouseenter", event => {
79-
cursor.current.style.width = el.dataset.cursorSize
80-
cursor.current.style.height = el.dataset.cursorSize
81-
})
82-
el.addEventListener("mouseleave", event => {
83-
cursor.current.style.width = cssVar('--cursor-size')
84-
cursor.current.style.height = cssVar('--cursor-size')
85-
})
73+
//size
74+
const sizes = document.querySelectorAll('[data-cursor-size]')
75+
sizes.forEach(el => {
76+
el.addEventListener("mouseenter", event => {
77+
cursor.current.style.width = el.dataset.cursorSize
78+
cursor.current.style.height = el.dataset.cursorSize
79+
})
80+
el.addEventListener("mouseleave", event => {
81+
cursor.current.style.width = cssVar('--cursor-size')
82+
cursor.current.style.height = cssVar('--cursor-size')
8683
})
87-
}
84+
})
8885
return () => { }
8986

9087
}, [path])

pages/contact/index.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
11
import Head from "next/head";
2+
import { useMemo, useState } from "react";
23
import Content from "../../components/content";
34

45
const Contacts = () => {
6+
const [message, setMessage] = useState({
7+
fullName: '',
8+
email: '',
9+
body: '',
10+
})
11+
12+
const changed = (e) => {
13+
setMessage(prev => ({ ...prev, [e.target.name]: e.target.value }))
14+
}
15+
16+
const addMessage = (e) => {
17+
e.preventDefault()
18+
19+
console.log(message)
20+
21+
/*
22+
const inputs = e.target.querySelectorAll('input, textarea')
23+
inputs.forEach(el => {
24+
el.value = ''
25+
})
26+
*/
27+
}
528
return (
629
<>
730
<Head>
@@ -10,26 +33,26 @@ const Contacts = () => {
1033
<Content type="links">
1134
<h3><span data-cursor-filter="invert(1)" data-cursor-size="50px">Message me </span></h3>
1235
<div>
13-
<form>
36+
<form onSubmit={addMessage}>
1437
<div>
1538
<label>
1639
<span>Full Name</span>
17-
<input type='text' required />
40+
<input type='text' name="fullName" onChange={changed} defaultValue={message.fullName} required />
1841
</label>
1942
</div>
2043
<div>
2144
<label>
2245
<span>Email</span>
23-
<input type='email' required />
46+
<input type='email' name="email" onChange={changed} defaultValue={message.email} required />
2447
</label>
2548
</div>
2649
<div>
2750
<label>
2851
<span>Message</span>
29-
<textarea onChange={(e) => {
52+
<textarea name="body" onChange={(e) => {
3053
e.target.style.height = e.target.scrollHeight + "px"
31-
}
32-
} required />
54+
changed(e)
55+
}} defaultValue={message.body} required />
3356
</label>
3457
</div>
3558
<button data-cursor-filter="invert(1)" data-cursor-size="40px">Send Message</button>

styles/globals.scss

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -542,26 +542,32 @@ footer {
542542
}
543543

544544
.cursor {
545-
@include flexCenter;
546-
position: fixed;
547-
z-index: 10;
548-
border-radius: 50%;
549-
pointer-events: none;
550-
border: 2px solid currentColor;
551-
border-width: 0;
552-
translate: -100px -100px;
553-
top: 0;
554-
left: 0;
555-
556-
>div {
557-
position: absolute;
558-
width: var(--cursor-size);
559-
height: var(--cursor-size);
560-
backdrop-filter: var(--cursor-filter);
561-
border-radius: inherit;
562-
border: inherit;
563-
transition: var(--fast-transition-speed) ease;
564-
//border: 2px solid var(--color-bright);
545+
display: none;
546+
}
547+
548+
@media (hover: hover) {
549+
.cursor {
550+
@include flexCenter;
551+
position: fixed;
552+
z-index: 10;
553+
border-radius: 50%;
554+
pointer-events: none;
555+
border: 2px solid currentColor;
556+
border-width: 0;
557+
translate: -100px -100px;
558+
top: 0;
559+
left: 0;
560+
561+
>div {
562+
position: absolute;
563+
width: var(--cursor-size);
564+
height: var(--cursor-size);
565+
backdrop-filter: var(--cursor-filter);
566+
border-radius: inherit;
567+
border: inherit;
568+
transition: var(--fast-transition-speed) ease;
569+
//border: 2px solid var(--color-bright);
570+
}
565571
}
566572
}
567573

0 commit comments

Comments
 (0)