Skip to content

fixes #1699 #1736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import './styles.scss';

import QAComponent from '../QAComponent';

const FAQ = ({ data }) => (
const FAQ = ({ data, hashLink }) => (
<div styleName="container">
{
data.AQs.map((question, index) => (
<QAComponent
data={question.fields}
key={question.fields.title}
isLastItem={(index + 1) === data.AQs.length ? 'last-item' : ''}
isActive={hashLink === question.fields.title}
/>
))
}
Expand All @@ -25,6 +26,7 @@ const FAQ = ({ data }) => (

FAQ.propTypes = {
data: PT.shape().isRequired,
hashLink: PT.string.isRequired,
};

export default FAQ;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class QAComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
isActive: false,
isActive: props.isActive,
};
}

Expand All @@ -30,7 +30,7 @@ class QAComponent extends React.Component {
const { isActive } = this.state;
const className = `container ${isLastItem}`;
return (
<div styleName={className}>
<div styleName={className} id={data.title}>
<div
tabIndex={0}
role="button"
Expand All @@ -57,6 +57,7 @@ class QAComponent extends React.Component {
QAComponent.propTypes = {
data: PT.shape().isRequired,
isLastItem: PT.string.isRequired,
isActive: PT.bool.isRequired,
};

export default QAComponent;
14 changes: 11 additions & 3 deletions src/shared/components/TrackHomePages/HowToCompetePage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import StepByStep from './StepByStep';

import './styles.scss';

const HowToCompetePage = ({ howToCompete }) => {
const HowToCompetePage = ({ howToCompete, location }) => {
const hashLink = decodeURIComponent(location.hash.substring(1));
const data = howToCompete;
let faq = {};
let howToExtras = {};
Expand Down Expand Up @@ -96,7 +97,10 @@ Step by Step
<h1>
Extras
</h1>
<FAQ data={howToExtras} />
<FAQ
data={howToExtras}
hashLink={hashLink}
/>
</div>
<div styleName="faq">
<h1>
Expand All @@ -105,7 +109,10 @@ FAQ
<div styleName="text">
Here are a few answers to our most common questions
</div>
<FAQ data={faq} />
<FAQ
data={faq}
hashLink={hashLink}
/>
</div>
</div>
</div>
Expand All @@ -117,6 +124,7 @@ Here are a few answers to our most common questions

HowToCompetePage.propTypes = {
howToCompete: PT.shape().isRequired,
location: PT.shape().isRequired,
};

export default HowToCompetePage;
4 changes: 3 additions & 1 deletion src/shared/containers/TrackHomePages/HowToCompetePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import LoadingIndicator from 'components/LoadingIndicator';
import Error404 from 'components/Error404';
import ContentfulLoader from '../ContentfulLoader';

const HowToCompetePageContainer = ({ match }) => (
const HowToCompetePageContainer = ({ match, location }) => (
<ContentfulLoader
entryQueries={{
content_type: 'trackHowToCompete',
Expand All @@ -31,6 +31,7 @@ const HowToCompetePageContainer = ({ match }) => (
render={() => (
<HowToCompetePage
howToCompete={howToCompete}
location={location}
/>
)}
renderPlaceholder={LoadingIndicator}
Expand All @@ -49,6 +50,7 @@ HowToCompetePageContainer.propTypes = {
track: PT.string,
}),
}).isRequired,
location: PT.shape().isRequired,
};

export default withRouter(HowToCompetePageContainer);