Skip to content

Commit cea6253

Browse files
committed
Shows new walkthrough progress
1 parent 0394dc6 commit cea6253

File tree

3 files changed

+22
-110
lines changed

3 files changed

+22
-110
lines changed
Lines changed: 15 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import { consume } from '@lit/context';
22
import { html, LitElement } from 'lit';
33
import { customElement, state } from 'lit/decorators.js';
4-
import { classMap } from 'lit/directives/class-map.js';
5-
import { when } from 'lit/directives/when.js';
64
import { Commands } from '../../../../constants.commands';
75
import { createCommandLink } from '../../../../system/commands';
86
import type { State } from '../../../home/protocol';
9-
import { CollapseSectionCommand, DismissWalkthroughSection } from '../../../home/protocol';
7+
import { DismissWalkthroughSection } from '../../../home/protocol';
108
import { ipcContext } from '../../shared/context';
119
import type { HostIpc } from '../../shared/ipc';
1210
import { stateContext } from '../context';
13-
import { alertStyles, buttonStyles, homeBaseStyles, walkthroughProgressStyles } from '../home.css';
11+
import { homeBaseStyles, walkthroughProgressStyles } from '../home.css';
1412
import '../../shared/components/button';
1513
import '../../shared/components/code-icon';
1614
import '../../shared/components/overlays/tooltip';
1715

1816
@customElement('gl-onboarding')
1917
export class GlOnboarding extends LitElement {
20-
static override styles = [alertStyles, homeBaseStyles, buttonStyles, walkthroughProgressStyles];
18+
static override styles = [homeBaseStyles, walkthroughProgressStyles];
2119

2220
@consume<State>({ context: stateContext, subscribe: true })
2321
@state()
@@ -27,130 +25,44 @@ export class GlOnboarding extends LitElement {
2725
@state()
2826
private _ipc!: HostIpc;
2927

30-
private onSectionExpandClicked(e: MouseEvent, isToggle = false) {
31-
if (isToggle) {
32-
e.stopImmediatePropagation();
33-
}
34-
const target = (e.target as HTMLElement).closest('[data-section-expand]') as HTMLElement;
35-
const section = target?.dataset.sectionExpand;
36-
if (section !== 'walkthrough') {
37-
return;
38-
}
39-
40-
if (isToggle) {
41-
this.updateCollapsedSections(!this._state.walkthroughCollapsed);
42-
return;
43-
}
44-
45-
this.updateCollapsedSections(false);
46-
}
47-
48-
private updateCollapsedSections(toggle = this._state.walkthroughCollapsed) {
49-
this._state.walkthroughCollapsed = toggle;
50-
this.requestUpdate();
51-
this._ipc.sendCommand(CollapseSectionCommand, {
52-
section: 'walkthrough',
53-
collapsed: toggle,
54-
});
55-
}
56-
5728
private dismissWalkthroughSection() {
5829
this._state.showWalkthroughProgress = false;
5930
this.requestUpdate();
6031
this._ipc.sendCommand(DismissWalkthroughSection);
6132
}
6233

63-
private renderProgress() {
34+
override render() {
6435
if (!this._state.showWalkthroughProgress) {
65-
return null;
36+
return undefined;
6637
}
38+
6739
return html`
68-
<div class="walkthrough-progress--wrapper">
69-
<div class="walkthrough-progress--title">
40+
<section class="walkthrough-progress">
41+
<header class="walkthrough-progress__title">
7042
<span
7143
>GitLens Walkthrough
7244
(${this._state.walkthroughProgress.doneCount}/${this._state.walkthroughProgress.allCount})</span
7345
>
74-
<div>
46+
<nav>
7547
<gl-button
7648
href=${createCommandLink(Commands.OpenWalkthrough, {})}
77-
class="walkthrough-progress--title__button"
49+
class="walkthrough-progress__button"
7850
appearance="toolbar"
7951
><code-icon icon="play"></code-icon
8052
></gl-button>
8153
<gl-button
8254
@click=${this.dismissWalkthroughSection.bind(this)}
83-
class="walkthrough-progress--title__button"
55+
class="walkthrough-progress__button"
8456
appearance="toolbar"
8557
><code-icon icon="x"></code-icon
8658
></gl-button>
87-
</div>
88-
</div>
59+
</nav>
60+
</header>
8961
<progress
90-
class=${classMap({
91-
'walkthrough-progress--progress': true,
92-
})}
62+
class="walkthrough-progress__bar"
9363
value=${this._state.walkthroughProgress.progress}
9464
></progress>
95-
</div>
96-
`;
97-
}
98-
99-
override render() {
100-
return html`
101-
${this.renderProgress()}
102-
<div
103-
id="section-walkthrough"
104-
data-section-expand="walkthrough"
105-
class="alert${this._state.walkthroughCollapsed ? ' is-collapsed' : ''}"
106-
@click=${(e: MouseEvent) => this.onSectionExpandClicked(e)}
107-
>
108-
<h1 class="alert__title">Get Started with GitLens</h1>
109-
<div class="alert__description">
110-
<p>Explore all of the powerful features in GitLens</p>
111-
<p class="button-container button-container--trio">
112-
<gl-button
113-
appearance="secondary"
114-
full
115-
href="command:gitlens.showWelcomePage"
116-
aria-label="Open Welcome"
117-
>Start Here (Welcome)</gl-button
118-
>
119-
<span class="button-group button-group--single">
120-
<gl-button appearance="secondary" full href="command:gitlens.getStarted?%22home%22"
121-
>Walkthrough
122-
${when(
123-
this._state.showWalkthroughProgress && this._state.walkthroughProgress.progress < 1,
124-
() => html`<span class="badge"></span>`,
125-
)}</gl-button
126-
>
127-
<gl-button
128-
appearance="secondary"
129-
full
130-
href=${'https://youtu.be/oJdlGtsbc3U?utm_source=inapp&utm_medium=home_banner&utm_id=GitLens+tutorial'}
131-
aria-label="Watch the GitLens Tutorial video"
132-
tooltip="Watch the GitLens Tutorial video"
133-
><code-icon icon="vm-running" slot="prefix"></code-icon>Tutorial</gl-button
134-
>
135-
</span>
136-
</p>
137-
</div>
138-
<a
139-
href="#"
140-
class="alert__close"
141-
data-section-toggle="walkthrough"
142-
@click=${(e: MouseEvent) => this.onSectionExpandClicked(e, true)}
143-
>
144-
<gl-tooltip hoist>
145-
<code-icon icon="chevron-down" aria-label="Collapse walkthrough section"></code-icon>
146-
<span slot="content">Collapse</span>
147-
</gl-tooltip>
148-
<gl-tooltip hoist>
149-
<code-icon icon="chevron-right" aria-label="Expand walkthrough section"></code-icon>
150-
<span slot="content">Expand</span>
151-
</gl-tooltip>
152-
</a>
153-
</div>
65+
</section>
15466
`;
15567
}
15668
}

src/webviews/apps/home/home.css.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,32 +362,32 @@ export const navListStyles = css`
362362
`;
363363

364364
export const walkthroughProgressStyles = css`
365-
.walkthrough-progress--wrapper {
365+
.walkthrough-progress {
366366
display: flex;
367367
flex-direction: column;
368368
gap: 2px;
369369
padding-block: 4px;
370370
margin-bottom: 16px;
371371
align-items: stretch;
372372
}
373-
.walkthrough-progress--title {
373+
.walkthrough-progress__title {
374374
display: flex;
375375
justify-content: space-between;
376376
align-items: center;
377377
}
378-
.walkthrough-progress--title__button {
378+
.walkthrough-progress__button {
379379
--button-padding: 1px 2px 0px 2px;
380380
}
381-
.walkthrough-progress--progress::-webkit-progress-bar {
381+
.walkthrough-progress__bar::-webkit-progress-bar {
382382
border-radius: 2px;
383383
background: var(--color-alert-neutralBackground);
384384
}
385-
.walkthrough-progress--progress::-webkit-progress-value {
385+
.walkthrough-progress__bar::-webkit-progress-value {
386386
background: var(--vscode-progressBar-background, blue);
387387
transition: 0.1s ease-in;
388388
border-radius: 2px;
389389
}
390-
.walkthrough-progress--progress {
390+
.walkthrough-progress__bar {
391391
pointer-events: none;
392392
border-radius: 2px;
393393
width: 100%;

src/webviews/apps/home/home.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class GlHomeApp extends GlApp<State> {
6666
<gl-home-nav class="home__nav"></gl-home-nav>
6767
<gl-repo-alerts class="home__header"></gl-repo-alerts>
6868
<main class="home__main scrollable" id="main">
69-
<gl-onboarding hidden></gl-onboarding>
69+
<gl-onboarding></gl-onboarding>
7070
<gl-integration-banner></gl-integration-banner>
7171
<gl-active-work></gl-active-work>
7272
<gl-launchpad></gl-launchpad>

0 commit comments

Comments
 (0)