Skip to content

Commit

Permalink
Merge pull request #20 from she-code-africa/Code_Playground
Browse files Browse the repository at this point in the history
Update: code playground
  • Loading branch information
EseAlli authored Jul 26, 2024
2 parents 917fef2 + ae0f544 commit 08d85b5
Show file tree
Hide file tree
Showing 10 changed files with 10,376 additions and 33 deletions.
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-hook-form": "^7.51.5",
"react-icons": "^5.2.1",
"react-infinite-scroll-component": "^6.1.0",
"react-modal": "^3.16.1",
"react-router-dom": "^6.23.1",
"react-scripts": "5.0.1",
"react-slick": "^0.30.2",
Expand Down
6 changes: 3 additions & 3 deletions src/components/Recaptcha.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React, { useEffect, useRef } from "react";
function GoogleRecaptcha({ onToken }) {
const recaptchaRef = useRef(null);
const siteKey = process.env.REACT_APP_RECAPTCHA_SITE_KEY;

useEffect(() => {
const script = document.createElement("script");
script.src =
`https://www.google.com/recaptcha/api.js?render=${siteKey}`;
script.src = `https://www.google.com/recaptcha/api.js?render=${siteKey}`;
script.addEventListener("load", () => {
window.grecaptcha.ready(() => {
window.grecaptcha
Expand All @@ -23,7 +23,7 @@ function GoogleRecaptcha({ onToken }) {
return () => {
document.body.removeChild(script);
};
}, [onToken]);
}, [onToken, siteKey]);

return (
<div
Expand Down
126 changes: 126 additions & 0 deletions src/components/activities/ReadyToCode.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import React, { useState } from "react";
import { Link } from "react-router-dom";
import Modal from "react-modal";
import { FaAngleRight, FaCheck, FaExternalLinkAlt } from "react-icons/fa";
import { starImage } from "../../assets/images";

const CodePlayground = ({ isOpen, onClose }) => {
return (
<Modal
isOpen={isOpen}
onRequestClose={onClose}
contentLabel="Code Playground"
className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center overflow-y-auto"
overlayClassName=" fixed inset-0 bg-black bg-opacity-50"
>
<div className="bg-white py-7 lg:px-16 px-5 rounded-lg max-w-[90%] w-full lg:top-64 top-[400px] md:top-[200px] z-50 relative ">
<div className="flex justify-between">
<button
className=" hover:text-primaryPink transition-all"
onClick={onClose}
>
Back
</button>
<a
href="https://codeplayground.vercel.app/"
target="_blank"
rel="noopener noreferrer"
className="hover:text-primaryPink transition-all"
>
<FaExternalLinkAlt />
</a>
</div>
<h2 className="text-2xl md:text-3xl lg:text-4xl mb-4 text-center ">
Explore Code Playground
</h2>
<div className="flex mb-5 lg:justify-center flex-wrap gap-2 w-full">
<div className="flex items-center gap-2 ">
<span className="text-primaryPink">
<FaCheck />
</span>
<p>HTML: The Building Blocks of Websites</p>
</div>
<div className="flex items-center gap-2 ">
<span className="text-primaryPink">
<FaCheck />
</span>
<p>CSS: Style Your Website Like a Pro</p>
</div>
<div className="flex items-center gap-2 ">
<span className="text-primaryPink">
<FaCheck />
</span>
<p>JavaScript: Bring Your Website to Life</p>
</div>
</div>
<h2 className="font-semibold text-lg my-4">Description</h2>
<hr className="border-primaryPink mb-5" />
<p className="mb-10">
This Playground allows you to experiment with code without having to
set up your own development environment. You can write HTML code to
structure the content of your webpage, CSS code to style the
appearance of your webpage, and JavaScript code to add interactivity
to your webpage. The playground will then execute your code and
display the results in a preview pane.
</p>
<div className="h-[70vh] overflow-y-auto mb-10">
<iframe
src="https://codeplayground.vercel.app/"
style={{ width: "100%", height: "100%", border: "none" }}
title="Code Playground"
></iframe>
</div>
</div>
</Modal>
);
};

const ReadyToCode = () => {
const [isLightboxOpen, setIsLightboxOpen] = useState(false);

const openLightbox = () => {
setIsLightboxOpen(true);
};

const closeLightbox = () => {
setIsLightboxOpen(false);
};

return (
<section
className="my-3 md:my-20 bg-lavender pt-5 pb-2 relative"
id="zero-tech-skills"
>
<img src={starImage} alt="" className="max-md:hidden left-28 top-16 absolute" />
<div className="w-[90%] max-w-[1280px] mx-auto">
<h4 className="font-medium text-2xl md:text-3xl lg:text-4xl leading-normal md:leading-normal lg:leading-normal text-center">
<span className="text-primaryPink font-bold ">Ready to Code?</span>
<br />
Make your ideas come alive. Start coding today!
</h4>
<p className="text-fiord text-base md:text-lg leading-normal md:leading-normal text-center mt-3 max-w-[800px] md:mx-auto w-full">
Unleash your creativity and build the future: empowering girls aged
10-21 to pursue careers in Science, Technology, Engineering, and
Mathematics (STEM).
</p>
<div className="flex justify-center my-7">
<Link
to="#"
className="text-white capitalize w-full max-w-[250px] h-[53px] rounded-[30px] text-sm flex items-center justify-center bg-primaryPink border-2 border-primaryPink hover:bg-transparent hover:text-primaryPink transition-all gap-2"
onClick={openLightbox}
>
Click here to explore
<span className="text-sm flex items-center justify-center w-[24px] h-[24px] rounded-[50%] bg-white text-primaryPink">
<FaAngleRight />
</span>
</Link>
</div>
</div>
<img src={starImage} alt="" className="max-md:hidden right-64 bottom-16 absolute" />
<CodePlayground isOpen={isLightboxOpen} onClose={closeLightbox} />

</section>
);
};

export default ReadyToCode;
34 changes: 21 additions & 13 deletions src/components/activities/coding-page/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { codingHeroImage } from "../../../assets/images";
// import { coursesSlider } from "../../../utils/appData";
import UpcomingEvents from "../UpcomingEvents";
import ReadyToCode from "../ReadyToCode";

import { useQuery } from "@tanstack/react-query";
import {
Expand Down Expand Up @@ -80,22 +81,33 @@ const CodingPageComponent = () => {

return (
<>
<section className=" text-sealBrown font-mulish w-full">
<div className=" w-[90%] max-w-[1280px] mx-auto">
<div className=" text-sealBrown font-mulish w-full ">
<section className=" w-[90%] max-w-[1280px] mx-auto ">
<HeroComponent
heroHeading="Unlock Your Coding Potential"
heroParagraph="Are you ready to dive into the world of coding? Whether you're a
complete beginner or looking to sharpen your skills, our workshops
offer something for everyone."
heroHeading="The Coding Hub"
heroParagraph="Are you ready to dive into the exciting world of coding? Explore beginner friendly coding concepts from scratch! Our free resources will help you to learn what coding is all about and how to begin. Start learning today!"
heroImage={codingHeroImage}
subContent={codingHeroSubContent}
/>

{/* <div className="mt-[100px] w-full mb-32">
<UpcomingEvents activityTitle="coding" />
</div> */}
</section>
<section>
</section>
<section>
<div className=" w-[100%] ">
<ReadyToCode />
</div>
</section>
<section className="w-[90%] max-w-[1280px] mx-auto ">
<div className="mt-[100px] w-full mb-32">
<UpcomingEvents activityTitle="coding" />
</div>

<div className="my-16 lg:my-20 ">
<section className="w-full">
<section className="w-full ">
<InfoCardHeader
infoCardHeading="Resources"
infoCardParagraph=""
Expand Down Expand Up @@ -131,12 +143,8 @@ const CodingPageComponent = () => {
)}
</section>
</div>

{/* <div className="mt-[100px] w-full mb-32">
<UpcomingEvents activityTitle="coding" />
</div> */}
</div>
</section>
</section>
</div>
</>
);
};
Expand Down
32 changes: 18 additions & 14 deletions src/components/contact-us/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import React, { useRef, useState } from "react";
import { useForm } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
import { toast } from "react-toastify";
import { toast, ToastContainer } from "react-toastify";
import { makeEnquiry } from "../../services/mutations";
import { useMutation } from "@tanstack/react-query";
import { PrimaryInput } from "../index";
import { floralWhiteImage, starImage } from "../../assets/images";
import "react-toastify/dist/ReactToastify.css";

import Recaptcha from "../Recaptcha";

const ContactUsComponent = () => {
Expand All @@ -26,16 +28,20 @@ const ContactUsComponent = () => {
register,
handleSubmit,
formState: { errors },
reset,
} = useForm({
resolver: yupResolver(schema),
mode: "onBlur",
});

const { mutate: handleContactUs } = useMutation({
mutationFn: makeEnquiry,
onSuccess: (data) => {
onSuccess: () => {
toast.success("Message sent Successfully!", {
position: toast.POSITION.TOP_RIGHT,
position: "top-right",
});
reset();
setRecaptchaToken("");
},
onError: (error, variables) => {
toast.error("An error occurred.", {
Expand All @@ -45,19 +51,13 @@ const ContactUsComponent = () => {
});

const onSubmit = (data) => {
if (recaptchaToken) {
data.recaptcha = recaptchaToken;
handleContactUs(data);
} else {
toast.error("Please complete the reCAPTCHA.", {
position: toast.POSITION.TOP_RIGHT,
});
if (!recaptchaToken) {
toast.error("Please complete the reCAPTCHA.", { position: toast.POSITION.TOP_RIGHT });
return;
}
handleContactUs(data);
};




const textareaRef = useRef();

const handleTextAreaFocus = () => {
Expand All @@ -67,8 +67,10 @@ const ContactUsComponent = () => {
const handleTextAreaBlur = () => {
textareaRef.current.classList.remove("border-[rgb(233,152,203)]");
};

return (
<>
<ToastContainer />
<section className=" text-sealBrown font-mulish w-full -mt-8 bg-whiteSmoke ">
<div className="stem-club-header relative bg-primaryPink pt-16 ">
<div className="w-[90%] max-w-[1280px] mx-auto min-h-[40px] flex flex-col justify-center 2md:justify-between 2md:flex-row md:items-center event-hero gap-8 py-12 2md:py-0 px-3 sm:px-0 ">
Expand Down Expand Up @@ -165,7 +167,7 @@ const ContactUsComponent = () => {
</div>
</div>
</form>
<Recaptcha onToken={(token) => setRecaptchaToken(token)} />
<Recaptcha onToken={(token) => setRecaptchaToken(token)} />
<img
src={starImage}
alt=""
Expand All @@ -178,3 +180,5 @@ const ContactUsComponent = () => {
};

export default ContactUsComponent;


Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const HeroComponent = ({
</div>
</article>

<div className="lg:max-w-[530px] w-full ">
<div className="lg:max-w-[530px] w-full z-0 ">
<figure className="m-0 p-0 max-w-[514px] w-full rounded-3xl mx-auto lg:mx-0 relative z-[1]">
<img
src={heroImage}
Expand Down
Loading

0 comments on commit 08d85b5

Please sign in to comment.