⚰️ [menu] Elimina implementación base de menús
This commit is contained in:
parent
93804721e1
commit
41369be8c7
10 changed files with 0 additions and 1035 deletions
|
|
@ -1,384 +0,0 @@
|
|||
/* Aislamiento & normalización */
|
||||
|
||||
.menu {
|
||||
isolation: isolate;
|
||||
}
|
||||
@supports (all: revert) {
|
||||
.menu {
|
||||
all: revert;
|
||||
display: block; }
|
||||
}
|
||||
.menu {
|
||||
box-sizing: border-box;
|
||||
line-height: var(--val-menu--line-height, 1.5);
|
||||
color: var(--val-color--text);
|
||||
text-align: left;
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
word-spacing: normal;
|
||||
white-space: normal;
|
||||
cursor: default;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
z-index: 9999;
|
||||
border: 0;
|
||||
background: var(--val-menu--color-bg);
|
||||
}
|
||||
.menu *,
|
||||
.menu *::before,
|
||||
.menu *::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
.menu :where(a, button) {
|
||||
appearance: none;
|
||||
background: none;
|
||||
border: 0;
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.menu :where(a, button):focus-visible {
|
||||
outline: 2px solid var(--val-menu--color-highlight);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.menu :where(ul, ol) {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.menu svg {
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
/* Estructura */
|
||||
|
||||
.menu__wrapper {
|
||||
padding-right: var(--val-gap);
|
||||
}
|
||||
|
||||
.menu__nav li {
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
margin-inline-start: 1.5rem;
|
||||
padding: 0;
|
||||
line-height: var(--val-menu--item-height);
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.menu__item--label,
|
||||
.menu__nav li > .menu__link {
|
||||
position: relative;
|
||||
font-weight: normal;
|
||||
text-rendering: optimizeLegibility;
|
||||
font-size: 1.45rem;
|
||||
}
|
||||
.menu__nav li > .menu__link {
|
||||
transition: color 0.3s ease-in-out;
|
||||
}
|
||||
.menu__nav li:hover > .menu__link,
|
||||
.menu__nav li > .menu__link:focus {
|
||||
color: var(--val-menu--color-highlight);
|
||||
}
|
||||
.menu__nav li > .menu__link > svg.icon {
|
||||
margin-left: 0.25rem;
|
||||
}
|
||||
|
||||
.menu__children {
|
||||
position: absolute;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
padding: var(--val-gap-0-5) var(--val-gap-1-5);
|
||||
border: 0;
|
||||
background: var(--val-menu--color-bg);
|
||||
border-top: 3px solid var(--val-menu--color-highlight);
|
||||
z-index: 500;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
box-shadow: 0 4px 6px -1px var(--val-menu--color-border), 0 2px 4px -1px var(--val-menu--color-shadow);
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.menu__item--children:hover > .menu__children,
|
||||
.menu__item--children > .menu__link:focus + .menu__children,
|
||||
.menu__item--children .menu__children:focus-within {
|
||||
margin-top: 0.4rem;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.menu__submenu {
|
||||
min-width: var(--val-menu--item-width-min);
|
||||
max-width: var(--val-menu--item-width-max);
|
||||
}
|
||||
.menu__submenu-title {
|
||||
font-size: 1rem;
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
padding: var(--val-menu--line-padding) 0;
|
||||
line-height: var(--val-menu--line-height);
|
||||
border: 0;
|
||||
color: var(--val-menu--color-highlight);
|
||||
text-transform: uppercase;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
.menu__submenu li {
|
||||
display: block;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.menu__children--mega {
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.menu__mega {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.menu__header,
|
||||
.menu__trigger {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Responsive <= 62rem (992px) */
|
||||
|
||||
@media (max-width: 62rem) {
|
||||
.menu__wrapper {
|
||||
padding-right: var(--val-gap-0-5);
|
||||
}
|
||||
.menu__trigger {
|
||||
width: var(--val-menu--trigger-width);
|
||||
height: var(--val-menu--item-height);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
.menu__trigger svg.icon {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
}
|
||||
|
||||
.menu__nav,
|
||||
.menu__children {
|
||||
overscroll-behavior: contain;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.menu__nav {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: var(--val-menu--side-width);
|
||||
height: 100%;
|
||||
z-index: 9099;
|
||||
overflow: hidden;
|
||||
background: var(--val-menu--color-bg);
|
||||
transform: translate(-100%);
|
||||
transition: transform .5s ease-in-out, opacity .5s ease-in-out;
|
||||
will-change: transform;
|
||||
backface-visibility: hidden;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
.menu__nav.active {
|
||||
transform: translate(0%);
|
||||
visibility: visible;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.menu__nav li {
|
||||
display: block;
|
||||
margin: 0;
|
||||
line-height: var(--val-menu--line-height);
|
||||
}
|
||||
|
||||
.menu__item--label,
|
||||
.menu__nav li > .menu__link {
|
||||
display: block;
|
||||
text-align: inherit;
|
||||
width: 100%;
|
||||
padding: var(--val-menu--line-padding) var(--val-menu--item-height) var(--val-menu--line-padding) var(--val-menu--item-gap);
|
||||
border-bottom: 1px solid var(--val-menu--color-border);
|
||||
}
|
||||
.menu__nav li ul li.menu__item--label,
|
||||
.menu__nav li ul li > .menu__link {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.menu__nav li > .menu__link > svg.icon {
|
||||
position: absolute;
|
||||
top: var(--val-menu--line-padding);
|
||||
right: var(--val-menu--line-padding);
|
||||
height: var(--val-menu--line-height);
|
||||
font-size: 1.25rem;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
.menu__children {
|
||||
position: absolute;
|
||||
display: none;
|
||||
top: 0;
|
||||
left: 0;
|
||||
max-width: none;
|
||||
min-width: auto;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0 !important;
|
||||
padding: 0;
|
||||
border-top: 0;
|
||||
opacity: 1;
|
||||
overflow-y: auto;
|
||||
visibility: visible;
|
||||
transform: translateX(0%);
|
||||
box-shadow: none;
|
||||
transition: opacity .5s ease-in-out, transform .5s ease-in-out, margin-top .5s ease-in-out;
|
||||
}
|
||||
.menu__children.active {
|
||||
display: block;
|
||||
}
|
||||
.menu__children > :first-child {
|
||||
margin-top: 2.675rem;
|
||||
}
|
||||
|
||||
.menu__submenu-title {
|
||||
padding: var(--val-menu--line-padding) var(--val-menu--item-height) var(--val-menu--line-padding) var(--val-menu--item-gap);
|
||||
}
|
||||
|
||||
.menu__mega {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.menu__header {
|
||||
position: sticky;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
top: 0;
|
||||
height: var(--val-menu--item-height);
|
||||
border-bottom: 1px solid var(--val-menu--color-border);
|
||||
background: var(--val-menu--color-bg);
|
||||
z-index: 501;
|
||||
}
|
||||
.menu__title {
|
||||
padding: var(--val-menu--line-padding);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-size: 1.45rem;
|
||||
font-weight: normal;
|
||||
opacity: 0;
|
||||
transform: translateY(.25rem);
|
||||
transition: opacity .5s ease-in-out, transform .5s ease-in-out;
|
||||
will-change: opacity, transform;
|
||||
}
|
||||
.menu__header.active .menu__title {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
.menu__close,
|
||||
.menu__back {
|
||||
width: var(--val-menu--item-height);
|
||||
min-width: var(--val-menu--item-height);
|
||||
height: var(--val-menu--item-height);
|
||||
line-height: var(--val-menu--item-height);
|
||||
color: var(--val-color--text);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--val-menu--color-bg);
|
||||
}
|
||||
.menu__close {
|
||||
font-size: 2.25rem;
|
||||
border: 1px solid var(--val-menu--color-border) !important;
|
||||
border-width: 0 0 1px 1px !important;
|
||||
}
|
||||
.menu__back {
|
||||
font-size: 1.25rem;
|
||||
border: 1px solid var(--val-menu--color-border) !important;
|
||||
border-width: 0 1px 1px 0 !important;
|
||||
display: none;
|
||||
}
|
||||
.menu__header.active .menu__back {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.menu__list {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.menu__overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 9098;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
background: rgba(0, 0, 0, 0.55);
|
||||
transition: opacity .5s ease-in-out, visibility 0s linear .5s;
|
||||
}
|
||||
.menu__overlay.active {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transition-delay: 0s, 0s;
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.menu__item--children:hover > .menu__children {
|
||||
margin-top: 0.4rem;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
.menu.menu--closing .menu__children {
|
||||
margin-top: 0 !important;
|
||||
opacity: 0 !important;
|
||||
visibility: hidden !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.menu__nav,
|
||||
.menu__children,
|
||||
.menu__title,
|
||||
.menu__overlay {
|
||||
transition: none !important;
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Animaciones */
|
||||
|
||||
@keyframes slideLeft {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: translateX(100%);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: translateX(0%);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideRight {
|
||||
0% {
|
||||
opacity: 1;
|
||||
transform: translateX(0%);
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
const getTitle = (li) => li.querySelector('.menu__label')?.textContent.trim() ?? '';
|
||||
|
||||
function menu__showChildren(nav, children) {
|
||||
const li = children[0];
|
||||
const submenu = li.querySelector('.menu__children');
|
||||
submenu.classList.add('active');
|
||||
submenu.style.animation = 'slideLeft 0.5s ease forwards';
|
||||
|
||||
nav.querySelector('.menu__title').textContent = getTitle(li);;
|
||||
nav.querySelector('.menu__header').classList.add('active');
|
||||
}
|
||||
|
||||
function menu__hideChildren(nav, children) {
|
||||
const submenu = children[0].querySelector('.menu__children');
|
||||
submenu.style.animation = 'slideRight 0.5s ease forwards';
|
||||
setTimeout(() => {
|
||||
submenu.classList.remove('active');
|
||||
submenu.style.removeProperty('animation');
|
||||
}, 300);
|
||||
|
||||
children.shift();
|
||||
if (children.length > 0) {
|
||||
nav.querySelector('.menu__title').textContent = getTitle(children[0]);
|
||||
} else {
|
||||
nav.querySelector('.menu__header').classList.remove('active');
|
||||
nav.querySelector('.menu__title').textContent = '';
|
||||
}
|
||||
}
|
||||
|
||||
function menu__toggle(nav, overlay) {
|
||||
nav.classList.toggle('active');
|
||||
overlay.classList.toggle('active');
|
||||
}
|
||||
|
||||
function menu__reset(menu, nav, overlay) {
|
||||
menu__toggle(nav, overlay);
|
||||
setTimeout(() => {
|
||||
nav.querySelector('.menu__header').classList.remove('active');
|
||||
nav.querySelector('.menu__title').textContent = '';
|
||||
menu.querySelectorAll('.menu__children').forEach(submenu => {
|
||||
submenu.classList.remove('active');
|
||||
submenu.style.removeProperty('animation');
|
||||
});
|
||||
}, 300);
|
||||
return [];
|
||||
}
|
||||
|
||||
document.querySelectorAll('.menu').forEach(menu => {
|
||||
let menuChildren = [];
|
||||
const menuNav = menu.querySelector('.menu__nav');
|
||||
const menuOverlay = menu.querySelector('.menu__overlay');
|
||||
|
||||
menu.querySelector('.menu__list').addEventListener('click', (e) => {
|
||||
if (menuNav.classList.contains('active')) {
|
||||
let target = e.target.closest('.menu__item--children');
|
||||
if (target && target != menuChildren[0]) {
|
||||
menuChildren.unshift(target);
|
||||
menu__showChildren(menuNav, menuChildren);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
menu.querySelector('.menu__back').addEventListener('click', () => {
|
||||
menu__hideChildren(menuNav, menuChildren);
|
||||
});
|
||||
|
||||
menu.querySelector('.menu__close').addEventListener('click', () => {
|
||||
menuChildren = menu__reset(menu, menuNav, menuOverlay);
|
||||
});
|
||||
|
||||
menu.querySelectorAll('.menu__item--link > a[target="_blank"]').forEach(link => {
|
||||
link.addEventListener('click', (e) => {
|
||||
menuChildren = menu__reset(menu, menuNav, menuOverlay);
|
||||
e.target.blur();
|
||||
});
|
||||
});
|
||||
|
||||
menu.querySelector('.menu__trigger').addEventListener('click', () => {
|
||||
menu__toggle(menuNav, menuOverlay);
|
||||
});
|
||||
|
||||
menuOverlay.addEventListener('click', () => {
|
||||
menu__toggle(menuNav, menuOverlay);
|
||||
});
|
||||
|
||||
let resizeTimeout;
|
||||
window.addEventListener('resize', () => {
|
||||
if (menuNav.classList.contains('active')) {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(() => {
|
||||
menuChildren = menu__reset(menu, menuNav, menuOverlay);
|
||||
}, 150);
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue