Skip to content

Commit

Permalink
Merge pull request #97 from OudomMunint/dev
Browse files Browse the repository at this point in the history
Dev => Maun
  • Loading branch information
OudomMunint authored Jan 11, 2025
2 parents ca1268e + 6433694 commit d5dc2d4
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: npx eslint --no-error-on-unmatched-pattern.

- name: Run all tests
run: npm run test
run: npm test

- name: Generate build
env:
Expand All @@ -45,4 +45,4 @@ jobs:
uses: ncipollo/[email protected]
with:
artifacts: "react-github-actions-build"
tag: v1.5.5.1
tag: v1.5.5.2
7 changes: 7 additions & 0 deletions src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ test('Find contact form', async () => {
expect(formFieldMessage).toBeInTheDocument();
});

// Test Alert message
test('Find alert message', () => {
render(<ContactForm />);
const alertMessage = screen.getByText(/This website serves as a showcase of my development work/i);
expect(alertMessage).toBeInTheDocument();
});

// Test form submit button
test('Find form submit button', () => {
render(<ContactForm />);
Expand Down
32 changes: 32 additions & 0 deletions src/components/AlertComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { useState, useEffect, useCallback } from "react";

const hideAlert = () => {
const alertElement = document.querySelector(".alert-container");
if (alertElement) {
alertElement.classList.add("hidden");
}
};

const AlertComponent = ({ message, animateAlert }) => {
return (
<div className={`alert-container ${animateAlert ? "" : "hidden"}`} id="alert">
<p style={{ margin: "0" }}>
{message}
</p>
<button
onClick={hideAlert}
style={{
backgroundColor: "transparent",
border: "none",
color: "#721c24",
cursor: "pointer",
float: "right",
}}
>
&#x2715;
</button>
</div>
);
};

export default AlertComponent;
96 changes: 53 additions & 43 deletions src/components/Contact.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
import React, { useState, useEffect, useCallback } from "react";
import AlertComponent from "./AlertComponent";

function ContactForm() {
const isDevelopment = process.env.NODE_ENV === "development";
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [message, setMessage] = useState("");
const handleSubmit = useCallback(async (event) => {
event.preventDefault();
let data = { name, email, message };
try {
// clear form
setName('');
setEmail('');
setMessage('');
if (isDevelopment) {
data = {
name: "testUser1",
email: "[email protected]",
message: "Hello, this is a test message."
};
const [animateAlert, setAnimateAlert] = useState(false);

useEffect(() => {
const timer = setTimeout(() => {
setAnimateAlert(true);
}, 500);
return () => clearTimeout(timer);
}, []);

const handleSubmit = useCallback(
async (event) => {
event.preventDefault();
let data = { name, email, message };
try {
setName("");
setEmail("");
setMessage("");
if (isDevelopment) {
data = {
name: "testUser1",
email: "[email protected]",
message: "Hello, this is a test message.",
};
}
console.log("Form submission successful:", data);
} catch (error) {
console.error("Form submission error:", error);
}
console.log('Form submission successful:', data);
} catch (error) {
console.error('Form submission error:', error);
console.log('Error caught');
}
}, [name, email, message, isDevelopment]);
},
[name, email, message, isDevelopment]
);

useEffect(() => {
if (isDevelopment) {
Expand All @@ -43,13 +54,26 @@ function ContactForm() {

return (
<>
<form name="contact" netlify="true" netlify-honeypot="bot-field" data-netlify-recaptcha="true" hidden>
<form name="contact" netlify="true" netlify-honeypot="bot-field" data-netlify-recaptcha="true" hidden>
<input type="text" name="name" />
<input type="email" name="email" />
<textarea name="message"></textarea>
</form>

<div className="formFlex">

{/* Alert Message */}
<AlertComponent message={
<>
This website serves as a showcase of my development work. The source code is hosted on GitHub and deployed via my personal Netlify account.
Therefore, all emails sent through this form will be directed to me. For inquiries related to
<strong className="purple"> Studio Zed</strong>, please contact
<a href="https://www.newcastle.edu.au/profile/simone-ocallaghan"> Dr. Simone O'Callaghan</a>.
</>
}
animateAlert={animateAlert} />

{/* Form */}
<div className="form">
<div className="top-bar">
<span></span>
Expand All @@ -59,35 +83,21 @@ function ContactForm() {
<div className="title">Get in touch!</div>
<form name="contact" method="POST" data-netlify-recaptcha="true">
<input type="hidden" name="form-name" value="contact" />

{/* Name */}
<div className="input-container ic1">
<label className="form-label" htmlFor="name"></label>
<input className="form-control input" type="text" id="name" name="name" value={name} onChange={(e) => setName(e.target.value)}
placeholder="Name"
required />
<input className="form-control input" type="text" id="name" name="name" value={name}
onChange={(e) => setName(e.target.value)} placeholder="Name" required/>
</div>

{/* Email */}
<div className="input-container ic2">
<label className="form-label" htmlFor="email"></label>
<input className="form-control input" type="email" id="email" name="email" value={email} onChange={(e) => setEmail(e.target.value)}
placeholder="Email"
required
pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"
title="Please enter a valid email address"
/>
<input className="form-control input" type="email" id="email" name="email" value={email}
onChange={(e) => setEmail(e.target.value)} placeholder="Email"
required pattern="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"
title="Please enter a valid email address"/>
</div>

{/* Message */}
<div className="input-container ic2">
<label className="form-label" htmlFor="message"></label>
<textarea className="form-control input from-textarea" id="message" name="message" value={message} onChange={(e) => setMessage(e.target.value)}
placeholder="Message"
required />
<textarea className="form-control input from-textarea" id="message" name="message"
value={message} onChange={(e) => setMessage(e.target.value)} placeholder="Message" required/>
</div>
<div data-netlify-recaptcha="true" className="reCaptcha"></div>
{/* Submit */}
<button title="submit" className="btn btn-danger submit" type="submit" style={{ position: "relative", marginTop: "68px" }}>
Submit
</button>
Expand Down
16 changes: 7 additions & 9 deletions src/components/Projects/ProjectCards.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import Card from "react-bootstrap/Card";
//import Button from "react-bootstrap/Button";
//import { CgWebsite } from "react-icons/cg";
import Button from "react-bootstrap/Button";
import { CgArrowRight } from "react-icons/cg";
//import { BsGithub } from "react-icons/bs";

function ProjectCards(props) {
Expand All @@ -20,21 +20,19 @@ function ProjectCards(props) {
{"\n"}
{"\n"}

{/* If the component contains Demo link and if it's not a Blog then, it will render the below component */}

{!props.isBlog && props.demoLink && (
{/* <Button
<Button
variant="primary"
href={props.demoLink}
target="_blank"
style={{ marginLeft: "10px" }}
>
<CgWebsite /> &nbsp;
{"Demo"}
</Button> */}
<CgArrowRight /> &nbsp;
{"Visit"}
</Button>
)}
</Card.Body>
</Card>
);
}
export default ProjectCards;
export default ProjectCards;
38 changes: 10 additions & 28 deletions src/components/Projects/Projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function Projects() {
isBlog={false}
title="Public Art Workers website and branding"
description="A website, Logo and branding for a newly formed company called Public art workers."
//ghLink="https://github.com/soumyajit4419/Chatify"
//demoLink="https://chatify-49.web.app/"
//ghLink="https://github.com/"
demoLink="https://www.publicartworkers.com/"
/>
</Col>

Expand All @@ -46,9 +46,7 @@ function Projects() {
imgPath={JH}
isBlog={false}
title="John Hunter Health anniversary book"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Bits-0f-C0de"
//demoLink="https://blogs.soumya-jit.tech/"
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -57,9 +55,7 @@ function Projects() {
imgPath={LocalConnect}
isBlog={false}
title="Local Connections restuarant"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Editor.io"
//demoLink="https://editor.soumya-jit.tech/"
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -68,9 +64,7 @@ function Projects() {
imgPath={newcastleArt}
isBlog={false}
title="Newcastle art gallery"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Plant_AI"
//demoLink="https://plant49-ai.herokuapp.com/"
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -79,9 +73,7 @@ function Projects() {
imgPath={wanersbay}
isBlog={false}
title="Warners Bay kids book"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/AI_For_Social_Good"
// demoLink="https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley" <--------Please include a demo link here
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -90,9 +82,7 @@ function Projects() {
imgPath={water}
isBlog={false}
title="Water conservation kids book"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Face_And_Emotion_Detection"
// demoLink="https://blogs.soumya-jit.tech/" <--------Please include a demo link here
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -101,9 +91,7 @@ function Projects() {
imgPath={tina}
isBlog={false}
title="This Is Not Art Program"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Face_And_Emotion_Detection"
// demoLink="https://blogs.soumya-jit.tech/" <--------Please include a demo link here
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -112,9 +100,7 @@ function Projects() {
imgPath={noWorries}
isBlog={false}
title="No worries rebranding and website"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Face_And_Emotion_Detection"
// demoLink="https://blogs.soumya-jit.tech/" <--------Please include a demo link here
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -123,9 +109,7 @@ function Projects() {
imgPath={air}
isBlog={false}
title="Art in Recovery rebrading and commemorative book"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Face_And_Emotion_Detection"
// demoLink="https://blogs.soumya-jit.tech/" <--------Please include a demo link here
//description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
/>
</Col>

Expand All @@ -135,8 +119,6 @@ function Projects() {
isBlog={false}
title="Head 2 Art website and branding project"
description="This project is about [Insert name] it is for [ inset ] by [inset] this project involved [ insert]"
//ghLink="https://github.com/soumyajit4419/Face_And_Emotion_Detection"
// demoLink="https://blogs.soumya-jit.tech/" <--------Please include a demo link here
/>
</Col> */}
</Row>
Expand Down
24 changes: 24 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,30 @@ a {
left: 0%;
position: relative;
margin-bottom: 210px;
flex-direction: column;
}

.alert-container {
display: flex;
background-color: rgb(247, 200, 205);
color: rgb(114, 28, 36);
padding: 10px;
border: 1px solid rgb(245, 198, 203);
border-radius: 5px;
margin-bottom: 10px;
flex-direction: row;
align-items: center;
width: 100%;
max-width: 800px;
opacity: 1;
transform: translateY(0);
transition: opacity 0.3s ease, transform 0.3s ease;
}

.alert-container.hidden {
opacity: 0;
transform: translateY(-10px);
pointer-events: none; /* Prevent interaction */
}

.form {
Expand Down

0 comments on commit d5dc2d4

Please sign in to comment.