-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5729 from topcoder-platform/develop
Release v1.13.1
- Loading branch information
Showing
17 changed files
with
513 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"title": "WHAT DO YOU WANT TO DO TODAY?", | ||
"items": [ | ||
{ | ||
"title": "COMPETE", | ||
"iconURL": "https://media-bucket-s3.s3.eu-central-1.amazonaws.com/sx/icon-compete.svg", | ||
"activeIconURL": "https://s3.eu-central-1.amazonaws.com/media-bucket-s3/sx/icon-compete-active.svg", | ||
"contentText": "A competition based, gig economy, a typical 9-5 job for you", | ||
"btnText": "Topcoder Challenges", | ||
"btnURL": "https://www.topcoder.com/challenges", | ||
"btnNewTab": true | ||
}, { | ||
"title": "BUILD SKILLS", | ||
"iconURL": "https://media-bucket-s3.s3.eu-central-1.amazonaws.com/sx/icon-build-skills.svg", | ||
"activeIconURL": "https://s3.eu-central-1.amazonaws.com/media-bucket-s3/sx/icon-build-skills-active.svg", | ||
"contentText": "Get stronger with Skill Builder Competitions", | ||
"btnText": "Find a Competition", | ||
"btnURL": "https://www.topcoder.com/challenges?bucket=openForRegistration&search=Topcoder%20Skill%20Builder%20Competition&tracks[DS]=true&tracks[Des]=true&tracks[Dev]=true&tracks[QA]=true&types[]=CH&types[]=F2F&types[]=TSK", | ||
"btnNewTab": true | ||
}, | ||
{ | ||
"title": "LEARN", | ||
"iconURL": "https://s3.eu-central-1.amazonaws.com/media-bucket-s3/sx/icon-learn.svg", | ||
"activeIconURL": "https://s3.eu-central-1.amazonaws.com/media-bucket-s3/sx/icon-learn-active.svg", | ||
"contentText": "Tutorials and workshops that matter", | ||
"btnText": "Thrive", | ||
"btnURL": "https://www.topcoder.com/thrive", | ||
"btnNewTab": true | ||
}, | ||
{ | ||
"title": "GET A GIG", | ||
"iconURL": "https://s3.eu-central-1.amazonaws.com/media-bucket-s3/sx/icon-gig.svg", | ||
"activeIconURL": "https://s3.eu-central-1.amazonaws.com/media-bucket-s3/sx/icon-get-a-gig-active.svg", | ||
"contentText": "Find a freelance job with our help", | ||
"btnText": "Gig Work", | ||
"btnURL": "https://www.topcoder.com/gigs", | ||
"btnNewTab": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
src/shared/components/MemberPath/PathSelector/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import PT from 'prop-types'; | ||
import React, { useEffect, useState } from 'react'; | ||
import cn from 'classnames'; | ||
import ArrowLeftIcon from 'assets/images/member-path/icon-left.svg'; | ||
import ArrowRightIcon from 'assets/images/member-path/icon-right.svg'; | ||
import styles from './styles.scss'; | ||
|
||
const colorStyles = [styles.purple, styles.blue, styles.teal, styles.orange]; | ||
|
||
export default function PathSelector({ | ||
data, | ||
animationTime, | ||
}) { | ||
const [activeItemIndex, setActiveItemIndex] = useState(0); | ||
const [timer, setTimer] = useState(null); | ||
|
||
useEffect( | ||
() => { | ||
setTimer(setInterval(() => { | ||
setActiveItemIndex(itemIndex => (itemIndex + 1) % data.items.length); | ||
}, | ||
animationTime)); | ||
return () => { | ||
if (timer) { | ||
clearInterval(timer); | ||
} | ||
}; | ||
}, | ||
[], | ||
); | ||
const stopTimer = () => { | ||
if (timer) { | ||
clearInterval(timer); | ||
setTimer(null); | ||
} | ||
}; | ||
|
||
const handleOptionSelect = index => () => { | ||
setActiveItemIndex(index); | ||
// Stop the animation if user selects an item | ||
stopTimer(); | ||
}; | ||
|
||
const handlePrevButton = () => { | ||
setActiveItemIndex(activeItemIndex - 1 < 0 ? data.items.length - 1 : activeItemIndex - 1); | ||
// Stop the animation if user selects an item | ||
stopTimer(); | ||
}; | ||
|
||
const handleNextButton = () => { | ||
setActiveItemIndex((activeItemIndex + 1) % data.items.length); | ||
// Stop the animation if user selects an item | ||
stopTimer(); | ||
}; | ||
|
||
const items = data.items.map((item, index) => ( | ||
<button | ||
key={`path-selector-${item.title}`} | ||
type="button" | ||
className={cn( | ||
styles.option, | ||
colorStyles[index % colorStyles.length], | ||
{ [styles.active]: activeItemIndex === index }, | ||
) | ||
} | ||
onClick={handleOptionSelect(index)} | ||
> | ||
<img | ||
className={styles.icon} | ||
src={item.iconURL} | ||
alt={item.title} | ||
/> | ||
<img | ||
className={styles.activeIcon} | ||
src={item.activeIconURL} | ||
alt={item.title} | ||
/> | ||
<span>{item.title}</span> | ||
</button> | ||
)); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<div className={styles.header}> | ||
<h2 className={styles.title}>{data.title}</h2> | ||
<div className={styles.options}> | ||
<ArrowLeftIcon | ||
className={styles.arrowIcon} | ||
onClick={handlePrevButton} | ||
/> | ||
{items} | ||
<ArrowRightIcon | ||
className={styles.arrowIcon} | ||
onClick={handleNextButton} | ||
/> | ||
</div> | ||
</div> | ||
<div className={cn(styles.content, colorStyles[activeItemIndex % colorStyles.length])}> | ||
<div className={styles.contentText}> | ||
<span>{data.items[activeItemIndex].contentText}</span> | ||
</div> | ||
<a | ||
href={data.items[activeItemIndex].btnURL} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className={styles.contentButton} | ||
> | ||
{data.items[activeItemIndex].btnText} | ||
</a> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
PathSelector.defaultProps = { | ||
animationTime: 3000, | ||
}; | ||
|
||
PathSelector.propTypes = { | ||
data: PT.shape({ | ||
items: PT.arrayOf(PT.shape({ | ||
title: PT.string, | ||
iconURL: PT.string, | ||
activeIconURL: PT.string, | ||
contentText: PT.string, | ||
btnText: PT.string, | ||
btnURL: PT.string, | ||
btnNewTab: PT.bool, | ||
})), | ||
title: PT.string, | ||
}).isRequired, | ||
animationTime: PT.number, | ||
}; |
Oops, something went wrong.