1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-02-24 03:23:08 +01:00
developer-roadmap/components/links-list-item.tsx

59 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-08-14 22:43:25 +02:00
import React from 'react';
import { Badge, Flex, Link, Text } from '@chakra-ui/react';
type LinksListItemProps = {
2021-09-02 18:08:02 +02:00
href: string;
2021-08-14 22:43:25 +02:00
title: string;
subtitle: string;
badgeText?: string;
2021-10-01 10:59:46 +02:00
target?: string;
2021-08-28 14:02:22 +02:00
icon?: React.ReactChild;
hideSubtitleOnMobile?: boolean;
2021-08-14 22:43:25 +02:00
};
export function LinksListItem(props: LinksListItemProps) {
2021-10-01 10:59:46 +02:00
const { title, subtitle, badgeText, icon, hideSubtitleOnMobile = false, href, target } = props;
2021-08-14 22:43:25 +02:00
return (
<Link
2021-10-01 10:59:46 +02:00
target={target || '_self'}
2021-09-02 18:08:02 +02:00
href={href}
2021-08-28 14:02:22 +02:00
fontSize={['14px', '14px', '15px']}
2021-08-14 22:43:25 +02:00
py='9px'
d='flex'
2021-08-28 13:38:29 +02:00
flexDirection={['column', 'row', 'row']}
2021-08-14 22:43:25 +02:00
fontWeight={500}
color='gray.600'
2021-08-28 13:38:29 +02:00
alignItems={['flex-start', 'center']}
2021-08-14 22:43:25 +02:00
justifyContent={'space-between'}
2021-12-08 19:10:44 +01:00
sx={{
'@media (hover: none)': {
'&:hover': {
'& .list-item-title': {
transform: 'none'
}
}
}
}}
2021-08-14 22:43:25 +02:00
_hover={{
textDecoration: 'none',
color: 'blue.400',
'& .list-item-title': {
transform: 'translateX(10px)'
}
}}
2021-08-28 13:38:29 +02:00
isTruncated
maxWidth='100%'
2021-08-14 22:43:25 +02:00
>
<Flex alignItems='center' className='list-item-title' transition={'200ms'}>
{icon}
2021-08-28 13:38:29 +02:00
<Text maxWidth={'345px'} isTruncated as='span'>{title}</Text>
2021-08-14 22:43:25 +02:00
{badgeText &&
<Badge pos='relative' top='1px' variant='subtle' colorScheme='green' ml='10px'>{badgeText}</Badge>}
2021-08-14 22:43:25 +02:00
</Flex>
2021-08-28 14:02:22 +02:00
<Text d={[hideSubtitleOnMobile ? 'none' : 'inline', 'inline']} mt={['3px', 0]} as='span'
fontSize={['11px', '11px', '12px']} color='gray.500'>{subtitle}</Text>
2021-08-14 22:43:25 +02:00
</Link>
);
}