2018-05-02 02:05:36 +02:00
|
|
|
<a class='main-nav-link {selected ? "selected" : ""}'
|
|
|
|
aria-label={ariaLabel}
|
|
|
|
aria-current={selected}
|
2018-04-11 07:51:42 +02:00
|
|
|
on:click="onClick(event)"
|
2018-05-02 02:05:36 +02:00
|
|
|
{href} >
|
2018-05-03 06:32:43 +02:00
|
|
|
<div class="nav-icon-and-label">
|
|
|
|
{#if name === 'notifications'}
|
2018-02-16 07:21:23 +01:00
|
|
|
<div class="nav-link-svg-wrapper">
|
2018-03-16 16:42:10 +01:00
|
|
|
<svg class="nav-link-svg">
|
2018-05-02 02:05:36 +02:00
|
|
|
<use xlink:href={svg} />
|
2018-02-16 07:21:23 +01:00
|
|
|
</svg>
|
2018-05-02 02:05:36 +02:00
|
|
|
{#if $hasNotifications}
|
2018-05-03 06:32:43 +02:00
|
|
|
<span class="nav-link-notifications" aria-hidden="true">
|
2018-05-02 02:05:36 +02:00
|
|
|
{$numberOfNotifications}
|
2018-02-16 07:21:23 +01:00
|
|
|
</span>
|
2018-05-02 02:05:36 +02:00
|
|
|
{/if}
|
2018-02-16 07:21:23 +01:00
|
|
|
</div>
|
2018-05-03 06:32:43 +02:00
|
|
|
{:else}
|
2018-03-16 16:42:10 +01:00
|
|
|
<svg class="nav-link-svg">
|
2018-05-02 02:05:36 +02:00
|
|
|
<use xlink:href={svg} />
|
2018-02-16 07:21:23 +01:00
|
|
|
</svg>
|
2018-05-03 06:32:43 +02:00
|
|
|
{/if}
|
|
|
|
<span class="nav-link-label">{label}</span>
|
|
|
|
</div>
|
|
|
|
<div class="nav-indicator"
|
|
|
|
nav-indicator-key={name}
|
|
|
|
ref:indicator
|
|
|
|
></div>
|
2018-01-13 08:24:05 +01:00
|
|
|
</a>
|
|
|
|
<style>
|
2018-01-20 21:35:38 +01:00
|
|
|
.main-nav-link {
|
2018-01-13 08:24:05 +01:00
|
|
|
text-decoration: none;
|
2018-05-03 06:32:43 +02:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
flex: 1;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-icon-and-label {
|
2018-03-27 18:34:29 +02:00
|
|
|
padding: 15px 20px;
|
2018-01-13 08:24:05 +01:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2018-03-27 18:34:29 +02:00
|
|
|
flex: 1;
|
2018-01-13 08:24:05 +01:00
|
|
|
}
|
|
|
|
|
2018-02-16 07:21:23 +01:00
|
|
|
.nav-link-svg-wrapper {
|
|
|
|
position: relative;
|
|
|
|
display: inline-block;
|
2018-03-31 02:21:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.nav-link-svg-wrapper, .nav-link-svg {
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
2018-02-16 07:21:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.nav-link-notifications {
|
|
|
|
position: absolute;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
transform: translate(10px, 7px);
|
|
|
|
z-index: 10;
|
|
|
|
border: 1px solid var(--nav-bg);
|
|
|
|
background: var(--nav-svg-fill);
|
|
|
|
color: var(--nav-bg);
|
|
|
|
border-radius: 100%;
|
|
|
|
font-size: 0.9em;
|
|
|
|
margin: 3px 0;
|
|
|
|
}
|
|
|
|
|
2018-01-20 21:35:38 +01:00
|
|
|
.main-nav-link.selected {
|
2018-01-13 08:24:05 +01:00
|
|
|
background: var(--nav-a-selected-bg);
|
|
|
|
}
|
|
|
|
|
2018-01-20 21:35:38 +01:00
|
|
|
.main-nav-link.selected:hover {
|
2018-01-13 08:24:05 +01:00
|
|
|
background: var(--nav-a-selected-bg-hover);
|
|
|
|
}
|
|
|
|
|
2018-05-03 06:32:43 +02:00
|
|
|
.nav-indicator {
|
|
|
|
width: 100%;
|
|
|
|
height: 1px;
|
|
|
|
background: var(--nav-a-border);
|
|
|
|
transform-origin: left;
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-indicator.animate {
|
|
|
|
transition: transform 333ms ease-in-out;
|
|
|
|
}
|
|
|
|
|
|
|
|
.main-nav-link:hover .nav-indicator {
|
|
|
|
background: var(--nav-a-border-hover);
|
|
|
|
}
|
|
|
|
|
|
|
|
.main-nav-link.selected .nav-indicator {
|
|
|
|
background: var(--nav-a-selected-border);
|
|
|
|
}
|
|
|
|
|
|
|
|
.main-nav-link.selected:hover .nav-indicator {
|
|
|
|
background: var(--nav-a-selected-border-hover);
|
|
|
|
}
|
|
|
|
|
2018-01-20 21:35:38 +01:00
|
|
|
.main-nav-link:hover {
|
2018-01-13 08:24:05 +01:00
|
|
|
background-color: var(--nav-a-bg-hover);
|
2018-03-14 15:24:24 +01:00
|
|
|
text-decoration: none;
|
2018-01-13 08:24:05 +01:00
|
|
|
}
|
|
|
|
|
2018-02-16 07:21:23 +01:00
|
|
|
.main-nav-link:hover .nav-link-label {
|
2018-01-13 08:24:05 +01:00
|
|
|
color: var(--nav-text-color-hover);
|
|
|
|
}
|
2018-03-16 16:42:10 +01:00
|
|
|
.main-nav-link:hover .nav-link-svg {
|
2018-01-13 08:24:05 +01:00
|
|
|
fill: var(--nav-svg-fill-hover);
|
|
|
|
}
|
|
|
|
|
2018-03-31 02:21:35 +02:00
|
|
|
.nav-link-svg {
|
2018-01-13 08:24:05 +01:00
|
|
|
display: inline-block;
|
|
|
|
fill: var(--nav-svg-fill);
|
|
|
|
}
|
|
|
|
|
2018-03-31 02:21:35 +02:00
|
|
|
.nav-link-label {
|
2018-01-13 08:24:05 +01:00
|
|
|
font-size: 16px;
|
|
|
|
color: var(--nav-text-color);
|
|
|
|
padding-left: 10px;
|
2018-01-23 06:16:27 +01:00
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2018-01-13 08:24:05 +01:00
|
|
|
}
|
|
|
|
|
2018-02-09 03:01:00 +01:00
|
|
|
@media (max-width: 991px) {
|
2018-02-16 07:21:23 +01:00
|
|
|
.main-nav-link .nav-link-label {
|
2018-01-13 08:24:05 +01:00
|
|
|
display: none;
|
|
|
|
}
|
2018-03-31 02:21:35 +02:00
|
|
|
.nav-link-svg-wrapper, .nav-link-svg {
|
2018-01-13 08:24:05 +01:00
|
|
|
width: 25px;
|
|
|
|
height: 25px;
|
|
|
|
}
|
2018-05-03 06:32:43 +02:00
|
|
|
.nav-icon-and-label {
|
2018-01-31 07:40:40 +01:00
|
|
|
padding: 20px 0;
|
2018-01-29 00:53:49 +01:00
|
|
|
}
|
2018-02-16 07:21:23 +01:00
|
|
|
.nav-link-notifications {
|
|
|
|
transform: translate(15px, 7px);
|
|
|
|
margin: 3px 1px 4px;
|
|
|
|
}
|
2018-01-13 08:24:05 +01:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
2018-02-16 07:21:23 +01:00
|
|
|
import { store } from '../_store/store'
|
2018-04-11 07:51:42 +02:00
|
|
|
import { smoothScrollToTop } from '../_utils/smoothScrollToTop'
|
2018-05-03 06:32:43 +02:00
|
|
|
import { on, emit } from '../_utils/eventBus'
|
|
|
|
import { mark, stop } from '../_utils/marks'
|
|
|
|
import { doubleRAF } from '../_utils/doubleRAF'
|
2018-02-16 07:21:23 +01:00
|
|
|
|
|
|
|
export default {
|
2018-05-03 06:32:43 +02:00
|
|
|
oncreate () {
|
|
|
|
let { name } = this.get()
|
|
|
|
let indicator = this.refs.indicator
|
|
|
|
on('animateNavPart1', this, ({fromPage, toPage}) => {
|
|
|
|
if (fromPage !== name) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
mark('animateNavPart1 gBCR')
|
|
|
|
let fromRect = indicator.getBoundingClientRect()
|
|
|
|
stop('animateNavPart1 gBCR')
|
|
|
|
emit('animateNavPart2', {fromRect, fromPage, toPage})
|
|
|
|
})
|
|
|
|
on('animateNavPart2', this, ({fromPage, fromRect, toPage}) => {
|
|
|
|
if (toPage !== name) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
mark('animateNavPart2 gBCR')
|
|
|
|
let toRect = indicator.getBoundingClientRect()
|
|
|
|
stop('animateNavPart2 gBCR')
|
|
|
|
let translateX = fromRect.left - toRect.left
|
|
|
|
let scaleX = fromRect.width / toRect.width
|
|
|
|
indicator.style.transform = `translateX(${translateX}px) scaleX(${scaleX})`
|
|
|
|
let onTransitionEnd = () => {
|
|
|
|
indicator.removeEventListener('transitionend', onTransitionEnd)
|
|
|
|
indicator.classList.remove('animate')
|
|
|
|
}
|
|
|
|
indicator.addEventListener('transitionend', onTransitionEnd)
|
|
|
|
doubleRAF(() => {
|
|
|
|
indicator.classList.add('animate')
|
|
|
|
indicator.style.transform = ''
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
2018-02-16 07:21:23 +01:00
|
|
|
store: () => store,
|
|
|
|
computed: {
|
2018-05-02 02:05:36 +02:00
|
|
|
selected: ({ page, name }) => page === name,
|
|
|
|
ariaLabel: ({ selected, name, label, $numberOfNotifications }) => {
|
2018-02-16 07:58:18 +01:00
|
|
|
let res = label
|
2018-04-11 07:51:42 +02:00
|
|
|
if (selected) {
|
2018-02-16 07:58:18 +01:00
|
|
|
res += ' (current page)'
|
|
|
|
}
|
2018-02-19 02:28:08 +01:00
|
|
|
if (name === 'notifications' && $numberOfNotifications) {
|
2018-02-16 17:59:44 +01:00
|
|
|
res += ` (${$numberOfNotifications})`
|
2018-02-16 07:58:18 +01:00
|
|
|
}
|
|
|
|
return res
|
2018-02-16 07:21:23 +01:00
|
|
|
}
|
2018-04-11 07:51:42 +02:00
|
|
|
},
|
|
|
|
methods: {
|
2018-04-20 06:38:01 +02:00
|
|
|
onClick (e) {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { selected } = this.get()
|
|
|
|
if (!selected) {
|
2018-04-11 07:51:42 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
e.preventDefault()
|
|
|
|
e.stopPropagation()
|
|
|
|
smoothScrollToTop(document.getElementsByClassName('container')[0])
|
|
|
|
}
|
2018-02-16 07:21:23 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-13 08:24:05 +01:00
|
|
|
</script>
|