Categories We Write About

Build a portfolio builder script

To build a portfolio builder script, it’s essential to clarify what kind of portfolio you want to create. Are you looking to create a simple personal project portfolio that users can fill with their own work, or do you have a more specific requirement, like a portfolio for photographers, designers, or developers? I’ll assume you’re asking for a general-purpose HTML/JavaScript-based portfolio builder that can help users build and showcase their projects.

Here’s a basic structure for a Portfolio Builder using HTML, CSS, and JavaScript. You can expand on it as needed.

1. Basic Structure of the HTML Portfolio Builder

html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Portfolio Builder</title> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="container"> <header> <h1>Portfolio Builder</h1> <p>Create your portfolio by adding your projects!</p> </header> <section class="portfolio-form"> <h2>Add a Project</h2> <form id="portfolioForm"> <label for="projectTitle">Project Title:</label> <input type="text" id="projectTitle" required> <label for="projectDescription">Project Description:</label> <textarea id="projectDescription" required></textarea> <label for="projectLink">Project Link (Optional):</label> <input type="url" id="projectLink"> <label for="projectImage">Project Image URL (Optional):</label> <input type="url" id="projectImage"> <button type="submit">Add Project</button> </form> </section> <section class="portfolio"> <h2>Your Portfolio</h2> <div id="projectsList" class="projects-list"></div> </section> </div> <script src="script.js"></script> </body> </html>

2. CSS for Basic Styling

css
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #f9f9f9; color: #333; padding: 20px; } .container { max-width: 800px; margin: 0 auto; background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } header { text-align: center; margin-bottom: 20px; } h1 { font-size: 2.5rem; color: #0073e6; } h2 { font-size: 1.5rem; color: #333; } .portfolio-form { margin-bottom: 40px; } .portfolio-form label { font-weight: bold; margin-bottom: 5px; } .portfolio-form input, .portfolio-form textarea { width: 100%; padding: 8px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; } .portfolio-form button { background-color: #0073e6; color: #fff; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; } .portfolio-form button:hover { background-color: #005bb5; } .projects-list { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } .project-card { background-color: #f1f1f1; padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } .project-card h3 { margin-bottom: 10px; font-size: 1.25rem; } .project-card p { margin-bottom: 10px; } .project-card img { width: 100%; height: auto; border-radius: 8px; } .project-card a { color: #0073e6; text-decoration: none; font-weight: bold; } .project-card a:hover { text-decoration: underline; }

3. JavaScript for Dynamic Project Management

javascript
// Get references to form and project list const portfolioForm = document.getElementById("portfolioForm"); const projectsList = document.getElementById("projectsList"); // Event listener for form submission portfolioForm.addEventListener("submit", function (event) { event.preventDefault(); // Collect data from the form const projectTitle = document.getElementById("projectTitle").value; const projectDescription = document.getElementById("projectDescription").value; const projectLink = document.getElementById("projectLink").value; const projectImage = document.getElementById("projectImage").value; // Create a new project card const projectCard = document.createElement("div"); projectCard.classList.add("project-card"); projectCard.innerHTML = ` <h3>${projectTitle}</h3> <p>${projectDescription}</p> ${projectImage ? `<img src="${projectImage}" alt="${projectTitle}">` : ""} ${projectLink ? `<a href="${projectLink}" target="_blank">View Project</a>` : ""} `; // Append the new project card to the projects list projectsList.appendChild(projectCard); // Reset the form fields portfolioForm.reset(); });

How This Works:

  1. HTML provides the structure for the portfolio, including a form to input project details (title, description, link, and image).

  2. CSS styles the page, giving it a clean and minimal look with a responsive grid layout for the projects.

  3. JavaScript handles the form submission. When a user submits the form:

    • The data is gathered (title, description, link, image).

    • A new “project card” is dynamically created and added to the “projects list” section.

    • The form is reset for the next entry.

Customizing and Expanding:

You can add extra features like:

  • Allowing users to edit or delete projects.

  • Saving the portfolio to local storage so that it persists even after the page reloads.

  • Implementing categories or tags for sorting projects.

  • Enhancing the layout with additional styles (e.g., adding hover effects, animations).

If you’d like more advanced features or customizations, feel free to ask!

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About