Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.

Commit 4054b58

Browse files
authored
Merge pull request #398 from openforge/ys-fix-bugs
Ys fix bugs
2 parents 0357bcf + e14b37e commit 4054b58

File tree

9 files changed

+69
-560
lines changed

9 files changed

+69
-560
lines changed

.firebase/hosting.d3d3.cache

Lines changed: 0 additions & 542 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ log.txt
1212
*.sublime-project
1313
*.sublime-workspace
1414

15+
.firebase/
1516
.idea/
1617
.vscode/
1718
.sass-cache/
465 KB
Loading

src/components/app-blog-content/app-blog-content.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ export class AppBlogContent {
5050
}
5151
}
5252

53+
componentDidUnload() {
54+
window.removeEventListener('resize', this.handleIcons, false);
55+
}
56+
5357
render() {
5458
const publishDate = new Date(this.blogPost.published);
5559
const contactIconsTop = (
@@ -70,8 +74,8 @@ export class AppBlogContent {
7074
return (
7175
<div class="blog-content">
7276
<div class="header">
73-
<h1>{this.blogPost.title}</h1>
74-
<p>{this.blogPost.summary}</p>
77+
<h1 class="text-left">{this.blogPost.title}</h1>
78+
<p class="text-left">{this.blogPost.summary}</p>
7579
<div>
7680
<div class="header--date">{formatDate(publishDate)}</div>
7781
<div class="header--author">
@@ -96,10 +100,10 @@ export class AppBlogContent {
96100
<div class="col-md-2">
97101
<div id="contact-icons-side">{contactIconsSide}</div>
98102
</div>
99-
<div class="col-md-8">
103+
<div class="text-left col-md-8">
100104
<div innerHTML={this.blogPost.body} class="blog-content-body" />
101105
</div>
102-
<div class="col-md-2" />
106+
<div class="col-md-2 col-sm-2" />
103107
</div>
104108
</div>
105109
<div class="blog-content-author">
@@ -112,7 +116,7 @@ export class AppBlogContent {
112116
<div class="col-md-6 blog-content-author-text">
113117
<h5>About the Author</h5>
114118
<h2>{`${this.blogPost.author.first_name} ${this.blogPost.author.last_name}`}</h2>
115-
<p>{this.blogPost.author.bio}</p>
119+
<p class="text-left">{this.blogPost.author.bio}</p>
116120
</div>
117121
<div class="col-md-2" />
118122
</div>

src/pages/app-blog/app-blog.tsx

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, State, h } from '@stencil/core';
1+
import { Component, State, h, Build } from '@stencil/core';
22
import { BlogPost } from '../../model/blog-post.model';
33
import { BlogMeta } from '../../model/blog-meta.model';
44
import { BlogCategory } from '../../model/blog-category.model';
@@ -33,6 +33,8 @@ export class AppBlog {
3333
@State() searchIsLoading: boolean = false;
3434

3535
pageSize = 3;
36+
indexOfFeaturedPost = -1;
37+
pageOfFeaturedPost = 0;
3638
private filters: BlogCategory[] = [
3739
{
3840
name: 'All',
@@ -61,6 +63,9 @@ export class AppBlog {
6163
}
6264

6365
componentDidLoad() {
66+
if (Build.isBrowser) {
67+
window.scrollTo(0, 0);
68+
}
6469
const input = document.getElementById('blog-search');
6570
input.addEventListener('search', () => this.handleSearch(input.innerText));
6671

@@ -80,8 +85,19 @@ export class AppBlog {
8085
this.allBlogPosts = resp.data;
8186
this.blogMeta = resp.meta;
8287
this.blogNumberOfPages = Math.ceil(resp.meta.count / this.pageSize);
83-
this.getBlogPosts(1);
88+
8489
this.getFeaturedPost();
90+
91+
// Find the index of the featuredPost.
92+
this.indexOfFeaturedPost = this.allBlogPosts.findIndex(post => {
93+
return (post.title == this.featuredPost.title && post.published == this.featuredPost.published);
94+
});
95+
// Find the page where the featuredPost is if found the featuredPost
96+
if (this.indexOfFeaturedPost > -1) {
97+
this.pageOfFeaturedPost = Math.floor(this.indexOfFeaturedPost / this.pageSize) + 1;
98+
}
99+
100+
this.getBlogPosts(1);
85101
}
86102
this.blogIsLoading = false;
87103
}
@@ -96,12 +112,19 @@ export class AppBlog {
96112

97113
getSearchPosts(page) {
98114
this.searchIsLoading = true;
99-
const pageSize = 3;
100-
Fetch.fetchSearchPosts(this.searchQuery, page, pageSize).then(resp => {
115+
Fetch.fetchSearchPosts(this.searchQuery, page, this.pageSize).then(resp => {
101116
if (resp.data) {
102117
this.searchPostsData = resp.data;
103118
this.searchMeta = resp.meta;
104-
this.searchNumberOfPages = Math.ceil(resp.meta.count / pageSize);
119+
120+
// Find the index of the featuredPost from the searhchPostsData
121+
const index = this.searchPostsData.findIndex(post => {
122+
return (post.title == this.featuredPost.title && post.published == this.featuredPost.published);
123+
});
124+
// If found it, remove it from the searchPostsData to avoid display again.
125+
if (index >= 0) this.searchPostsData.splice(index, 1);
126+
127+
this.searchNumberOfPages = Math.ceil(this.searchPostsData.length / this.pageSize);
105128
this.searchCurrentPage = page;
106129
} else {
107130
this.searchIsError = true;
@@ -114,15 +137,29 @@ export class AppBlog {
114137
this.blogIsLoading = true;
115138
if (this.blogFilter) {
116139
this.blogPostsData = await Fetch.fetchFilteredPosts(this.blogFilter, 1, this.pageSize, true);
140+
141+
// Find the index of the featuredPost from the blogPostsData
142+
const index = this.blogPostsData.findIndex(post => {
143+
return (post.title == this.featuredPost.title && post.published == this.featuredPost.published);
144+
});
145+
// If found it, remove it from the blogPostsData to avoid display again.
146+
if (index >= 0) this.blogPostsData.splice(index, 1);
147+
117148
this.blogNumberOfPages = Math.ceil(this.blogPostsData.length / this.pageSize);
118149
this.blogCurrentPage = 1;
119150
} else {
120151
this.blogNumberOfPages = Math.ceil(this.allBlogPosts.length / this.pageSize);
121152
this.blogPostsData = [];
122153
let index = (page - 1) * this.pageSize;
123-
const endPoint = Math.min(this.allBlogPosts.length, page * this.pageSize);
154+
let endPoint = Math.min(this.allBlogPosts.length, page * this.pageSize);
155+
156+
// Adjust the index and the endPoint by the index of the featuredPost
157+
if (page > this.pageOfFeaturedPost) index++;
158+
if (page == this.pageOfFeaturedPost) endPoint++;
159+
124160
for (index; index < endPoint; index++) {
125-
this.blogPostsData.push(this.allBlogPosts[index]);
161+
// Don't push to the blogPostsData if it is the featuredPost.
162+
if (index != this.indexOfFeaturedPost) this.blogPostsData.push(this.allBlogPosts[index]);
126163
}
127164
}
128165
this.blogIsLoading = false;
@@ -149,8 +186,6 @@ export class AppBlog {
149186
if (!this.searchQuery && this.blogFilter !== filterName) {
150187
this.blogFilter = filterName;
151188
this.getBlogPosts(1);
152-
// if (this.blogFilter) this.getBlogPosts(1);
153-
// else this.getAllBlogPosts();
154189
}
155190
}
156191

src/pages/app-case-study/app-case-study.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class AppCaseStudy {
5555
</div>
5656
</section>
5757
<section class="container product-section">
58-
<app-img class="" src="/assets/work-example-juntoscope-mobile.png" alt="juntoscope mobile view" />
58+
<app-img class="" src="/assets/work-example-juntoscope-mobile.jpg" alt="juntoscope mobile view" />
5959
<div class="text-container">
6060
<h2>The Product</h2>
6161
<p>

src/pages/app-contact/app-contact.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, State, Listen, Prop, h } from '@stencil/core';
1+
import { Component, State, Listen, Prop, h, Build } from '@stencil/core';
22
import { translate } from '../../services/translation.service';
33

44
@Component({
@@ -56,7 +56,10 @@ export class AppContact {
5656
}
5757

5858
componentDidLoad() {
59-
this.resetFormValues();
59+
if (Build.isBrowser) {
60+
this.resetFormValues();
61+
window.scrollTo(0, 0);
62+
}
6063
}
6164

6265
validateField(e) {

src/pages/app-home/app-home.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class AppHome {
2828
}
2929

3030
componentDidLoad() {
31+
if (Build.isBrowser) {
32+
window.scrollTo(0, 0);
33+
}
3134
/* tslint:disable-next-line */
3235
window.addEventListener('scroll', () => {
3336
const innerPanel = document.getElementById('content-panel-inner');

src/pages/app-services/app-services.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { Component, h } from '@stencil/core';
1+
import { Component, h, Build } from '@stencil/core';
22

33
@Component({
44
tag: 'app-services',
55
styleUrl: 'app-services.scss',
66
})
77
export class AppServices {
8+
componentDidLoad() {
9+
if (Build.isBrowser) {
10+
window.scrollTo(0, 0);
11+
}
12+
}
813

914
changeMetadata() {
1015
// Change meta tags dynamically

0 commit comments

Comments
 (0)