сделал подписку + js
This commit is contained in:
@@ -2253,4 +2253,75 @@ button{
|
|||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.subscription{
|
||||||
|
|
||||||
|
}
|
||||||
|
.subscription__item{
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
color: var(--text-black);
|
||||||
|
font-family: var(--font-family);
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 120%;
|
||||||
|
}
|
||||||
|
.subscription__item:nth-last-child(n + 2){
|
||||||
|
border-bottom: 1px solid var(--background-9);
|
||||||
|
}
|
||||||
|
.subscription__item span{
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
.subscription__item span small{
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.subscription__status{
|
||||||
|
color: var(--text-black);
|
||||||
|
}
|
||||||
|
.subscription__status--close{
|
||||||
|
color: var(--text-red);
|
||||||
|
}
|
||||||
|
.subscription__status--end{
|
||||||
|
color: var(--text-green);
|
||||||
|
}
|
||||||
|
.subscription__toggle{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.subscription__toggle-header{
|
||||||
|
|
||||||
|
}
|
||||||
|
.subscription__toggle-product{
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
.subscription__toggle-product > *:not(:first-child){
|
||||||
|
padding-top: 14px;
|
||||||
|
}
|
||||||
|
.subscription__toggle-title{
|
||||||
|
font-family: var(--font-family);
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 133%;
|
||||||
|
}
|
||||||
|
.subscription__toggle-wrapper{
|
||||||
|
height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: all .3s;
|
||||||
|
}
|
||||||
|
.subscription__toggle-content{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs__buttons{
|
||||||
|
margin: -12px;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.tabs__content-wrap{
|
||||||
|
margin-top: 24px;
|
||||||
|
}
|
||||||
|
.tabs__content{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.tabs__content.active{
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,6 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 125%;
|
line-height: 125%;
|
||||||
color: #121212;
|
|
||||||
color: var(--text-black);
|
color: var(--text-black);
|
||||||
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -892,7 +891,6 @@ main{
|
|||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
line-height: 111%;
|
line-height: 111%;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
color: #121212;
|
|
||||||
}
|
}
|
||||||
.detail-block-price__price::after{
|
.detail-block-price__price::after{
|
||||||
content: '₽';
|
content: '₽';
|
||||||
@@ -1947,13 +1945,53 @@ main{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.subscription{
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
.subscription__item{
|
||||||
|
padding: 12px 0;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.subscription__item{
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
.subscription__toggle{
|
||||||
|
color: var(--text-black);
|
||||||
|
}
|
||||||
|
.subscription__toggle-header{
|
||||||
|
|
||||||
|
}
|
||||||
|
.subscription__toggle-title{
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
.subscription__toggle-wrapper{
|
||||||
|
|
||||||
|
}
|
||||||
|
.subscription__toggle-content{
|
||||||
|
padding: 24px 0 12px 0;
|
||||||
|
}
|
||||||
/* Стили для лептопов */
|
.subscription__toggle-product{
|
||||||
/* @media only screen and (min-width: 992px) and (max-width: 1400px) {
|
align-items: start;
|
||||||
|
}
|
||||||
} */
|
.subscription__toggle-product > *:nth-child(3){
|
||||||
|
margin-left: auto;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.subscription__toggle .cabinet-card-order-detail-main-product-description__what {
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 125%;
|
||||||
|
}
|
||||||
|
.subscription__toggle .cabinet-card-order-detail-main-product-description__with-what {
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.subscription__toggle .cabinet-card-order-detail-main-product__count{
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
|
.subscription__toggle .cabinet-card-order-detail-main-product__price{
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 120%;
|
||||||
|
}
|
||||||
67
assets/js/tabs.js
Normal file
67
assets/js/tabs.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
const rootSelectorTabs = '[data-js-tabs]';
|
||||||
|
|
||||||
|
class Tabs{
|
||||||
|
// элементы для поиска
|
||||||
|
selectors = {
|
||||||
|
root: rootSelectorTabs,
|
||||||
|
button: '[data-js-tabs-button]',
|
||||||
|
content: '[data-js-tabs-content]',
|
||||||
|
}
|
||||||
|
// класс отображения состояния
|
||||||
|
stateClasses = {
|
||||||
|
isActive: 'active',
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(rootElement){
|
||||||
|
this.rootElement = rootElement;
|
||||||
|
this.buttonElements = this.rootElement.querySelectorAll(this.selectors.button);
|
||||||
|
this.contentElements = this.rootElement.querySelectorAll(this.selectors.content);
|
||||||
|
this.state = {
|
||||||
|
activeMenuIndex: [...this.buttonElements]
|
||||||
|
.findIndex((buttonElement) => buttonElement.classList.contains(this.stateClasses.isActive)),
|
||||||
|
};
|
||||||
|
this.limitTabsIndex = this.buttonElements.length - 1;
|
||||||
|
this.bindEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateUI(){
|
||||||
|
const { activeMenuIndex } = this.state;
|
||||||
|
|
||||||
|
this.buttonElements.forEach((buttonElement, index) => {
|
||||||
|
const isActive = index === activeMenuIndex;
|
||||||
|
|
||||||
|
buttonElement.classList.toggle(this.stateClasses.isActive, isActive);
|
||||||
|
})
|
||||||
|
|
||||||
|
this.contentElements.forEach((contentElement, index) => {
|
||||||
|
const isActive = index === activeMenuIndex;
|
||||||
|
|
||||||
|
contentElement.classList.toggle(this.stateClasses.isActive, isActive);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onButtonClick(buttonIndex){
|
||||||
|
this.state.activeMenuIndex = buttonIndex;
|
||||||
|
this.updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
bindEvents(){
|
||||||
|
this.buttonElements.forEach((buttonElement, index) => {
|
||||||
|
buttonElement.addEventListener('click', () => this.onButtonClick(index))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TabsCollection {
|
||||||
|
constructor(){
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init(){
|
||||||
|
document.querySelectorAll(rootSelectorTabs).forEach((element) => {
|
||||||
|
new Tabs(element);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TabsCollection;
|
||||||
91
assets/js/toggle.js
Normal file
91
assets/js/toggle.js
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
const rootSelectorToggles = '[data-js-toggle]';
|
||||||
|
|
||||||
|
class Toggle{
|
||||||
|
// элементы для поиска
|
||||||
|
selectors = {
|
||||||
|
root: rootSelectorToggles,
|
||||||
|
button: '[data-js-toggle-button]',
|
||||||
|
wrapper: '[data-js-toggle-wrapper]',
|
||||||
|
content: '[data-js-toggle-content]',
|
||||||
|
}
|
||||||
|
// класс отображения состояния
|
||||||
|
stateClasses = {
|
||||||
|
isActive: 'active',
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(rootElement){
|
||||||
|
this.rootElement = rootElement;
|
||||||
|
this.buttonElements = this.rootElement.querySelectorAll(this.selectors.button);
|
||||||
|
this.wrapperElements = this.rootElement.querySelectorAll(this.selectors.wrapper);
|
||||||
|
this.contentElements = this.rootElement.querySelectorAll(this.selectors.content);
|
||||||
|
this.state = {
|
||||||
|
activeToggleIndex: [...this.buttonElements]
|
||||||
|
.findIndex((buttonElement) => buttonElement.classList.contains(this.stateClasses.isActive)),
|
||||||
|
};
|
||||||
|
this.bindEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateUI(newHeight){
|
||||||
|
const { activeToggleIndex } = this.state;
|
||||||
|
|
||||||
|
this.buttonElements.forEach((buttonElement, index) => {
|
||||||
|
const isActive = index === activeToggleIndex;
|
||||||
|
|
||||||
|
buttonElement.classList.toggle(this.stateClasses.isActive, isActive);
|
||||||
|
})
|
||||||
|
|
||||||
|
this.wrapperElements.forEach((wrapperElement, index) => {
|
||||||
|
const isActive = index === activeToggleIndex,
|
||||||
|
newHeight = this.contentElements[index].offsetHeight;
|
||||||
|
|
||||||
|
wrapperElement.classList.toggle(this.stateClasses.isActive, isActive);
|
||||||
|
|
||||||
|
if (isActive) {
|
||||||
|
console.log(this.contentElements[index]);
|
||||||
|
|
||||||
|
wrapperElement.style.height = `${newHeight}px`;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (wrapperElement.classList.contains('active')) {
|
||||||
|
wrapperElement.style.height = `auto`;
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}else{
|
||||||
|
wrapperElement.style.height = `${newHeight}px`;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!wrapperElement.classList.contains('active')) {
|
||||||
|
wrapperElement.style.height = `${0}px`;
|
||||||
|
}
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onButtonClick(buttonIndex){
|
||||||
|
this.state.activeToggleIndex = (buttonIndex === this.state.activeToggleIndex) ? -1 : buttonIndex;
|
||||||
|
|
||||||
|
this.updateUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
bindEvents(){
|
||||||
|
this.buttonElements.forEach((buttonElement, index) => {
|
||||||
|
buttonElement.addEventListener('click', () => this.onButtonClick(index))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TogglesCollection{
|
||||||
|
constructor(){
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
init(){
|
||||||
|
document.querySelectorAll(rootSelectorToggles).forEach((element) => {
|
||||||
|
new Toggle(element);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TogglesCollection;
|
||||||
735
subscription-2.html
Normal file
735
subscription-2.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user