1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2024-11-14 16:13:14 +01:00
.profile/components/Skills/Skill.tsx

50 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-04-18 01:56:23 +02:00
import Image from 'next/image'
import { getTheme } from '@/theme/theme.server'
2022-10-20 22:24:01 +02:00
import type { SkillName } from './skills'
2021-04-18 01:56:23 +02:00
import { skills } from './skills'
2021-06-24 19:46:44 +02:00
export interface SkillComponentProps {
2022-10-20 22:24:01 +02:00
skill: SkillName
2021-04-18 01:56:23 +02:00
}
export const SkillComponent = (props: SkillComponentProps): JSX.Element => {
2021-04-18 01:56:23 +02:00
const { skill } = props
2021-04-18 01:56:23 +02:00
const skillProperties = skills[skill]
2021-06-24 19:46:44 +02:00
const theme = getTheme()
const getImage = (): string => {
2022-10-20 22:24:01 +02:00
if (typeof skillProperties.image === 'string') {
return skillProperties.image
2021-06-24 19:46:44 +02:00
}
2022-10-20 22:24:01 +02:00
if (theme === 'light') {
return skillProperties.image.light
}
return skillProperties.image.dark
}
2021-04-18 01:56:23 +02:00
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'>
2022-10-27 19:13:29 +02:00
<Image
2023-06-18 12:18:24 +02:00
className='inline h-16 w-16'
2022-10-27 19:13:29 +02:00
quality={100}
2023-06-18 12:18:24 +02:00
width={64}
height={64}
2022-10-27 19:13:29 +02:00
alt={skill}
src={getImage()}
2022-10-27 19:13:29 +02:00
/>
<p className='mt-1'>{skill}</p>
</div>
</a>
2021-04-18 01:56:23 +02:00
)
}