|
14 | 14 | import SideNavigation from '$lib/layout/navigation.svelte'; |
15 | 15 | import { hasOnboardingDismissed } from '$lib/helpers/onboarding'; |
16 | 16 | import { isSidebarOpen, noWidthTransition } from '$lib/stores/sidebar'; |
17 | | - import { page } from '$app/stores'; |
| 17 | + import { page } from '$app/state'; |
18 | 18 | import { BillingPlanGroup, type Models } from '@appwrite.io/console'; |
19 | 19 | import { getSidebarState, isInDatabasesRoute, updateSidebarState } from '$lib/helpers/sidebar'; |
20 | 20 | import { isTabletViewport } from '$lib/stores/viewport'; |
|
25 | 25 | export let showSideNavigation = false; |
26 | 26 | export let selectedProject: Models.Project = null; |
27 | 27 |
|
| 28 | + $: activeProject = selectedProject && page.params.project ? selectedProject : null; |
| 29 | +
|
28 | 30 | // variables |
29 | 31 | let yOnMenuOpen: number; |
30 | 32 | let showAccountMenu = false; |
|
52 | 54 | } |
53 | 55 |
|
54 | 56 | function getProgressCard() { |
55 | | - if (selectedProject && !hasOnboardingDismissed(selectedProject.$id, $user)) { |
56 | | - const { platforms, pingCount } = selectedProject; |
57 | | - let percentage = 33; |
58 | | -
|
59 | | - if (platforms.length > 0 && pingCount === 0) { |
60 | | - percentage = 66; |
61 | | - } else if (pingCount > 0) { |
62 | | - percentage = 100; |
63 | | - } |
| 57 | + if (!activeProject || hasOnboardingDismissed(activeProject.$id, $user)) return undefined; |
64 | 58 |
|
65 | | - return { |
66 | | - title: 'Get started', |
67 | | - percentage |
68 | | - }; |
| 59 | + const { platforms, pingCount } = activeProject; |
| 60 | + let percentage = 33; |
| 61 | +
|
| 62 | + if (platforms.length > 0 && pingCount === 0) { |
| 63 | + percentage = 66; |
| 64 | + } else if (pingCount > 0) { |
| 65 | + percentage = 100; |
69 | 66 | } |
70 | 67 |
|
71 | | - return undefined; |
| 68 | + return { |
| 69 | + title: 'Get started', |
| 70 | + percentage |
| 71 | + }; |
72 | 72 | } |
73 | 73 |
|
74 | 74 | function handleResize() { |
|
139 | 139 | // subscriptions |
140 | 140 | isNewWizardStatusOpen.subscribe((value) => (showHeader = !value)); |
141 | 141 |
|
142 | | - page.subscribe(({ url }) => { |
143 | | - $showSubNavigation = url.searchParams.get('openNavbar') === 'true'; |
| 142 | + $: { |
| 143 | + const url = page.url; |
| 144 | + showSubNavigation.set(url.searchParams.get('openNavbar') === 'true'); |
144 | 145 | clearTimeout(timeoutId); |
145 | 146 |
|
146 | 147 | if (url.pathname.includes('project-')) { |
|
150 | 151 | } else { |
151 | 152 | showContentTransition = false; |
152 | 153 | } |
153 | | - }); |
| 154 | + } |
154 | 155 |
|
155 | 156 | // reactive blocks |
156 | 157 | $: sideSize = $hasSubNavigation ? ($isNarrow ? '17rem' : '25rem') : '12.5rem'; |
|
185 | 186 | }; |
186 | 187 | }), |
187 | 188 |
|
188 | | - currentProject: selectedProject |
| 189 | + currentProject: activeProject |
189 | 190 | }; |
190 | 191 |
|
191 | 192 | $: state = $isSidebarOpen ? 'open' : 'closed'; |
192 | 193 |
|
193 | | - $: subNavigation = $page.data.subNavigation; |
| 194 | + $: subNavigation = page.data.subNavigation; |
194 | 195 |
|
195 | 196 | $: shouldRenderSidebar = |
196 | 197 | !$isNewWizardStatusOpen && showSideNavigation && !$showOnboardingAnimation; |
197 | | - $: hasSidebarSpace = shouldRenderSidebar && !$isTabletViewport && !!selectedProject; |
198 | | - $: isProjectBlocked = getIsProjectBlocked(selectedProject); |
| 198 | + $: hasSidebarSpace = shouldRenderSidebar && !$isTabletViewport && !!activeProject; |
| 199 | + $: isProjectBlocked = getIsProjectBlocked(activeProject); |
199 | 200 | $: { |
200 | 201 | if ($isSidebarOpen) { |
201 | 202 | closeOpenDialogs(); |
|
219 | 220 | <main |
220 | 221 | class:has-alert={$activeHeaderAlert?.show} |
221 | 222 | class:is-open={$showSubNavigation} |
| 223 | + class:is-sidebar-open={$isSidebarOpen} |
222 | 224 | class:u-hide={$wizard.show || $wizard.cover} |
223 | 225 | class:is-fixed-layout={$activeHeaderAlert?.show} |
224 | 226 | class:no-header={!showHeader || $showOnboardingAnimation} |
|
230 | 232 | <div class="shell-sidebar-area" inert={isProjectBlocked || undefined}> |
231 | 233 | {#if shouldRenderSidebar} |
232 | 234 | <Sidebar |
233 | | - project={selectedProject} |
| 235 | + project={activeProject} |
234 | 236 | progressCard={getProgressCard()} |
235 | 237 | avatar={navbarProps.avatar} |
236 | 238 | bind:subNavigation |
|
247 | 249 | <div |
248 | 250 | class="content" |
249 | 251 | class:has-transition={showContentTransition} |
250 | | - class:icons-content={state === 'icons' && selectedProject} |
| 252 | + class:icons-content={state === 'icons' && activeProject} |
251 | 253 | class:no-sidebar={!hasSidebarSpace}> |
252 | 254 | <section class="main-content" data-test={showSideNavigation}> |
253 | | - {#if $page.data?.header} |
| 255 | + {#if page.data?.header} |
254 | 256 | <div class="layout-header"> |
255 | | - <svelte:component this={$page.data.header} /> |
| 257 | + <svelte:component this={page.data.header} /> |
256 | 258 | </div> |
257 | 259 | {/if} |
258 | 260 | <slot /> |
|
278 | 280 | z-index: 20; |
279 | 281 | } |
280 | 282 |
|
| 283 | + @media (max-width: 1023px) { |
| 284 | + main.is-sidebar-open .content { |
| 285 | + pointer-events: none; |
| 286 | + } |
| 287 | + } |
| 288 | +
|
281 | 289 | .content { |
282 | 290 | width: 100%; |
283 | 291 |
|
|
0 commit comments