Skip to content

Commit

Permalink
added testimonials page
Browse files Browse the repository at this point in the history
  • Loading branch information
hugh5 committed Apr 28, 2024
1 parent 9669fa7 commit 2cc1377
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 9 deletions.
92 changes: 91 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@


:root {
--accent-color: #9B70ff;

--background-color: #808080;

/* Dark theme */
body[data-theme="dark"] {
--accent-color: #9B70ff;
--background-color: #141414;
--secondary-background-color: #525252;
--secondary-background-color-rgb: 82, 82, 82;
Expand All @@ -19,6 +20,7 @@

/* Light theme */
body[data-theme="light"] {
--accent-color: #3a47f0;
--background-color: #ececec;
--secondary-background-color: #fff;
--secondary-background-color-rgb: 255, 255, 255;
Expand Down Expand Up @@ -177,6 +179,11 @@ footer a {
.theme-button {
position: fixed;
top: 20px;

@media (min-width: 801px) and (max-width: 960px) {
top: 80px;
}

right: 20px;
width: 50px;
height: 50px;
Expand Down Expand Up @@ -486,4 +493,87 @@ ul {
background-color: var(--accent-color);
}
}
}

#testimonials {
width: 1000px;
}

.split-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 40px;
width: 100%;
padding: 20px 0;

@media (max-width: 800px) {
grid-template-columns: 1fr;
}
}

.linear-grid {
display: grid;
grid-template-columns: 1fr;
gap: 40px;
width: 100%;
height: min-content;
}

.card {
display: flex;
flex-direction: row;
height: min-content;
border-radius: 25px;
background-color: var(--secondary-background-color);
padding: 15px;
cursor: pointer;
border: 2px solid transparent;

@media (max-width: 800px) {
flex-direction: column;
}

&:hover {
background-color: var(--tertiary-background-color);
}

&.active {
background-color: var(--tertiary-background-color);
border: 2px solid var(--accent-color);
}

}

.testimonial-image {
border-radius: 50%;
width: 120px;
height: 120px;
object-fit: cover;
display: block;

@media (max-width: 800px) {
width: 60px;
height: 60px;
}
}

.card-content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-left: 20px;
line-height: 2;

@media (max-width: 800px) {
margin-left: 0;
}
}

.testimonial {
display: none;
font-size: 20px;
padding: 40px;
border-radius: 25px;
background-color: var(--tertiary-background-color);
}
Binary file added images/connor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/harrison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lorenzo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 69 additions & 8 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,45 @@
/**
* Sets the appearance of the page to light mode
*/
function setLightMode() {
// Set the theme attribute to light
$("body").attr("data-theme", "light");
// Change the theme icon to the light theme icon
$(".theme-icon").attr("src", "images/light-theme.png");
// Save the theme to local storage
window.localStorage.setItem("data-theme", "light");
}

/**
* Sets the appearance of the page to dark mode
*/
function setDarkMode() {
// Set the theme attribute to dark
$("body").attr("data-theme", "dark");
// Change the theme icon to the dark theme icon
$(".theme-icon").attr("src", "images/dark-theme.png");
// Save the theme to local storage
window.localStorage.setItem("data-theme", "dark");
}

/**
* Toggle the theme between light and dark mode
*/
function toggleTheme() {
// Toggle between light and dark mode
if (isLightMode) {
// If the current theme is light, set the dark theme
setDarkMode();
} else {
// If the current theme is dark, set the light theme
setLightMode();
}
// Toggle the theme variable
isLightMode = !isLightMode;
}

/**
* Load the theme toggle based on the current theme
*/
function loadThemeToggle() {
if (isLightMode) {
setLightMode();
Expand All @@ -28,6 +48,11 @@ function loadThemeToggle() {
}
}

/**
* Performs the following actions when the page is loaded:
* 1. Highlight the current page in the nav menu
* 2. Show/hide the nav menu on mobile using a button
*/
function loadNav() {
// Determine the current page
var path = window.location.pathname;
Expand All @@ -46,17 +71,24 @@ function loadNav() {

// Show/hide the nav menu on mobile using the menu image
$("nav > .menu-image").on("click", function () {
$("nav > .menu-item").slideToggle(150);
$("nav > .menu-item").slideToggle(200);
});
}

/**
* Perform the following actions when the page is scrolled:
* 1. Add event listener to make sure the navbar is shown when the window is resized
* 2. Add event listener to show/hide the navbar and theme toggle on scroll
*/
function loadScrollBehavior() {
// Show the nav menu when the window is resized
$(window).resize(function () {
if ($(window).width() > 800) {
if (window.innerWidth > 800) {
$("nav").show();
$("nav > .menu-item").show();
} else {
$("nav").show();
$("nav > .menu-item").hide();
}
});

Expand All @@ -72,12 +104,12 @@ function loadScrollBehavior() {
// Otherwise, if the scroll direction is down, hide the navbar
if (current < 20 || (current < lastScroll && current < scrollMax)) {
// Scroll up, show the navbar
$("nav").show(150);
$(".theme-button").show(150);
$("nav").fadeIn(150);
$(".theme-button").fadeIn(150);
} else if (current > lastScroll) {
// Scroll down, hide the navbar
$("nav").hide(150);
$(".theme-button").hide(150);
$("nav").fadeOut(350);
$(".theme-button").fadeOut(350);
}
lastScroll = current;
});
Expand Down Expand Up @@ -131,7 +163,9 @@ function updateSlider(projectname) {
}

/**
* Load the image sliders for each project on the Projects page
* Perform the following actions when the page is loaded:
* 1. Set the content for the first image for each project
* 2. Add click event listeners to the left and right arrows to change the image
*/
function loadImageSliders() {
// For each project, set the content for the first image
Expand Down Expand Up @@ -168,6 +202,30 @@ function loadImageSliders() {
});
}

/**
* Add click event listeners to the cards on the Testimonials page
* to show the testimonial for the clicked card
*/
function loadTestimonials() {
// Add click event listeners to the cards
$("#testimonials .card").each(function () {
// On click, show the testimonial for the clicked card
// Hide the testimonial for the other cards
$(this).on("click", function () {
let id = $(this).attr("id");
// Remove the active class for the other cards
$("#testimonials .card").not(this).removeClass("active");
$("p.testimonial").not(`p#${id}`).slideUp(300);

// Add the active class for the clicked card
$(this).addClass("active");
$(`p#${id}`).slideDown(300);
});
});
$("#testimonials .card").first().addClass("active");
$("p.testimonial").first().show();
}

// Holds the current theme mode
let isLightMode = window.localStorage.getItem("data-theme") === "light";

Expand All @@ -190,5 +248,8 @@ $(function () {
for (let i = 1; i <= numProjects; i++) {
counts[`project${i}`] = $(`#project${i} > .content`).length;
}
// Projects page
loadImageSliders();
// Testimonials page
loadTestimonials();
});
Loading

0 comments on commit 2cc1377

Please sign in to comment.