diff --git a/public/logo-dark.png b/public/logo-dark.png new file mode 100644 index 0000000..2121efc Binary files /dev/null and b/public/logo-dark.png differ diff --git a/src/app/contextapi/ThemeContext.js b/src/app/contextapi/ThemeContext.js index 2f794f8..0cf8eef 100644 --- a/src/app/contextapi/ThemeContext.js +++ b/src/app/contextapi/ThemeContext.js @@ -1,6 +1,6 @@ -import React from 'react' +import React from "react"; export const ThemeContext = React.createContext({ darkMode: false, - TtoggleDarkMode: () => {} -}) + TtoggleDarkMode: () => {}, +}); diff --git a/src/app/docs/page.js b/src/app/docs/page.js new file mode 100644 index 0000000..d598509 --- /dev/null +++ b/src/app/docs/page.js @@ -0,0 +1,273 @@ +"use client"; +import { useContext } from "react"; +import React from "react"; +import Editor from "@monaco-editor/react"; +import { ThemeContext } from "../contextapi/ThemeContext"; + +function Docs() { + const { darkMode } = useContext(ThemeContext); + + return ( +
+
+
+ {/* Introduction Section */} +
+

# Welcome to ZenDocs

+

+ Welcome to the{" "} + + Zen programming universe + {" "} + — a place where coding is simple, fun, and totally stress-free! 🌟 + In Zen, we've ditched the complicated stuff like delimiters + and indentation. Why? Because we believe coding should be a breeze + for beginners, letting you focus on the exciting world of + algorithms without the hassle of tricky syntax. +

+

+ Whether you're taking your first coding steps or just want a + laid-back space to express your creativity, Zen is here for you. + So, kick back, relax, and let's make coding a joyful + experience together! 🚀 +

+
+ + {/* Hello, Zen Section */} +
+

Hello, Zen !!

+ + +
+
+

What's Inside Zen?

+

+ Zen is made up of simple words and phrases that guide the computer + in a friendly way. Here are a few friends you'll meet often: +

+
+
+ {/* PARAMPARA PRATISHTA ANUSHASHAN */} +
+

+ PARAMPARA PRATISHTA ANUSHASHAN +

+ +

+ Think of this as the magic words that begin your journey into + the world of Zen. It tells the computer that a Zen program is + about to begin. +

+
+
+
+ {/* KHATAM TATA BYE BYE */} +
+

KHATAM TATA BYE BYE

+

+ And this is how Zen gracefully concludes its conversation with + the computer, saying "Goodbye for now!" +

+
+
+
+ {/* BOLE TOH */} +
+

BOLE TOH

+

+ Introduce Zen to a new friend (variable) and provide them with a + starting value. +

+ + +

+ Here, a variable named A is created and initialised with the + value 10. +

+
+
+ {/* INPUT LE LE RE BABA Section */} +
+

INPUT LE LE RE BABA

+

+ Imagine Zen asking the user, "Hey, what's up?" This + is how you can reply and share something with Zen. +

+ + + +

+ Zen asks for input (Re Baba!), and the user's response is + stored in the variable C. +

+
+ + {/* PRINT BASANTI PRINT Section */} +
+

PRINT BASANTI PRINT

+

+ Zen loves to share its thoughts. Use this to make Zen tell you or + others what it's thinking. +

+ + +

+ Zen expresses its love for coding by printing the message + "Coding is fun!" to the console. +

+
+ + {/* AGAR, WARNA AGAR, NHI TOH Section */} + {/* Include similar sections for other Zen features and keywords */} + + {/* JAB TAK HAI JAAN Section */} +
+

JAB TAK HAI JAAN

+

+ Zen loves doing things repeatedly, like saying, "Let's + do this until something happens!" You can use this to create + exciting loops. +

+ + + +

+ Zen prints numbers from 1 to 4 because the loop continues while A + is less than 5. +

+
+ + {/* Comments in Zen Section */} +
+

Comments in Zen

+

+ In Zen, comments are your way of leaving little notes for yourself + or your fellow coders. You express comments using the @ symbol. + It's like a secret message that won't affect how your + program runs. +

+ + +

+ In this snippet, the line `@ This is a comment is there just for + you or anyone else reading the code. Zen sees it and says, + "Oh, I can ignore this part." Comments are handy for + making your code more understandable and sharing insights without + affecting how the program behaves. Happy commenting! 📝✨ +

+
+

+ {" "} + So, are you ready to start your Zen adventure? Dive in, have fun, + and let your imagination run wild! Remember, in Zen, coding is not + just a skill; it's a journey full of discovery and joy. Enjoy + the ride! 🌟 +

+
+
+
+ ); +} + +export default Docs; diff --git a/src/app/example/page.js b/src/app/example/page.js new file mode 100644 index 0000000..6c29569 --- /dev/null +++ b/src/app/example/page.js @@ -0,0 +1,205 @@ +"use client"; +import Head from "next/head"; +import { useContext } from "react"; +import Editor from "@monaco-editor/react"; +import { ThemeContext } from "../contextapi/ThemeContext"; + +const ExampleCard = ({ title, code, description, height }) => { + const { darkMode } = useContext(ThemeContext); + return ( +
+

{title}

+
+ +
+

+ {description} +

+
+ ); +}; + +const Examples = () => { + const { darkMode } = useContext(ThemeContext); + return ( +
+ + Code Examples + + +

Code Examples

+
+ {/* First column */} +
+ +
+ +
+ +
+ +
+ NUM2 TAB\n MAX BOLE TOH NUM1\nWARNA\n MAX BOLE TOH NUM2\nBAS ITNA HI\nPRINT BASANTI PRINT " Maximum Is : "\nPRINT BASANTI PRINT MAX\nKHATAM TATA BYE BYE`} + description="This program takes two numbers as input and prints the maximum of the two." + height={35} + /> +
+ 1 TAB TAK\n factorial BOLE TOH factorial * Num\n Num BOLE TOH Num - 1\nJAHAN\nPRINT BASANTI PRINT factorial\nKHATAM TATA BYE BYE`} + description="This program calculates the factorial of a number." + height={28} + /> +
+ + {/* Second column */} +
+ {/* Add more ExampleCard components for the second column */} + + 0 TAB TAK\n PRINT BASANTI PRINT A\n NEXT BOLE TOH A + B\n A BOLE TOH B\n B BOLE TOH NEXT\n N BOLE TOH N - 1\nJAHAN\nKHATAM TATA BYE BYE`} + description="This program generates the Fibonacci sequence for the first 10 numbers." + height={34} + /> +
+ 0 TAB TAK\n PRINT BASANTI PRINT c\n c BOLE TOH c - 1\nJAHAN\nPRINT BASANTI PRINT 'Surprise !!'\nKHATAM TATA BYE BYE`} + description="This program uses a loop to countdown from 5 to 1 and then prints 'Surprise !!'" + height={27} + /> +
+ +
+ +
+ +
+
+
+ ); +}; + +export default Examples; diff --git a/src/app/forgotpassword/page.js b/src/app/forgotpassword/page.js index 458836d..cdf66b9 100644 --- a/src/app/forgotpassword/page.js +++ b/src/app/forgotpassword/page.js @@ -1,64 +1,87 @@ -'use client' -import React, { useState, useContext } from 'react' -import Link from 'next/link' -import { ThemeContext } from '../contextapi/ThemeContext' +"use client"; +import React, { useState, useContext } from "react"; +import Link from "next/link"; +import { ThemeContext } from "../contextapi/ThemeContext"; export default function Forgotpassword() { - const { darkMode } = useContext(ThemeContext) - const [passwordError, setPasswordError] = useState(''); + const { darkMode } = useContext(ThemeContext); + const [passwordError, setPasswordError] = useState(""); - const validatePassword = (password) => { - const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; - return regex.test(password); - } + const validatePassword = (password) => { + const regex = + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; + return regex.test(password); + }; - const handlePasswordChange = (event) => { - if (!validatePassword(event.target.value)) { - setPasswordError('Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character.'); - } else { - setPasswordError(''); - } + const handlePasswordChange = (event) => { + if (!validatePassword(event.target.value)) { + setPasswordError( + "Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character." + ); + } else { + setPasswordError(""); } + }; - const backgroundImageURL = '/zen-lang-img.jpg'; + const backgroundImageURL = "/zen-lang-img.jpg"; - return ( -
-
-
-
-
-

FORGOT PASSWORD

-

Don't have an account? Sign up

-
-
-
e.preventDefault()} - className="mt-8 space-y-9 ml-20px" - > -
- - -
+ return ( +
+
+
+
+
+

+ FORGOT PASSWORD +

+

+ Don't have an account?{" "} + + + Sign up + + +

+
+
+ e.preventDefault()} + className="mt-8 space-y-9 ml-20px" + > +
+ + +
-
-
-
-
- - -
-
+
+ +
+
+
+
- ) -} \ No newline at end of file +
+
+ ); +} diff --git a/src/app/help/page.js b/src/app/help/page.js index 9d82de0..8da83a7 100644 --- a/src/app/help/page.js +++ b/src/app/help/page.js @@ -1,53 +1,58 @@ -'use client' -import React, { useState, useEffect, useContext } from 'react' -import Image from 'next/image' -import { ThemeContext } from '../contextapi/ThemeContext' +"use client"; +import React, { useState, useEffect, useContext } from "react"; +import Image from "next/image"; +import { ThemeContext } from "../contextapi/ThemeContext"; // Define your variables for text and contributors -const logo = { src: '/logo.png', alt: 'Zen Logo', width: 200, height: 200 } -const pageTitle = 'Welcome to Zen Lang' -const pageDescription = `Zen Lang is an open-source programming language designed for simplicity and ease of use. It allows you to express your ideas with clarity and minimal boilerplate code. Whether you're a beginner or an experienced programmer, Zen Lang offers a clean and intuitive syntax that makes coding a breeze.` +const pageTitle = "Welcome to Zen Lang"; +const pageDescription = `Zen Lang is an open-source programming language designed for simplicity and ease of use. It allows you to express your ideas with clarity and minimal boilerplate code. Whether you're a beginner or an experienced programmer, Zen Lang offers a clean and intuitive syntax that makes coding a breeze.`; -const creditsTitle = 'Credits' +const creditsTitle = "Credits"; const creditsDescription = - 'Zen Lang was developed by a dedicated team of contributors:' + "Zen Lang was developed by a dedicated team of contributors:"; const footerText = - 'If you have any questions or need assistance, please feel free to reach out to the Zen Lang community.' + "If you have any questions or need assistance, please feel free to reach out to the Zen Lang community."; const contributorsData = [ { - name: 'rootCircle', - githubLink: 'https://github.com/rootCircle', - avatarUrl: 'https://github.com/rootCircle.png' + name: "rootCircle", + githubLink: "https://github.com/rootCircle", + avatarUrl: "https://github.com/rootCircle.png", }, { - name: 'mohit07raghav19', - githubLink: 'https://github.com/mohit07raghav19', - avatarUrl: 'https://github.com/mohit07raghav19.png' + name: "mohit07raghav19", + githubLink: "https://github.com/mohit07raghav19", + avatarUrl: "https://github.com/mohit07raghav19.png", }, { - name: 'Harshit-Chordiya', - githubLink: 'https://github.com/Harshit-Chordiya', - avatarUrl: 'https://github.com/Harshit-Chordiya.png' - } -] + name: "Harshit-Chordiya", + githubLink: "https://github.com/Harshit-Chordiya", + avatarUrl: "https://github.com/Harshit-Chordiya.png", + }, +]; // Define the maximum number of contributors to display -const maxContributorsToShow = 3 +const maxContributorsToShow = 3; -function Help () { - const [showAllContributors, setShowAllContributors] = useState(false) - const { darkMode } = useContext(ThemeContext) +function Help() { + const [showAllContributors, setShowAllContributors] = useState(false); + const { darkMode } = useContext(ThemeContext); const visibleContributors = showAllContributors ? contributorsData - : contributorsData.slice(0, maxContributorsToShow) + : contributorsData.slice(0, maxContributorsToShow); + const logo = { + src: darkMode ? "/logo-dark.png" : "/logo.png", + alt: "Zen Logo", + width: 200, + height: 200, + }; return ( -
+
{logo.alt} {pageTitle} @@ -65,50 +70,50 @@ function Help () {

{pageDescription}

-
+

{creditsTitle}

-

+

{creditsDescription}

-
    +
      {visibleContributors.map((contributor, index) => (
    • {contributor.avatarUrl && ( -
      +
      {`Avatar
      )} {contributor.name} @@ -118,17 +123,17 @@ function Help () { {contributorsData.length > maxContributorsToShow && ( )}
-
+
{footerText}
- ) + ); } -export default Help +export default Help; diff --git a/src/app/layout.js b/src/app/layout.js index 27614b8..a63bc19 100644 --- a/src/app/layout.js +++ b/src/app/layout.js @@ -1,30 +1,30 @@ -'use client' -import { Inter } from 'next/font/google' -import './globals.css' -import Navbar from '@/components/layout/Navbar' -import { useState } from 'react' -import { ThemeContext } from '../app/contextapi/ThemeContext' +"use client"; +import { Inter } from "next/font/google"; +import "./globals.css"; +import Navbar from "@/components/layout/Navbar"; +import { useState } from "react"; +import { ThemeContext } from "../app/contextapi/ThemeContext"; -const inter = Inter({ subsets: ['latin'] }) +const inter = Inter({ subsets: ["latin"] }); const metadata = { - title: 'Zen Playground', - description: 'Playground to test and run zen language on the go!' -} + title: "Zen Playground", + description: "Playground to test and run zen language on the go!", +}; -export default function RootLayout ({ children }) { - const [darkMode, setDarkMode] = useState(false) +export default function RootLayout({ children }) { + const [darkMode, setDarkMode] = useState(false); const toggleDarkMode = () => { - setDarkMode(!darkMode) - } + setDarkMode(!darkMode); + }; return ( - +
@@ -34,5 +34,5 @@ export default function RootLayout ({ children }) { - ) + ); } diff --git a/src/app/login/page.js b/src/app/login/page.js index 6ae2c72..95d0494 100644 --- a/src/app/login/page.js +++ b/src/app/login/page.js @@ -1,58 +1,58 @@ -'use client' -import React, { useState, useContext } from 'react' -import Link from 'next/link' -import { ThemeContext } from '../../app/contextapi/ThemeContext' +"use client"; +import React, { useState, useContext } from "react"; +import Link from "next/link"; +import { ThemeContext } from "../../app/contextapi/ThemeContext"; -export default function Login () { - const { darkMode } = useContext(ThemeContext) - const [passwordError, setPasswordError] = useState('') +export default function Login() { + const { darkMode } = useContext(ThemeContext); + const [passwordError, setPasswordError] = useState(""); - const validatePassword = password => { + const validatePassword = (password) => { const regex = - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ - return regex.test(password) - } + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; + return regex.test(password); + }; - const handlePasswordChange = event => { + const handlePasswordChange = (event) => { if (!validatePassword(event.target.value)) { setPasswordError( - 'Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character.' - ) + "Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character." + ); } else { - setPasswordError('') + setPasswordError(""); } - } + }; - const backgroundImageURL = '/zen-lang-img.jpg' + const backgroundImageURL = "/zen-lang-img.jpg"; return (
-
+
-
-
+
+

Log in to your account

-

- Don't have an account?{' '} - - +

+ Don't have an account?{" "} + + Sign up @@ -60,35 +60,37 @@ export default function Login () {

e.preventDefault()} - className='mt-8 space-y-9 ml-20px' + onSubmit={(e) => e.preventDefault()} + className="mt-8 space-y-9 ml-20px" >
- +
- + {passwordError && ( - {passwordError} + {passwordError} )}
-
- - - Forgot password? + + + Forgot password? +
@@ -98,5 +100,5 @@ export default function Login () {
- ) -} \ No newline at end of file + ); +} diff --git a/src/app/page.js b/src/app/page.js index 12e5be9..ee3d82f 100644 --- a/src/app/page.js +++ b/src/app/page.js @@ -1,53 +1,54 @@ -'use client' -import React, { useRef, useState, useContext } from 'react' -import Editor from '@monaco-editor/react' -import { ThemeContext } from '../app/contextapi/ThemeContext' +"use client"; +import React, { useRef, useState, useContext } from "react"; +import Editor from "@monaco-editor/react"; +import { ThemeContext } from "../app/contextapi/ThemeContext"; -export default function Home () { - const [output, setOutput] = useState('') - const [loading, setLoading] = useState(false) - const [error, setError] = useState(null) - const editorRef = useRef(null) - const { darkMode } = useContext(ThemeContext) +export default function Home() { + const [output, setOutput] = useState(""); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const editorRef = useRef(null); + const { darkMode } = useContext(ThemeContext); - function handleEditorDidMount (editor, monaco) { - editorRef.current = editor + function handleEditorDidMount(editor, monaco) { + editorRef.current = editor; } - async function showValue () { - const code = editorRef.current.getValue() - setOutput('') - setLoading(true) - setError(null) + async function showValue() { + const code = editorRef.current.getValue(); + setOutput(""); + setLoading(true); + setError(null); try { // Make an API call to compile the code // @TODO - const server_host = process.env.SERVER_HOSTNAME || 'http://localhost:8000' + const server_host = + process.env.SERVER_HOSTNAME || "http://localhost:8000"; - const response = await fetch(server_host.concat('/api/compile'), { - method: 'POST', + const response = await fetch(server_host.concat("/api/compile"), { + method: "POST", body: JSON.stringify({ code: code }), headers: { - 'Content-Type': 'application/json' - } - }) + "Content-Type": "application/json", + }, + }); if (!response.ok) { - throw new Error('Failed to compile code') + throw new Error("Failed to compile code"); } - const data = await response.json() + const data = await response.json(); if (!data.output || !data.output.Ok) { - throw new Error('Failed to compile code') + throw new Error("Failed to compile code"); } - setOutput(data.output.Ok) + setOutput(data.output.Ok); } catch (error) { - setError('Error compiling code. Please try again.') + setError("Error compiling code. Please try again."); } finally { - setLoading(false) + setLoading(false); } } @@ -55,16 +56,16 @@ export default function Home () {
-
+

Write Code here @@ -72,29 +73,29 @@ export default function Home () {

-
+
-
+

Output: @@ -102,19 +103,19 @@ export default function Home () { {loading ? (

Loading...

) : error ? ( -

{error}

+

{error}

) : (
-
{output}
+
{output}
)}

- ) + ); } diff --git a/src/app/signup/page.js b/src/app/signup/page.js index 3a67c2c..8272ef9 100644 --- a/src/app/signup/page.js +++ b/src/app/signup/page.js @@ -1,105 +1,105 @@ -'use client' -import React, { useState, useContext } from 'react' -import Link from 'next/link' -import { ThemeContext } from '../../app/contextapi/ThemeContext' +"use client"; +import React, { useState, useContext } from "react"; +import Link from "next/link"; +import { ThemeContext } from "../../app/contextapi/ThemeContext"; -export default function Login () { - const { darkMode } = useContext(ThemeContext) - const [passwordError, setPasswordError] = useState('') +export default function Login() { + const { darkMode } = useContext(ThemeContext); + const [passwordError, setPasswordError] = useState(""); - const validatePassword = password => { + const validatePassword = (password) => { const regex = - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/ - return regex.test(password) - } + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; + return regex.test(password); + }; - const handlePasswordChange = event => { + const handlePasswordChange = (event) => { if (!validatePassword(event.target.value)) { setPasswordError( - 'Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character.' - ) + "Password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character." + ); } else { - setPasswordError('') + setPasswordError(""); } - } + }; - const backgroundImageURL = '/zen-lang-img.jpg' + const backgroundImageURL = "/zen-lang-img.jpg"; return (
-
+
-
-
+
+

CREATE NEW ACCOUNT

-

- Already have an account?{' '} - - +

+ Already have an account?{" "} + + log-in

- e.preventDefault()} className='mt-8 space-y-5'> + e.preventDefault()} className="mt-8 space-y-5">
{passwordError && ( - {passwordError} + {passwordError} )}
-
-
-
{' '} +
{" "}
@@ -107,5 +107,5 @@ export default function Login () {
- ) + ); } diff --git a/src/components/layout/Navbar.js b/src/components/layout/Navbar.js index aa966c7..4d9dff5 100644 --- a/src/components/layout/Navbar.js +++ b/src/components/layout/Navbar.js @@ -1,34 +1,39 @@ -'use client' -import React, { useState, useContext } from 'react' -import Link from 'next/link' -import Image from 'next/image' -import { ThemeContext } from '../../app/contextapi/ThemeContext' +"use client"; +import React, { useState, useContext } from "react"; +import Link from "next/link"; +import Image from "next/image"; +import { ThemeContext } from "../../app/contextapi/ThemeContext"; -export default function Navbar () { - const { darkMode, toggleDarkMode } = useContext(ThemeContext) - const logo = { src: '/logo.png', alt: 'Zen Logo', width: 30, height: 30 } +export default function Navbar() { + const { darkMode, toggleDarkMode } = useContext(ThemeContext); + const logo = { + src: darkMode ? "/logo-dark.png" : "/logo.png", + alt: "Zen Logo", + width: 30, + height: 30, + }; const links = [ - { name: 'Code Playground', href: '/' }, - { name: 'Docs', href: '/docs' }, - { name: 'Example', href: '/example' }, - { name: 'Help', href: '/help' } - ] + { name: "Code Playground", href: "/" }, + { name: "Docs", href: "/docs" }, + { name: "Example", href: "/example" }, + { name: "Help", href: "/help" }, + ]; - const sideLinks = { name: 'GitHub', href: 'https://github.com/zenlang-rs' } + const sideLinks = { name: "GitHub", href: "https://github.com/zenlang-rs" }; - const [isMenuOpen, setMenuOpen] = useState(false) + const [isMenuOpen, setMenuOpen] = useState(false); const toggleMenu = () => { - setMenuOpen(!isMenuOpen) - } + setMenuOpen(!isMenuOpen); + }; return ( <> -