aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ProjectPreview/ProjectPreview.tsx
blob: 1e1ced25394806de0c199316c5187e00d7b662dd (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { Project } from '@ts/types/app';
import { slugify } from '@utils/helpers/slugify';
import Image from 'next/image';
import Link from 'next/link';
import { useIntl } from 'react-intl';
import styles from './ProjectPreview.module.scss';

const ProjectPreview = ({ project }: { project: Project }) => {
  const { id, meta, tagline, title } = project;
  const intl = useIntl();

  return (
    <Link href={`/projet/${project.slug}`}>
      <a className={styles.link}>
        <article className={styles.article}>
          <header>
            {meta.hasCover && (
              <div className={styles.cover}>
                <Image
                  src={`/projects/${id}.jpg`}
                  layout="fill"
                  objectFit="contain"
                  objectPosition="center"
                  alt={intl.formatMessage(
                    {
                      defaultMessage: '{title} picture',
                      description: 'ProjectPreview: cover alt text',
                      id: '2pykor',
                    },
                    { title }
                  )}
                />
              </div>
            )}
            <h2 className={styles.title}>{title}</h2>
          </header>
          {tagline && (
            <div
              className={styles.body}
              dangerouslySetInnerHTML={{ __html: tagline }}
            ></div>
          )}
          <footer className={styles.footer}>
            <dl className={styles.meta}>
              {meta.technologies && (
                <div className={styles.meta__item}>
                  <dt className="screen-reader-text">
                    {intl.formatMessage(
                      {
                        defaultMessage:
                          '{count, plural, =0 {Technologies:} one {Technology:} other {Technologies:}}',
                        description: 'ProjectPreview: technologies list label',
                        id: 'okFrAO',
                      },
                      { count: meta.technologies.length }
                    )}
                  </dt>
                  {meta.technologies.map((techno) => (
                    <dd key={slugify(techno)} className={styles.techno}>
                      {techno}
                    </dd>
                  ))}
                </div>
              )}
            </dl>
          </footer>
        </article>
      </a>
    </Link>
  );
};

export default ProjectPreview;