<div class="portfolio">
<div class="portfolio-grid">
<button class="project-thumb active"
data-project="0" aria-pressed="true">
<img src="IMAGE_URL_1" alt="Project one">
<span>Project One</span>
</button>
<button class="project-thumb"
data-project="1" aria-pressed="false">
<img src="IMAGE_URL_2" alt="Project two">
<span>Project Two</span>
</button>
<button class="project-thumb"
data-project="2" aria-pressed="false">
<img src="IMAGE_URL_3" alt="Project three">
<span>Project Three</span>
</button>
<button class="project-thumb"
data-project="3" aria-pressed="false">
<img src="IMAGE_URL_4" alt="Project four">
<span>Project Four</span>
</button>
</div>
<div class="project-detail" aria-live="polite">
<img id="detail-image" src="IMAGE_URL_1"
alt="Selected project">
<div class="detail-copy">
<p class="project-kicker" id="detail-year">2021</p>
<h2 id="detail-title">Project One</h2>
<p id="detail-description">
A description of this project goes here.
Include the client, year, your role, and
a little about the work.
</p>
</div>
</div>
</div>
<style>
.portfolio {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 42px;
width: 100%;
align-items: start;
}
.portfolio-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 14px;
}
.project-thumb {
display: block;
padding: 0;
border: 0;
background: transparent;
text-align: left;
cursor: pointer;
opacity: .65;
transition: opacity .2s ease;
font: inherit;
}
.project-thumb:hover,
.project-thumb.active {
opacity: 1;
}
.project-thumb img {
display: block;
width: 100%;
aspect-ratio: 4 / 3;
object-fit: cover;
}
.project-thumb span {
display: block;
padding-top: 8px;
font-size: 13px;
}
.project-thumb.active img {
outline: 2px solid currentColor;
outline-offset: 3px;
}
.project-detail {
position: sticky;
top: 30px;
}
.project-detail > img {
display: block;
width: 100%;
height: auto;
aspect-ratio: 4 / 3;
object-fit: cover;
}
.detail-copy {
padding-top: 20px;
}
.project-kicker {
font-size: 11px;
letter-spacing: .12em;
text-transform: uppercase;
opacity: .65;
}
.detail-copy h2 {
margin: 8px 0 12px;
font-size: clamp(23px, 3vw, 34px);
}
.detail-copy p {
line-height: 1.65;
}
@media (max-width: 700px) {
.portfolio {
grid-template-columns: 1fr;
gap: 28px;
}
.project-detail {
position: static;
grid-row: 1;
}
.portfolio-grid {
grid-template-columns: repeat(2, 1fr);
}
}
</style>
<script>
(function () {
const projects = [
{
title: "Project One",
year: "2021 · Client Name",
description: "Describe the project, its purpose, your creative role, and the finished work.",
image: "IMAGE_URL_1"
},
{
title: "Project Two",
year: "2022 · Client Name",
description: "Describe the second project here.",
image: "IMAGE_URL_2"
},
{
title: "Project Three",
year: "2023 · Client Name",
description: "Describe the third project here.",
image: "IMAGE_URL_3"
},
{
title: "Project Four",
year: "2024 · Personal Work",
description: "Describe the fourth project here.",
image: "IMAGE_URL_4"
}
];
const container = document.querySelector(".portfolio");
if (!container) return;
const buttons = container.querySelectorAll(".project-thumb");
const detailImage = container.querySelector("#detail-image");
const detailTitle = container.querySelector("#detail-title");
const detailYear = container.querySelector("#detail-year");
const detailDescription = container.querySelector("#detail-description");
buttons.forEach(function (button) {
button.addEventListener("click", function () {
const index = Number(button.dataset.project);
const project = projects[index];
if (!project) return;
buttons.forEach(function (item) {
const selected = item === button;
item.classList.toggle("active", selected);
item.setAttribute("aria-pressed", String(selected));
});
detailImage.src = project.image;
detailImage.alt = project.title;
detailTitle.textContent = project.title;
detailYear.textContent = project.year;
detailDescription.textContent = project.description;
});
});
})();
</script>