Topic header fixes

This commit is contained in:
kvakazyambra 2024-05-10 17:14:06 +03:00
parent 7d24fe5598
commit 9ec36168ae
7 changed files with 169 additions and 120 deletions

View File

@ -429,64 +429,6 @@
} }
} }
.subscribersContainer {
display: flex;
flex-wrap: wrap;
font-size: 1.4rem;
margin-top: 1.5rem;
@include media-breakpoint-down(md) {
justify-content: center;
}
}
.subscribers {
align-items: center;
cursor: pointer;
display: inline-flex;
margin: 0 2% 1rem;
vertical-align: top;
border-bottom: unset !important;
&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
.subscribersItem {
position: relative;
&:nth-child(1) {
z-index: 2;
}
&:nth-child(2) {
z-index: 1;
}
&:not(:last-child) {
margin-right: -4px;
box-shadow: 0 0 0 1px var(--background-color);
}
}
.subscribersCounter {
font-weight: 500;
margin-left: 1rem;
}
&:hover {
background: none !important;
.subscribersCounter {
background: var(--background-color-invert);
}
}
}
.listWrapper { .listWrapper {
max-height: 70vh; max-height: 70vh;
} }

View File

@ -18,6 +18,7 @@ import { Modal } from '../../Nav/Modal'
import { TopicBadge } from '../../Topic/TopicBadge' import { TopicBadge } from '../../Topic/TopicBadge'
import { Button } from '../../_shared/Button' import { Button } from '../../_shared/Button'
import { ShowOnlyOnClient } from '../../_shared/ShowOnlyOnClient' import { ShowOnlyOnClient } from '../../_shared/ShowOnlyOnClient'
import { Subscribers } from '../../_shared/Subscribers'
import { AuthorBadge } from '../AuthorBadge' import { AuthorBadge } from '../AuthorBadge'
import { Userpic } from '../Userpic' import { Userpic } from '../Userpic'
@ -126,59 +127,7 @@ export const AuthorCard = (props: Props) => {
<div class={styles.authorAbout} innerHTML={props.author.bio} /> <div class={styles.authorAbout} innerHTML={props.author.bio} />
</Show> </Show>
<Show when={props.followers?.length > 0 || props.following?.length > 0}> <Show when={props.followers?.length > 0 || props.following?.length > 0}>
<div class={styles.subscribersContainer}> <Subscribers followers={props.followers} following={props.following} />
<Show when={props.followers && props.followers.length > 0}>
<a href="?m=followers" class={styles.subscribers}>
<For each={props.followers.slice(0, 3)}>
{(f) => (
<Userpic size={'XS'} name={f.name} userpic={f.pic} class={styles.subscribersItem} />
)}
</For>
<div class={styles.subscribersCounter}>
{t('SubscriberWithCount', {
count: props.followers.length ?? 0,
})}
</div>
</a>
</Show>
<Show when={props.following && props.following.length > 0}>
<a href="?m=following" class={styles.subscribers}>
<For each={props.following.slice(0, 3)}>
{(f) => {
if ('name' in f) {
return (
<Userpic
size={'XS'}
name={f.name}
userpic={f.pic}
class={styles.subscribersItem}
/>
)
}
if ('title' in f) {
return (
<Userpic
size={'XS'}
name={f.title}
userpic={f.pic}
class={styles.subscribersItem}
/>
)
}
return null
}}
</For>
<div class={styles.subscribersCounter}>
{t('SubscriptionWithCount', {
count: props?.following.length ?? 0,
})}
</div>
</a>
</Show>
</div>
</Show> </Show>
</div> </div>
<ShowOnlyOnClient> <ShowOnlyOnClient>

View File

@ -1,6 +1,5 @@
.topicHeader { .topicHeader {
@include font-size(1.7rem); font-weight: 500;
padding: 2.8rem $container-padding-x 0; padding: 2.8rem $container-padding-x 0;
text-align: center; text-align: center;
@ -12,10 +11,16 @@
} }
} }
.topicDescription {
@include font-size(1.8rem);
line-height: 1.4;
margin: 1rem 0 2rem;
}
.topicActions { .topicActions {
margin-top: 2.8rem; margin-top: 2.8rem;
.write { .writeControl {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -23,13 +28,34 @@
min-width: 64px; min-width: 64px;
font-size: 17px; font-size: 17px;
padding: 8px 16px; padding: 8px 16px;
background: var(--background-color-invert); border: 1px solid #f7f7f7;
color: var(--default-color-invert); background: #f7f7f7;
border: none; color: var(--default-color);
font-weight: 500; font-weight: 500;
border-radius: 2px;
cursor: pointer; cursor: pointer;
margin: 0 1.2rem 1em; margin: 0 1.2rem 1em;
white-space: nowrap; white-space: nowrap;
} }
.followControl,
.writeControl {
border-radius: 0.8rem;
}
}
.topicDetails {
display: flex;
flex-wrap: wrap;
font-size: 1.4rem;
justify-content: center;
gap: 4rem;
margin-top: 1.5rem;
}
.topicDetailsItem {
display: flex;
}
.topicDetailsIcon {
} }

View File

@ -9,6 +9,8 @@ import { useSession } from '../../context/session'
import { FollowingEntity } from '../../graphql/schema/core.gen' import { FollowingEntity } from '../../graphql/schema/core.gen'
import { Button } from '../_shared/Button' import { Button } from '../_shared/Button'
import { Icon } from '../_shared/Icon'
import { Subscribers } from '../_shared/Subscribers'
import styles from './Full.module.scss' import styles from './Full.module.scss'
type Props = { type Props = {
@ -40,14 +42,29 @@ export const FullTopic = (props: Props) => {
return ( return (
<div class={clsx(styles.topicHeader, 'col-md-16 col-lg-12 offset-md-4 offset-lg-6')}> <div class={clsx(styles.topicHeader, 'col-md-16 col-lg-12 offset-md-4 offset-lg-6')}>
<h1>#{props.topic?.title}</h1> <h1>#{props.topic?.title}</h1>
<p innerHTML={props.topic?.body} /> <p class={styles.topicDescription} innerHTML={props.topic?.body} />
<div class={styles.topicDetails}>
<Show when={props.topic?.stat}>
<div class={styles.topicDetailsItem}>
<Icon name="feed-all" class={styles.topicDetailsIcon} />
{t('PublicationsWithCount', {
count: props.topic?.stat.shouts ?? 0,
})}
</div>
</Show>
<Subscribers followers={props.topic?.followers} following={props.topic?.following} />
</div>
<div class={clsx(styles.topicActions)}> <div class={clsx(styles.topicActions)}>
<Button <Button
variant="primary" variant="primary"
onClick={handleFollowClick} onClick={handleFollowClick}
value={followed() ? t('Unfollow the topic') : t('Follow the topic')} value={followed() ? t('Unfollow the topic') : t('Follow the topic')}
class={styles.followControl}
/> />
<a class={styles.write} href={`/create/?topicId=${props.topic?.id}`}> <a class={styles.writeControl} href={`/create/?topicId=${props.topic?.id}`}>
{t('Write about the topic')} {t('Write about the topic')}
</a> </a>
</div> </div>

View File

@ -0,0 +1,57 @@
.subscribersContainer {
display: flex;
flex-wrap: wrap;
font-size: 1.4rem;
margin-top: 1.5rem;
@include media-breakpoint-down(md) {
justify-content: center;
}
}
.subscribers {
align-items: center;
cursor: pointer;
display: inline-flex;
margin: 0 2% 1rem;
vertical-align: top;
border-bottom: unset !important;
&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
.subscribersItem {
position: relative;
&:nth-child(1) {
z-index: 2;
}
&:nth-child(2) {
z-index: 1;
}
&:not(:last-child) {
margin-right: -4px;
box-shadow: 0 0 0 1px var(--background-color);
}
}
.subscribersCounter {
font-weight: 500;
margin-left: 1rem;
}
&:hover {
background: none !important;
.subscribersCounter {
background: var(--background-color-invert);
}
}
}

View File

@ -0,0 +1,57 @@
import { For, Show } from 'solid-js'
import { useLocalize } from '../../../context/localize'
import { Author, Topic } from '../../../graphql/schema/core.gen'
import { Userpic } from '../../Author/Userpic'
import styles from './Subscribers.module.scss'
type Props = {
followers: Author[]
following?: Array<Author | Topic>
}
export const Subscribers = (props: Props) => {
const { t } = useLocalize()
return (
<div class={styles.subscribersContainer}>
<Show when={props.followers && props.followers.length > 0}>
<a href="?m=followers" class={styles.subscribers}>
<For each={props.followers.slice(0, 3)}>
{(f) => <Userpic size={'XS'} name={f.name} userpic={f.pic} class={styles.subscribersItem} />}
</For>
<div class={styles.subscribersCounter}>
{t('SubscriberWithCount', {
count: props.followers.length ?? 0,
})}
</div>
</a>
</Show>
<Show when={props.following && props.following.length > 0}>
<a href="?m=following" class={styles.subscribers}>
<For each={props.following.slice(0, 3)}>
{(f) => {
if ('name' in f) {
return <Userpic size={'XS'} name={f.name} userpic={f.pic} class={styles.subscribersItem} />
}
if ('title' in f) {
return <Userpic size={'XS'} name={f.title} userpic={f.pic} class={styles.subscribersItem} />
}
return null
}}
</For>
<div class={styles.subscribersCounter}>
{t('SubscriptionWithCount', {
count: props?.following.length ?? 0,
})}
</div>
</a>
</Show>
</div>
)
}

View File

@ -0,0 +1 @@
export { Subscribers } from './Subscribers'