Skip to content

shuvomdhar/codepen-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ CodePen Clone

A lightweight CodePen-inspired online code editor built with React and Vite. This application allows users to write HTML, CSS, and JavaScript code in separate editors and instantly preview the output in real time. Users can also download their project as a ZIP file containing index.html, style.css, and script.js.


โœจ Features

  • ๐Ÿ“ Separate editors for HTML, CSS, and JavaScript
  • โšก Live preview with automatic updates
  • ๐Ÿ’พ Auto-save using Local Storage
  • ๐Ÿ“ฆ Download the complete project as a ZIP file
  • ๐Ÿ“ฑ Responsive interface
  • ๐ŸŽจ Syntax highlighting for all three languages
  • ๐Ÿ”ฝ Expand/Collapse editor panels
  • โš™๏ธ Lightweight and fast with Vite

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 19
  • Vite
  • JavaScript (ES6+)
  • HTML5
  • CSS3

Code Editor

  • CodeMirror 6
  • @uiw/react-codemirror

Icons

  • Font Awesome

File Download

  • JSZip
  • FileSaver.js

Browser APIs

  • Local Storage API
  • iframe (Live Preview)

๐Ÿ“‚ Project Structure

codepen-clone/
โ”‚
โ”œโ”€โ”€ public/
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ assets/
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ DownloadButton.jsx
โ”‚   โ”‚   โ””โ”€โ”€ Editor.jsx
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ””โ”€โ”€ useLocalStorage.jsx
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ App.jsx
โ”‚   โ”œโ”€โ”€ App.css
โ”‚   โ”œโ”€โ”€ index.css
โ”‚   โ””โ”€โ”€ main.jsx
โ”‚
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ vite.config.js
โ””โ”€โ”€ README.md

โš™๏ธ Installation

Clone the repository

git clone https://github.com/shuvomdhar/codepen-clone.git

Go inside the project

cd codepen-clone

Install dependencies

npm install

Start the development server

npm run dev

Open your browser and visit

http://localhost:5173

๐Ÿ“ฆ Dependencies

npm install @uiw/react-codemirror
npm install @codemirror/lang-html
npm install @codemirror/lang-css
npm install @codemirror/lang-javascript

npm install jszip
npm install file-saver

npm install @fortawesome/react-fontawesome
npm install @fortawesome/free-solid-svg-icons

๐Ÿš€ How to Use

Step 1

Start the application.

You'll see three code editors.

  • HTML
  • CSS
  • JavaScript

Step 2

Write your HTML.

Example

<h1>Hello World</h1>

<p>Welcome to my CodePen Clone.</p>

Step 3

Write your CSS.

body{
    background:#282c34;
    color:white;
    text-align:center;
}

h1{
    color:tomato;
}

Step 4

Write your JavaScript.

document.querySelector("h1").onclick = () => {
    alert("Hello!");
}

Step 5

The output will be displayed instantly in the preview panel.

No page refresh is required.


Step 6

Click the Download ZIP button.

The application downloads

codepen-project.zip
โ”‚
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ style.css
โ””โ”€โ”€ script.js

Extract the ZIP file and open index.html in your browser.


๐Ÿ’พ Auto Save

The application automatically stores your code in the browser using Local Storage.

This means:

  • Refreshing the page won't erase your work.
  • Closing and reopening the browser keeps your code.
  • No manual save button is required.

๐ŸŽจ Live Preview

The preview updates automatically while you type.

The generated page is rendered inside an iframe, providing a safe and isolated environment for running your HTML, CSS, and JavaScript.


๐Ÿ“ฅ Export Project

The Download ZIP feature creates a complete web project containing

  • index.html
  • style.css
  • script.js

The HTML file is automatically linked with the CSS and JavaScript files, allowing the downloaded project to run immediately after extraction.


๐Ÿ“ฑ Responsive Design

The interface is designed to work on different screen sizes.

  • Desktop
  • Laptop
  • Tablet
  • Mobile (basic support)

๐Ÿ”ฎ Future Improvements

Some possible future enhancements include:

  • ๐ŸŒ™ Dark / Light Mode
  • ๐Ÿ“ Open Existing Project
  • ๐Ÿ“„ Multiple Files Support
  • ๐Ÿ” Search & Replace
  • ๐ŸŒˆ Theme Selection
  • ๐Ÿ–‹๏ธ Font Size Controls
  • ๐Ÿ“ค Shareable Project Links
  • โ˜๏ธ Cloud Storage
  • ๐Ÿ”„ Auto Formatting (Prettier)
  • ๐Ÿ”ฅ Console Output Panel
  • ๐Ÿ“‹ Copy Project to Clipboard
  • ๐Ÿงฉ Additional Language Support (TypeScript, SCSS, Markdown)

๐Ÿค Contributing

Contributions are welcome!

  1. Fork the repository.
  2. Create a new branch.
git checkout -b feature-name
  1. Commit your changes.
git commit -m "Added new feature"
  1. Push to GitHub.
git push origin feature-name
  1. Open a Pull Request.

๐Ÿž Known Limitations

  • Browser security restrictions apply to code executed inside the preview iframe.
  • JavaScript errors written by the user will appear in the browser console.
  • Very large projects are not intended to run inside this lightweight editor.

๐Ÿ“„ License

This project is only for educational pursose.


๐Ÿ‘จโ€๐Ÿ’ป Author

Shuvom Dhar

GitHub: https://github.com/shuvomdhar

LinkedIn: https://linkedin.com/in/shuvom-dhar


โญ If you found this project useful, consider giving it a Star on GitHub!

About

A lightweight CodePen-inspired online code editor built with React and Vite. This application allows users to write HTML, CSS, and JavaScript code in separate editors and instantly preview the output in real time. Users can also download their project as a ZIP file containing index.html, style.css, and script.js.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors