-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
Adding feature star rating to top ribbon #562 #586
base: main
Are you sure you want to change the base?
Changes from 4 commits
7e3f79d
481f7a6
d8affed
3ad66bb
28f8908
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,62 @@ | |
class="file-container" | ||
[ngClass]="{ 'dark-mode-override': darkMode }" | ||
> | ||
<app-icon class="icon" [icon]="'icon-video-blank'" (click)="openInExplorer()"></app-icon> | ||
<span | ||
*ngFor="let item of fileNameArray" | ||
(click)="fileWordClicked(item)" | ||
class="file-word" | ||
<!-- Star rating --> | ||
<div | ||
class="starRating" | ||
> | ||
{{ item }} | ||
</span> | ||
</div> | ||
<button | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section is duplicating the same code as happens in the |
||
(click)="setStarRating(1.5)" | ||
class="star-rating" | ||
[ngClass]="{ 'star-lit': starRatingHack > 1 }" | ||
tabindex="-1" | ||
> | ||
<app-icon [icon]="'icon-star'"></app-icon> | ||
</button> | ||
<button | ||
(click)="setStarRating(2.5)" | ||
class="star-rating" | ||
[ngClass]="{ 'star-lit': starRatingHack > 2 }" | ||
tabindex="-1" | ||
> | ||
<app-icon [icon]="'icon-star'"></app-icon> | ||
</button> | ||
<button | ||
(click)="setStarRating(3.5)" | ||
class="star-rating" | ||
[ngClass]="{ 'star-lit': starRatingHack > 3 }" | ||
tabindex="-1" | ||
> | ||
<app-icon [icon]="'icon-star'"></app-icon> | ||
</button> | ||
<button | ||
(click)="setStarRating(4.5)" | ||
class="star-rating" | ||
[ngClass]="{ 'star-lit': starRatingHack > 4 }" | ||
tabindex="-1" | ||
> | ||
<app-icon [icon]="'icon-star'"></app-icon> | ||
</button> | ||
<button | ||
(click)="setStarRating(5.5)" | ||
class="star-rating" | ||
[ngClass]="{ 'star-lit': starRatingHack > 5 }" | ||
tabindex="-1" | ||
> | ||
<app-icon [icon]="'icon-star'"></app-icon> | ||
</button> | ||
</div> | ||
|
||
<app-icon class="icon" [icon]="'icon-video-blank'" (click)="openInExplorer()" style="margin-left: 0; "></app-icon> | ||
<div | ||
style="margin-left: 23px; width: 80%;" | ||
> | ||
<span | ||
*ngFor="let item of fileNameArray" | ||
(click)="fileWordClicked(item)" | ||
class="file-word" | ||
> | ||
{{ item }} | ||
</span> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,18 +50,14 @@ | |
|
||
.file-container { | ||
max-height: 20px; | ||
min-width: calc(100vw - 100px); | ||
width: 100%; | ||
overflow: hidden; | ||
|
||
.icon-video-blank { | ||
position: absolute; | ||
transform: translate(0, 3px); | ||
} | ||
|
||
:nth-child(2) { | ||
margin-left: 23px; | ||
} | ||
|
||
.file-word { | ||
color: $gray-80; | ||
cursor: pointer; | ||
|
@@ -77,6 +73,33 @@ | |
} | ||
} | ||
|
||
.star-rating { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicating the CSS that we already have. But it really feels best to just break out the star rating chunk into its own element 👍 |
||
background-color: transparent; | ||
border: 0; | ||
cursor: pointer; | ||
fill: yellow; | ||
height: 20px; | ||
margin: 0; | ||
opacity: 0.4; | ||
outline: none; | ||
padding: 0; | ||
stroke: #000000; | ||
stroke-linejoin: round; | ||
stroke-width: 0.3px; | ||
width: 20px; | ||
} | ||
|
||
.star-lit { | ||
opacity: 1; | ||
transform: scale(1.5); | ||
} | ||
|
||
.starRating { | ||
float: right; | ||
width: 117px; | ||
margin-left: 5px; | ||
} | ||
|
||
.dark-mode-override { | ||
& .folder-word { | ||
color: $gray-30; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { ImageElementService } from './../../services/image-element.service'; | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { StarRating, ImageElement } from '../../../../interfaces/final-object.interface'; | ||
import { StarRatingService } from '../../pipes/star-rating.service'; | ||
|
||
@Component({ | ||
selector: 'app-top-component', | ||
templateUrl: './top.component.html', | ||
styleUrls: ['./top.component.scss', | ||
'../../fonts/icons.scss'] | ||
}) | ||
export class TopComponent { | ||
export class TopComponent implements OnInit { | ||
|
||
@Input() darkMode: boolean; | ||
@Input() index: number; | ||
|
||
starRatingHack: StarRating; | ||
|
||
@Input() set starRating(stars: StarRating) { | ||
this.starRatingHack = stars; | ||
} | ||
|
||
constructor( | ||
public imageElementService: ImageElementService, | ||
private starRatingService: StarRatingService, | ||
) { } | ||
|
||
ngOnInit() { | ||
|
||
this.starRatingService.currentStarRating.subscribe(starRatingList => { | ||
this.starRating = starRatingList[this.index]; | ||
this.starRatingHack = starRatingList[this.index]; | ||
}); | ||
|
||
} | ||
|
||
// Handle folder input | ||
private _folder = ''; | ||
|
@@ -52,4 +76,16 @@ export class TopComponent { | |
this.onOpenInExplorer.emit(true); | ||
} | ||
|
||
setStarRating(rating: StarRating): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicating |
||
if (this.starRatingHack === rating) { | ||
rating = 0.5; // reset to "N/A" (not rated) | ||
} | ||
this.starRatingHack = rating; // hack for getting star opacity updated instantly | ||
this.imageElementService.HandleEmission({ | ||
index: this.index, | ||
stars: rating | ||
}); | ||
|
||
this.starRatingService.changeStarRating(rating, this.index); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind too much, but it's generally better not to change versions and keep a PR focused on one thing.
We could update to Angular 11 in a separate PR 🤝