2023-10-20 16:21:40 +00:00
|
|
|
import { clsx } from 'clsx'
|
2023-12-19 09:34:24 +00:00
|
|
|
import { createMemo } from 'solid-js'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-12-19 09:34:24 +00:00
|
|
|
import { useLocalize } from '../../../context/localize'
|
2023-11-28 13:18:25 +00:00
|
|
|
import { Author } from '../../../graphql/schema/core.gen'
|
2023-12-19 09:34:24 +00:00
|
|
|
import { capitalize } from '../../../utils/capitalize'
|
2023-12-31 05:01:34 +00:00
|
|
|
import { translit } from '../../../utils/ru2en'
|
2024-02-04 17:40:15 +00:00
|
|
|
import { isCyrillic } from '../../../utils/translate'
|
2023-10-20 16:21:40 +00:00
|
|
|
import { Userpic } from '../Userpic'
|
|
|
|
|
2023-11-14 15:10:00 +00:00
|
|
|
import styles from './AhtorLink.module.scss'
|
|
|
|
|
2023-10-20 16:21:40 +00:00
|
|
|
type Props = {
|
|
|
|
author: Author
|
|
|
|
size?: 'XS' | 'M' | 'L'
|
|
|
|
class?: string
|
2023-11-20 21:31:52 +00:00
|
|
|
isFloorImportant?: boolean
|
2023-10-20 16:21:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const AuthorLink = (props: Props) => {
|
2023-12-19 09:34:24 +00:00
|
|
|
const { lang } = useLocalize()
|
|
|
|
const name = createMemo(() => {
|
2024-06-24 17:50:27 +00:00
|
|
|
return lang() === 'en' && isCyrillic(props.author.name || '')
|
|
|
|
? translit(capitalize(props.author.name || ''))
|
2023-12-19 09:34:24 +00:00
|
|
|
: props.author.name
|
|
|
|
})
|
2023-10-20 16:21:40 +00:00
|
|
|
return (
|
2023-11-20 21:31:52 +00:00
|
|
|
<div
|
2024-06-24 17:50:27 +00:00
|
|
|
class={clsx(styles.AuthorLink, props.class, styles[(props.size ?? 'M') as keyof Props['size']], {
|
2023-11-20 21:31:52 +00:00
|
|
|
[styles.authorLinkFloorImportant]: props.isFloorImportant,
|
|
|
|
})}
|
|
|
|
>
|
2023-10-20 16:21:40 +00:00
|
|
|
<a class={styles.link} href={`/author/${props.author.slug}`}>
|
2024-06-24 17:50:27 +00:00
|
|
|
<Userpic size={props.size ?? 'M'} name={name() || ''} userpic={props.author.pic || ''} />
|
2023-12-19 09:34:24 +00:00
|
|
|
<div class={styles.name}>{name()}</div>
|
2023-10-20 16:21:40 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|