Skip to content

Commit 0368aea

Browse files
committed
Adds AMA banner to home
1 parent 40d690b commit 0368aea

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { consume } from '@lit/context';
2+
import { css, html, LitElement, nothing } from 'lit';
3+
import { customElement, state } from 'lit/decorators.js';
4+
import type { State } from '../../../home/protocol';
5+
import { CollapseSectionCommand } from '../../../home/protocol';
6+
import { linkBase } from '../../shared/components/styles/lit/base.css';
7+
import { ipcContext } from '../../shared/context';
8+
import type { HostIpc } from '../../shared/ipc';
9+
import { stateContext } from '../context';
10+
import '../../shared/components/button';
11+
import '../../shared/components/code-icon';
12+
import '../../shared/components/card/card';
13+
14+
@customElement('gl-ama-banner')
15+
export class GlAmaBanner extends LitElement {
16+
static override styles = [
17+
linkBase,
18+
css`
19+
:host {
20+
margin-inline: 1.2rem;
21+
}
22+
h4 {
23+
font-weight: normal;
24+
margin-block-end: 0.4em;
25+
}
26+
27+
p {
28+
margin-block: 0;
29+
color: var(--vscode-descriptionForeground);
30+
}
31+
`,
32+
];
33+
34+
@consume<State>({ context: stateContext, subscribe: true })
35+
@state()
36+
private _state!: State;
37+
38+
@consume<HostIpc>({ context: ipcContext, subscribe: true })
39+
@state()
40+
private _ipc!: HostIpc;
41+
42+
@state()
43+
private closed = false;
44+
45+
override render() {
46+
if (this.closed || this._state.amaBannerCollapsed === true) return nothing;
47+
48+
return html`
49+
<gl-card indicator="info">
50+
<h4>Live AMA w/ the creator of GitLens</h4>
51+
<p>
52+
Feb 13 @ 1pm EST &mdash;
53+
<a
54+
href="https://www.gitkraken.com/lp/gitlensama?utm_source=githubdisucssion&utm_medium=hyperlink&utm_campaign=GLAMA&utm_id=GLAMA"
55+
>Register now</a
56+
>
57+
</p>
58+
<gl-button slot="actions" appearance="toolbar" tooltip="Dismiss" @click=${() => this.onClose()}
59+
><code-icon icon="close"></code-icon
60+
></gl-button>
61+
</gl-card>
62+
`;
63+
}
64+
65+
private onClose() {
66+
this.closed = true;
67+
this._state.amaBannerCollapsed = true;
68+
69+
this._ipc.sendCommand(CollapseSectionCommand, {
70+
section: 'feb2025AmaBanner',
71+
collapsed: true,
72+
});
73+
}
74+
}

src/webviews/apps/home/home.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import '../plus/home/components/active-work';
1818
import '../plus/home/components/launchpad';
1919
import '../plus/home/components/overview';
2020
import './components/feature-nav';
21+
import './components/ama-banner';
2122
import './components/integration-banner';
2223
import './components/preview-banner';
2324
import './components/promo-banner';
@@ -59,6 +60,7 @@ export class GlHomeApp extends GlApp<State> {
5960
return html`
6061
<div class="home scrollable">
6162
<gl-home-header class="home__header"></gl-home-header>
63+
${when(this.state?.amaBannerCollapsed === false, () => html`<gl-ama-banner></gl-ama-banner>`)}
6264
${when(!this.state?.previewEnabled, () => html`<gl-preview-banner></gl-preview-banner>`)}
6365
<gl-repo-alerts class="home__alerts"></gl-repo-alerts>
6466
<main class="home__main scrollable" id="main">

src/webviews/apps/shared/components/card/card.css.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export const cardStyles = css`
140140
);
141141
}
142142
143+
.card.is-info,
143144
.card.is-branch-changes {
144145
border-inline-start-color: var(--gl-card-indicator-border, color-mix(in lab, #1a79ff 80%, transparent));
145146
}

src/webviews/apps/shared/components/card/card.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class GlCard extends LitElement {
1818
indicator?:
1919
| 'base'
2020
| 'active'
21+
| 'info'
2122
| 'cherry-picking'
2223
| 'merging'
2324
| 'rebasing'

src/webviews/home/homeWebview.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,12 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
601601
return this.container.storage.get('home:sections:collapsed')?.includes('newHomePreview') ?? false;
602602
}
603603

604+
private getAmaBannerCollapsed() {
605+
if (Date.now() >= new Date('2025-02-13T13:00:00-05:00').getTime()) return true;
606+
607+
return this.container.storage.get('home:sections:collapsed')?.includes('feb2025AmaBanner') ?? false;
608+
}
609+
604610
private getIntegrationBannerCollapsed() {
605611
return this.container.storage.get('home:sections:collapsed')?.includes('integrationBanner') ?? false;
606612
}
@@ -659,6 +665,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
659665
showWalkthroughProgress: !this.getWalkthroughDismissed(),
660666
previewEnabled: this.getPreviewEnabled(),
661667
newInstall: getContext('gitlens:install:new', false),
668+
amaBannerCollapsed: this.getAmaBannerCollapsed(),
662669
};
663670
}
664671

src/webviews/home/protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface State extends WebviewState {
3636
showWalkthroughProgress?: boolean;
3737
previewEnabled: boolean;
3838
newInstall: boolean;
39+
amaBannerCollapsed: boolean;
3940
}
4041

4142
export interface IntegrationState extends IntegrationDescriptor {

0 commit comments

Comments
 (0)