Conditional stat (#263)

Show when={author()} in profile
This commit is contained in:
Ilya Y 2023-10-16 13:31:10 +03:00 committed by GitHub
parent fdd05246a5
commit d7d1c41d85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 41 deletions

View File

@ -203,7 +203,7 @@
"Manifesto": "Манифест",
"Many files, choose only one": "Много файлов, выберете один",
"Material card": "Карточка материала",
"Message": "Сообщение",
"Message": "Написать",
"More": "Ещё",
"Most commented": "Комментируемое",
"Most read": "Читаемое",

View File

@ -19,6 +19,7 @@ import { AuthorRatingControl } from '../../Author/AuthorRatingControl'
import { hideModal } from '../../../stores/ui'
import { getPagePath } from '@nanostores/router'
import { useSession } from '../../../context/session'
import { Loading } from '../../_shared/Loading'
type Props = {
shouts: Shout[]
@ -125,47 +126,51 @@ export const AuthorView = (props: Props) => {
return (
<div class={styles.authorPage}>
<div class="wide-container">
<Show when={author()}>
<div class={styles.authorHeader}>
<AuthorCard
author={author()}
isAuthorPage={true}
followers={followers()}
following={following()}
isCurrentUser={author().slug === user()?.slug}
/>
</div>
</Show>
<div class={clsx(styles.groupControls, 'row')}>
<div class="col-md-16">
<ul class="view-switcher">
<li classList={{ 'view-switcher__item--selected': getPage().route === 'author' }}>
<a href={getPagePath(router, 'author', { slug: props.authorSlug })}>{t('Publications')}</a>
<span class="view-switcher__counter">{author().stat?.shouts}</span>
</li>
<li classList={{ 'view-switcher__item--selected': getPage().route === 'authorComments' }}>
<a href={getPagePath(router, 'authorComments', { slug: props.authorSlug })}>
{t('Comments')}
</a>
<span class="view-switcher__counter">{author().stat?.commented}</span>
</li>
<li classList={{ 'view-switcher__item--selected': getPage().route === 'authorAbout' }}>
<a
onClick={() => checkBioHeight()}
href={getPagePath(router, 'authorAbout', { slug: props.authorSlug })}
>
{t('Profile')}
</a>
</li>
</ul>
</div>
<div class={clsx('col-md-8', styles.additionalControls)}>
<div class={styles.ratingContainer}>
{t('Karma')}
<AuthorRatingControl author={props.author} class={styles.ratingControl} />
<Show when={author()} fallback={<Loading />}>
<>
<div class={styles.authorHeader}>
<AuthorCard
author={author()}
isAuthorPage={true}
followers={followers()}
following={following()}
isCurrentUser={author().slug === user()?.slug}
/>
</div>
</div>
</div>
<div class={clsx(styles.groupControls, 'row')}>
<div class="col-md-16">
<ul class="view-switcher">
<li classList={{ 'view-switcher__item--selected': getPage().route === 'author' }}>
<a href={getPagePath(router, 'author', { slug: props.authorSlug })}>
{t('Publications')}
</a>
<span class="view-switcher__counter">{author().stat.shouts}</span>
</li>
<li classList={{ 'view-switcher__item--selected': getPage().route === 'authorComments' }}>
<a href={getPagePath(router, 'authorComments', { slug: props.authorSlug })}>
{t('Comments')}
</a>
<span class="view-switcher__counter">{author().stat.commented}</span>
</li>
<li classList={{ 'view-switcher__item--selected': getPage().route === 'authorAbout' }}>
<a
onClick={() => checkBioHeight()}
href={getPagePath(router, 'authorAbout', { slug: props.authorSlug })}
>
{t('Profile')}
</a>
</li>
</ul>
</div>
<div class={clsx('col-md-8', styles.additionalControls)}>
<div class={styles.ratingContainer}>
{t('Karma')}
<AuthorRatingControl author={props.author} class={styles.ratingControl} />
</div>
</div>
</div>
</>
</Show>
</div>
<Switch>