Skip to content
Snippets Groups Projects
Commit 2c336f13 authored by xaralis's avatar xaralis
Browse files

fix(navbar): js submenu acting weird, replaced by NavbarSubitemReplacing

parent 56ebe08b
No related branches found
No related tags found
No related merge requests found
Pipeline #7820 passed
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
<a href="#" data-href="{{ link.templates-homepage }}" class="navbar-menu__link">Hlavní strana</a> <a href="#" data-href="{{ link.templates-homepage }}" class="navbar-menu__link">Hlavní strana</a>
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<ui-navbar-subitem label="Lidé"> <ui-navbar-subitem-replacing label="Lidé">
<ul class="navbar-menu__submenu"> <span class="navbar-menu__link navbar-menu__submenu-toggle">Lidé</span>
<li><a href="#" data-href="{{ link.templates-people }}" class="navbar-menu__link">Delší link co je delší než hlavní menu položka</a></li> <div class="navbar-menu__submenu-wrap">
</ul> <ul class="navbar-menu__submenu">
</ui-navbar-subtitem> <li><a href="#" data-href="{{ link.templates-people }}" class="navbar-menu__link">Delší link co je delší než hlavní menu položka</a></li>
</ul>
</div>
</ui-navbar-subtitem-replacing>
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<a href="#" data-href="{{ link.templates-pirate-center }}" class="navbar-menu__link">Pirátské centrum</a> <a href="#" data-href="{{ link.templates-pirate-center }}" class="navbar-menu__link">Pirátské centrum</a>
......
...@@ -28,25 +28,34 @@ ...@@ -28,25 +28,34 @@
<a href="#" data-href="{{ link.templates-homepage }}" class="navbar-menu__link">Hlavní strana</a> <a href="#" data-href="{{ link.templates-homepage }}" class="navbar-menu__link">Hlavní strana</a>
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<ui-navbar-subitem label="Lidé"> <ui-navbar-subitem-replacing label="Lidé" items="[[&quot;Delší link co je delší než hlavní menu položka&quot;, &quot;{{ link.templates-people }}&quot;]]">
<ul class="navbar-menu__submenu"> <span class="navbar-menu__link navbar-menu__submenu-toggle">Lidé</span>
<li><a href="#" data-href="{{ link.templates-people }}" class="navbar-menu__link">Delší link co je delší než hlavní menu položka</a></li> <div class="navbar-menu__submenu-wrap">
</ul> <ul class="navbar-menu__submenu">
</ui-navbar-subtitem> <li><a href="#" data-href="{{ link.templates-people }}" class="navbar-menu__link">Delší link co je delší než hlavní menu položka</a></li>
</ul>
</div>
</ui-navbar-subtitem-replacing>
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<ui-navbar-subitem label="Aktuality" href="{{ link.templates-article-listing }}"> <ui-navbar-subitem-replacing label="Aktuality" href="{{ link.templates-article-listing }}" items="[[&quot;Detail aktuality&quot;, &quot;{{ link.templates-article-detail }}&quot;]]">
<ul class="navbar-menu__submenu"> <a href="{{ link.templates-article-listing }}" class="navbar-menu__link navbar-menu__submenu-toggle">Lidé</a>
<li><a href="#" data-href="{{ link.templates-article-detail }}" class="navbar-menu__link">Detail aktuality</a></li> <div class="navbar-menu__submenu-wrap">
</ul> <ul class="navbar-menu__submenu">
</ui-navbar-subtitem> <li><a href="#" data-href="{{ link.templates-article-detail }}" class="navbar-menu__link">Detail aktuality</a></li>
</ul>
</div>
</ui-navbar-subtitem-replacing>
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<ui-navbar-subitem label="Volby"> <ui-navbar-subitem-replacing label="Volby" items="[[&quot;Volební rozcestník&quot;, &quot;{{ link.templates-elections }}&quot;]]">
<ul class="navbar-menu__submenu"> <span class="navbar-menu__link navbar-menu__submenu-toggle">Volby</span>
<li><a href="#" data-href="{{ link.templates-elections }}" class="navbar-menu__link">Volební rozcestník</a></li> <div class="navbar-menu__submenu-wrap">
</ul> <ul class="navbar-menu__submenu">
</ui-navbar-subtitem> <li><a href="#" data-href="{{ link.templates-elections }}" class="navbar-menu__link">Volební rozcestník</a></li>
</ul>
</div>
</ui-navbar-subtitem-replacing>
</li> </li>
<li class="navbar-menu__item"> <li class="navbar-menu__item">
<a href="#" data-href="{{ link.templates-pirate-center }}" class="navbar-menu__link">Pirátské centrum</a> <a href="#" data-href="{{ link.templates-pirate-center }}" class="navbar-menu__link">Pirátské centrum</a>
......
<script> <script>
import UiNavbarSubitem from "./NavbarSubitem"; import UiNavbarSubitem from "./NavbarSubitem";
import UiNavbarSubitemReplacing from "./NavbarSubitemReplacing";
import { isLgScreenSize } from "../../utils"; import { isLgScreenSize } from "../../utils";
export default { export default {
components: { components: {
UiNavbarSubitem UiNavbarSubitem,
UiNavbarSubitemReplacing,
}, },
data() { data() {
return { return {
......
<template>
<div @mouseenter="onMouseEnter" @mouseleave="onMouseLeave">
<span v-if="!href" class="navbar-menu__link navbar-menu__submenu-toggle" :class="{'navbar-menu__submenu-toggle--open': show}" @click="handleClick">{{ label }}</span>
<a v-if="href" :href="href" class="navbar-menu__link navbar-menu__submenu-toggle" :class="{'navbar-menu__submenu-toggle--open': show}" @click.prevent="handleClick">{{ label }}</a>
<div :class="{'navbar-menu__submenu-wrap--show': show}" class="navbar-menu__submenu-wrap">
<ul class="navbar-menu__submenu">
<li v-for="(item, index) in parsedItems" :key="index">
<a :href="item[1]" class="navbar-menu__link">{{ item[0] }}</a>
</li>
</ul>
</div>
</div>
</template>
<script>
import { isLgScreenSize } from "../../utils";
export default {
data() {
return {
show: false,
parsedItems: JSON.parse(this.items),
};
},
props: {
href: {
type: String,
},
label: {
type: String,
},
items: {
type: String,
}
},
methods: {
onMouseEnter() {
if (isLgScreenSize()) {
this.$data.show = true;
}
},
onMouseLeave() {
if (isLgScreenSize()) {
this.$data.show = false;
}
},
handleClick(evt) {
// On mobile screens, first click should just toggle and redir on second one
if (isLgScreenSize() || this.$data.show) {
if (this.$props.href) {
window.location = this.$props.href;
}
}
this.$data.show = !this.$data.show;
}
}
}
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment