webapp/src/components/Feed/Placeholder/Placeholder.tsx

121 lines
3.4 KiB
TypeScript
Raw Normal View History

2024-05-10 16:52:13 +00:00
import { clsx } from 'clsx'
2024-05-11 17:27:57 +00:00
import { For, Show } from 'solid-js'
2024-05-10 16:52:13 +00:00
import { useLocalize } from '../../../context/localize'
import { useSession } from '../../../context/session'
2024-05-11 17:33:40 +00:00
import { Icon } from '../../_shared/Icon'
2024-05-10 16:52:13 +00:00
import styles from './Placeholder.module.scss'
export type PlaceholderProps = {
2024-05-11 17:33:40 +00:00
type: string
2024-05-11 17:27:57 +00:00
mode: 'feed' | 'profile'
2024-05-10 16:52:13 +00:00
}
export const Placeholder = (props: PlaceholderProps) => {
const { t } = useLocalize()
const { author } = useSession()
const data = {
2024-05-18 22:03:06 +00:00
feedMy: {
2024-05-10 16:52:13 +00:00
image: 'placeholder-feed.webp',
header: t('Feed settings'),
text: t('Placeholder feed'),
buttonLabel: author() ? t('Popular authors') : t('Create own feed'),
href: '/authors?by=followers',
2024-05-10 16:52:13 +00:00
},
feedCollaborations: {
image: 'placeholder-experts.webp',
header: t('Find collaborators'),
text: t('Placeholder feedCollaborations'),
buttonLabel: t('Find co-authors'),
href: '/authors?by=name',
2024-05-10 16:52:13 +00:00
},
feedDiscussions: {
image: 'placeholder-discussions.webp',
header: t('Participate in discussions'),
text: t('Placeholder feedDiscussions'),
buttonLabel: author() ? t('Current discussions') : t('Enter'),
href: '/feed?by=last_comment',
2024-05-10 16:52:13 +00:00
},
2024-05-11 17:27:57 +00:00
author: {
image: 'placeholder-join.webp',
header: t('Join our team of authors'),
text: t('Join our team of authors text'),
buttonLabel: t('Create post'),
href: '/create',
profileLinks: [
{
href: '/how-to-write-a-good-article',
2024-05-11 17:33:40 +00:00
label: t('How to write a good article'),
},
],
2024-05-11 17:27:57 +00:00
},
authorComments: {
image: 'placeholder-discussions.webp',
header: t('Join discussions'),
text: t('Placeholder feedDiscussions'),
buttonLabel: t('Go to discussions'),
href: '/feed?by=last_comment',
profileLinks: [
{
href: '/about/discussion-rules',
2024-05-11 17:33:40 +00:00
label: t('Discussion rules'),
2024-05-11 17:27:57 +00:00
},
{
href: '/about/discussion-rules#ban',
2024-05-11 17:33:40 +00:00
label: t('Block rules'),
},
],
2024-05-11 17:27:57 +00:00
},
2024-05-10 16:52:13 +00:00
}
return (
2024-05-11 17:33:40 +00:00
<div
class={clsx(
styles.placeholder,
styles[`placeholder--${props.type}`],
styles[`placeholder--${props.mode}-mode`],
)}
>
2024-05-10 16:52:13 +00:00
<div class={styles.placeholderCover}>
2024-05-16 14:22:26 +00:00
<img src={`/${data[props.type].image}`} />
2024-05-10 16:52:13 +00:00
</div>
<div class={styles.placeholderContent}>
2024-05-11 17:27:57 +00:00
<div>
2024-05-11 17:33:40 +00:00
<h3 innerHTML={data[props.type].header} />
<p innerHTML={data[props.type].text} />
2024-05-11 17:27:57 +00:00
</div>
<Show when={data[props.type].profileLinks}>
<div class={styles.bottomLinks}>
<For each={data[props.type].profileLinks}>
{(link) => (
<a href={link.href}>
2024-05-11 17:33:40 +00:00
<Icon name="link-white" class={styles.icon} />
2024-05-11 17:27:57 +00:00
{link.label}
</a>
)}
</For>
</div>
</Show>
2024-05-10 16:52:13 +00:00
<Show
when={author()}
fallback={
<a class={styles.button} href="?m=auth&mode=login">
{data[props.type].buttonLabel}
</a>
}
>
2024-05-11 17:27:57 +00:00
<a class={styles.button} href={data[props.type].href}>
{data[props.type].buttonLabel}
<Show when={props.mode === 'profile'}>
2024-05-11 17:33:40 +00:00
<Icon name="arrow-right-2" class={styles.icon} />
2024-05-11 17:27:57 +00:00
</Show>
</a>
2024-05-10 16:52:13 +00:00
</Show>
</div>
</div>
)
}