Skip to content

Commit dc08a57

Browse files
committed
2.1 - Fixing bugs, UI improvements
1 parent 78e2417 commit dc08a57

File tree

10 files changed

+119
-44
lines changed

10 files changed

+119
-44
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ Angular2 YT Player v2.1
8282
- Categories with videos like (music, gaming, autos, films, sports, etc.)
8383
- Refactoring code
8484
- Search on specific region
85+
- Fixing copy link for featured video
86+
- UX improvements
8587

8688
Angular2 YT Player v2.0.1
8789
- Import & export youtube playlist as .JSON file

src/app/app.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,17 @@ export class AppComponent implements OnInit {
126126

127127
async getFeedVideos() {
128128
await this._shared.initFeed();
129+
await this._shared.initChannel();
129130
this.feedVideos = this._shared.feedVideos;
130131
if (!this.currentVideo.id) {
131132
this.setDefaultPlayer();
132133
}
133134
}
134135

136+
async getChannel() {
137+
await this._shared.initChannel();
138+
}
139+
135140
setCurrentVideoObject(data: any) {
136141
this.currentVideoObject = [];
137142
this.currentVideoObject.push(data);
@@ -623,7 +628,7 @@ export class AppComponent implements OnInit {
623628
let listType;
624629
const youtubeLink = 'https://youtu.be/';
625630
if (list === 0) {
626-
listType = this.feedVideos[i];
631+
listType = this._shared.feedVideos[i];
627632
}
628633
if (list === 1) {
629634
listType = this._shared.lastSearchedVideos[i];

src/app/components/youtube-search.component.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
<form id="main-search" role="search" [formGroup]="searchForm" (ngSubmit)="onSubmit($event)" novalidate>
33
<div class="form-group">
44
<div class="input-group">
5-
<input type="text" id="input-search" class="form-control" placeholder="Search for Songs, Videos, Artists, Albums..." formControlName="searchInput">
5+
<input type="text" id="input-search" class="form-control" placeholder="Search for Songs, Videos, Artists, Albums..." formControlName="searchInput" autocomplete="off">
66
<label for="input-search" class="search-icon"><span class="fa fa-search"></span></label>
77
<button class="clear-button" (click)="clearSearch()"><span class="fa fa-times"></span></button>
88
</div>
99
</div>
1010
<ng-container *ngIf="searchForm.valid">
1111
<span class="search-list arrow-up"></span>
1212
<div id="search-video-list" class="video-list">
13+
<div *ngIf="noResults" class="video-item text-center">
14+
There are no results
15+
</div>
1316
<div *ngFor="let video of videos; let i = index" [attr.data-index]="i" class="video-item">
1417
<div class="video-item-info">
1518
<div *ngIf="thumbnails" class="video-item-image" [ngStyle]="{'background-image': 'url(' + video.snippet.thumbnails.default.url +')'}"></div>
@@ -35,6 +38,12 @@
3538
</form>
3639
</div>
3740
<div class="app-content">
41+
<ng-container *ngIf="loading">
42+
<div class="loading-app">
43+
<i class="fa fa-circle-o-notch fa-spin fa-2x fa-fw"></i>
44+
<span class="sr-only">Loading...</span>
45+
</div>
46+
</ng-container>
3847
<ng-container *ngIf="feedVideos">
3948
<div [ngStyle]="{'background-image': 'url(' + trendingFirst.bannerURL + ')'}" class="video-list-featured">
4049
<div class="video-item" [attr.data-index]="0">
@@ -67,10 +76,11 @@
6776
<p>{{ trendingFirst.stats.views | number:'1.0' }}</p>
6877
<p>{{ trendingFirst.stats.videoCount | number:'1.0' }}</p>-->
6978
</div>
70-
<div class="categories">
79+
<div class="categories" *ngIf="categories">
7180
<ng-container *ngFor="let category of categories.items">
7281
<div *ngIf="category.snippet.assignable && categoriesBlocked.indexOf(category.id) === -1" id="category-{{category.id}}" id="category-{{category.id}}">
7382
<button type="button" (click)="getCategoriesVideos(category.id)">
83+
<span class="tooltip">{{category.snippet.title}}</span>
7484
<ng-container *ngIf="category.snippet.title === 'Film & Animation'">
7585
<i class="material-icons">movie</i>
7686
</ng-container>

src/app/components/youtube-search.component.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export class SearchComponent implements OnInit {
1818

1919
searchForm: FormGroup;
2020
thumbnails = false;
21+
loading = true;
22+
noResults = false;
2123

2224
videos: Array<ISearchVideo>;
2325
feedVideos: Array<IFeedVideo>;
@@ -77,6 +79,10 @@ export class SearchComponent implements OnInit {
7779
async getCategoriesVideos(val: number) {
7880
const res2 = await this.youtube.videoCategories(val);
7981
this.feedVideos = res2['items'];
82+
this._shared.feedVideos = res2['items'];
83+
84+
await this._shared.initChannel();
85+
this.getChannelTrending();
8086
}
8187

8288
async setSettings() {
@@ -85,8 +91,13 @@ export class SearchComponent implements OnInit {
8591
}
8692

8793
async getFeedVideos() {
88-
await this._shared.initFeed();
89-
await this._shared.initChannel();
94+
this.loading = true;
95+
if (!this._shared.feedVideos) {
96+
await this._shared.initFeed();
97+
}
98+
if (!this._shared.channel) {
99+
await this._shared.initChannel();
100+
}
90101
this.feedVideos = this._shared.feedVideos;
91102
this.channel = this._shared.channel;
92103
this.getChannelTrending();
@@ -95,6 +106,11 @@ export class SearchComponent implements OnInit {
95106
async searchVideo(query: any) {
96107
const res = await this.youtube.searchVideo(query);
97108
this.videos = res['items'];
109+
if (res['items'].length === 0) {
110+
this.noResults = true;
111+
} else {
112+
this.noResults = false;
113+
}
98114
this._shared.lastSearchedVideos = res['items'];
99115
}
100116

@@ -126,6 +142,7 @@ export class SearchComponent implements OnInit {
126142
}
127143
this.trendingFirst.stats.videoCount = this.channel.items[0].statistics.videoCount;
128144
this.trendingFirst.stats.views = this.channel.items[0].statistics.viewCount;
145+
this.loading = false;
129146
}
130147

131148
clearSearch() {
@@ -144,13 +161,16 @@ export class SearchComponent implements OnInit {
144161
} else if (list === 3) {
145162
this._app.getVideo(this.feedVideos[i]);
146163
}
164+
this.clearSearch();
147165
}
148166

149167
onCopyVideoItemLink(i: number, list: number) {
150-
this._app.onCopyVideoItemLink(i, list);
168+
this._app.onCopyVideoItemLink(i, list);
169+
this.clearSearch();
151170
}
152171

153172
addPlaylistItem(i: number, list: number) {
154-
this._app.addPlaylistItem(i, list);
173+
this._app.addPlaylistItem(i, list);
174+
this.clearSearch();
155175
}
156176
}

src/assets/scss/_buttons.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
&-primary {
4343
background-color: var(--c-primary);
4444
color: var(--c-white);
45-
&:hover {
46-
box-shadow: 0 0 10px var(--c-primary);
47-
}
4845
&:active {
4946
background-color: var(--c-primary-active);
5047
}

src/assets/scss/_common.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
100% { opacity: 1; top: 50%; }
1818
}
1919

20+
.text-center {
21+
text-align: center;
22+
justify-content: center;
23+
}
24+
2025
.loading-bar {
2126
position: fixed;
2227
margin: 0;
@@ -126,6 +131,10 @@
126131
overflow: hidden;
127132
.app-content {
128133
padding: 0 20px;
134+
position: absolute;
135+
.loading-app {
136+
position: absolute;
137+
}
129138
}
130139
}
131140
&-player {

src/assets/scss/_controls.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@
9999
left: 50%;
100100
transform: translate(-50%, -50%);
101101
}
102-
&:not(#play-song):hover {
103-
color: var(--c-primary);
104-
text-shadow: 0 0 10px var(--c-primary);
105-
}
106102
&:not(#play-song):active {
107103
color: var(--c-primary);
108104
transform: scale(1.2);
@@ -118,9 +114,6 @@
118114
margin-left: 0;
119115
}
120116
}
121-
&:hover {
122-
box-shadow: 0 0 10px var(--c-primary);
123-
}
124117
&:active {
125118
transform: scale(1.1);
126119
}
@@ -169,9 +162,6 @@
169162
}
170163
.fa {
171164
transition: all 0.1s ease-in-out;
172-
&:hover {
173-
text-shadow: 0 0 10px var(--c-primary);
174-
}
175165
}
176166
&.inactive .volume-input {
177167
visibility: hidden;
@@ -221,7 +211,6 @@
221211
&:active,
222212
&:hover {
223213
+ .duration-input-shadow {
224-
box-shadow: 0 0 10px var(--c-primary);
225214
border-radius: 20px 0 0 20px;
226215
}
227216
&::-webkit-slider-thumb {
@@ -281,7 +270,6 @@
281270
&:active,
282271
&:hover {
283272
+ .volume-input-shadow {
284-
box-shadow: 0 0 10px var(--c-primary);
285273
border-radius: 20px 0 0 20px;
286274
}
287275
&::-webkit-slider-thumb {

src/assets/scss/_search.scss

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,71 @@
6969
}
7070
}
7171

72+
.tooltip {
73+
background-color: var(--c-black);
74+
padding: 5px 10px;
75+
line-height: 22px;
76+
width: 111px;
77+
font-size: 12px;
78+
position: absolute;
79+
left: 50%;
80+
transform: translateX(-50%);
81+
border-radius: 3px;
82+
opacity: 0;
83+
bottom: 100%;
84+
transition: all 0.1s ease-out;
85+
&:before {
86+
content: '';
87+
background-color: var(--c-black);
88+
height: 10px;
89+
width: 10px;
90+
left: 50%;
91+
transform: translateX(-50%) rotate(45deg);
92+
display: block;
93+
position: absolute;
94+
bottom: -4px;
95+
z-index: -1;
96+
}
97+
}
98+
7299
.categories {
73100
display: flex;
74101
flex-wrap: nowrap;
75102
width: 100%;
103+
height: 70px;
104+
button {
105+
background-color: var(--c-base);
106+
color: var(--c-white);
107+
display: flex;
108+
justify-content: center;
109+
align-items: center;
110+
text-align: center;
111+
cursor: pointer;
112+
border-radius: 3px;
113+
border: none;
114+
color: inherit;
115+
padding: 0 5px;
116+
margin: auto;
117+
display: block;
118+
height: 40px;
119+
width: 40px;
120+
transition: all 0.1s ease-out;
121+
&:hover {
122+
background-color: #40404c;
123+
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
124+
.tooltip {
125+
opacity: 1;
126+
bottom: calc(100% + 10px);
127+
}
128+
}
129+
&:active {
130+
background-color: #363642;
131+
}
132+
}
76133
> div {
77-
margin: 8px 0;
134+
position: relative;
135+
margin: auto 0;
78136
flex: 0 0 calc(10% - 10px);
79-
button {
80-
background-color: var(--c-primary);
81-
color: var(--c-white);
82-
display: flex;
83-
justify-content: center;
84-
align-items: center;
85-
text-align: center;
86-
cursor: pointer;
87-
border-radius: 3px;
88-
border: none;
89-
color: inherit;
90-
padding: 0 5px;
91-
margin: 0;
92-
display: block;
93-
height: 55px;
94-
width: calc(100% - 2px);
95-
}
96137
+ div {
97138
margin-left: 10px;
98139
}
@@ -116,4 +157,4 @@
116157
background-color: rgba(#FFF, 0.4);
117158
}
118159
}
119-
}
160+
}

src/assets/scss/_videos.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ iframe {
8282
border: none;
8383
display: block;
8484
user-select: none;
85-
&:hover {
86-
box-shadow: 0 0 10px var(--c-primary);
87-
}
8885
&:active {
8986
background-color: var(--c-primary-active);
9087
}

src/assets/scss/theme/light.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ nav {
191191
}
192192
}
193193

194+
.search-icon,
194195
.clear-button {
195196
color: var(--c-black);
196197
}
198+
197199
}
198200

199201
.related-video-content {
@@ -267,4 +269,8 @@ input[type="checkbox"]:checked + label .round-check:before, input[type="radio"]:
267269

268270
.app-feed:before {
269271
display: none;
272+
}
273+
274+
.categories {
275+
color: var(--c-white);
270276
}

0 commit comments

Comments
 (0)