import { clsx } from 'clsx' import { For, Show, createMemo } from 'solid-js' import { useLocalize } from '../../../context/localize' import { useSession } from '../../../context/session' import { Icon } from '../../_shared/Icon' import styles from './Placeholder.module.scss' type ProfileLink = { href: string label: string } type PlaceholderData = { [key: string]: { image: string header: string text: string buttonLabel?: string buttonLabelAuthor?: string buttonLabelFeed?: string href: string profileLinks?: ProfileLink[] } } export type PlaceholderProps = { type: keyof PlaceholderData mode: 'feed' | 'profile' } const data: PlaceholderData = { feedMy: { image: 'placeholder-feed.webp', header: 'Feed settings', text: 'Placeholder feed', buttonLabelAuthor: 'Popular authors', buttonLabelFeed: 'Create own feed', href: '/authors?by=followers', }, feedCollaborations: { image: 'placeholder-experts.webp', header: 'Find collaborators', text: 'Placeholder feedCollaborations', buttonLabel: 'Find co-authors', href: '/authors?by=name', }, feedDiscussions: { image: 'placeholder-discussions.webp', header: 'Participate in discussions', text: 'Placeholder feedDiscussions', buttonLabelAuthor: 'Current discussions', buttonLabelFeed: 'Enter', href: '/feed?by=last_comment', }, author: { image: 'placeholder-join.webp', header: 'Join our team of authors', text: 'Join our team of authors text', buttonLabel: 'Create post', href: '/create', profileLinks: [ { href: '/how-to-write-a-good-article', label: 'How to write a good article', }, ], }, authorComments: { image: 'placeholder-discussions.webp', header: 'Join discussions', text: 'Placeholder feedDiscussions', buttonLabel: 'Go to discussions', href: '/feed?by=last_comment', profileLinks: [ { href: '/about/discussion-rules', label: 'Discussion rules', }, { href: '/about/discussion-rules#ban', label: 'Block rules', }, ], }, } export const Placeholder = (props: PlaceholderProps) => { const { t } = useLocalize() const { session } = useSession() const placeholderData = createMemo(() => data[props.type]) return (
{placeholderData().header}

{(link) => ( {t(link.label)} )}
{t( session()?.access_token ? placeholderData()?.buttonLabelAuthor || '' : placeholderData()?.buttonLabelFeed || '', )} } > {t( session()?.access_token ? placeholderData()?.buttonLabelAuthor || '' : placeholderData()?.buttonLabelFeed || '', )}
) }