Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: skeleton loader on landing page (#DEV-3569) #1568

Merged
merged 5 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<a (click)="navigateToProject(project.id)" data-cy="navigate-to-project-button">
<ng-container *ngIf="isLoading">
<div class="project-tile skeleton">
<div class="project-tile-content">
<div class="title"></div>
</div>
</div>
</ng-container>

<a *ngIf="isLoading === false" (click)="navigateToProject(project.id)" data-cy="navigate-to-project-button">
<div class="project-tile" data-cy="tile">
<div class="project-tile-content">
<div class="title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
@use '../../../styles/typography' as t;
@use '../../../styles/responsive' as *;

.skeleton {
background: linear-gradient(90deg, $cool_gray_50 33%, $cool_gray_100 50%, $cool_gray_50 66%) #f2f2f2;
background-size: 300% 100%;
animation: skeleton-loading 2s infinite ease-in-out;
}

@keyframes skeleton-loading {
0% {
background-position: right;
}
}

.project-tile {
:hover {
border-radius: 6px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { StoredProject } from '@dasch-swiss/dsp-js';
import { RouteConstants } from '@dasch-swiss/vre/shared/app-config';
import { ProjectService } from '@dasch-swiss/vre/shared/app-helper-services';
import { ClearProjectsAction, ClearProjectsMembershipAction } from '@dasch-swiss/vre/shared/app-state';
import { Actions, Store } from '@ngxs/store';
import { Store } from '@ngxs/store';

@Component({
selector: 'app-project-tile',
templateUrl: './project-tile.component.html',
styleUrls: ['./project-tile.component.scss'],
})
export class ProjectTileComponent {
@Input() isLoading = false;
@Input() project: StoredProject;
@Input() sysAdmin: boolean; // used to show settings button

constructor(
private _router: Router,
private _store: Store,
private _actions: Actions
private _store: Store
) {}

navigateToProject(id: string) {
Expand Down
60 changes: 38 additions & 22 deletions apps/dsp-app/src/app/user/overview/overview.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<div class="content extra-large middle">
<dasch-swiss-app-progress-indicator *ngIf="isProjectsLoading$ | async"></dasch-swiss-app-progress-indicator>

<div class="overview">
<div *ngIf="isProjectsLoading$ | async" [@replaceAnimation]>
<div class="title-bar admin">
<div class="title">
<p>Browse Research Projects</p>
</div>
</div>
<div class="project-tiles">
<div *ngFor="let item of loadingTiles" class="project-tile-container">
<app-project-tile isLoading="true"></app-project-tile>
</div>
</div>
</div>

<!-- user is a system admin -->
<div *ngIf="(isSysAdmin$ | async) && (isProjectsLoading$ | async) === false">
<div *ngIf="(allProjects$ | async).length > 0 && ((isSysAdmin$ | async) && (isProjectsLoading$ | async) === false)">
<!-- list all projects -->
<div class="title-bar admin">
<div class="title">
Expand All @@ -18,32 +29,37 @@
</div>
<!-- user is logged in and not a system admin -->
<div *ngIf="(isSysAdmin$ | async) === false && (user$ | async)">
<div class="title-bar">
<div class="title">
<p>My Projects</p>
<ng-container *ngIf="(userActiveProjects$ | async).length > 0">
<div class="title-bar">
<div class="title">
<p>My Projects</p>
</div>
</div>
</div>
<div class="project-tiles">
<div *ngFor="let userProj of userActiveProjects$ | async; trackBy: trackByFn" class="project-tile-container">
<app-project-tile [project]="userProj" [sysAdmin]="false"></app-project-tile>
<div class="project-tiles">
<div *ngFor="let userProj of userActiveProjects$ | async; trackBy: trackByFn" class="project-tile-container">
<app-project-tile [project]="userProj" [sysAdmin]="false"></app-project-tile>
</div>
</div>
</div>
<div class="title-bar other-projects">
<div class="title">
<p>Browse Other Research Projects</p>
</ng-container>
<ng-container *ngIf="(userOtherActiveProjects$ | async).length > 0">
<div class="title-bar other-projects">
<div class="title">
<p>Browse Other Research Projects</p>
</div>
</div>
</div>
<div class="project-tiles">
<div
*ngFor="let otherProj of userOtherActiveProjects$ | async; trackBy: trackByFn"
class="project-tile-container">
<app-project-tile [project]="otherProj" [sysAdmin]="false"></app-project-tile>
<div class="project-tiles">
<div
*ngFor="let otherProj of userOtherActiveProjects$ | async; trackBy: trackByFn"
class="project-tile-container">
<app-project-tile [project]="otherProj" [sysAdmin]="false"></app-project-tile>
</div>
</div>
</div>
</ng-container>
</div>

<!-- user is not logged in -->
<div *ngIf="((isProjectsLoading$ | async) === false) && user$ | async | isFalsy">
<div
*ngIf="((allActiveProjects$ | async).length > 0) && (((isProjectsLoading$ | async) === false) && user$ | async | isFalsy)">
<!-- list all projects -->
<div class="title-bar admin">
<div class="title">
Expand Down
4 changes: 4 additions & 0 deletions apps/dsp-app/src/app/user/overview/overview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { LoadProjectsAction, ProjectsSelectors, UserSelectors } from '@dasch-swi
import { Select, Store } from '@ngxs/store';
import { Observable, combineLatest } from 'rxjs';
import { filter, take } from 'rxjs/operators';
import { ReplaceAnimation } from '../../main/animations/replace-animation';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'app-overview',
templateUrl: './overview.component.html',
styleUrls: ['./overview.component.scss'],
animations: [ReplaceAnimation.animation],
})
export class OverviewComponent implements OnInit {
@Select(UserSelectors.user) user$: Observable<ReadUser>;
Expand All @@ -23,6 +25,8 @@ export class OverviewComponent implements OnInit {
@Select(ProjectsSelectors.isProjectsLoading) isProjectsLoading$: Observable<boolean>;
@Select(UserSelectors.isSysAdmin) isSysAdmin$: Observable<boolean>;

loadingTiles = new Array(8);

constructor(
private _titleService: Title,
private _router: Router,
Expand Down
Loading