Skip to content

Commit

Permalink
enhance(ai-help): disable top banner if quota banner is visible (#10532)
Browse files Browse the repository at this point in the history
* refactor(ai-help): move AiHelpBanner into AIHelpInner

* enhance(ai-help): change top banner if quota banner is visible

1. Change the background-color.
2. Hide the "Upgrade Now" button.
3. Add a margin equivalent to the height of the button to avoid layout shift.
  • Loading branch information
caugner authored Feb 29, 2024
1 parent aa34dab commit 0b03586
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions client/src/plus/ai-help/banners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { useUserData } from "../../user-context";
import { PlusLoginBanner } from "../common/login-banner";
import { isPlusSubscriber } from "../../utils";

export function AiHelpBanner() {
export function AiHelpBanner({
isDisabled = false,
}: { isDisabled?: boolean } = {}) {
const user = useUserData();

const isSubscriber = useMemo(() => isPlusSubscriber(user), [user]);

return (
<div className="ai-help-banner">
<div className={`ai-help-banner ${isDisabled ? "disabled" : ""}`}>
<p>
<Icon name="bell-ring" />
<strong>
Expand Down
10 changes: 10 additions & 0 deletions client/src/plus/ai-help/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
.auth-container {
margin-top: 1rem;
}

&.disabled {
background-color: var(--background-secondary);

margin-bottom: 2.25rem;

.button {
display: none;
}
}
}

.ai-help-inner {
Expand Down
4 changes: 1 addition & 3 deletions client/src/plus/ai-help/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ function AIHelpAuthenticated() {
</a>
</p>
</Container>
<Container>
<AiHelpBanner />
</Container>
<AIHelpInner />
</div>
);
Expand Down Expand Up @@ -635,6 +632,7 @@ export function AIHelpInner() {
messageId={messages.length === 2 ? messages[0]?.messageId : undefined}
/>
<Container>
<AiHelpBanner isDisabled={isQuotaExceeded(quota)} />
{isQuotaLoading || isHistoryLoading ? (
<Loading />
) : (
Expand Down

0 comments on commit 0b03586

Please sign in to comment.