Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | 78x 78x 4x 78x 44x 78x 46x 4x 11x 4x 52x 78x 52x 52x 52x 55x 55x 52x 72x 122x 122x | <template>
<AppNavRail
:storage-key="`space-nav-scroll:${space.slug}`"
end-width="72px"
class="space-nav"
:aria-label="t('space.menuLabel')"
data-testid="space-menu"
>
<template #pinned>
<router-link
:to="pageRoute(HOME_SLUG)"
class="nav-link"
:class="{ active: currentPageSlug === HOME_SLUG }"
:aria-current="currentPageSlug === HOME_SLUG ? 'page' : undefined"
data-testid="space-menu-home"
>
<PageIcon :name="pageIcon(homeEntry ?? { slug: HOME_SLUG })" fallback="house" />
<span class="space-nav-label">{{ homeLabel }}</span>
</router-link>
</template>
<router-link
v-for="entry in pages"
:key="entry.slug"
:to="pageRoute(entry.slug)"
class="nav-link"
:class="{ active: entry.slug === currentPageSlug }"
:aria-current="entry.slug === currentPageSlug ? 'page' : undefined"
:data-testid="`space-menu-${entry.slug}`"
>
<PageIcon :name="pageIcon(entry)" :fallback="defaultPageIcon(entry)" />
<font-awesome-icon
v-if="entry.membersOnly"
icon="lock"
class="space-nav-lock"
:title="t('space.membersOnly')"
/>
<span class="space-nav-label">{{
localize(entry.title, contentLanguage, space.defaultLanguage)
}}</span>
</router-link>
<template v-if="memberFlowSlug">
<div class="nav-separator" />
<router-link
:to="flowRoute(memberFlowSlug, 'home')"
class="nav-link"
data-testid="space-menu-open-in-flows"
>
<font-awesome-icon icon="up-right-from-square" />
<span class="space-nav-label">{{ t('space.openInFlows') }}</span>
</router-link>
</template>
<template #end>
<div class="space-powered-by" data-testid="space-powered-by">
{{ t('space.poweredBy') }}
<router-link to="/" class="space-powered-by-link">Flows</router-link>
</div>
</template>
</AppNavRail>
</template>
<script setup lang="ts">
// @implements UC-SPACE-015.1
/**
* The space's menu, in the app's place (on the left, at the bottom on a
* phone): the home first, then the published pages shown in the menu with
* their icon (members-only ones locked), "Open in Flows" for a member, and
* "Powered by Flows" at its end.
*/
import { computed, toRef } from 'vue'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import AppNavRail from '@/components/AppNavRail.vue'
import PageIcon from '@/components/PageIcon.vue'
import { useUILanguage } from '@/composables/useUILanguage'
import { useSpaceLanguage } from '@/composables/useSpaceLanguage'
import { flowRoute } from '@/router/flowRoutes'
import {
HOME_SLUG,
defaultPageIcon,
localize,
pageIcon,
type SpacePageMenuEntry
} from '@/utils/spacePages'
import type { PublicSpace } from '@/components/SpaceLayout.vue'
const props = withDefaults(
defineProps<{
space: PublicSpace
menu?: SpacePageMenuEntry[]
currentPageSlug?: string | null
memberFlowSlug?: string | null
}>(),
{ menu: () => [], currentPageSlug: null, memberFlowSlug: null }
)
const { t } = useUILanguage()
const { contentLanguage } = useSpaceLanguage(toRef(props, 'space'))
/** The home page's own entry, when it is published and shown in the menu */
const homeEntry = computed(() => props.menu.find((entry) => entry.slug === HOME_SLUG))
const pages = computed(() => props.menu.filter((entry) => entry.slug !== HOME_SLUG))
const homeLabel = computed(() =>
homeEntry.value
? localize(homeEntry.value.title, contentLanguage.value, props.space.defaultLanguage) ||
t('space.home')
: t('space.home')
)
function pageRoute(pageSlug: string) {
const slug = props.space.slug
return pageSlug === HOME_SLUG
? { name: 'space', params: { slug } }
: { name: 'space-page', params: { slug, pageSlug } }
}
</script>
<style>
/* Not scoped, like AppNavRail's rules it completes */
.space-nav .nav-link.active {
/* The accent color carries no text: it only marks the current page */
box-shadow: inset 4px 0 0 var(--space-secondary);
}
.space-nav .nav-link .space-nav-lock {
position: absolute;
top: 0.5rem;
right: 0.75rem;
font-size: 0.7rem;
margin: 0;
}
.space-nav .space-nav-label {
max-width: 100%;
overflow-wrap: anywhere;
}
.space-nav .space-powered-by {
width: 100%;
padding: 0.75rem 0.5rem;
text-align: center;
font-size: 0.7rem;
line-height: 1.3;
color: var(--bw-sidebar-text);
opacity: 0.8;
border-top: 1px solid rgba(127, 127, 127, 0.35);
}
.space-nav .space-powered-by-link {
display: block;
color: inherit;
font-weight: 700;
font-size: 0.85rem;
}
@media (max-width: 767px) {
.space-nav .space-powered-by {
display: flex;
flex-direction: column;
justify-content: center;
padding: 0 0.25rem;
border-top: none;
border-left: 1px solid rgba(127, 127, 127, 0.35);
font-size: 0.6rem;
}
.space-nav .space-powered-by-link {
font-size: 0.75rem;
}
.space-nav .nav-link.active {
box-shadow: inset 0 3px 0 var(--space-secondary);
}
.space-nav .nav-link .space-nav-lock {
top: 0.3rem;
right: 0.6rem;
}
.space-nav .space-nav-label {
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>
|