|
| 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 — |
| 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 | +} |
0 commit comments