mirror of
https://github.com/theoludwig/theoludwig.git
synced 2024-12-08 00:44:30 +01:00
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { useTheme } from 'next-themes'
|
|
import Image from 'next/image'
|
|
import { useMemo } from 'react'
|
|
|
|
import type { SkillName } from './skills'
|
|
import { skills } from './skills'
|
|
|
|
export interface SkillComponentProps {
|
|
skill: SkillName
|
|
}
|
|
|
|
export const SkillComponent: React.FC<SkillComponentProps> = (props) => {
|
|
const { skill } = props
|
|
const skillProperties = skills[skill]
|
|
const { theme } = useTheme()
|
|
|
|
const image = useMemo(() => {
|
|
if (typeof skillProperties.image === 'string') {
|
|
return skillProperties.image
|
|
}
|
|
if (theme === 'light') {
|
|
return skillProperties.image.light
|
|
}
|
|
return skillProperties.image.dark
|
|
}, [skillProperties, theme])
|
|
|
|
return (
|
|
<a
|
|
href={skillProperties.link}
|
|
className='mx-2 max-w-xl text-yellow hover:underline dark:text-yellow-dark'
|
|
target='_blank'
|
|
rel='noopener noreferrer'
|
|
>
|
|
<div className='text-center'>
|
|
<Image
|
|
className='inline h-16 w-16'
|
|
quality={100}
|
|
width={64}
|
|
height={64}
|
|
alt={skill}
|
|
src={image}
|
|
/>
|
|
<p className='mt-1'>{skill}</p>
|
|
</div>
|
|
</a>
|
|
)
|
|
}
|