Skip to content

Commit

Permalink
feat(frontend): add a back to results link
Browse files Browse the repository at this point in the history
  • Loading branch information
UnbearableBear committed Feb 21, 2019
1 parent 0eec10c commit cf65b4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions packages/code-du-travail-frontend/src/common/Answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import Head from "next/head";
import { Container, Alert, Article, NoAnswer, Button } from "@cdt/ui";
import { withRouter } from "next/router";
import ReactPiwik from "react-piwik";
import styled from "styled-components";

import { Link } from "../../routes";
import Disclaimer from "../common/Disclaimer";
import Html from "../common/Html";
import Search from "../search/Search";
Expand All @@ -14,6 +17,13 @@ const BigError = ({ children }) => (
</Container>
);

// manuC: Doing this feels stange, we should talk about it
// https://github.com/SocialGouv/code-du-travail-numerique/issues/541
const StyledAnchor = styled.a`
padding-left: 1.25rem; /* thanks IE11 */
padding-left: var(--spacing-medium);
`;

class Answer extends React.Component {
state = {
modalVisible: false
Expand Down Expand Up @@ -64,6 +74,11 @@ class Answer extends React.Component {
<title>{title}</title>
</Head>
<Search onResults={this.setResults} />
{router.query.q && (
<Link route="index" params={{ q: router.query.q }} passHref>
<StyledAnchor>{"< Retour aux résultats de recherche"}</StyledAnchor>
</Link>
)}
{!html && !children && <BigError>{emptyMessage}</BigError>}
{(html || children) && (
<React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ exports[`<Answer /> should display feedback modal when click on feedback button
est prévue pour 2020.
</div>
<div
class="sc-cSHVUG UZPwC"
class="sc-kAzzGY YkpsC"
>
<div>
html
Expand Down Expand Up @@ -759,7 +759,7 @@ exports[`<Answer /> should display feedback modal when click on thumbDown 1`] =
est prévue pour 2020.
</div>
<div
class="sc-fjdhpX faZXWb"
class="sc-jzJRlG gIKICC"
>
<div>
html
Expand Down Expand Up @@ -1253,7 +1253,7 @@ exports[`<Answer /> should render 1`] = `
</div>
intro de l'article
<div
class="sc-VigVT epqSFI"
class="sc-jTzLTM bpAevs"
>
<p
class="test-content"
Expand Down Expand Up @@ -1618,7 +1618,7 @@ exports[`<Answer /> should render additional content 1`] = `
est prévue pour 2020.
</div>
<div
class="sc-chPdSV gMFNpU"
class="sc-kgoBCf fknYyF"
>
<div>
html
Expand Down

0 comments on commit cf65b4b

Please sign in to comment.