Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(sidebar): promo card for plan upgrade (#3467)

dev-rb8870ee869d7b
diff --git a/js/app/packages/app/component/app-sidebar/sidebar-promo.tsx b/js/app/packages/app/component/app-sidebar/sidebar-promo.tsx
new file mode 100644
index 0000000000..2f78c94872
--- /dev/null
+++ b/js/app/packages/app/component/app-sidebar/sidebar-promo.tsx
@@ -0,0 +1,185 @@
+import ClockIcon from '@phosphor/clock.svg';
+import XIcon from '@phosphor/x.svg';
+import { Button, cn, Layer } from '@ui';
+import { createSignal, onCleanup, onMount, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+
+export const PROMO_HINT_DURATION_MS = 8000;
+
+type SidebarPromoCardAction = {
+ label: string;
+ onClick: () => void;
+};
+
+type SidebarPromoCardProps = {
+ label: string;
+ description: string;
+ onDismiss: () => void;
+ onClick?: () => void;
+ primaryAction?: SidebarPromoCardAction;
+ secondaryAction?: SidebarPromoCardAction;
+};
+
+export const SidebarPromoCard = (props: SidebarPromoCardProps) => {
+ return (
+ <Layer depth={1}>
+ <section aria-label={props.label} class="relative group/promo w-full">
+ <div class="rounded-lg border border-ink-muted/8 bg-ink-muted/2.5 overflow-hidden divide-y divide-ink-muted/8">
+ <header class="flex items-center gap-2 min-w-0 px-2.5 py-1.5">
+ <h3 class="flex-1 min-w-0 text-xs font-medium text-ink leading-tight m-0">
+ {props.label}
+ </h3>
+ <Button
+ variant="ghost"
+ class="shrink-0 size-5 rounded-sm p-0 [&_svg]:size-3"
+ label="Dismiss"
+ onClick={(e) => {
+ e.stopPropagation();
+ props.onDismiss();
+ }}
+ >
+ <XIcon />
+ </Button>
+ </header>
+ <Dynamic
+ component={props.onClick ? 'button' : 'div'}
+ type={props.onClick ? 'button' : undefined}
+ class={cn(
+ 'w-full text-left px-2.5 py-2',
+ props.onClick && 'cursor-default hover:bg-ink-muted/6'
+ )}
+ onClick={props.onClick}
+ >
+ <p class="text-xs text-ink-extra-muted leading-snug m-0">
+ {props.description}
+ </p>
+ </Dynamic>
+ <Show when={props.primaryAction || props.secondaryAction}>
+ <div
+ role="group"
+ aria-label={`${props.label} actions`}
+ class="flex items-center justify-end gap-1 px-2.5 py-1.5"
+ >
+ <Show when={props.secondaryAction}>
+ {(action) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={(e) => {
+ e.stopPropagation();
+ action().onClick();
+ }}
+ >
+ {action().label}
+ </Button>
+ )}
+ </Show>
+ <Show when={props.primaryAction}>
+ {(action) => (
+ <Button
+ variant="cta"
+ size="sm"
+ onClick={(e) => {
+ e.stopPropagation();
+ action().onClick();
+ }}
+ >
+ {action().label}
+ </Button>
+ )}
+ </Show>
+ </div>
+ </Show>
+ </div>
+ </section>
+ </Layer>
+ );
+};
+
+type SidebarPromoHintProps = {
+ title: string;
+ message: string;
+ onDone: () => void;
+ secondaryAction?: SidebarPromoCardAction;
+};
+
+export const SidebarPromoHint = (props: SidebarPromoHintProps) => {
+ const [fading, setFading] = createSignal(false);
+ const [progressDepleted, setProgressDepleted] = createSignal(false);
+
+ onMount(() => {
+ // Kick the progress bar animation on the next frame so the
+ // initial 100% width is committed before the transition starts.
+ requestAnimationFrame(() => setProgressDepleted(true));
+ const fadeTimer = setTimeout(
+ () => setFading(true),
+ PROMO_HINT_DURATION_MS - 400
+ );
+ const doneTimer = setTimeout(props.onDone, PROMO_HINT_DURATION_MS);
+ onCleanup(() => {
+ clearTimeout(fadeTimer);
+ clearTimeout(doneTimer);
+ });
+ });
+
+ return (
+ <Layer depth={2}>
+ <div
+ role="status"
+ aria-label={props.title}
+ class={cn(
+ 'w-full transition-opacity duration-300',
+ fading() ? 'opacity-0' : 'opacity-100'
+ )}
+ >
+ <div class="rounded-lg border border-ink-muted/8 bg-ink-muted/2.5 overflow-hidden">
+ <div
+ role="progressbar"
+ aria-label="Auto-dismiss countdown"
+ class="h-0.5 w-full bg-ink-muted/8"
+ >
+ <div
+ class="h-full bg-accent ease-linear"
+ style={{
+ width: progressDepleted() ? '0%' : '100%',
+ transition: `width ${PROMO_HINT_DURATION_MS}ms linear`,
+ }}
+ />
+ </div>
+ <div class="divide-y divide-ink-muted/8">
+ <header class="flex items-center gap-2 min-w-0 px-2.5 py-1.5">
+ <ClockIcon class="shrink-0 size-4 text-ink-muted" />
+ <h3 class="flex-1 min-w-0 text-xs font-medium text-ink leading-tight m-0">
+ {props.title}
+ </h3>
+ </header>
+ <div class="px-2.5 py-2">
+ <p class="text-xs text-ink-extra-muted leading-snug m-0 min-h-[3lh]">
+ {props.message}
+ </p>
+ </div>
+ <div class="flex items-center justify-end gap-1 px-2.5 py-1.5">
+ <Show when={props.secondaryAction}>
+ {(action) => (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ action().onClick();
+ props.onDone();
+ }}
+ >
+ {action().label}
+ </Button>
+ )}
+ </Show>
+ <Button variant="cta" size="sm" onClick={props.onDone}>
+ Got it
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </Layer>
+ );
+};
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index 03aa4dbfd8..e9fbea2466 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -4,6 +4,10 @@ import {
InviteModal,
setInviteModalOpen,
} from '@app/component/app-sidebar/invite-modal';
+import {
+ SidebarPromoCard,
+ SidebarPromoHint,
+} from '@app/component/app-sidebar/sidebar-promo';
import { CommandState } from '@app/component/command';
import { createMenuOpen, setCreateMenuOpen } from '@app/component/Launcher';
import { requestSearchFocus } from '@app/component/next-soup/soup-view/search-controllers';
@@ -64,6 +68,7 @@ import PlugIcon from '@phosphor/plug.svg';
import UserIconPhosphor from '@phosphor/user.svg';
import UsersThreeIcon from '@phosphor/users-three.svg';
import { debounce } from '@solid-primitives/scheduled';
+import { makePersisted } from '@solid-primitives/storage';
import { useLocation } from '@solidjs/router';
import { Button, cn, Dropdown, Hotkey } from '@ui';
import {
@@ -388,6 +393,15 @@ const registerSidebarHotkeys = ({
}
};
+/** Persisted dismissal for the Premium upgrade promo card. */
+const [premiumCardDismissed, setPremiumCardDismissed] = makePersisted(
+ createSignal<boolean>(false),
+ { name: 'sidebar-premium-card-dismissed' }
+);
+
+/** Session-only signal so a hint shows after dismissal until the user acknowledges or the timer expires. */
+const [premiumHintVisible, setPremiumHintVisible] = createSignal(false);
+
type SidebarActionButtonProps = {
icon: Component<{ triggerAnimation?: boolean; class?: string }>;
onClick: (event?: MouseEvent) => void;
@@ -908,6 +922,43 @@ export const AppSidebar = (props: AppSidebarProps) => {
<hr class="border-transparent mb-2" />
</div>
+ <Show when={!isSlim() && !premiumCardDismissed()}>
+ <div class="w-full px-2 mb-2">
+ <SidebarPromoCard
+ label="Upgrade to Premium"
+ description="Unlock MCP integrations, better AI models, and team collaboration."
+ onDismiss={() => {
+ setPremiumCardDismissed(true);
+ setPremiumHintVisible(true);
+ }}
+ primaryAction={{
+ label: 'Upgrade',
+ onClick: () => openSettingsTab('Account'),
+ }}
+ secondaryAction={{
+ label: 'Later',
+ onClick: () => {
+ setPremiumCardDismissed(true);
+ setPremiumHintVisible(true);
+ },
+ }}
+ />
+ </div>
+ </Show>
+ <Show when={!isSlim() && premiumHintVisible() && premiumCardDismissed()}>
+ <div class="w-full px-2 mb-2">
+ <SidebarPromoHint
+ title="Maybe later"
+ message="You can upgrade anytime from Account settings."
+ onDone={() => setPremiumHintVisible(false)}
+ secondaryAction={{
+ label: 'Take me there',
+ onClick: () => openSettingsTab('Account'),
+ }}
+ />
+ </div>
+ </Show>
+
<div class="w-full px-2 flex flex-col gap-1 mb-1">
<Show when={isTabAvailable('Mobile App')}>
<SidebarShortcutLink