Merge branch 'naventry-unnest' into 'develop'

make custom router-link for nav-entry to un-nest the interactive elements

Closes #1191

See merge request pleroma/pleroma-fe!1634
This commit is contained in:
tusooa 2022-08-31 19:55:10 +00:00
commit 4beaea2fcc
4 changed files with 101 additions and 68 deletions

View File

@ -121,7 +121,6 @@
border-bottom: 1px solid;
border-color: $fallback--border;
border-color: var(--border, $fallback--border);
padding: 0;
}
> li {
@ -150,12 +149,6 @@
font-size: 1.1em;
}
.menu-item {
.timelines-chevron {
margin-right: 0;
}
}
.timelines-background {
padding: 0 0 0 0.6em;
background-color: $fallback--lightBg;

View File

@ -1,5 +1,6 @@
import { mapState } from 'vuex'
import { USERNAME_ROUTES } from 'src/components/navigation/navigation.js'
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
@ -7,6 +8,9 @@ library.add(faThumbtack)
const NavigationEntry = {
props: ['item', 'showPin'],
components: {
OptionalRouterLink
},
methods: {
isPinned (value) {
return this.pinnedItems.has(value)

View File

@ -1,9 +1,19 @@
<template>
<li class="NavigationEntry">
<component
:is="routeTo ? 'router-link' : 'button'"
class="menu-item button-unstyled"
<OptionalRouterLink
v-slot="{ isActive, href, navigate } = {}"
ass="ass"
:to="routeTo"
>
<li
class="NavigationEntry menu-item"
:class="{ '-active': isActive }"
v-bind="$attrs"
>
<component
:is="routeTo ? 'a' : 'button'"
class="main-link button-unstyled"
:href="href"
@click="navigate"
>
<span>
<FAIcon
@ -21,6 +31,7 @@
<span class="label">
{{ item.labelRaw || $t(item.label) }}
</span>
</component>
<slot />
<div
v-if="item.badgeGetter && getters[item.badgeGetter]"
@ -45,8 +56,8 @@
icon="thumbtack"
/>
</button>
</component>
</li>
</OptionalRouterLink>
</template>
<script src="./navigation_entry.js"></script>
@ -55,7 +66,21 @@
@import '../../_variables.scss';
.NavigationEntry {
.label {
display: flex;
box-sizing: border-box;
align-items: baseline;
height: 3.5em;
line-height: 3.5em;
padding: 0 1em;
width: 100%;
color: $fallback--link;
color: var(--link, $fallback--link);
.timelines-chevron {
margin-right: 0;
}
.main-link {
flex: 1;
}
@ -72,17 +97,6 @@
}
}
.menu-item {
display: flex;
box-sizing: border-box;
align-items: baseline;
height: 3.5em;
line-height: 3.5em;
padding: 0 1em;
width: 100%;
color: $fallback--link;
color: var(--link, $fallback--link);
&:hover {
background-color: $fallback--lightBg;
background-color: var(--selectedMenu, $fallback--lightBg);
@ -97,7 +111,7 @@
}
}
&.router-link-active {
&.-active {
font-weight: bolder;
background-color: $fallback--lightBg;
background-color: var(--selectedMenu, $fallback--lightBg);
@ -116,5 +130,4 @@
}
}
}
}
</style>

View File

@ -0,0 +1,23 @@
<template>
<!-- eslint-disable vue/no-multiple-template-root -->
<router-link
v-if="to"
v-slot="props"
:to="to"
custom
>
<slot
v-bind="props"
/>
</router-link>
<slot
v-else
v-bind="{}"
/>
</template>
<script>
export default {
props: ['to']
}
</script>