mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat(console): add a top banner for the new Console
Uses GradientBanner, the same component newDevUpgradePro uses, registered through headerAlert at importance 1 so it sits in the promo tier and can never outrank a payment or usage warning. Dismissal is keyed on the alert id in localStorage, matching newDevUpgradePro. Also makes GradientBanner stack-aware. It is position:fixed and offsets the shell itself, but AlertStack is fixed too and measures its children to do the same job. Inside a stack the banner measured as 0, so the stack reset the header offset the banner had just set and the banner covered the navigation until the next resize. It now stands down when a stack is in charge, mirroring headerAlert.svelte. This also fixes the same first-paint overlap for newDevUpgradePro and enterpriseTrial. The CTA carries utm_medium=banner so this surface can be compared against the promo card.
This commit is contained in:
1 parent
4d806026fc
commit
58febd4e65
3 files changed
+75
-1
No files matched your search
@@ -6,10 +6,18 @@
|
||||
import { isTabletViewport } from '$lib/stores/viewport';
|
||||
import PinkBackground from '$lib/images/pink-background.svg';
|
||||
import { bannerSpacing } from '$lib/layout/headerAlert.svelte';
|
||||
import { createEventDispatcher, onMount, onDestroy } from 'svelte';
|
||||
import { createEventDispatcher, getContext, onMount, onDestroy } from 'svelte';
|
||||
|
||||
export let variant: 'gradient' | 'image' = 'gradient';
|
||||
|
||||
/**
|
||||
* An AlertStack parent is itself fixed and measures its children to offset the shell. This
|
||||
* banner is position:fixed, so inside a stack it measures as 0 and the stack resets the
|
||||
* header offset we just set, leaving the banner covering the navigation until the next
|
||||
* resize. Mirror headerAlert.svelte and stand down when the stack is in charge.
|
||||
*/
|
||||
const isInStack: boolean = getContext('isInAlertStack') ?? false;
|
||||
|
||||
let container: HTMLElement;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
@@ -20,6 +28,8 @@
|
||||
});
|
||||
|
||||
const setNavigationHeight = () => {
|
||||
if (isInStack) return;
|
||||
|
||||
const alertHeight = container?.getBoundingClientRect()?.height || 0;
|
||||
const { header, sidebar, content } = queryLayoutElements();
|
||||
const headerHeight = header?.getBoundingClientRect().height || 0;
|
||||
@@ -51,6 +61,7 @@
|
||||
<div
|
||||
bind:this={container}
|
||||
class:darker={variant === 'image'}
|
||||
class:in-stack={isInStack}
|
||||
class="top-banner alert is-action is-action-and-top-sticky">
|
||||
{#if variant === 'gradient'}
|
||||
<div class="top-banner-bg">
|
||||
@@ -92,6 +103,11 @@
|
||||
position: fixed;
|
||||
padding: 0.8rem;
|
||||
|
||||
&.in-stack {
|
||||
position: relative;
|
||||
z-index: unset;
|
||||
}
|
||||
|
||||
&.darker {
|
||||
background: var(--bgcolor-neutral-default);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<script lang="ts">
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import { activeHeaderAlert } from '$routes/(console)/store';
|
||||
import GradientBanner from './billing/gradientBanner.svelte';
|
||||
|
||||
// utm_medium separates this from the promo card, so the two surfaces can be compared.
|
||||
const href =
|
||||
'https://appwrite.io/?utm_source=old-console&utm_medium=banner&utm_campaign=new-console';
|
||||
|
||||
let show = true;
|
||||
|
||||
function handleClose() {
|
||||
show = false;
|
||||
localStorage.setItem($activeHeaderAlert.id, new Date().getTime().toString());
|
||||
trackEvent('close_new_console_banner', { source: 'new_console_banner' });
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if show}
|
||||
<GradientBanner on:close={handleClose}>
|
||||
<Layout.Stack
|
||||
gap="m"
|
||||
alignItems="center"
|
||||
alignContent="center"
|
||||
direction={$isSmallViewport ? 'column' : 'row'}>
|
||||
<Typography.Text>
|
||||
Introducing the new Appwrite Console, rebuilt from the ground up.
|
||||
</Typography.Text>
|
||||
|
||||
<Button
|
||||
secondary
|
||||
external
|
||||
fullWidthMobile
|
||||
class="u-line-height-1"
|
||||
{href}
|
||||
on:click={() => trackEvent('click_new_console', { source: 'new_console_banner' })}>
|
||||
Try it now
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
</GradientBanner>
|
||||
{/if}
|
||||
@@ -45,6 +45,7 @@
|
||||
import { UsageRates } from '$lib/components/billing';
|
||||
import { canSeeProjects } from '$lib/stores/roles';
|
||||
import { BottomModalAlert } from '$lib/components';
|
||||
import NewConsoleBanner from '$lib/components/newConsoleBanner.svelte';
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import {
|
||||
IconAnnotation,
|
||||
@@ -325,6 +326,19 @@
|
||||
|
||||
$registerSearchers(orgSearcher, projectsSearcher);
|
||||
|
||||
onMount(() => {
|
||||
// Same shape as newDevUpgradePro: promo tier (importance 1) so it can never outrank a
|
||||
// payment or usage warning, dismissal keyed on the alert id in localStorage.
|
||||
if (isCloud && !localStorage.getItem('newConsoleBanner')) {
|
||||
headerAlert.add({
|
||||
id: 'newConsoleBanner',
|
||||
component: NewConsoleBanner,
|
||||
show: true,
|
||||
importance: 1
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$: (void $headerAlert, ($activeHeaderAlert = headerAlert.getExcluding('impersonation')));
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user