11import { consume } from '@lit/context' ;
22import { html , LitElement } from 'lit' ;
33import { customElement , state } from 'lit/decorators.js' ;
4- import { classMap } from 'lit/directives/class-map.js' ;
5- import { when } from 'lit/directives/when.js' ;
64import { Commands } from '../../../../constants.commands' ;
75import { createCommandLink } from '../../../../system/commands' ;
86import type { State } from '../../../home/protocol' ;
9- import { CollapseSectionCommand , DismissWalkthroughSection } from '../../../home/protocol' ;
7+ import { DismissWalkthroughSection } from '../../../home/protocol' ;
108import { ipcContext } from '../../shared/context' ;
119import type { HostIpc } from '../../shared/ipc' ;
1210import { stateContext } from '../context' ;
13- import { alertStyles , buttonStyles , homeBaseStyles , walkthroughProgressStyles } from '../home.css' ;
11+ import { homeBaseStyles , walkthroughProgressStyles } from '../home.css' ;
1412import '../../shared/components/button' ;
1513import '../../shared/components/code-icon' ;
1614import '../../shared/components/overlays/tooltip' ;
1715
1816@customElement ( 'gl-onboarding' )
1917export 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}
0 commit comments