File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed
components/TrackHomePages/HowToCompetePage
containers/TrackHomePages Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,15 @@ import './styles.scss';
8
8
9
9
import QAComponent from '../QAComponent' ;
10
10
11
- const FAQ = ( { data } ) => (
11
+ const FAQ = ( { data, hashLink } ) => (
12
12
< div styleName = "container" >
13
13
{
14
14
data . AQs . map ( ( question , index ) => (
15
15
< QAComponent
16
16
data = { question . fields }
17
17
key = { question . fields . title }
18
18
isLastItem = { ( index + 1 ) === data . AQs . length ? 'last-item' : '' }
19
+ isActive = { hashLink === question . fields . title }
19
20
/>
20
21
) )
21
22
}
@@ -25,6 +26,7 @@ const FAQ = ({ data }) => (
25
26
26
27
FAQ . propTypes = {
27
28
data : PT . shape ( ) . isRequired ,
29
+ hashLink : PT . string . isRequired ,
28
30
} ;
29
31
30
32
export default FAQ ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class QAComponent extends React.Component {
14
14
constructor ( props ) {
15
15
super ( props ) ;
16
16
this . state = {
17
- isActive : false ,
17
+ isActive : props . isActive ,
18
18
} ;
19
19
}
20
20
@@ -30,7 +30,7 @@ class QAComponent extends React.Component {
30
30
const { isActive } = this . state ;
31
31
const className = `container ${ isLastItem } ` ;
32
32
return (
33
- < div styleName = { className } >
33
+ < div styleName = { className } id = { data . title } >
34
34
< div
35
35
tabIndex = { 0 }
36
36
role = "button"
@@ -57,6 +57,7 @@ class QAComponent extends React.Component {
57
57
QAComponent . propTypes = {
58
58
data : PT . shape ( ) . isRequired ,
59
59
isLastItem : PT . string . isRequired ,
60
+ isActive : PT . bool . isRequired ,
60
61
} ;
61
62
62
63
export default QAComponent ;
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ import StepByStep from './StepByStep';
13
13
14
14
import './styles.scss' ;
15
15
16
- const HowToCompetePage = ( { howToCompete } ) => {
16
+ const HowToCompetePage = ( { howToCompete, location } ) => {
17
+ const hashLink = decodeURIComponent ( location . hash . substring ( 1 ) ) ;
17
18
const data = howToCompete ;
18
19
let faq = { } ;
19
20
let howToExtras = { } ;
@@ -96,7 +97,10 @@ Step by Step
96
97
< h1 >
97
98
Extras
98
99
</ h1 >
99
- < FAQ data = { howToExtras } />
100
+ < FAQ
101
+ data = { howToExtras }
102
+ hashLink = { hashLink }
103
+ />
100
104
</ div >
101
105
< div styleName = "faq" >
102
106
< h1 >
105
109
< div styleName = "text" >
106
110
Here are a few answers to our most common questions
107
111
</ div >
108
- < FAQ data = { faq } />
112
+ < FAQ
113
+ data = { faq }
114
+ hashLink = { hashLink }
115
+ />
109
116
</ div >
110
117
</ div >
111
118
</ div >
@@ -117,6 +124,7 @@ Here are a few answers to our most common questions
117
124
118
125
HowToCompetePage . propTypes = {
119
126
howToCompete : PT . shape ( ) . isRequired ,
127
+ location : PT . shape ( ) . isRequired ,
120
128
} ;
121
129
122
130
export default HowToCompetePage ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import LoadingIndicator from 'components/LoadingIndicator';
11
11
import Error404 from 'components/Error404' ;
12
12
import ContentfulLoader from '../ContentfulLoader' ;
13
13
14
- const HowToCompetePageContainer = ( { match } ) => (
14
+ const HowToCompetePageContainer = ( { match, location } ) => (
15
15
< ContentfulLoader
16
16
entryQueries = { {
17
17
content_type : 'trackHowToCompete' ,
@@ -31,6 +31,7 @@ const HowToCompetePageContainer = ({ match }) => (
31
31
render = { ( ) => (
32
32
< HowToCompetePage
33
33
howToCompete = { howToCompete }
34
+ location = { location }
34
35
/>
35
36
) }
36
37
renderPlaceholder = { LoadingIndicator }
@@ -49,6 +50,7 @@ HowToCompetePageContainer.propTypes = {
49
50
track : PT . string ,
50
51
} ) ,
51
52
} ) . isRequired ,
53
+ location : PT . shape ( ) . isRequired ,
52
54
} ;
53
55
54
56
export default withRouter ( HowToCompetePageContainer ) ;
You can’t perform that action at this time.
0 commit comments