Improved downloads modal CSS

This commit is contained in:
Geomitron
2021-04-07 11:08:02 -05:00
parent 1c860bd0d9
commit 30e6e0fc19
7 changed files with 54 additions and 34 deletions

View File

@@ -1,27 +1,30 @@
<div class="ui cards"> <div *ngIf="downloads.length > 0" class="ui segments">
<div *ngFor="let download of downloads; trackBy:trackByVersionID" class="card" [style.background-color]="getBackgroundColor(download)"> <div *ngFor="let download of downloads; trackBy:trackByVersionID" class="ui segment" [style.background-color]="getBackgroundColor(download)">
<div class="content">
<i class="inside right floated close icon" (click)="cancelDownload(download.versionID)"></i> <h3 id="downloadTitle">
<div class="header">{{download.title}}</div> <span style="flex-grow: 1;">{{download.title}}</span>
</div> <i class="inside right close icon" (click)="cancelDownload(download.versionID)"></i>
<div class="content"> </h3>
<button
*ngIf="download.type == 'error'" <div id="downloadText">
class="ui right floated labeled icon button" <span style="flex-grow: 1;">{{download.header}}</span>
(click)="retryDownload(download.versionID)"> <span *ngIf="!download.isLink" class="description">{{download.description}}</span>
<i class="redo icon"></i> <span *ngIf="download.isLink" class="description">
Retry
</button>
<div class="header">{{download.header}}</div>
<div *ngIf="download.type != 'done'" class="description">{{download.description}}</div>
<div *ngIf="download.type == 'done'" class="description">
<a (click)="openFolder(download.description)">{{download.description}}</a> <a (click)="openFolder(download.description)">{{download.description}}</a>
</span>
</div> </div>
<div appProgressBar [percent]="download.percent" class="ui progress">
<div id="downloadProgressDiv">
<div id="downloadProgressBar" appProgressBar [percent]="download.percent" class="ui small progress">
<div class="bar"> <div class="bar">
<div class="progress"></div> <div class="progress"></div>
</div> </div>
</div> </div>
<button *ngIf="download.type == 'error'" class="ui right attached labeled compact icon button"
(click)="retryDownload(download.versionID)">
<i class="redo icon"></i>
Retry
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,11 +1,26 @@
.card { #downloadTitle,
#downloadText {
display: flex;
margin-bottom: 0.3rem;
}
#downloadText {
flex-wrap: wrap;
}
#downloadProgressDiv {
display: flex;
}
#downloadProgressBar {
flex-grow: 1; flex-grow: 1;
}
.ui.progress {
margin: 0; margin: 0;
.bar {
transform: translateY(-50%);
top: 50%;
}
} }
i.close.icon { i.close.icon, a {
cursor: pointer; cursor: pointer;
} }

View File

@@ -44,8 +44,8 @@ export class DownloadsModalComponent {
getBackgroundColor(download: DownloadProgress) { getBackgroundColor(download: DownloadProgress) {
switch (download.type) { switch (download.type) {
case 'error': return 'indianred' case 'error': return '#a63a3a'
default: return 'unset' default: return undefined
} }
} }

View File

@@ -298,7 +298,7 @@ input[type=number]::-webkit-inner-spin-button {
} }
.ui.segments:not(.horizontal)>.segment { .ui.segments:not(.horizontal)>.segment {
background-color: var(--dk-04dp) !important; background-color: var(--dk-04dp); /* not important; the code changes this color */
border-top: 1px solid var(--dk-12dp) !important; border-top: 1px solid var(--dk-12dp) !important;
} }
.ui.segments:not(.horizontal)>.segment:first-child { .ui.segments:not(.horizontal)>.segment:first-child {

View File

@@ -19,7 +19,7 @@ type EventCallback = {
} }
type Callbacks = { [E in keyof EventCallback]: EventCallback[E] } type Callbacks = { [E in keyof EventCallback]: EventCallback[E] }
export type DownloadError = { header: string; body: string } export type DownloadError = { header: string; body: string; isLink?: boolean }
export class ChartDownload { export class ChartDownload {
@@ -98,7 +98,7 @@ export class ChartDownload {
/** /**
* Updates the GUI with new information about this chart download. * Updates the GUI with new information about this chart download.
*/ */
private updateGUI(header: string, description: string, type: ProgressType) { private updateGUI(header: string, description: string, type: ProgressType, isLink = false) {
if (this.wasCanceled) { return } if (this.wasCanceled) { return }
if (type == 'fastUpdate') { if (type == 'fastUpdate') {
if (this.dropFastUpdate) { if (this.dropFastUpdate) {
@@ -115,7 +115,8 @@ export class ChartDownload {
header: header, header: header,
description: description, description: description,
percent: this.percent, percent: this.percent,
type: type type: type,
isLink
}) })
} }
@@ -125,7 +126,7 @@ export class ChartDownload {
private handleError(err: DownloadError, retry: () => void) { private handleError(err: DownloadError, retry: () => void) {
this._hasFailed = true this._hasFailed = true
this.retryFn = retry this.retryFn = retry
this.updateGUI(err.header, err.body, 'error') this.updateGUI(err.header, err.body, 'error', err.isLink == true)
this.callbacks.error() this.callbacks.error()
} }
@@ -270,7 +271,7 @@ export class ChartDownload {
transfer.on('start', (_destinationFolder) => { transfer.on('start', (_destinationFolder) => {
destinationFolder = _destinationFolder destinationFolder = _destinationFolder
this.updateGUI('Moving files to library folder...', destinationFolder, 'good') this.updateGUI('Moving files to library folder...', destinationFolder, 'good', true)
}) })
transfer.on('error', this.handleError.bind(this)) transfer.on('error', this.handleError.bind(this))
@@ -278,7 +279,7 @@ export class ChartDownload {
return new Promise<void>(resolve => { return new Promise<void>(resolve => {
transfer.on('complete', () => { transfer.on('complete', () => {
this.percent = 100 this.percent = 100
this.updateGUI('Download complete.', destinationFolder, 'done') this.updateGUI('Download complete.', destinationFolder, 'done', true)
resolve() resolve()
}) })
}) })

View File

@@ -21,7 +21,7 @@ const filesystemErrors = {
libraryFolder: () => { return { header: 'Library folder not specified', body: 'Please go to the settings to set your library folder.' } }, libraryFolder: () => { return { header: 'Library folder not specified', body: 'Please go to the settings to set your library folder.' } },
libraryAccess: (err: NodeJS.ErrnoException) => fsError(err, 'Failed to access library folder.'), libraryAccess: (err: NodeJS.ErrnoException) => fsError(err, 'Failed to access library folder.'),
destinationFolderExists: (destinationPath: string) => { destinationFolderExists: (destinationPath: string) => {
return { header: 'This chart already exists in your library folder.', body: destinationPath } return { header: 'This chart already exists in your library folder.', body: destinationPath, isLink: true }
}, },
mkdirError: (err: NodeJS.ErrnoException) => fsError(err, 'Failed to create temporary folder.') mkdirError: (err: NodeJS.ErrnoException) => fsError(err, 'Failed to create temporary folder.')
} }

View File

@@ -29,6 +29,7 @@ export interface DownloadProgress {
description: string description: string
percent: number percent: number
type: ProgressType type: ProgressType
isLink: boolean
} }
export type ProgressType = 'good' | 'error' | 'cancel' | 'done' | 'fastUpdate' export type ProgressType = 'good' | 'error' | 'cancel' | 'done' | 'fastUpdate'