Updated project styling

This commit is contained in:
r-freeman 2023-01-25 22:41:21 +00:00
parent 0dcf899129
commit c5e332f915
3 changed files with 38 additions and 17 deletions

View File

@ -1,15 +1,17 @@
import Link from 'next/link' import Link from 'next/link'
import {ElementType} from 'react' import {ElementType} from 'react'
import clsx from 'clsx'
type SocialLink = { type SocialLink = {
href: string href: string
ariaLabel: string ariaLabel: string
icon: ElementType icon: ElementType
className?: string
} }
export function SocialLink({icon: Icon, href, ariaLabel}: SocialLink) { export function SocialLink({icon: Icon, href, ariaLabel, className}: SocialLink) {
return ( return (
<Link className="group -m-1 p-1" href={href} aria-label={ariaLabel}> <Link className={clsx(className, "group -m-1 p-1")} href={href} aria-label={ariaLabel}>
<Icon <Icon
className="h-6 w-6 fill-zinc-500 transition group-hover:fill-zinc-600 dark:fill-zinc-400 dark:group-hover:fill-zinc-300"/> className="h-6 w-6 fill-zinc-500 transition group-hover:fill-zinc-600 dark:fill-zinc-400 dark:group-hover:fill-zinc-300"/>
</Link> </Link>

10
components/StarIcon.tsx Normal file
View File

@ -0,0 +1,10 @@
import {Props} from '@/types'
export function StarIcon(props: Props) {
return (
<svg viewBox="0 0 16 16" aria-label="stars" data-view-component="true" {...props}>
<path fillRule="evenodd"
d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.75.75 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694v.001z"/>
</svg>
)
}

View File

@ -1,9 +1,9 @@
import {GetStaticProps} from 'next'
import Head from 'next/head' import Head from 'next/head'
import {Card} from '@/components/Card' import {Card} from '@/components/Card'
import {SimpleLayout} from '@/components/SimpleLayout' import {SimpleLayout} from '@/components/SimpleLayout'
import {GitHubIcon} from '@/components/SocialIcons'
import {SocialLink} from '@/components/SocialLink' import {SocialLink} from '@/components/SocialLink'
import {GetStaticProps} from 'next' import {StarIcon} from '@/components/StarIcon'
import {getPinnedRepos} from '@/lib/github' import {getPinnedRepos} from '@/lib/github'
import type {Repo} from '@/types' import type {Repo} from '@/types'
@ -36,19 +36,29 @@ export default function Projects({pinnedRepos}: { pinnedRepos: Repo[] }) {
> >
{pinnedRepos.map((repo) => ( {pinnedRepos.map((repo) => (
<Card as="li" key={repo.name}> <Card as="li" key={repo.name}>
<h2 className="text-base font-semibold text-zinc-800 dark:text-zinc-100"> <h2 className="text-base font-semibold transition group-hover:text-indigo-500 text-zinc-800 dark:text-zinc-100">
<Card.Link href={repo.url}>{repo.name}</Card.Link> <Card.Link href={repo.url}>{repo.name}</Card.Link>
</h2> </h2>
<Card.Description>{repo.description}</Card.Description> <Card.Description>{repo.description}</Card.Description>
<p <div
className="relative z-10 mt-6 flex text-sm font-medium text-zinc-400 transition group-hover:text-indigo-500 dark:text-zinc-200"> className="flex space-x-8 md:justify-between mt-6 items-center w-full group text-sm text-zinc-500 dark:text-zinc-400">
<SocialLink <p
href={repo.url} className="relative z-10 flex items-center">
ariaLabel={`Checkout ${repo.name} on GitHub`} <span className="ml-2">{repo.primaryLanguage.name}</span>
icon={GitHubIcon} <span
/> className="w-4 h-4 rounded-full order-first"
<span className="ml-2">{`r-freeman/${repo.name}`}</span> style={{backgroundColor: repo.primaryLanguage.color}}/>
</p> </p>
<p className="relative z-10 flex items-center">
<span className="ml-2">{repo.stargazerCount}</span>
<SocialLink
href={repo.url}
ariaLabel={`Star ${repo.name} on GitHub`}
icon={StarIcon}
className={'order-first m-0 p-0'}
/>
</p>
</div>
</Card> </Card>
))} ))}
</ul> </ul>
@ -58,11 +68,10 @@ export default function Projects({pinnedRepos}: { pinnedRepos: Repo[] }) {
} }
export const getStaticProps: GetStaticProps = async () => { export const getStaticProps: GetStaticProps = async () => {
const pinnedRepos = await getPinnedRepos()
return { return {
props: { props: {
pinnedRepos pinnedRepos: (await getPinnedRepos())
.sort((a, b) => b.stargazerCount - a.stargazerCount)
} }
} }
} }