1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-06-28 00:27:40 +02:00
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'
2019-11-13 11:59:59 +01:00
import Icon from '../atoms/Icon'
2021-03-12 23:47:28 +01:00
import { repo as styleRepo, repoTitle, meta } from './Repository.module.css'
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 (
2021-03-12 23:47:28 +01:00
<div className={styleRepo}>
<h1 className={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>
2021-03-12 23:47:28 +01:00
<p className={meta}>
2019-05-26 16:55:56 +02:00
{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-11-13 13:32:11 +01:00
<Icon name="Compass" /> More info
2019-05-26 16:55:56 +02:00
</a>
)}
<a href={html_url}>
2019-11-13 13:32:11 +01:00
<Icon name="GitHub" /> GitHub
2019-05-26 16:55:56 +02:00
</a>
<a href={`${html_url}/stargazers`}>
2019-11-13 13:32:11 +01:00
<Icon name="Star" /> {stargazers_count}
2019-05-26 16:55:56 +02:00
</a>
</p>
</div>
)
}
Repository.propTypes = {
repo: PropTypes.object.isRequired
}