generated from goitacademy/vanilla-app-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from KristinaHranovska/modal-window
Modal window
- Loading branch information
Showing
8 changed files
with
383 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
.backdrop-thumb { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
z-index: 100; | ||
background-color: rgba(46, 47, 66, 0.40); | ||
|
||
opacity: 1; | ||
transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1), visibility 250ms cubic-bezier(0.4, 0, 0.2, 1); | ||
} | ||
|
||
.backdrop-thumb.is-open { | ||
opacity: 0; | ||
visibility: hidden; | ||
pointer-events: auto; | ||
} | ||
|
||
.modal-window { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: 335px; | ||
overflow-y: auto; | ||
|
||
transform: translate(-50%, -50%) scale(1); | ||
|
||
border-radius: 20px; | ||
background-color: var(--text-light); | ||
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 1px 3px rgba(0, 0, 0, 0.12), 0px 2px 1px rgba(0, 0, 0, 0.2); | ||
|
||
transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1); | ||
|
||
padding: 40px 20px; | ||
} | ||
|
||
.modal-button-close { | ||
position: absolute; | ||
top: 14px; | ||
right: 14px; | ||
width: 15px; | ||
height: 15px; | ||
|
||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
background-color: transparent; | ||
border-radius: 50%; | ||
border: none; | ||
|
||
padding: 0; | ||
|
||
transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1), border 250ms cubic-bezier(0.4, 0, 0.2, 1); | ||
} | ||
|
||
.close-btn-icon { | ||
stroke: var(--text-dark); | ||
|
||
transition: fill 250ms cubic-bezier(0.4, 0, 0.2, 1); | ||
} | ||
|
||
.img-modal { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.modal-exer-thumb { | ||
margin-bottom: 40px; | ||
} | ||
|
||
.modal-title { | ||
font-weight: 500; | ||
font-size: 20px; | ||
line-height: 1; | ||
color: var(--text-dark); | ||
|
||
margin-bottom: 10px; | ||
} | ||
|
||
.raiting { | ||
display: flex; | ||
align-items: center; | ||
gap: 2px; | ||
|
||
margin-bottom: 20px; | ||
} | ||
|
||
.raiting-number { | ||
font-weight: 400; | ||
font-size: 12px; | ||
line-height: 1.5; | ||
color: var(--text-dark); | ||
} | ||
|
||
.raiting-item { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.icon-star { | ||
fill: var(--star); | ||
} | ||
|
||
.icon-star.non-activ { | ||
fill: var(--not-color-star); | ||
} | ||
|
||
.exer-item { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 20px; | ||
|
||
border-top: 1px solid var(--not-color-star); | ||
border-bottom: 1px solid var(--not-color-star); | ||
|
||
margin-bottom: 20px; | ||
padding: 10px 0; | ||
} | ||
|
||
.title-exer { | ||
font-size: 12px; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
color: var(--border-color); | ||
} | ||
|
||
.paragraf-exer { | ||
color: var(--text-dark); | ||
font-weight: 500; | ||
line-height: 1.28; | ||
font-size: 14px; | ||
} | ||
|
||
.main-parag { | ||
font-weight: 400; | ||
font-size: 14px; | ||
line-height: 1.29; | ||
color: var(--text); | ||
} | ||
|
||
.buttons-modal { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 9px; | ||
} | ||
|
||
.hidden-btn { | ||
position: absolute; | ||
width: 1px; | ||
height: 1px; | ||
margin: -1px; | ||
border: 0; | ||
padding: 0; | ||
|
||
white-space: nowrap; | ||
clip-path: inset(100%); | ||
clip: rect(0 0 0 0); | ||
overflow: hidden; | ||
} | ||
|
||
.add-to-favorities { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 8px; | ||
|
||
border-radius: 30px; | ||
background-color: var(--accent); | ||
color: var(--text-light); | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 1.28; | ||
border: none; | ||
|
||
padding: 12px 80px; | ||
} | ||
|
||
.heart-btn-icon { | ||
fill: none; | ||
stroke: var(--text-light); | ||
} | ||
|
||
.heart-btn-icon.active-favorites { | ||
fill: var(--star); | ||
stroke: var(--star); | ||
} | ||
|
||
@media screen and (min-width: 768px) { | ||
.modal-window { | ||
width: 716px; | ||
} | ||
|
||
.exer-thumb { | ||
display: flex; | ||
align-items: flex-start; | ||
gap: 40px; | ||
} | ||
|
||
.modal-button-close { | ||
top: 16px; | ||
right: 16px; | ||
} | ||
|
||
.img-modal { | ||
width: 270px; | ||
margin-bottom: 0; | ||
} | ||
|
||
.modal-title { | ||
font-size: 24px; | ||
line-height: 1.33; | ||
} | ||
|
||
.add-to-favorities { | ||
font-size: 16px; | ||
} | ||
|
||
.heart-btn-icon { | ||
width: 20px; | ||
height: 20px; | ||
} | ||
} | ||
|
||
@media screen and (min-width: 1440px) { | ||
.modal-window { | ||
width: 732px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
@import url('./components/reset'); | ||
@import url('./components/variables.css'); | ||
@import url('./components/components.css'); | ||
|
||
@import url('./header.css'); | ||
@import url('./hero.css'); | ||
@import url('./quote.css'); | ||
@import url('./exercises.css'); | ||
@import url('./static.css'); | ||
@import url('./footer.css'); | ||
|
||
@import url('./quote-favorities.css'); | ||
@import url('./favorities-exercise.css'); | ||
@import url('./favorities-exercise.css'); | ||
@import url('./modal-window.css'); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { getAccess } from "./helper/get-access"; | ||
|
||
|
||
const backdrop = document.querySelector('.backdrop-thumb'); | ||
const closeIcon = document.querySelector('.js-modal-window'); | ||
const galleryWindow = document.querySelector('.exercises-card'); | ||
|
||
galleryWindow.addEventListener('click', openModal); | ||
|
||
// Відкриття модалки | ||
function openModal(e) { | ||
if (e.target.classList.contains('ex-arrow-icon') || e.target.classList.contains('js-start')) { | ||
backdrop.classList.remove('is-open'); | ||
document.body.style.overflow = 'hidden'; | ||
|
||
const liElement = e.target.closest('.exercise-item'); | ||
|
||
if (liElement) { | ||
const id = liElement.dataset.id; | ||
getExercisesObject(id); | ||
} | ||
} | ||
} | ||
|
||
|
||
// Закриття модального вікна | ||
closeIcon.addEventListener('click', closeModal) | ||
|
||
function closeModal() { | ||
backdrop.classList.add('is-open'); | ||
document.body.style.overflow = ''; | ||
} | ||
|
||
function getExercisesObject(id) { | ||
getAccess({ typeFilter: 'exercises', id: id }) | ||
.then(({ data }) => { | ||
const { name, rating, target, bodyPart, equipment, popularity, burnedCalories, description, gifUrl, _id } = data | ||
|
||
const refs = { | ||
img: document.querySelector(".js-img"), | ||
title: document.querySelector('.js-title'), | ||
raiting: document.querySelector('.js-raiting'), | ||
targetValue: document.querySelector('.js-target'), | ||
bodyPartValue: document.querySelector('.js-body-part'), | ||
equipmentValue: document.querySelector('.js-equipment'), | ||
popularValue: document.querySelector('.js-popular'), | ||
caloriesValue: document.querySelector('.js-calories'), | ||
descriptionValue: document.querySelector('.js-description'), | ||
} | ||
|
||
refs.img.setAttribute('src', gifUrl); | ||
refs.title.textContent = name; | ||
refs.raiting.textContent = rating; | ||
refs.targetValue.textContent = target; | ||
refs.bodyPartValue.textContent = bodyPart; | ||
refs.equipmentValue.textContent = equipment; | ||
refs.popularValue.textContent = popularity; | ||
refs.caloriesValue.textContent = burnedCalories; | ||
refs.descriptionValue.textContent = description; | ||
}) | ||
.catch((err) => console.error(err)); | ||
} |
Oops, something went wrong.