Long bio expanding on the author page
This commit is contained in:
parent
9e87a0f55c
commit
4d055064fb
|
@ -267,6 +267,7 @@
|
||||||
"Share": "Share",
|
"Share": "Share",
|
||||||
"Show": "Show",
|
"Show": "Show",
|
||||||
"Show lyrics": "Show lyrics",
|
"Show lyrics": "Show lyrics",
|
||||||
|
"Show more": "Show more",
|
||||||
"Show table of contents": "Show table of contents",
|
"Show table of contents": "Show table of contents",
|
||||||
"Slug": "Slug",
|
"Slug": "Slug",
|
||||||
"Social networks": "Social networks",
|
"Social networks": "Social networks",
|
||||||
|
|
|
@ -282,6 +282,7 @@
|
||||||
"Share": "Поделиться",
|
"Share": "Поделиться",
|
||||||
"Short opening": "Расскажите вашу историю...",
|
"Short opening": "Расскажите вашу историю...",
|
||||||
"Show": "Показать",
|
"Show": "Показать",
|
||||||
|
"Show more": "Читать дальше",
|
||||||
"Show lyrics": "Текст песни",
|
"Show lyrics": "Текст песни",
|
||||||
"Show table of contents": "Показать главление",
|
"Show table of contents": "Показать главление",
|
||||||
"Slug": "Постоянная ссылка",
|
"Slug": "Постоянная ссылка",
|
||||||
|
|
|
@ -53,3 +53,44 @@
|
||||||
.comment {
|
.comment {
|
||||||
background: #efefef;
|
background: #efefef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.longBio {
|
||||||
|
margin-bottom: 0;
|
||||||
|
max-height: 25em;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-bottom: 4em;
|
||||||
|
position: relative;
|
||||||
|
transition: max-height 0.5s, margin-bottom 0s 0.3s;
|
||||||
|
|
||||||
|
&:after {
|
||||||
|
background-image: linear-gradient(to top, #fff, rgb(255 255 255 / 0.8), rgb(255 255 255 / 0));
|
||||||
|
bottom: 0;
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
height: 4em;
|
||||||
|
left: 0;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.longBioExpanded {
|
||||||
|
max-height: 200em;
|
||||||
|
margin-bottom: -2em;
|
||||||
|
|
||||||
|
&:after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.longBioExpandedControl {
|
||||||
|
border-radius: 1.2rem;
|
||||||
|
display: block;
|
||||||
|
height: auto;
|
||||||
|
@include font-size(1.6rem);
|
||||||
|
padding-bottom: 1.2rem;
|
||||||
|
padding-top: 1.2rem;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
|
@ -40,8 +40,12 @@ export const AuthorView = (props: AuthorProps) => {
|
||||||
const author = createMemo(() => authorEntities()[props.authorSlug])
|
const author = createMemo(() => authorEntities()[props.authorSlug])
|
||||||
|
|
||||||
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
|
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
|
||||||
|
const [isBioExpanded, setIsBioExpanded] = createSignal(false)
|
||||||
const [followers, setFollowers] = createSignal<Author[]>([])
|
const [followers, setFollowers] = createSignal<Author[]>([])
|
||||||
const [subscriptions, setSubscriptions] = createSignal<Array<Author | Topic>>([])
|
const [subscriptions, setSubscriptions] = createSignal<Array<Author | Topic>>([])
|
||||||
|
const [bioWrapper, setBioWrapper] = createSignal<HTMLElement>()
|
||||||
|
const [bioContainer, setBioContainer] = createSignal<HTMLElement>()
|
||||||
|
const [showExpandBioControl, setShowExpandBioControl] = createSignal(false)
|
||||||
|
|
||||||
const fetchSubscriptions = async (): Promise<{ authors: Author[]; topics: Topic[] }> => {
|
const fetchSubscriptions = async (): Promise<{ authors: Author[]; topics: Topic[] }> => {
|
||||||
try {
|
try {
|
||||||
|
@ -58,6 +62,12 @@ export const AuthorView = (props: AuthorProps) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkBioHeight = () => {
|
||||||
|
if (bioContainer()) {
|
||||||
|
setShowExpandBioControl(bioContainer().offsetHeight > bioWrapper().offsetHeight)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
hideModal()
|
hideModal()
|
||||||
try {
|
try {
|
||||||
|
@ -66,6 +76,9 @@ export const AuthorView = (props: AuthorProps) => {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[getAuthorFollowers]', error)
|
console.error('[getAuthorFollowers]', error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkBioHeight()
|
||||||
|
|
||||||
if (!searchParams().by) {
|
if (!searchParams().by) {
|
||||||
changeSearchParam('by', 'rating')
|
changeSearchParam('by', 'rating')
|
||||||
}
|
}
|
||||||
|
@ -139,7 +152,13 @@ export const AuthorView = (props: AuthorProps) => {
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li classList={{ 'view-switcher__item--selected': searchParams().by === 'about' }}>
|
<li classList={{ 'view-switcher__item--selected': searchParams().by === 'about' }}>
|
||||||
<button type="button" onClick={() => changeSearchParam('by', 'about')}>
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
changeSearchParam('by', 'about')
|
||||||
|
checkBioHeight()
|
||||||
|
}}
|
||||||
|
>
|
||||||
{t('About myself')}
|
{t('About myself')}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
@ -157,7 +176,26 @@ export const AuthorView = (props: AuthorProps) => {
|
||||||
<Switch>
|
<Switch>
|
||||||
<Match when={searchParams().by === 'about'}>
|
<Match when={searchParams().by === 'about'}>
|
||||||
<div class="wide-container">
|
<div class="wide-container">
|
||||||
<p>{author().about}</p>
|
<div class="row">
|
||||||
|
<div class="col-md-20 col-lg-18">
|
||||||
|
<div
|
||||||
|
ref={setBioWrapper}
|
||||||
|
class={styles.longBio}
|
||||||
|
classList={{ [styles.longBioExpanded]: isBioExpanded() }}
|
||||||
|
>
|
||||||
|
<div ref={setBioContainer}>{author().about}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Show when={showExpandBioControl()}>
|
||||||
|
<button
|
||||||
|
class={clsx('button button--subscribe-topic', styles.longBioExpandedControl)}
|
||||||
|
onClick={() => setIsBioExpanded(!isBioExpanded())}
|
||||||
|
>
|
||||||
|
{t('Show more')}
|
||||||
|
</button>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={searchParams().by === 'commented'}>
|
<Match when={searchParams().by === 'commented'}>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user