-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8245486
commit 674f37b
Showing
6 changed files
with
195 additions
and
0 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,29 @@ | ||
const titleEl = document.querySelectorAll(".accordion__title"); | ||
const contentEl = document.querySelectorAll(".accordion__content"); | ||
|
||
titleEl.forEach((item) => | ||
item.addEventListener("click", () => { | ||
const activeContent = document.querySelector("#" + item.dataset.tab); | ||
|
||
if (activeContent.classList.contains("active")) { | ||
activeContent.classList.remove("active"); | ||
item.classList.remove("active"); | ||
activeContent.style.maxHeight = 0; | ||
} else { | ||
contentEl.forEach((element) => { | ||
element.classList.remove("active"); | ||
element.style.maxHeight = 0; | ||
}); | ||
titleEl.forEach((element) => element.classList.remove("active")); | ||
|
||
item.classList.add("active"); | ||
activeContent.classList.add("active"); | ||
activeContent.style.maxHeight = activeContent.scrollHeight + "px"; | ||
} | ||
}) | ||
); | ||
|
||
document.querySelector('[data-tab="tab-1"]').classList.add("active"); | ||
document.querySelector("#tab-1").classList.add("active"); | ||
document.querySelector("#tab-1").style.maxHeight = | ||
document.querySelector("#tab-1").scrollHeight + "px"; |
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 |
---|---|---|
|
@@ -21,3 +21,4 @@ import "./mouse"; | |
// import "./hero"; | ||
|
||
import "./timer"; | ||
import "./accordion"; |
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,112 @@ | ||
.accordion__title-1 { | ||
margin-bottom: 0; | ||
} | ||
|
||
.accordion__wapper { | ||
margin-top: 50px; | ||
display: flex; | ||
flex-direction: column; | ||
// justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.accordion { | ||
display: flex; | ||
flex-direction: column; | ||
max-width: 600px; | ||
width: 100%; | ||
} | ||
|
||
// .accordion__content { | ||
// display: none; | ||
// } | ||
|
||
.accordion__title { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
font-size: 22px; | ||
padding: 10px 20px; | ||
// cursor: pointer; | ||
cursor: url("../image/cursor-hand.png"), auto; | ||
|
||
border: 1px solid $border-grey-color; | ||
border-top: 0; | ||
// color: $text-color; | ||
background-color: $white-color; | ||
} | ||
|
||
.accordion:first-child { | ||
border-top: 1px solid $border-grey-color; | ||
} | ||
|
||
.accordion__title.active { | ||
box-shadow: 0 0 12px 1px $accent-color; | ||
// color: $white-color; | ||
// background-color: $accent-color; | ||
} | ||
|
||
.accordion__title span { | ||
display: inline-flex; | ||
position: relative; | ||
width: 40px; | ||
height: 40px; | ||
// background-color: transparent; | ||
transform: rotate(0); | ||
transition: transform 0.5s ease-out; | ||
} | ||
|
||
.accordion__title.active span { | ||
transform: rotate(45deg); | ||
} | ||
|
||
.accordion__title span:before { | ||
content: ""; | ||
position: absolute; | ||
width: 50%; | ||
height: 2%; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: $plus-grey-color; | ||
} | ||
|
||
.accordion__title span::after { | ||
content: ""; | ||
position: absolute; | ||
width: 2px; | ||
height: 50%; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: $plus-grey-color; | ||
} | ||
|
||
.accordion__content { | ||
font-size: 20px; | ||
line-height: 1.3; | ||
overflow: hidden; | ||
padding: 0 20px; | ||
border: 1px solid $border-grey-color; | ||
border-top: none; | ||
background-color: $white-color; | ||
max-height: 0; | ||
// opacity: 0; | ||
// visibility: hidden; | ||
transition: | ||
max-height 0.5s ease-out, | ||
padding 0.5s ease-out; | ||
// opacity 0.1s ease-out 0.5s; | ||
// visibility 0.1s ease-out 0.5s; | ||
} | ||
|
||
.accordion__content.active { | ||
visibility: visible; | ||
opacity: 1; | ||
padding: 20px; | ||
transition: | ||
max-height 0.5s ease-out, | ||
padding 0.5s ease-out; | ||
// opacity 0.1s ease-out; | ||
// visibility 0.1s ease-out 0.5s; | ||
} |
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