Skip to content

Commit 4556736

Browse files
authored
Merge pull request #4313 from topcoder-platform/feature-contentful
Feature contentful
2 parents a5ab281 + ff9f642 commit 4556736

File tree

18 files changed

+605
-221
lines changed

18 files changed

+605
-221
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ workflows:
209209
filters:
210210
branches:
211211
only:
212-
- hot-fix
212+
- develop
213+
- feature-contentful
213214
# This is beta env for production soft releases
214215
- "build-prod-beta":
215216
context : org-global

__tests__/shared/components/__snapshots__/TopcoderFooter.jsx.snap

+9
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,15 @@ exports[`Matches shallow shapshot 1`] = `
321321
Talk to Sales
322322
</a>
323323
</li>
324+
<li
325+
className="src-shared-components-TopcoderFooter-___style__link___3-nzm"
326+
>
327+
<a
328+
href="https://www.topcoder-dev.com/community/terms"
329+
>
330+
Terms
331+
</a>
332+
</li>
324333
</ul>
325334
</div>
326335
<div

src/shared/components/Contentful/Article/Article.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export default class Article extends React.Component {
250250
{subData.entries.items[rec.sys.id].fields.title}
251251
</a>
252252
) : (
253-
<a href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${subData.entries.items[rec.sys.id].fields.title}`}>
253+
<a href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${subData.entries.items[rec.sys.id].fields.slug || subData.entries.items[rec.sys.id].fields.title}`}>
254254
{subData.entries.items[rec.sys.id].fields.title}
255255
</a>
256256
)
@@ -278,7 +278,7 @@ export default class Article extends React.Component {
278278
Read More <ReadMoreArrow />
279279
</a>
280280
) : (
281-
<a href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${subData.entries.items[rec.sys.id].fields.title}`} className={theme.readMore}>
281+
<a href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${subData.entries.items[rec.sys.id].fields.slug || subData.entries.items[rec.sys.id].fields.title}`} className={theme.readMore}>
282282
Read More <ReadMoreArrow />
283283
</a>
284284
)

src/shared/components/Contentful/ArticleCard/ArticleCard.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ArticleCard extends React.Component {
6767
// determine if article cards will redirect to external link or article details page
6868
const articlePageUrl = article.externalArticle && article.contentUrl
6969
? article.contentUrl
70-
: `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${article.title}`;
70+
: `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${article.slug || article.title}`;
7171
const articlePageTarget = article.externalArticle && article.contentUrl
7272
? '_blank'
7373
: '_self';

src/shared/components/Contentful/ContentBlock/themes/TCO19.scss

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
}
1414
}
1515

16+
strong a {
17+
font-weight: 600 !important;
18+
}
19+
1620
.container {
1721
align-content: center;
1822
background: white;

src/shared/components/Contentful/ContentBlock/themes/TCO20.scss

+22-18
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
}
2828
}
2929

30+
strong a {
31+
font-weight: 600 !important;
32+
}
33+
3034
.content {
3135
flex: 1;
3236
padding: 0;
@@ -48,6 +52,24 @@
4852

4953
@include gui-kit-headers;
5054

55+
a {
56+
@include roboto-regular;
57+
58+
font-size: 16px;
59+
line-height: 24px;
60+
color: #0d61bf;
61+
text-decoration: underline;
62+
63+
&:hover {
64+
text-decoration: none;
65+
color: #0d61bf;
66+
}
67+
68+
&:visited {
69+
color: #8231a9;
70+
}
71+
}
72+
5173
p {
5274
@include tc-body-md;
5375

@@ -163,24 +185,6 @@
163185
sub {
164186
bottom: -0.25em;
165187
}
166-
167-
a {
168-
@include roboto-regular;
169-
170-
font-size: 16px;
171-
line-height: 24px;
172-
color: #0d61bf;
173-
text-decoration: underline;
174-
175-
&:hover {
176-
text-decoration: none;
177-
color: #0d61bf;
178-
}
179-
180-
&:visited {
181-
color: #8231a9;
182-
}
183-
}
184188
}
185189

186190
.image {

src/shared/components/Contentful/ContentBlock/themes/default.scss

+4
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ pre {
6363
white-space: pre;
6464
}
6565
}
66+
67+
strong a {
68+
font-weight: 600 !important;
69+
}

src/shared/components/Contentful/ContentBlock/themes/general.scss

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
}
2727
}
2828

29+
strong a {
30+
font-weight: 600 !important;
31+
}
32+
2933
.content {
3034
flex: 1;
3135
padding: 0;

src/shared/components/Contentful/SearchBar/SearchBar.jsx

+18-10
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class SearchBarInner extends Component {
5555
this.getDropdownPopup = this.getDropdownPopup.bind(this);
5656
this.getSuggestionList = this.getSuggestionList.bind(this);
5757
this.handleSearchChange = this.handleSearchChange.bind(this);
58+
this.handleClickOutside = this.handleClickOutside.bind(this);
5859
// using debounce to avoid processing or requesting too much
5960
this.updateSuggestionListWithNewSearch = _.debounce(
6061
this.updateSuggestionListWithNewSearch.bind(this), 400,
@@ -66,6 +67,10 @@ export class SearchBarInner extends Component {
6667
this.apiService = getService({ spaceName: 'EDU' });
6768
}
6869

70+
componentWillUnmount() {
71+
document.removeEventListener('mousedown', this.handleClickOutside);
72+
}
73+
6974
/**
7075
* Set the search field ref
7176
*/
@@ -164,13 +169,13 @@ export class SearchBarInner extends Component {
164169
className={theme['group-cell']}
165170
onClick={() => {
166171
window.location.href = (item.externalArticle && item.contentUrl)
167-
? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`;
172+
? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.slug || item.title}`;
168173
}}
169174
onKeyPress={_.noop}
170175
>
171176
<a
172177
className={theme.articleLink}
173-
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}
178+
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.slug || item.title}`}
174179
target={(item.externalArticle && item.contentUrl) ? '_blank' : '_self'}
175180
onClick={(e) => {
176181
e.nativeEvent.stopImmediatePropagation();
@@ -215,13 +220,13 @@ export class SearchBarInner extends Component {
215220
className={theme['group-cell']}
216221
onClick={() => {
217222
window.location.href = (item.externalArticle && item.contentUrl)
218-
? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`;
223+
? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.slug || item.title}`;
219224
}}
220225
onKeyPress={_.noop}
221226
>
222227
<a
223228
className={theme.articleLink}
224-
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}
229+
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.slug || item.title}`}
225230
target={(item.externalArticle && item.contentUrl) ? '_blank' : '_self'}
226231
onClick={(e) => {
227232
e.nativeEvent.stopImmediatePropagation();
@@ -267,7 +272,7 @@ export class SearchBarInner extends Component {
267272
>
268273
<a
269274
className={theme.forumLink}
270-
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.title}`}
275+
href={(item.externalArticle && item.contentUrl) ? item.contentUrl : `${config.TC_EDU_BASE_PATH}${config.TC_EDU_ARTICLES_PATH}/${item.slug || item.title}`}
271276
target={(item.externalArticle && item.contentUrl) ? '_blank' : '_self'}
272277
>
273278
<span className={theme['cell-text']}>
@@ -317,6 +322,13 @@ export class SearchBarInner extends Component {
317322
));
318323
}
319324

325+
handleClickOutside(e) {
326+
if (this.popupSearchResultRef && !this.popupSearchResultRef.contains(e.target)) {
327+
this.setState({ isShowSuggestion: false });
328+
document.removeEventListener('mousedown', this.handleClickOutside);
329+
}
330+
}
331+
320332
/**
321333
* Update size of popup search result
322334
*/
@@ -453,14 +465,10 @@ export class SearchBarInner extends Component {
453465
ref={this.setSearchFieldRef}
454466
type="text"
455467
placeholder="Search..."
456-
onBlur={() => {
457-
_.delay(() => {
458-
this.setState({ isShowSuggestion: false });
459-
}, 100);
460-
}}
461468
onFocus={(e) => {
462469
this.updateSuggestionListWithNewSearch(e.target.value);
463470
this.setState({ isShowSuggestion: true, isShowFilterPopup: false });
471+
document.addEventListener('mousedown', this.handleClickOutside);
464472
}}
465473
onChange={this.handleSearchChange}
466474
/>

0 commit comments

Comments
 (0)