Skip to content

Commit 2f041f6

Browse files
committed
ContentDetailComponent
1 parent f991757 commit 2f041f6

10 files changed

+208
-3
lines changed

src/app/screens/content-detail/content-detail.component.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,24 @@
66
backUrl="/conteudo"
77
></t4e-page-header>
88
<section class="t4e-content-item">
9-
<t4e-media-player *ngIf="contentItem.videoUrl" [videoUrl]="contentItem.videoUrl"></t4e-media-player>
9+
<div class="content__media-player">
10+
<t4e-media-player
11+
*ngIf="contentItem.videoUrl"
12+
[videoUrl]="contentItem.videoUrl"
13+
[videoPoster]="getVideoPoster()"
14+
></t4e-media-player>
15+
</div>
16+
<div class="content__info">
17+
<div class="block" *ngFor="let block of contentInfoBlocks">
18+
<div class="block__title">{{block.title}}</div>
19+
<div class="block__value">{{block.value}}</div>
20+
</div>
21+
</div>
22+
<div class="content__text">
23+
<div class="title" *ngIf="contentItem.type === 'CONTENT-TUTORIAL-VIDEO'">DESCRITIVO</div>
24+
<div class="text" [innerHTML]="contentItem.text"></div>
25+
</div>
26+
<div class="content__tags">
27+
28+
</div>
1029
</section>
Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
1+
@import 'theme';
2+
13
.t4e-content-item {
2-
margin-top: 60px;
4+
@include containerPadding();
5+
max-width: 1280px;
6+
margin: 60px auto 0;
7+
8+
.content {
9+
&__media-player {
10+
margin-bottom: 60px;
11+
}
12+
13+
&__info {
14+
display: flex;
15+
margin-left: 90px;
16+
margin-right: 90px;
17+
margin-bottom: 40px;
18+
19+
@include media-laptop {
20+
margin-left: 45px;
21+
margin-right: 45px;
22+
}
23+
24+
@include media-tablet {
25+
margin-right: 0;
26+
margin-left: 0;
27+
}
28+
29+
.block {
30+
margin-right: 80px;
31+
32+
@include media-tablet {
33+
margin-right: 24px;
34+
}
35+
36+
&__title {
37+
@include font('title2', 130%);
38+
color: $color-text-blue;
39+
}
40+
41+
&__value {
42+
@include font('bodyTextLarge');
43+
color: $color-primary-blue;
44+
}
45+
}
46+
}
47+
48+
&__text {
49+
margin-left: 90px;
50+
margin-right: 90px;
51+
52+
@include media-laptop {
53+
margin-left: 45px;
54+
margin-right: 45px;
55+
}
56+
57+
@include media-tablet {
58+
margin-right: 0;
59+
margin-left: 0;
60+
}
61+
62+
.title {
63+
@include font('title2', 130%);
64+
color: $color-text-blue;
65+
}
66+
67+
.text {
68+
@include bodyTextFormatting()
69+
}
70+
}
71+
72+
&__tags {
73+
74+
}
75+
}
376
}

src/app/screens/content-detail/content-detail.component.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class ContentDetailComponent implements OnInit {
1111

1212
contentItem: IContentItem
1313
loading: boolean;
14+
contentInfoBlocks: Array<{ title: string, value: string }> = [];
1415

1516
constructor(
1617
private route: ActivatedRoute
@@ -20,7 +21,10 @@ export class ContentDetailComponent implements OnInit {
2021
this.route.data.subscribe(({queryResult}) => {
2122
this.loading = queryResult.data.loading;
2223
this.contentItem = queryResult.data.contentItem;
24+
this.contentInfoBlocks = this.getContentInfoBlocks();
2325
})
26+
27+
2428
}
2529
getBackgroundHeader(): string {
2630
if (this.contentItem.stakeholder) {
@@ -33,10 +37,66 @@ export class ContentDetailComponent implements OnInit {
3337

3438
case 'PAIS':
3539
return 'assets/pages/content-detail/pais-header-bg.png';
40+
41+
default:
42+
return '';
3643
}
3744
} else {
3845
return 'assets/pages/content-detail/generic-header-bg.png';
3946
}
4047
}
4148

49+
getVideoPoster(): string {
50+
if (this.contentItem.stakeholder) {
51+
switch (this.contentItem.stakeholder.code) {
52+
case 'PROFESSOR':
53+
return 'assets/pages/content-detail/professor-video-poster.png';
54+
55+
case 'ALUNO':
56+
return 'assets/pages/content-detail/aluno-video-poster.png';
57+
58+
case 'PAIS':
59+
return 'assets/pages/content-detail/pais-video-poster.png';
60+
61+
default:
62+
return '';
63+
}
64+
} else {
65+
return '';
66+
}
67+
}
68+
69+
getReadingTime() {
70+
const WORDS_PER_MINUTE = 223;
71+
const wordCount = this.contentItem.text.split(' ').length;
72+
const readingTime = wordCount / WORDS_PER_MINUTE;
73+
74+
return readingTime.toFixed(0);
75+
}
76+
77+
getContentInfoBlocks(): Array<{ title: string, value: string }> {
78+
let infoBlocks = [];
79+
80+
console.log('type', this.contentItem.type)
81+
82+
switch(this.contentItem.type) {
83+
case 'CONTENT-TUTORIAL-VIDEO':
84+
infoBlocks.push({ title: 'Conteúdo', value: 'Vídeo' })
85+
infoBlocks.push({ title: 'Duração', value: this.contentItem.videoTime + ' min' })
86+
infoBlocks.push({ title: 'Plataforma', value: this.contentItem.provider.title })
87+
break;
88+
case 'CONTENT-ARTICLE':
89+
infoBlocks.push({ title: 'Conteúdo', value: 'Artigo' })
90+
infoBlocks.push({ title: 'Tempo Leitura', value: this.getReadingTime() })
91+
infoBlocks.push({ title: 'Temática', value: this.contentItem.tags[0].title })
92+
break;
93+
default:
94+
return infoBlocks;
95+
}
96+
97+
return infoBlocks;
98+
}
99+
100+
101+
42102
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div class="t4e-media-player">
2-
<video #mediaPlayerElement preload="auto" style="width:100%;height:100%;" controls="controls" ></video>
2+
<video #mediaPlayerElement preload="auto" style="width:100%;height:100%;" controls="controls" [poster]="videoPoster"></video>
33
</div>

src/app/shared/components/media-player/media-player.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
justify-content: center;
99
align-items: flex-start;
1010
overflow: hidden;
11+
position: relative;
1112

1213
::ng-deep .mejs__mediaelement,
1314
.mejs__poster {

src/app/shared/components/media-player/media-player.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ declare const MediaElementPlayer: any;
1212
export class MediaPlayerComponent implements OnInit, OnChanges {
1313

1414
@Input() videoUrl: string;
15+
@Input() videoPoster: string;
16+
1517
@ViewChild('mediaPlayerElement') mediaPlayerElement: ElementRef
1618

1719
mediaPlayer: any;
Loading
Loading
Loading

src/theme/_mixins.scss

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,53 @@
147147
max-width: 95%;
148148
}
149149
}
150+
151+
@mixin bodyTextFormatting() {
152+
h1 {
153+
154+
}
155+
156+
h2 {
157+
158+
}
159+
160+
h3 {
161+
162+
}
163+
164+
h4 {
165+
166+
}
167+
168+
h5 {
169+
170+
}
171+
172+
h6 {
173+
174+
}
175+
176+
blockquote {
177+
178+
}
179+
180+
pre {
181+
182+
}
183+
184+
figure {
185+
186+
}
187+
188+
ul {
189+
190+
}
191+
192+
ol {
193+
194+
}
195+
196+
li {
197+
198+
}
199+
}

0 commit comments

Comments
 (0)