loadby-refactored-merged

This commit is contained in:
tonyrewin 2022-11-17 09:32:48 +03:00
commit ff85721961
18 changed files with 100 additions and 34 deletions

View File

@ -20,6 +20,7 @@ interface AuthorCardProps {
isAuthorPage?: boolean isAuthorPage?: boolean
noSocialButtons?: boolean noSocialButtons?: boolean
isAuthorsList?: boolean isAuthorsList?: boolean
truncateBio?: boolean
} }
export const AuthorCard = (props: AuthorCardProps) => { export const AuthorCard = (props: AuthorCardProps) => {
@ -63,7 +64,8 @@ export const AuthorCard = (props: AuthorCardProps) => {
</Show> </Show>
<Show when={!props.hideDescription}> <Show when={!props.hideDescription}>
<div class={styles.authorAbout} classList={{ 'text-truncate': props.isAuthorsList }}> {props.isAuthorsList}
<div class={styles.authorAbout} classList={{ 'text-truncate': props.truncateBio }}>
{bio()} {bio()}
</div> </div>
</Show> </Show>
@ -86,7 +88,6 @@ export const AuthorCard = (props: AuthorCardProps) => {
> >
<Show when={!props.isAuthorsList}> <Show when={!props.isAuthorsList}>
<Icon name="author-subscribe" class={styles.icon} /> <Icon name="author-subscribe" class={styles.icon} />
&nbsp;
</Show> </Show>
<span class={styles.buttonLabel}>{t('Follow')}</span> <span class={styles.buttonLabel}>{t('Follow')}</span>
</button> </button>
@ -103,7 +104,6 @@ export const AuthorCard = (props: AuthorCardProps) => {
> >
<Show when={!props.isAuthorsList}> <Show when={!props.isAuthorsList}>
<Icon name="author-unsubscribe" class={styles.icon} /> <Icon name="author-unsubscribe" class={styles.icon} />
&nbsp;
</Show> </Show>
<span class={styles.buttonLabel}>{t('Unfollow')}</span> <span class={styles.buttonLabel}>{t('Unfollow')}</span>
</button> </button>

View File

@ -70,6 +70,7 @@
@include font-size(1.5rem); @include font-size(1.5rem);
font-weight: 500; font-weight: 500;
padding-right: 0.3em;
white-space: nowrap; white-space: nowrap;
img { img {
@ -108,3 +109,7 @@ button.follow {
max-width: 2em; max-width: 2em;
max-height: 2em; max-height: 2em;
} }
.shoutCardContainer {
display: flex;
}

View File

@ -4,10 +4,11 @@ import { For, Show } from 'solid-js'
import { ArticleCard } from './Card' import { ArticleCard } from './Card'
import { AuthorCard } from '../Author/Card' import { AuthorCard } from '../Author/Card'
import { TopicCard } from '../Topic/Card' import { TopicCard } from '../Topic/Card'
import style from './Beside.module.scss' import styles from './Beside.module.scss'
import type { Author, Shout, Topic, User } from '../../graphql/types.gen' import type { Author, Shout, Topic, User } from '../../graphql/types.gen'
import { Icon } from '../_shared/Icon' import { Icon } from '../_shared/Icon'
import { t } from '../../utils/intl' import { t } from '../../utils/intl'
import { clsx } from 'clsx'
interface BesideProps { interface BesideProps {
title?: string title?: string
@ -29,21 +30,28 @@ export const Beside = (props: BesideProps) => {
<Show when={!!props.values}> <Show when={!!props.values}>
<div class="col-md-4"> <div class="col-md-4">
<Show when={!!props.title}> <Show when={!!props.title}>
<div class={style.besideColumnTitle}> <div class={styles.besideColumnTitle}>
<h4>{props.title}</h4> <h4>{props.title}</h4>
<Show when={props.wrapper === 'author'}> <Show when={props.wrapper === 'author'}>
<a href="/user/list"> <a href="/user/list">
{t('All authors')} {t('All authors')}
<Icon name="arrow-right" /> <Icon name="arrow-right" class={styles.icon} />
</a>
</Show>
<Show when={props.wrapper === 'topic'}>
<a href="/topics">
{t('All topics')}
<Icon name="arrow-right" class={styles.icon} />
</a> </a>
</Show> </Show>
</div> </div>
</Show> </Show>
<ul class={style.besideColumn}> <ul class={styles.besideColumn}>
<For each={[...props.values]}> <For each={[...props.values]}>
{(value: Partial<Shout | User | Topic>) => ( {(value: Partial<Shout | User | Topic>) => (
<li classList={{ [style.top]: props.wrapper.startsWith('top-') }}> <li classList={{ [styles.top]: props.wrapper.startsWith('top-') }}>
<Show when={props.wrapper === 'topic'}> <Show when={props.wrapper === 'topic'}>
<TopicCard <TopicCard
topic={value as Topic} topic={value as Topic}
@ -51,10 +59,16 @@ export const Beside = (props: BesideProps) => {
shortDescription={props.topicShortDescription} shortDescription={props.topicShortDescription}
isTopicInRow={props.isTopicInRow} isTopicInRow={props.isTopicInRow}
iconButton={props.iconButton} iconButton={props.iconButton}
showPublications={true}
/> />
</Show> </Show>
<Show when={props.wrapper === 'author'}> <Show when={props.wrapper === 'author'}>
<AuthorCard author={value as Author} compact={true} hasLink={true} /> <AuthorCard
author={value as Author}
compact={true}
hasLink={true}
truncateBio={true}
/>
</Show> </Show>
<Show when={props.wrapper === 'article' && value?.slug}> <Show when={props.wrapper === 'article' && value?.slug}>
<ArticleCard article={value as Shout} settings={{ noimage: true }} /> <ArticleCard article={value as Shout} settings={{ noimage: true }} />
@ -71,8 +85,8 @@ export const Beside = (props: BesideProps) => {
</ul> </ul>
</div> </div>
</Show> </Show>
<div class="col-md-8"> <div class={clsx('col-md-8', styles.shoutCardContainer)}>
<ArticleCard article={props.beside} settings={{ isBigTitle: true }} /> <ArticleCard article={props.beside} settings={{ isBigTitle: true, isBeside: true }} />
</div> </div>
</div> </div>
</div> </div>

View File

@ -675,3 +675,19 @@
@include font-size(2.4rem); @include font-size(2.4rem);
} }
} }
.shoutCardBeside {
&,
.shoutCardCoverContainer {
flex: 1;
}
.shoutCardCover {
height: 100%;
padding: 0;
}
.shoutCardContent {
padding-top: 1.6rem;
}
}

View File

@ -29,6 +29,7 @@ interface ArticleCardProps {
withBorder?: boolean withBorder?: boolean
isCompact?: boolean isCompact?: boolean
isSingle?: boolean isSingle?: boolean
isBeside?: boolean
} }
article: Shout article: Shout
} }
@ -82,7 +83,8 @@ export const ArticleCard = (props: ArticleCardProps) => {
[styles.shoutCardVertical]: props.settings?.isVertical, [styles.shoutCardVertical]: props.settings?.isVertical,
[styles.shoutCardWithBorder]: props.settings?.withBorder, [styles.shoutCardWithBorder]: props.settings?.withBorder,
[styles.shoutCardCompact]: props.settings?.isCompact, [styles.shoutCardCompact]: props.settings?.isCompact,
[styles.shoutCardSingle]: props.settings?.isSingle [styles.shoutCardSingle]: props.settings?.isSingle,
[styles.shoutCardBeside]: props.settings?.isBeside
}} }}
> >
<Show when={!props.settings?.noimage && cover}> <Show when={!props.settings?.noimage && cover}>

View File

@ -23,7 +23,7 @@ export const Row2 = (props: { articles: Shout[]; isEqual?: boolean }) => {
<div class={`col-md-${props.isEqual ? '6' : x[y()][i()]}`}> <div class={`col-md-${props.isEqual ? '6' : x[y()][i()]}`}>
<ArticleCard <ArticleCard
article={a} article={a}
settings={{ isWithCover: props.isEqual || x[y()][i()] === '8' }} settings={{ isWithCover: props.isEqual || x[y()][i()] === '8', nodate: props.isEqual }}
/> />
</div> </div>
</Show> </Show>

View File

@ -0,0 +1,3 @@
.mainContent {
padding-top: 100px;
}

View File

@ -5,6 +5,7 @@ import { createSignal, onCleanup, onMount, Show } from 'solid-js'
import { loadShoutsBy, resetSortedArticles } from '../../stores/zine/articles' import { loadShoutsBy, resetSortedArticles } from '../../stores/zine/articles'
import { loadRandomTopics } from '../../stores/zine/topics' import { loadRandomTopics } from '../../stores/zine/topics'
import { Loading } from '../Loading' import { Loading } from '../Loading'
import styles from './HomePage.module.scss'
export const HomePage = (props: PageProps) => { export const HomePage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.randomTopics)) const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.randomTopics))
@ -23,7 +24,7 @@ export const HomePage = (props: PageProps) => {
onCleanup(() => resetSortedArticles()) onCleanup(() => resetSortedArticles())
return ( return (
<PageWrap> <PageWrap class={styles.mainContent}>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<HomeView randomTopics={props.randomTopics} shouts={props.shouts || []} /> <HomeView randomTopics={props.randomTopics} shouts={props.shouts || []} />
</Show> </Show>

View File

@ -28,6 +28,7 @@
@include font-size(2.2rem); @include font-size(2.2rem);
margin-bottom: 1.2rem; margin-bottom: 1.2rem;
margin-top: 0.5rem !important;
} }
.topicAvatar { .topicAvatar {
@ -104,3 +105,13 @@
text-align: right; text-align: right;
} }
} }
.topicCompact {
.topicTitle {
@include font-size(1.7rem);
}
}
.buttonCompact {
margin-top: 0.6rem;
}

View File

@ -21,6 +21,7 @@ interface TopicProps {
additionalClass?: string additionalClass?: string
isTopicInRow?: boolean isTopicInRow?: boolean
iconButton?: boolean iconButton?: boolean
showPublications?: boolean
} }
export const TopicCard = (props: TopicProps) => { export const TopicCard = (props: TopicProps) => {
@ -47,6 +48,7 @@ export const TopicCard = (props: TopicProps) => {
class={styles.topic} class={styles.topic}
classList={{ classList={{
row: !props.compact && !props.subscribeButtonBottom, row: !props.compact && !props.subscribeButtonBottom,
[styles.topicCompact]: props.compact,
[styles.topicInRow]: props.isTopicInRow [styles.topicInRow]: props.isTopicInRow
}} }}
> >
@ -75,7 +77,7 @@ export const TopicCard = (props: TopicProps) => {
<Show when={props.topic?.stat}> <Show when={props.topic?.stat}>
<div class={styles.topicDetails}> <div class={styles.topicDetails}>
<Show when={!props.compact}> <Show when={props.showPublications}>
<span class={styles.topicDetailsItem} classList={{ compact: props.compact }}> <span class={styles.topicDetailsItem} classList={{ compact: props.compact }}>
{props.topic.stat?.shouts + {props.topic.stat?.shouts +
' ' + ' ' +
@ -85,6 +87,8 @@ export const TopicCard = (props: TopicProps) => {
locale() === 'ru' ? ['ов', '', 'а'] : ['s', '', 's'] locale() === 'ru' ? ['ов', '', 'а'] : ['s', '', 's']
)} )}
</span> </span>
</Show>
<Show when={!props.compact}>
<span class={styles.topicDetailsItem} classList={{ compact: props.compact }}> <span class={styles.topicDetailsItem} classList={{ compact: props.compact }}>
{props.topic.stat?.authors + {props.topic.stat?.authors +
' ' + ' ' +
@ -132,19 +136,30 @@ export const TopicCard = (props: TopicProps) => {
class={styles.controlContainer} class={styles.controlContainer}
classList={{ 'col-md-3': !props.compact && !props.subscribeButtonBottom }} classList={{ 'col-md-3': !props.compact && !props.subscribeButtonBottom }}
> >
{}
<Show <Show
when={subscribed()} when={subscribed()}
fallback={ fallback={
<button onClick={() => subscribe(true)} class="button--light button--subscribe-topic"> <button
onClick={() => subscribe(true)}
class="button--light button--subscribe-topic"
classList={{
[styles.buttonCompact]: props.compact
}}
>
<Show when={props.iconButton}>+</Show> <Show when={props.iconButton}>+</Show>
<Show when={!props.iconButton}>{t('Follow')}</Show> <Show when={!props.iconButton}>{t('Follow')}</Show>
</button> </button>
} }
> >
<button onClick={() => subscribe(false)} class="button--light button--subscribe-topic"> <button
onClick={() => subscribe(false)}
class="button--light button--subscribe-topic"
classList={{
[styles.buttonCompact]: props.compact
}}
>
<Show when={props.iconButton}>-</Show> <Show when={props.iconButton}>-</Show>
<Show when={!props.iconButton}>{t('Unfollow')}</Show> <Show when={!props.iconButton}>{t('Unfollow')}</Show>
</button> </button>
</Show> </Show>

View File

@ -1,7 +1,7 @@
.topicHeader { .topicHeader {
@include font-size(1.7rem); @include font-size(1.7rem);
padding-top: 5.8rem; padding-top: 2.8rem;
text-align: center; text-align: center;
h1 { h1 {

View File

@ -109,6 +109,7 @@ export const AllAuthorsView = (props: Props) => {
subscribed={subscribed(author.slug)} subscribed={subscribed(author.slug)}
noSocialButtons={true} noSocialButtons={true}
isAuthorsList={true} isAuthorsList={true}
truncateBio={true}
/> />
)} )}
</For> </For>
@ -118,7 +119,7 @@ export const AllAuthorsView = (props: Props) => {
<div class="row"> <div class="row">
<div class={clsx(styles.loadMoreContainer, 'col-12 col-md-10')}> <div class={clsx(styles.loadMoreContainer, 'col-12 col-md-10')}>
<button class={clsx('button', styles.loadMoreButton)} onClick={showMore}> <button class={clsx('button', styles.loadMoreButton)} onClick={showMore}>
{t('More')} {t('Load more')}
</button> </button>
</div> </div>
</div> </div>

View File

@ -113,7 +113,7 @@ export const AllTopicsView = (props: AllTopicsViewProps) => {
<div class="row"> <div class="row">
<div class={clsx(styles.loadMoreContainer, 'col-12 col-md-10')}> <div class={clsx(styles.loadMoreContainer, 'col-12 col-md-10')}>
<button class={clsx('button', styles.loadMoreButton)} onClick={showMore}> <button class={clsx('button', styles.loadMoreButton)} onClick={showMore}>
{t('More')} {t('Load more')}
</button> </button>
</div> </div>
</div> </div>

View File

@ -69,14 +69,7 @@ export const HomeView = (props: HomeProps) => {
return ( return (
<Show when={Boolean(selectedRandomLayout)}> <Show when={Boolean(selectedRandomLayout)}>
<Group <Group articles={articlesByLayout()[selectedRandomLayout]} header={''} />
articles={articlesByLayout()[selectedRandomLayout]}
header={
<div class="layout-icon">
<Icon name={selectedRandomLayout} />
</div>
}
/>
</Show> </Show>
) )
}) })

View File

@ -4,12 +4,14 @@ import { Footer } from '../Discours/Footer'
import '../../styles/app.scss' import '../../styles/app.scss'
import { Show } from 'solid-js' import { Show } from 'solid-js'
import { clsx } from 'clsx'
type PageWrapProps = { type PageWrapProps = {
headerTitle?: string headerTitle?: string
children: JSX.Element children: JSX.Element
isHeaderFixed?: boolean isHeaderFixed?: boolean
hideFooter?: boolean hideFooter?: boolean
class?: string
} }
export const PageWrap = (props: PageWrapProps) => { export const PageWrap = (props: PageWrapProps) => {
@ -18,7 +20,10 @@ export const PageWrap = (props: PageWrapProps) => {
return ( return (
<> <>
<Header title={props.headerTitle} isHeaderFixed={isHeaderFixed} /> <Header title={props.headerTitle} isHeaderFixed={isHeaderFixed} />
<main class="main-content" classList={{ 'main-content--no-padding': !isHeaderFixed }}> <main
class={clsx('main-content', props.class)}
classList={{ 'main-content--no-padding': !isHeaderFixed }}
>
{props.children} {props.children}
</main> </main>
<Show when={props.hideFooter !== true}> <Show when={props.hideFooter !== true}>

View File

@ -4,6 +4,7 @@
"All": "Все", "All": "Все",
"All posts": "Все публикации", "All posts": "Все публикации",
"All topics": "Все темы", "All topics": "Все темы",
"All authors": "Все авторы",
"Authors": "Авторы", "Authors": "Авторы",
"Back to mainpage": "Вернуться на главную", "Back to mainpage": "Вернуться на главную",
"Become an author": "Стать автором", "Become an author": "Стать автором",

View File

@ -39,7 +39,7 @@
text-align: center; text-align: center;
.loadMoreButton { .loadMoreButton {
padding: 0.6em 5em; padding: 0.6em 3em;
width: 100%; width: 100%;
@include media-breakpoint-up(sm) { @include media-breakpoint-up(sm) {

View File

@ -232,7 +232,6 @@ button {
font-weight: 400; font-weight: 400;
height: auto; height: auto;
margin-top: 0.6rem;
padding: 0.6rem 1.2rem 0.6rem 1rem; padding: 0.6rem 1.2rem 0.6rem 1rem;
} }
@ -641,7 +640,7 @@ astro-island {
.main-content { .main-content {
flex: 1 100%; flex: 1 100%;
min-height: 300px; min-height: 300px;
padding-top: 100px; padding-top: 120px;
position: relative; position: relative;
} }