import { clsx } from 'clsx' import { Show, createMemo, createSignal } from 'solid-js' import { useFollowing } from '../../context/following' import { useLocalize } from '../../context/localize' import { useSession } from '../../context/session' import { FollowingEntity, type Topic } from '../../graphql/schema/core.gen' import { capitalize } from '../../utils/capitalize' import { CardTopic } from '../Feed/CardTopic' import { Button } from '../_shared/Button' import { CheckButton } from '../_shared/CheckButton' import { Icon } from '../_shared/Icon' import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient' import stylesButton from '../_shared/Button/Button.module.scss' import styles from './Card.module.scss' interface TopicProps { topic: Topic compact?: boolean subscribed?: boolean shortDescription?: boolean subscribeButtonBottom?: boolean additionalClass?: string isTopicInRow?: boolean iconButton?: boolean showPublications?: boolean showDescription?: boolean isCardMode?: boolean minimizeSubscribeButton?: boolean isNarrow?: boolean withIcon?: boolean } export const TopicCard = (props: TopicProps) => { const { t, lang } = useLocalize() const title = createMemo(() => capitalize(lang() === 'en' ? props.topic.slug.replaceAll('-', ' ') : props.topic.title || ''), ) const { author, actions: { requireAuthentication }, } = useSession() const { setFollowing, loading: subLoading } = useFollowing() const [followed, setFollowed] = createSignal() const handleFollowClick = () => { const value = !followed() requireAuthentication(() => { setFollowed(value) setFollowing(FollowingEntity.Topic, props.topic.slug, value) }, 'subscribe') } const subscribeValue = () => { return ( <> {t('Unfollow')} {t('Following')} ) } return (

{title()}

{props.topic.body}
} >
) }