Skip to content

Commit ce0d624

Browse files
Fazendo estrelas moldaveis na table
1 parent 6b634a3 commit ce0d624

File tree

14 files changed

+53
-8
lines changed

14 files changed

+53
-8
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@angular/platform-browser-dynamic": "~9.1.9",
2121
"@angular/router": "~9.1.9",
2222
"bootstrap": "^4.5.0",
23+
"font-awesome": "^4.7.0",
2324
"rxjs": "~6.5.4",
2425
"tslib": "^1.10.0",
2526
"zone.js": "~0.10.2"

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { StarComponent } from './star/star.component';
12
import { BrowserModule } from '@angular/platform-browser';
23
import { NgModule } from '@angular/core';
34

@@ -9,7 +10,8 @@ import { CourseListComponent } from './courses/course-list.component';
910
@NgModule({
1011
declarations: [
1112
AppComponent,
12-
CourseListComponent
13+
CourseListComponent,
14+
StarComponent
1315
],
1416
imports: [
1517
BrowserModule,

src/app/courses/course-list.component.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ <h2>Course List</h2>
1515

1616
<tbody>
1717
<tr *ngFor=" let course of courses">
18-
<td>{{ course.imageUrl }}</td>
18+
<td>
19+
<img [src]="course.imageUrl" width="40" height="40" alt="">
20+
</td>
1921
<td>{{ course.name }}</td>
2022
<td>{{ course.price }}</td>
2123
<td>{{ course.code }}</td>
2224
<td>{{ course.releaseDate }}</td>
23-
<td>{{ course.rating }}</td>
25+
<td>
26+
<app-star [rating]="course.rating"></app-star>
27+
</td>
2428
<td></td>
2529
</tr>
2630
</tbody>

src/app/courses/course-list.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export class CourseListComponent implements OnInit {
1414
this.courses = [
1515
{
1616
id: 1,
17-
name: "Angula",
18-
imageUrl: "",
17+
name: "Angular",
18+
imageUrl: "/assets/images/forms.png",
1919
price: 99.99,
2020
code: "XPS123",
2121
duration: 120,
@@ -24,8 +24,8 @@ export class CourseListComponent implements OnInit {
2424
},
2525
{
2626
id: 2,
27-
name: "Angula",
28-
imageUrl: "",
27+
name: "Angular",
28+
imageUrl: "/assets/images/http.png",
2929
price: 99.99,
3030
code: "XPS123",
3131
duration: 120,

src/app/star/star.component.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.crop {
2+
overflow: hidden;
3+
}

src/app/star/star.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="crop" [style.width.px]="starWidth" [title]="rating">
2+
<div style="width: 100px;">
3+
<span class="fa fa-star"></span>
4+
<span class="fa fa-star"></span>
5+
<span class="fa fa-star"></span>
6+
<span class="fa fa-star"></span>
7+
<span class="fa fa-star"></span>
8+
</div>
9+
</div>

src/app/star/star.component.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Component, OnChanges, Input } from '@angular/core';
2+
3+
@Component({
4+
selector: "app-star",
5+
templateUrl: "./star.component.html",
6+
styleUrls: ["./star.component.css"]
7+
})
8+
9+
export class StarComponent implements OnChanges {
10+
11+
@Input()
12+
13+
rating: number = 0;
14+
starWidth: number;
15+
16+
ngOnChanges(): void {
17+
this.starWidth = this.rating * 74 / 5;
18+
}
19+
20+
}

src/assets/images/animations.png

3.29 KB
Loading

src/assets/images/cli.png

2.35 KB
Loading

0 commit comments

Comments
 (0)