Skip to content

Commit 5246516

Browse files
committed
Updates home loading and layout
- prevents unnessary banners showing during discovery - removes spacing from empty banners and alerts - fixes section header skeletons - fixes pill alignments
1 parent 6f07fd9 commit 5246516

File tree

13 files changed

+100
-25
lines changed

13 files changed

+100
-25
lines changed

src/webviews/apps/home/components/promo-banner.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { consume } from '@lit/context';
22
import { css, html, LitElement, nothing } from 'lit';
3-
import { customElement, state } from 'lit/decorators.js';
3+
import { customElement, property, state } from 'lit/decorators.js';
44
import { getApplicablePromo } from '../../../../plus/gk/account/promos';
55
import type { State } from '../../../home/protocol';
66
import { stateContext } from '../context';
@@ -31,14 +31,22 @@ export class GlPromoBanner extends LitElement {
3131
@state()
3232
private _state!: State;
3333

34+
@property({ type: Boolean, reflect: true, attribute: 'has-promo' })
35+
get hasPromos() {
36+
return this.promo == null ? undefined : true;
37+
}
38+
39+
get promo() {
40+
return getApplicablePromo(this._state.subscription.state, 'home');
41+
}
42+
3443
override render() {
35-
const promo = getApplicablePromo(this._state.subscription.state, 'home');
36-
if (!promo) {
44+
if (!this.promo) {
3745
return nothing;
3846
}
3947

4048
return html`
41-
<gl-promo .promo=${promo} class="promo-banner promo-banner--eyebrow" id="promo" type="link"></gl-promo>
49+
<gl-promo .promo=${this.promo} class="promo-banner promo-banner--eyebrow" id="promo" type="link"></gl-promo>
4250
`;
4351
}
4452
}

src/webviews/apps/home/components/repo-alerts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class GlRepoAlerts extends GlElement {
4040

4141
@property({ type: Boolean, reflect: true, attribute: 'has-alerts' })
4242
get hasAlerts() {
43-
return this.alertVisibility.header;
43+
return this.alertVisibility.header !== true ? undefined : true;
4444
}
4545

4646
@consume<State>({ context: stateContext, subscribe: true })
@@ -54,7 +54,7 @@ export class GlRepoAlerts extends GlElement {
5454
noRepo: false,
5555
unsafeRepo: false,
5656
};
57-
if (this._state == null) {
57+
if (this._state == null || this._state.discovering) {
5858
return sections;
5959
}
6060

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ export const homeStyles = css`
4242
gap: 0.4rem;
4343
overflow: hidden;
4444
}
45-
.home__header {
45+
46+
.home__alerts {
4647
flex: none;
4748
padding: 0 2rem;
4849
position: relative;
4950
}
51+
.home__alerts:not([has-alerts]) {
52+
display: none;
53+
}
54+
5055
.home__main {
5156
flex: 1;
5257
overflow: auto;
@@ -55,11 +60,16 @@ export const homeStyles = css`
5560
.home__main > *:last-child {
5661
margin-bottom: 0;
5762
}
63+
5864
.home__aux,
5965
.home__footer {
6066
flex: none;
6167
}
6268
69+
.home__aux:has(gl-promo-banner:not([has-promo]):only-child) {
70+
display: none;
71+
}
72+
6373
summary {
6474
font-size: 1.3rem;
6575
font-weight: normal;

src/webviews/apps/home/home.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class GlHomeApp extends GlApp<State> {
7171
<gl-promo-banner></gl-promo-banner>
7272
${when(!this.state.previewEnabled, () => html`<gl-preview-banner></gl-preview-banner>`)}
7373
</aside>
74-
<gl-repo-alerts class="home__header"></gl-repo-alerts>
74+
<gl-repo-alerts class="home__alerts"></gl-repo-alerts>
7575
<main class="home__main scrollable" id="main">
7676
<gl-onboarding></gl-onboarding>
7777
${when(

src/webviews/apps/home/stateProvider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
DidChangeRepositories,
99
DidChangeSubscription,
1010
DidChangeWalkthroughProgress,
11+
DidCompleteDiscoveringRepositories,
1112
} from '../../home/protocol';
1213
import type { Disposable } from '../shared/events';
1314
import type { HostIpc } from '../shared/ipc';
@@ -34,6 +35,13 @@ export class HomeStateProvider implements Disposable {
3435
this.state.repositories = msg.params;
3536
this.state.timestamp = Date.now();
3637

38+
this.provider.setValue(this.state, true);
39+
break;
40+
case DidCompleteDiscoveringRepositories.is(msg):
41+
this.state.repositories = msg.params.repositories;
42+
this.state.discovering = msg.params.discovering;
43+
this.state.timestamp = Date.now();
44+
3745
this.provider.setValue(this.state, true);
3846
break;
3947
case DidChangeWalkthroughProgress.is(msg):

src/webviews/apps/plus/home/components/active-work.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { GitTrackingState } from '../../../../../git/models/branch';
88
import { createWebviewCommandLink } from '../../../../../system/webview';
99
import type { GetOverviewBranch, State } from '../../../../home/protocol';
1010
import { stateContext } from '../../../home/context';
11-
import { branchCardStyles, createCommandLink } from './branch-section';
11+
import { branchCardStyles, createCommandLink, headingLoaderStyles } from './branch-section';
1212
import type { Overview, OverviewState } from './overviewState';
1313
import { overviewStateContext } from './overviewState';
1414
import '../../../shared/components/button';
@@ -27,6 +27,7 @@ export const activeWorkTagName = 'gl-active-work';
2727
export class GlActiveWork extends SignalWatcher(LitElement) {
2828
static override styles = [
2929
branchCardStyles,
30+
headingLoaderStyles,
3031
css`
3132
:host {
3233
display: block;
@@ -56,6 +57,10 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
5657
}
5758

5859
override render() {
60+
if (this._homeState.discovering) {
61+
return this.renderLoader();
62+
}
63+
5964
if (this._homeState.repositories.openCount === 0) {
6065
return nothing;
6166
}
@@ -67,14 +72,18 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
6772
});
6873
}
6974

75+
private renderLoader() {
76+
return html`
77+
<gl-section>
78+
<skeleton-loader slot="heading" class="heading-loader" lines="1"></skeleton-loader>
79+
<skeleton-loader lines="3"></skeleton-loader>
80+
</gl-section>
81+
`;
82+
}
83+
7084
private renderPending() {
7185
if (this._overviewState.state == null) {
72-
return html`
73-
<gl-section>
74-
<skeleton-loader slot="heading" lines="1"></skeleton-loader>
75-
<skeleton-loader lines="3"></skeleton-loader>
76-
</gl-section>
77-
`;
86+
return this.renderLoader();
7887
}
7988
return this.renderComplete(this._overviewState.state, true);
8089
}

src/webviews/apps/plus/home/components/branch-section.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ export class GlBranchSection extends LitElement {
7272
}
7373
}
7474

75+
export const headingLoaderStyles = css`
76+
.heading-loader {
77+
flex: 1;
78+
}
79+
`;
80+
7581
export const branchCardStyles = css`
7682
.branch-item {
7783
position: relative;

src/webviews/apps/plus/home/components/overview.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { SetOverviewFilter } from '../../../../home/protocol';
88
import { stateContext } from '../../../home/context';
99
import { ipcContext } from '../../../shared/context';
1010
import type { HostIpc } from '../../../shared/ipc';
11+
import { headingLoaderStyles } from './branch-section';
1112
import type { OverviewState } from './overviewState';
1213
import { overviewStateContext } from './overviewState';
1314
import '../../../shared/components/skeleton-loader';
14-
import './branch-section';
1515
import './branch-threshold-filter';
1616

1717
type Overview = GetOverviewResponse;
@@ -21,6 +21,7 @@ export const overviewTagName = 'gl-overview';
2121
@customElement(overviewTagName)
2222
export class GlOverview extends SignalWatcher(LitElement) {
2323
static override styles = [
24+
headingLoaderStyles,
2425
css`
2526
:host {
2627
display: block;
@@ -46,6 +47,10 @@ export class GlOverview extends SignalWatcher(LitElement) {
4647
}
4748

4849
override render() {
50+
if (this._homeState.discovering) {
51+
return this.renderLoader();
52+
}
53+
4954
if (this._homeState.repositories.openCount === 0) {
5055
return nothing;
5156
}
@@ -57,14 +62,18 @@ export class GlOverview extends SignalWatcher(LitElement) {
5762
});
5863
}
5964

65+
private renderLoader() {
66+
return html`
67+
<gl-section>
68+
<skeleton-loader slot="heading" class="heading-loader" lines="1"></skeleton-loader>
69+
<skeleton-loader lines="3"></skeleton-loader>
70+
</gl-section>
71+
`;
72+
}
73+
6074
private renderPending() {
6175
if (this._overviewState.state == null) {
62-
return html`
63-
<gl-section>
64-
<skeleton-loader slot="heading" lines="1"></skeleton-loader>
65-
<skeleton-loader lines="3"></skeleton-loader>
66-
</gl-section>
67-
`;
76+
return this.renderLoader();
6877
}
6978
return this.renderComplete(this._overviewState.state, true);
7079
}

src/webviews/apps/plus/home/components/overviewState.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export class OverviewState extends AsyncComputedState<Overview> {
3434
this._disposable = this._ipc.onReceiveMessage(msg => {
3535
switch (true) {
3636
case DidCompleteDiscoveringRepositories.is(msg):
37+
if (msg.params.repositories.openCount > 0) {
38+
this.run(true);
39+
}
40+
break;
3741
case DidChangeRepositoryWip.is(msg):
3842
this.run(true);
3943
break;

src/webviews/apps/shared/components/commit/commit-stats.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export class CommitStats extends LitElement {
1616
flex-direction: row;
1717
align-items: center;
1818
gap: 1rem;
19+
white-space: nowrap;
20+
}
21+
22+
:host([symbol='icons']) {
23+
gap: 0.8rem;
1924
}
2025
2126
.stat {

0 commit comments

Comments
 (0)