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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | 145x 152x 4x 4x 4x 4x 10x 61x 61x 61x 61x 61x 61x 61x 61x 61x 134x | <template>
<div
class="space-page"
:class="{ 'space-page-framed': framed && !!space, 'space-page-preview': preview }"
:style="themeStyle"
data-testid="space-page"
>
<!-- The app's frame, in the space's colors (UC-SPACE-015.1) -->
<template v-if="framed && space">
<SpaceHeader :space="space" />
<RibbonsBanner v-if="authStore.isAuthenticated" />
<SpaceNav
:space="space"
:menu="entries"
:current-page-slug="currentPageSlug"
:member-flow-slug="memberFlowSlug"
/>
<AppMain class="space-content">
<div
v-if="showCover"
class="space-cover"
:style="{ backgroundImage: `url(${JSON.stringify(space.pictureUrl)})` }"
data-testid="space-cover"
></div>
<div class="space-main">
<slot />
</div>
</AppMain>
</template>
<!-- First load: nothing is known of the space yet (colors, name, menu), so only
the spinner, never Flows' own footer flashing before the space appears -->
<main v-else-if="loading && !preview" class="space-main" data-testid="space-loading">
<slot />
</main>
<!-- The editor's preview (inside the app), or no space to frame (not found):
"Powered by Flows" in a footer, as there is no menu -->
<template v-else>
<div v-if="space" class="space-preview-bar">
<img
v-if="space.iconUrl"
:src="space.iconUrl"
alt=""
class="space-preview-logo"
data-testid="space-logo"
/>
<span class="space-preview-name">{{ space.name }}</span>
</div>
<div
v-if="showCover && space"
class="space-cover"
:style="{ backgroundImage: `url(${JSON.stringify(space.pictureUrl)})` }"
data-testid="space-cover"
></div>
<main class="space-main">
<slot />
</main>
<footer class="space-footer">
{{ t('space.poweredBy') }}
<router-link to="/" class="space-footer-link">Flows</router-link>
</footer>
</template>
</div>
</template>
<script setup lang="ts">
// @implements UC-SPACE-002.1, UC-SPACE-004.1, UC-SPACE-010.1, UC-SPACE-015.1, UC-SPACE-017.1
/**
* The frame of a flow's public pages: the app's frame (header, ribbons for a
* signed-in user, menu, content) in the flow's colors and font, with the
* flow's icon and name in the header, the space's pages and "Powered by
* Flows" in the menu, and the cover on the home page. `compact` (the
* join page and the other pages) drops the cover; `preview` (the page editor)
* draws the page alone, inside the app.
*/
import { computed, defineAsyncComponent } from 'vue'
import AppMain from '@/components/AppMain.vue'
import SpaceHeader from '@/components/SpaceHeader.vue'
import SpaceNav from '@/components/SpaceNav.vue'
import { useAuthStore } from '@/stores/auth'
import { useUILanguage } from '@/composables/useUILanguage'
import { useTheme } from '@/composables/useTheme'
import { spaceThemeStyle, type SpaceTheme } from '@/utils/spaceTheme'
import type { SpacePageMenuEntry } from '@/utils/spacePages'
// Platform announcements, for signed-in users only (their endpoint needs an account)
const RibbonsBanner = defineAsyncComponent(() => import('@/components/RibbonsBanner.vue'))
export interface PublicSpace {
slug: string
name: string
description?: string
defaultLanguage: string
/** The languages the flow's content is written in (UC-SPACE-018.1) */
languages?: string[]
theme: SpaceTheme
pictureUrl?: string
iconUrl?: string
joinOpen?: boolean
/** The published pages for everyone, in menu order */
menu?: SpacePageMenuEntry[]
/** Whether a home page is published for everyone */
hasHome?: boolean
}
const props = withDefaults(
defineProps<{
space?: PublicSpace | null
compact?: boolean
/** The menu entries; the space's public ones by default */
menu?: SpacePageMenuEntry[] | null
currentPageSlug?: string | null
/** A member's way into the app ("Open in Flows" in the menu) */
memberFlowSlug?: string | null
preview?: boolean
/** The space is still loading (shows the slot alone, no footer) */
loading?: boolean
/** The look to draw while the space loads: its theme as last shown here */
loadingTheme?: SpaceTheme
}>(),
{
space: null,
compact: false,
menu: null,
currentPageSlug: null,
memberFlowSlug: null,
preview: false,
loading: false,
loadingTheme: undefined
}
)
const { t } = useUILanguage()
const authStore = useAuthStore()
const framed = computed(() => !props.preview)
const entries = computed(() => props.menu ?? props.space?.menu ?? [])
const showCover = computed(() => !props.compact && !!props.space?.pictureUrl)
// In the reader's light or dark mode, the app's own preference (UC-SPACE-017.1)
const { resolvedTheme } = useTheme()
const themeStyle = computed(() =>
spaceThemeStyle(props.space?.theme ?? props.loadingTheme, resolvedTheme.value)
)
</script>
<style scoped>
.space-page {
background: var(--space-background);
color: var(--space-text);
font-family: var(--space-font);
/* The app's frame (header, menu, content) takes the space's colors */
--bw-sidebar-start: var(--space-primary);
--bw-sidebar-end: var(--space-primary);
--bw-sidebar-text: var(--space-on-primary);
--bw-sidebar-section: var(--space-on-primary);
--bw-sidebar-hover: rgba(127, 127, 127, 0.18);
--bw-sidebar-active: rgba(127, 127, 127, 0.28);
--bw-main-content-bg: var(--space-background);
}
/* Alone (preview, loading, not found): the page's own height */
.space-page:not(.space-page-framed),
.space-page-preview {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.space-page-preview {
min-height: 0;
}
.space-content {
color: var(--space-text);
}
.space-cover {
flex-shrink: 0;
height: clamp(140px, 28vw, 320px);
background-size: cover;
background-position: center;
border-bottom: 6px solid var(--space-secondary);
}
.space-preview-bar {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
background: var(--space-primary);
color: var(--space-on-primary);
font-size: 1.25rem;
font-weight: 600;
}
.space-preview-logo {
width: 44px;
height: 44px;
object-fit: cover;
border-radius: 10px;
background: var(--space-background);
flex-shrink: 0;
}
.space-preview-name {
overflow-wrap: anywhere;
}
.space-main {
flex: 1 0 auto;
width: 100%;
margin: 0 auto;
padding: 2rem 1rem;
}
.space-footer {
flex-shrink: 0;
padding: 1rem;
text-align: center;
font-size: 0.875rem;
opacity: 0.75;
border-top: 1px solid var(--space-secondary);
}
.space-footer-link {
color: inherit;
font-weight: 600;
}
@media (max-width: 767px) {
.space-cover {
height: clamp(110px, 35vw, 200px);
}
.space-main {
padding: 1.25rem 1rem;
}
}
</style>
<style>
/* Shared by the pages inside the frame (slot content is styled by its own page) */
.space-page .space-button {
background: var(--space-primary);
color: var(--space-on-primary);
border: none;
}
.space-page .space-button:hover,
.space-page .space-button:focus-visible {
background: var(--space-primary);
color: var(--space-on-primary);
filter: brightness(0.9);
}
.space-page .space-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem 1rem;
text-align: center;
}
</style>
|