Skip to content

Commit ee748a7

Browse files
Merge pull request #1736 from sumitdaga/issue-1699
fixes #1699
2 parents 69e8b30 + 7cd143a commit ee748a7

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

src/shared/components/TrackHomePages/HowToCompetePage/FAQ/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import './styles.scss';
88

99
import QAComponent from '../QAComponent';
1010

11-
const FAQ = ({ data }) => (
11+
const FAQ = ({ data, hashLink }) => (
1212
<div styleName="container">
1313
{
1414
data.AQs.map((question, index) => (
1515
<QAComponent
1616
data={question.fields}
1717
key={question.fields.title}
1818
isLastItem={(index + 1) === data.AQs.length ? 'last-item' : ''}
19+
isActive={hashLink === question.fields.title}
1920
/>
2021
))
2122
}
@@ -25,6 +26,7 @@ const FAQ = ({ data }) => (
2526

2627
FAQ.propTypes = {
2728
data: PT.shape().isRequired,
29+
hashLink: PT.string.isRequired,
2830
};
2931

3032
export default FAQ;

src/shared/components/TrackHomePages/HowToCompetePage/QAComponent/index.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class QAComponent extends React.Component {
1414
constructor(props) {
1515
super(props);
1616
this.state = {
17-
isActive: false,
17+
isActive: props.isActive,
1818
};
1919
}
2020

@@ -30,7 +30,7 @@ class QAComponent extends React.Component {
3030
const { isActive } = this.state;
3131
const className = `container ${isLastItem}`;
3232
return (
33-
<div styleName={className}>
33+
<div styleName={className} id={data.title}>
3434
<div
3535
tabIndex={0}
3636
role="button"
@@ -57,6 +57,7 @@ class QAComponent extends React.Component {
5757
QAComponent.propTypes = {
5858
data: PT.shape().isRequired,
5959
isLastItem: PT.string.isRequired,
60+
isActive: PT.bool.isRequired,
6061
};
6162

6263
export default QAComponent;

src/shared/components/TrackHomePages/HowToCompetePage/index.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import StepByStep from './StepByStep';
1313

1414
import './styles.scss';
1515

16-
const HowToCompetePage = ({ howToCompete }) => {
16+
const HowToCompetePage = ({ howToCompete, location }) => {
17+
const hashLink = decodeURIComponent(location.hash.substring(1));
1718
const data = howToCompete;
1819
let faq = {};
1920
let howToExtras = {};
@@ -96,7 +97,10 @@ Step by Step
9697
<h1>
9798
Extras
9899
</h1>
99-
<FAQ data={howToExtras} />
100+
<FAQ
101+
data={howToExtras}
102+
hashLink={hashLink}
103+
/>
100104
</div>
101105
<div styleName="faq">
102106
<h1>
@@ -105,7 +109,10 @@ FAQ
105109
<div styleName="text">
106110
Here are a few answers to our most common questions
107111
</div>
108-
<FAQ data={faq} />
112+
<FAQ
113+
data={faq}
114+
hashLink={hashLink}
115+
/>
109116
</div>
110117
</div>
111118
</div>
@@ -117,6 +124,7 @@ Here are a few answers to our most common questions
117124

118125
HowToCompetePage.propTypes = {
119126
howToCompete: PT.shape().isRequired,
127+
location: PT.shape().isRequired,
120128
};
121129

122130
export default HowToCompetePage;

src/shared/containers/TrackHomePages/HowToCompetePage.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import LoadingIndicator from 'components/LoadingIndicator';
1111
import Error404 from 'components/Error404';
1212
import ContentfulLoader from '../ContentfulLoader';
1313

14-
const HowToCompetePageContainer = ({ match }) => (
14+
const HowToCompetePageContainer = ({ match, location }) => (
1515
<ContentfulLoader
1616
entryQueries={{
1717
content_type: 'trackHowToCompete',
@@ -31,6 +31,7 @@ const HowToCompetePageContainer = ({ match }) => (
3131
render={() => (
3232
<HowToCompetePage
3333
howToCompete={howToCompete}
34+
location={location}
3435
/>
3536
)}
3637
renderPlaceholder={LoadingIndicator}
@@ -49,6 +50,7 @@ HowToCompetePageContainer.propTypes = {
4950
track: PT.string,
5051
}),
5152
}).isRequired,
53+
location: PT.shape().isRequired,
5254
};
5355

5456
export default withRouter(HowToCompetePageContainer);

0 commit comments

Comments
 (0)