Skip to content

Commit b3511fd

Browse files
authored
Merge pull request #4701 from topcoder-platform/feature-contentful
Feature contentful
2 parents 08663d4 + 86a2263 commit b3511fd

File tree

35 files changed

+692
-483
lines changed

35 files changed

+692
-483
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ workflows:
231231
branches:
232232
only:
233233
- develop
234+
- feature-contentful
234235
# This is alternate dev env for parallel testing
235236
- "build-test":
236237
context : org-global

__tests__/shared/components/Contentful/Image/__snapshots__/Image.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`Matches shallow shapshot 1`] = `
44
<div
55
id="image-1"
6+
style={Object {}}
67
>
78
<InlineSVG
89
baseURL=""

__tests__/shared/components/Contentful/MemberCard/__snapshots__/MemberCard.jsx.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Matches shallow shapshot 1`] = `
4-
<a>
4+
<a
5+
style={Object {}}
6+
>
57
<div>
68
<div
79
style={

__tests__/shared/components/Contentful/TracksTree/__snapshots__/TracksTree.jsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ exports[`Matches shallow shapshot 1`] = `
44
<div
55
className="undefined "
66
>
7-
<a
8-
href="/thrive"
7+
<Link
8+
to="/thrive"
99
>
1010
THRIVE
11-
</a>
11+
</Link>
1212
</div>
1313
`;

__tests__/shared/components/Leaderboard/__snapshots__/LeaderboardTable.jsx.snap

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,10 @@ exports[`Matches shallow shapshot 1`] = `
4444
<span
4545
className="src-shared-components-Leaderboard-LeaderboardTable-themes-___styles__leaderboard-avatar___21pJ3"
4646
>
47-
<ThemedAvatar
48-
composeAdhocTheme="deeply"
49-
composeContextTheme="softly"
50-
mapThemrProps={[Function]}
51-
theme={
52-
Object {
53-
"avatar": "src-shared-components-Leaderboard-avatarStyles___default___1bHTzy",
54-
}
55-
}
56-
themePriority="adhoc-context-default"
47+
<DefaultAvatar
48+
data-name="Layer 1"
49+
viewBox="0 0 33 33.00137"
50+
xmlns="http://www.w3.org/2000/svg"
5751
/>
5852
</span>
5953
</td>
@@ -97,16 +91,10 @@ exports[`Matches shallow shapshot 1`] = `
9791
<span
9892
className="src-shared-components-Leaderboard-LeaderboardTable-themes-___styles__leaderboard-avatar___21pJ3"
9993
>
100-
<ThemedAvatar
101-
composeAdhocTheme="deeply"
102-
composeContextTheme="softly"
103-
mapThemrProps={[Function]}
104-
theme={
105-
Object {
106-
"avatar": "src-shared-components-Leaderboard-avatarStyles___default___1bHTzy",
107-
}
108-
}
109-
themePriority="adhoc-context-default"
94+
<DefaultAvatar
95+
data-name="Layer 1"
96+
viewBox="0 0 33 33.00137"
97+
xmlns="http://www.w3.org/2000/svg"
11098
/>
11199
</span>
112100
</td>
@@ -150,16 +138,10 @@ exports[`Matches shallow shapshot 1`] = `
150138
<span
151139
className="src-shared-components-Leaderboard-LeaderboardTable-themes-___styles__leaderboard-avatar___21pJ3"
152140
>
153-
<ThemedAvatar
154-
composeAdhocTheme="deeply"
155-
composeContextTheme="softly"
156-
mapThemrProps={[Function]}
157-
theme={
158-
Object {
159-
"avatar": "src-shared-components-Leaderboard-avatarStyles___default___1bHTzy",
160-
}
161-
}
162-
themePriority="adhoc-context-default"
141+
<DefaultAvatar
142+
data-name="Layer 1"
143+
viewBox="0 0 33 33.00137"
144+
xmlns="http://www.w3.org/2000/svg"
163145
/>
164146
</span>
165147
</td>
@@ -203,16 +185,10 @@ exports[`Matches shallow shapshot 1`] = `
203185
<span
204186
className="src-shared-components-Leaderboard-LeaderboardTable-themes-___styles__leaderboard-avatar___21pJ3"
205187
>
206-
<ThemedAvatar
207-
composeAdhocTheme="deeply"
208-
composeContextTheme="softly"
209-
mapThemrProps={[Function]}
210-
theme={
211-
Object {
212-
"avatar": "src-shared-components-Leaderboard-avatarStyles___default___1bHTzy",
213-
}
214-
}
215-
themePriority="adhoc-context-default"
188+
<DefaultAvatar
189+
data-name="Layer 1"
190+
viewBox="0 0 33 33.00137"
191+
xmlns="http://www.w3.org/2000/svg"
216192
/>
217193
</span>
218194
</td>

__tests__/shared/components/Leaderboard/__snapshots__/PodiumSpot.jsx.snap

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@ exports[`Matches shallow shapshot 1`] = `
77
<span
88
className="src-shared-components-Leaderboard-PodiumSpot-themes-___styles__leaderboard-avatar___JjdZ_"
99
>
10-
<ThemedAvatar
11-
composeAdhocTheme="deeply"
12-
composeContextTheme="softly"
13-
mapThemrProps={[Function]}
14-
theme={
15-
Object {
16-
"avatar": "src-shared-components-Leaderboard-avatarStyles___gold___1KUGNq",
17-
}
18-
}
19-
themePriority="adhoc-context-default"
10+
<DefaultAvatar
11+
data-name="Layer 1"
12+
viewBox="0 0 33 33.00137"
13+
xmlns="http://www.w3.org/2000/svg"
2014
/>
2115
<div
2216
className="src-shared-components-Leaderboard-PodiumSpot-themes-___styles__ranking___3eGBy"
@@ -72,16 +66,10 @@ exports[`Matches shallow shapshot 2`] = `
7266
<span
7367
className="src-shared-components-Leaderboard-PodiumSpot-themes-___styles__leaderboard-avatar___JjdZ_"
7468
>
75-
<ThemedAvatar
76-
composeAdhocTheme="deeply"
77-
composeContextTheme="softly"
78-
mapThemrProps={[Function]}
79-
theme={
80-
Object {
81-
"avatar": "src-shared-components-Leaderboard-avatarStyles___gold___1KUGNq",
82-
}
83-
}
84-
themePriority="adhoc-context-default"
69+
<DefaultAvatar
70+
data-name="Layer 1"
71+
viewBox="0 0 33 33.00137"
72+
xmlns="http://www.w3.org/2000/svg"
8573
/>
8674
<div
8775
className="src-shared-components-Leaderboard-PodiumSpot-themes-___styles__ranking___3eGBy"
Lines changed: 1 addition & 0 deletions
Loading

src/assets/images/icon-facebook.svg

Lines changed: 11 additions & 0 deletions
Loading

src/assets/images/icon-linkedIn.svg

Lines changed: 11 additions & 0 deletions
Loading

src/assets/images/icon-twitter.svg

Lines changed: 11 additions & 0 deletions
Loading

src/assets/images/minimal-down.svg

Lines changed: 23 additions & 0 deletions
Loading

src/shared/actions/leaderboard.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ async function getTcoHistoryChallengesDone(url, competitor) {
4242
const res = await fetch(url)
4343
.then(response => response.json())
4444
.then(jsonResponse => ({
45-
challenges: _.filter(jsonResponse, challenge => challenge.userid === competitor.userid),
45+
challenges: _.filter(jsonResponse, challenge => (
46+
challenge['tco_leaderboard.user_id']
47+
? (challenge['tco_leaderboard.user_id'] === competitor['tco_leaderboard.user_id'])
48+
: (challenge.userid === competitor.userid)
49+
)),
4650
}));
4751
return res;
4852
}

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

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import LoadingIndicator from 'components/LoadingIndicator';
1515
import YouTubeVideo from 'components/YouTubeVideo';
1616
import moment from 'moment';
1717
import localStorage from 'localStorage';
18-
import { config } from 'topcoder-react-utils';
19-
import ShareSocial from 'components/challenge-detail/Specification/SideBar/ShareSocial';
18+
import { config, Link, isomorphy } from 'topcoder-react-utils';
19+
import qs from 'qs';
2020
// SVGs and assets
2121
import GestureIcon from 'assets/images/icon-gesture.svg';
22-
import UserDefault from 'assets/images/ico-user-default.svg';
2322
import ReadMoreArrow from 'assets/images/read-more-arrow.svg';
24-
import qs from 'qs';
23+
import IconFacebook from 'assets/images/icon-facebook.svg';
24+
import IconTwitter from 'assets/images/icon-twitter.svg';
25+
import IconLinkedIn from 'assets/images/icon-linkedIn.svg';
2526

2627
const htmlToText = require('html-to-text');
2728

@@ -105,20 +106,31 @@ export default class Article extends React.Component {
105106
spaceName, environment, preview,
106107
};
107108
const { upvotes, downvotes } = this.state || {};
109+
let shareUrl;
110+
if (isomorphy.isClientSide()) {
111+
shareUrl = encodeURIComponent(window.location.href);
112+
}
108113

109114
return (
110115
<React.Fragment>
111116
{/* Banner */}
112-
<div className={theme.bannerContainer}>
113-
{
114-
fields.featuredImage ? (
115-
<div className={theme.featuredImage} style={{ backgroundImage: `url(${subData.assets.items[fields.featuredImage.sys.id].fields.file.url})` }} />
116-
) : null
117-
}
118-
</div>
119-
<div className={theme.bannerBottomShape} />
117+
{
118+
fields.featuredImage ? (
119+
<div className={theme.bannerContainer}>
120+
<svg viewBox="0 25 1050 600" version="1.1" preserveAspectRatio="none" className={theme['site-header-background']}>
121+
<defs>
122+
<clipPath id="user-space" clipPathUnits="userSpaceOnUse">
123+
<path id="jagged-top" d="M955.643,455.426c113.929-152.899,130.923-281.812-19.966-387.73 C883.769,31.258,814.91-10.997,685,3c-87.558,9.434-218,32-332,9c-48.207-9.726-146.137-5.765-167.796,6.768 C45.296,99.719-82.626,352.551,69.262,473.459c151.887,120.908,379.734,0.979,533.623,75.92 C756.773,624.319,841.715,608.326,955.643,455.426" />
124+
</clipPath>
125+
</defs>
126+
<image width="100%" height="100%" preserveAspectRatio="none" href={subData.assets.items[fields.featuredImage.sys.id].fields.file.url} clipPath="url(#user-space)" />
127+
</svg>
128+
</div>
129+
) : null
130+
}
120131
<div
121-
className={theme.contentContainer}
132+
className={fields.featuredImage
133+
? theme.contentContainerWithBanner : theme.contentContainer}
122134
style={fixStyle(fields.extraStylesForContainer)}
123135
>
124136
<div className={theme.contentLeftBar}>
@@ -139,9 +151,7 @@ export default class Article extends React.Component {
139151
)}
140152
renderPlaceholder={LoadingIndicator}
141153
/>
142-
) : (
143-
<UserDefault alt="article author avatar" className={theme.avatar} />
144-
)
154+
) : null
145155
}
146156
<div className={theme.authorInfos}>
147157
<span className={theme.name}>
@@ -169,14 +179,24 @@ export default class Article extends React.Component {
169179
{
170180
_.map(fields.tags, tag => (
171181
<div className={theme.tagItem} key={tag} title={`Search for articles labelled as ${tag}`}>
172-
<a href={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_SEARCH_PATH}?${qs.stringify({ tags: tag })}`} key={`${tag}`}>{tag}</a>
182+
<Link to={`${config.TC_EDU_BASE_PATH}${config.TC_EDU_SEARCH_PATH}?${qs.stringify({ tags: tag })}`} key={`${tag}`}>{tag}</Link>
173183
</div>
174184
))
175185
}
176186
</div>
177187
<div className={theme.separator} />
178188
<h3 className={theme.label}>share</h3>
179-
<ShareSocial />
189+
<div className={theme.shareButtons}>
190+
<a href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`} target="_blank" rel="noopener noreferrer">
191+
<IconLinkedIn />
192+
</a>
193+
<a href={`https://www.facebook.com/sharer/sharer.php?u=${shareUrl}&src=share_button`} target="_blank" rel="noopener noreferrer">
194+
<IconFacebook />
195+
</a>
196+
<a href={`https://twitter.com/intent/tweet?url=${shareUrl}`} target="_blank" rel="noopener noreferrer">
197+
<IconTwitter />
198+
</a>
199+
</div>
180200
<div className={theme.mobileSeparator} />
181201
</div>
182202
{/* Content */}
@@ -250,9 +270,9 @@ export default class Article extends React.Component {
250270
{subData.entries.items[rec.sys.id].fields.title}
251271
</a>
252272
) : (
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}`}>
273+
<Link to={`${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}`}>
254274
{subData.entries.items[rec.sys.id].fields.title}
255-
</a>
275+
</Link>
256276
)
257277
}
258278
</h3>
@@ -278,9 +298,9 @@ export default class Article extends React.Component {
278298
Read More <ReadMoreArrow />
279299
</a>
280300
) : (
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}>
301+
<Link to={`${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}>
282302
Read More <ReadMoreArrow />
283-
</a>
303+
</Link>
284304
)
285305
}
286306
</div>

0 commit comments

Comments
 (0)