aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/FormListing.tsx
blob: 7bd841f5a0fb1779a450d02086f15030ee8b6b21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/** @jsx jsx */
import { css, jsx } from "@emotion/react";
import { Link } from "react-router-dom";

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowRight } from "@fortawesome/free-solid-svg-icons";

import Tag from "./Tag";

import colors from "../colors";

import { Form, FormFeatures } from "../api/forms";

interface FormListingProps {
  form: Form
}

function FormListing({ form }: FormListingProps): JSX.Element {
    const listingStyle = css`
    background-color: ${form.features.includes(FormFeatures.Open) ? colors.success : colors.darkButNotBlack};
    width: 60%;
    padding: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    transition-property: transform, width;
    transition-duration: 500ms;
    text-decoration: none;
    color: inherit;

    @media (max-width: 575px) {
      width: 80%;
    }

    &:hover {
      transform: scale(1.03);
    }
  `;

    let closedTag;

    if (!form.features.includes(FormFeatures.Open)) {
        closedTag = <Tag text="CLOSED" color={colors.error}/>;
    }

    return <Link to={`/form/${form.id}`} css={listingStyle}>
        <div>
            <h3 css={{fontSize: "1.5em", marginBottom: "0"}}>{closedTag}{form.name} <FontAwesomeIcon icon={faArrowRight} css={{fontSize: "0.75em", paddingBottom: "1px"}}/></h3>
            <p css={{marginTop: "5px"}}>{form.description}</p>
        </div>
    </Link>;
}

export default FormListing;