Skip to content

Commit

Permalink
Merge pull request #40 from Torehirth/17-create-description-modal
Browse files Browse the repository at this point in the history
17 create extended description
  • Loading branch information
Torehirth authored Oct 9, 2024
2 parents adb6987 + 076e562 commit 287917d
Show file tree
Hide file tree
Showing 16 changed files with 639 additions and 181 deletions.
555 changes: 401 additions & 154 deletions index.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 78 additions & 9 deletions src/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ footer {
outline: none;
border: none;
}
.hamburger:focus {
border: 1px solid #f0e9f2;
padding: 2px;
}
.hamburger-bar,
.hamburger::after,
.hamburger::before {
Expand Down Expand Up @@ -314,12 +318,13 @@ footer {
flex-direction: column;
justify-content: start;
align-items: center;
gap: 4rem;
gap: 8rem;
top: 0;
left: 100%;
width: 100%;
height: 100vh;
background-color: #363d48;
background-color: #22252c;
opacity: 0.95;
padding-top: 150px;
z-index: 1000;
transition: 0.3s ease-in-out;
Expand Down Expand Up @@ -378,6 +383,64 @@ footer {
opacity: 0;
}

.description-btn {
align-self: flex-start;
font-size: 1rem;
font-style: italic;
border-bottom: 1px solid #f22c50;
padding: 2px 5px;
transition: all 0.3s ease-in-out;
}
.description-btn:hover {
filter: opacity(0.7);
}
.description-btn:active {
border-bottom: 1px solid #f0e9f2;
}

.description-wrapper {
display: flex;
flex-direction: column;
gap: 2rem;
position: relative;
top: -100%;
transition: all 0.3s ease-in-out;
height: 0;
opacity: 0;
margin-bottom: -2rem;
}
.description-wrapper ul {
list-style: disc;
padding-left: 1.125rem;
}
.description-wrapper li,
.description-wrapper p {
font-weight: 300;
}
.description-wrapper.is-active {
top: 0;
height: 100%;
opacity: 1;
margin-bottom: 0;
}

.tech-wrapper {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0.5rem;
}
.tech-wrapper img {
width: 3rem;
}

.project-description-underline {
display: inline-block;
border-bottom: 1px solid #363d48;
width: 50%;
align-self: start;
}

.header-bar {
display: flex;
justify-content: space-between;
Expand All @@ -403,6 +466,7 @@ footer {
}
.header-bar-container.scroll-up {
background-color: #363d48;
filter: drop-shadow(0 1px 3px #f22c50);
opacity: 0.9;
padding: 1.5rem;
}
Expand All @@ -412,6 +476,7 @@ footer {

.logo-container {
color: #f0e9f2;
line-height: 0;
}

.links-container {
Expand Down Expand Up @@ -485,14 +550,20 @@ footer {
.colour-mode-wrapper button {
line-height: 0;
}
.colour-mode-wrapper button:focus-visible {
border: 1px solid #f0e9f2;
padding: 2px;
}
.colour-mode-wrapper p {
font-size: 0.75rem;
}

.light-mode-btn:hover,
.light-mode-btn:hover {
filter: opacity(0.7);
}
.light-mode-btn:active {
transform: scale(1.2);
}

@media (width <= 1000px) {
.header-bar-container nav:last-of-type {
Expand Down Expand Up @@ -548,6 +619,9 @@ footer {
gap: 0.5rem;
color: #f0e9f2;
}
.footer-logo-container a {
line-height: 0;
}

.copyright {
border-top: 1px solid #f0e9f2;
Expand Down Expand Up @@ -716,6 +790,7 @@ footer {
grid-template-columns: 1fr 1fr;
align-items: center;
justify-items: left;
position: relative;
}

.text-outer-wrapper {
Expand All @@ -742,12 +817,6 @@ footer {
flex-direction: column;
gap: 0.5rem;
}
.text-inner-wrapper button {
align-self: flex-start;
font-size: 1rem;
font-weight: 500;
font-style: italic;
}

.project-btn-container {
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion src/css/styles.css.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/js/components/navigation/mobileNavHandlers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ export function closeMobileNavByClickOutside(e) {

export const disableScrollWhenMobileNavOpen = () => {
if (mobileNav.classList.contains("is-active")) {
console.log("Nav is active, disabling scroll");
HTMLbody.classList.add("no-scroll");
} else {
console.log("Nav is not active, enabling scroll");
HTMLbody.classList.remove("no-scroll");
}
};
41 changes: 41 additions & 0 deletions src/js/ui/toggleProjectDescription.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const toggleProjectDescription = () => {
document.addEventListener("click", (e) => {
// If clicking the "Read more" button (e.target = read more button)
if (e.target.classList.contains("read-more-btn")) {
// Selecting the related/closest container with the closest() method.
const projectWrapper = e.target.closest(".project-wrapper");
const descriptionWrapper = projectWrapper.querySelector(".description-wrapper");
const readLessBtn = projectWrapper.querySelector(".read-less-btn");

// Display the extended description and update buttons styling
descriptionWrapper.classList.add("is-active");
e.target.style.display = "none";
readLessBtn.style.display = "block";

// Scroll to the extended container when clicking read more button
descriptionWrapper.scrollIntoView({
behavior: "smooth",
block: "start",
});
}

// If clicking the "Read less" button (e.target = read less button)
if (e.target.classList.contains("read-less-btn")) {
// Selecting the related/closest container with the closest() method.
const projectWrapper = e.target.closest(".project-wrapper");
const descriptionWrapper = projectWrapper.querySelector(".description-wrapper");
const readMoreBtn = projectWrapper.querySelector(".read-more-btn");

// Hide the extended description and update buttons styling
descriptionWrapper.classList.remove("is-active");
e.target.style.display = "none";
readMoreBtn.style.display = "block";

// Scroll to the parent container of the project when clicking read less button
projectWrapper.scrollIntoView({
behavior: "smooth",
block: "start",
});
}
});
};
9 changes: 9 additions & 0 deletions src/js/utils/scrollToSectionOnClick.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Scroll to HTML ID by click event
export const scrollToSectionOnClick = (button, sectionId) => {
button.addEventListener("click", () => {
sectionId.scrollIntoView({
behavior: "smooth",
block: "start",
});
});
};
3 changes: 3 additions & 0 deletions src/js/views/index.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { mobileNavEventListeners } from "../components/navigation/mobileNavEventListeners.mjs";
import { renderSkillElements } from "../components/skills/renderSkillElements.mjs";
import { displayHeaderOnScrollUp } from "../ui/displayHeaderOnScrollUp.mjs";
import { toggleProjectDescription } from "../ui/toggleProjectDescription.mjs";

// Open/close the mobile nav
mobileNavEventListeners();
// Render Skill elements
renderSkillElements();
// Display nav bar on scroll up
displayHeaderOnScrollUp();
// Open and Close project description
toggleProjectDescription();
7 changes: 7 additions & 0 deletions src/scss/abstracts/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@use "./variables";

// Focus state style
@mixin focus-styles {
border: 1px solid variables.$main-text-colour;
padding: 2px;
}
64 changes: 64 additions & 0 deletions src/scss/components/_extended-description.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
@use "../abstracts/variables";

.description-btn {
align-self: flex-start;
font-size: 1rem;
font-style: italic;
border-bottom: variables.$main-border;
padding: 2px 5px;
transition: all variables.$transition;

&:hover {
filter: opacity(variables.$opacity);
}
&:active {
border-bottom: 1px solid variables.$main-text-colour;
}
}

.description-wrapper {
display: flex;
flex-direction: column;
gap: 2rem;
//transition effects
position: relative;
top: -100%;
transition: all variables.$transition;
height: 0;
opacity: 0;
margin-bottom: -2rem;

ul {
list-style: disc;
padding-left: 1.125rem;
}
li,
p {
font-weight: 300;
}
// displaying content through JS
&.is-active {
top: 0;
height: 100%;
opacity: 1;
margin-bottom: 0;
}
}

.tech-wrapper {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0.5rem;

img {
width: 3rem;
}
}

.project-description-underline {
display: inline-block;
border-bottom: 1px solid variables.$sub-bg-colour;
width: 50%;
align-self: start;
}
9 changes: 7 additions & 2 deletions src/scss/components/_mobile-nav.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use "../abstracts/variables";
@use "../abstracts/mixins";

/* --- hamburger menu --- */
.hamburger,
Expand All @@ -14,6 +15,9 @@
cursor: pointer;
outline: none;
border: none;
&:focus {
@include mixins.focus-styles;
}
}

.hamburger-bar,
Expand Down Expand Up @@ -50,12 +54,13 @@
flex-direction: column;
justify-content: start;
align-items: center;
gap: 4rem;
gap: 8rem;
top: 0;
left: 100%;
width: 100%;
height: 100vh;
background-color: variables.$sub-bg-colour;
background-color: variables.$main-bg-colour;
opacity: 0.95;
padding-top: 150px;
z-index: 1000;
transition: variables.$transition;
Expand Down
3 changes: 3 additions & 0 deletions src/scss/layout/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
gap: 0.5rem;
// Add white colour to the logo to cheat the contrast ratio
color: variables.$main-text-colour;
a {
line-height: 0;
}
}

.copyright {
Expand Down
Loading

0 comments on commit 287917d

Please sign in to comment.