mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix(console): make the new Console banner responsive and snoozeable
Three fixes found while testing on production. Responsive: the layout switched to a column at isSmallViewport (max-width 767px) but Button's .is-full-width-mobile applies at max-width 768px. At exactly 768px the row stayed horizontal while the button took the full line, crushing the copy into a ~90px column seven lines tall. Switched the direction to isTabletViewport and dropped fullWidthMobile so the button sizes to its content. 768px goes from 182px tall to 96px. Dismissal: closing the banner wrote a localStorage key that was never cleared, so one click removed the message for the entire migration. Now uses hideNotification with a one week cool-off and exponential backoff, and shouldShowNotification to gate registration. Repeated dismissals still fade it out, but a stray click no longer opts the user out permanently. Resize: AlertStack owns the shell offset for alerts inside it but only re-measured via ResizeObserver and afterNavigate. GradientBanner used to compensate with its own window resize handler, which no longer runs when a stack is in charge, so resizing left the header overlapping the banner. Added the resize listener to AlertStack, which also covers HeaderAlert.
This commit is contained in:
1 parent
ca32b8560e
commit
0feccd0ad9
3 files changed
+16
-6
No files matched your search
@@ -2,7 +2,8 @@
|
||||
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 { isTabletViewport } from '$lib/stores/viewport';
|
||||
import { hideNotification } from '$lib/helpers/notifications';
|
||||
import { headerAlert } from '$lib/stores/headerAlert';
|
||||
import { activeHeaderAlert } from '$routes/(console)/store';
|
||||
import GradientBanner from './billing/gradientBanner.svelte';
|
||||
@@ -13,7 +14,11 @@
|
||||
|
||||
function handleClose() {
|
||||
const { id } = $activeHeaderAlert;
|
||||
localStorage.setItem(id, new Date().getTime().toString());
|
||||
|
||||
// A migration runs for months, so dismissal is a snooze rather than a permanent opt-out:
|
||||
// a week at first, doubling each time. Someone who keeps closing it stops seeing it, but a
|
||||
// single stray click on the X does not remove the message for the whole rollout.
|
||||
hideNotification(id, { coolOffPeriod: 24 * 7, exponentialBackoff: true });
|
||||
trackEvent('close_new_console_banner', { source: 'new_console_banner' });
|
||||
|
||||
// Clear the store entry, not just this component. headerAlert.get() picks the highest
|
||||
@@ -28,15 +33,15 @@
|
||||
gap="m"
|
||||
alignItems="center"
|
||||
alignContent="center"
|
||||
direction={$isSmallViewport ? 'column' : 'row'}>
|
||||
<Typography.Text>
|
||||
justifyContent="center"
|
||||
direction={$isTabletViewport ? 'column' : 'row'}>
|
||||
<Typography.Text align={$isTabletViewport ? 'center' : 'start'}>
|
||||
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' })}>
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
afterNavigate(() => setNavigationHeight());
|
||||
</script>
|
||||
|
||||
<!-- The stack owns the shell offset for every alert inside it, so it has to re-measure when
|
||||
the viewport changes and an alert reflows to a different height. -->
|
||||
<svelte:window on:resize={setNavigationHeight} />
|
||||
|
||||
<div bind:this={container} class="alert-stack">
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
import { UsageRates } from '$lib/components/billing';
|
||||
import { canSeeProjects } from '$lib/stores/roles';
|
||||
import { BottomModalAlert, NewConsoleBanner } from '$lib/components';
|
||||
import { shouldShowNotification } from '$lib/helpers/notifications';
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import {
|
||||
IconAnnotation,
|
||||
@@ -328,7 +329,7 @@
|
||||
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')) {
|
||||
if (isCloud && shouldShowNotification('newConsoleBanner')) {
|
||||
headerAlert.add({
|
||||
id: 'newConsoleBanner',
|
||||
component: NewConsoleBanner,
|
||||
|
||||
Reference in new issue
Block a user