portfolio/src/components/molecules/Repository.jsx

56 lines
1.3 KiB
React
Raw Normal View History

2019-05-26 16:55:56 +02:00
import React from 'react'
import PropTypes from 'prop-types'
import LinkIcon from '../atoms/LinkIcon'
2019-05-26 22:20:16 +02:00
import styles from './Repository.module.scss'
2019-05-26 16:55:56 +02:00
2019-10-10 00:40:57 +02:00
export default function Repository({ repo }) {
const {
name,
full_name,
description,
html_url,
homepage,
stargazers_count
} = repo
const isExternal = !full_name.includes('kremalicious')
2019-05-26 16:55:56 +02:00
// for blog & portfolio and if there's no homepage, use github url
// else use homepage field
const repoLink =
2019-10-10 00:40:57 +02:00
name === 'blog' || name === 'portfolio' || !homepage || isExternal
? html_url
: homepage
2019-05-26 16:55:56 +02:00
return (
<div className={styles.repo}>
<h1 className={styles.repoTitle}>
2019-10-10 00:40:57 +02:00
<a href={repoLink}>{isExternal ? full_name : name}</a>
2019-05-26 16:55:56 +02:00
</h1>
<p>{description}</p>
<p className={styles.meta}>
{name === 'portfolio' || name === 'blog'
? null
2019-10-10 00:40:57 +02:00
: !isExternal &&
homepage && (
2019-06-10 19:02:58 +02:00
<a href={homepage}>
2019-10-10 00:40:57 +02:00
<LinkIcon title="website" /> More info
2019-05-26 16:55:56 +02:00
</a>
)}
<a href={html_url}>
<LinkIcon title="github" /> GitHub
</a>
<a href={`${html_url}/stargazers`}>
2019-05-26 22:20:16 +02:00
<LinkIcon title="star" /> {stargazers_count}
2019-05-26 16:55:56 +02:00
</a>
</p>
</div>
)
}
Repository.propTypes = {
repo: PropTypes.object.isRequired
}