Message header - clickable avatar (#287)
* Message header - clickable avatar * Hide cancel button in messenger
This commit is contained in:
parent
c806c6e304
commit
d79716bde0
|
@ -5,6 +5,13 @@
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
|
||||||
|
&.nameOnly {
|
||||||
|
align-items: center;
|
||||||
|
.info {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@include media-breakpoint-down(sm) {
|
@include media-breakpoint-down(sm) {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
margin-bottom: 3rem;
|
margin-bottom: 3rem;
|
||||||
|
|
|
@ -17,6 +17,7 @@ type Props = {
|
||||||
minimizeSubscribeButton?: boolean
|
minimizeSubscribeButton?: boolean
|
||||||
showMessageButton?: boolean
|
showMessageButton?: boolean
|
||||||
iconButtons?: boolean
|
iconButtons?: boolean
|
||||||
|
nameOnly?: boolean
|
||||||
}
|
}
|
||||||
export const AuthorBadge = (props: Props) => {
|
export const AuthorBadge = (props: Props) => {
|
||||||
const [isSubscribing, setIsSubscribing] = createSignal(false)
|
const [isSubscribing, setIsSubscribing] = createSignal(false)
|
||||||
|
@ -63,7 +64,7 @@ export const AuthorBadge = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={clsx(styles.AuthorBadge)}>
|
<div class={clsx(styles.AuthorBadge, { [styles.nameOnly]: props.nameOnly })}>
|
||||||
<Userpic
|
<Userpic
|
||||||
hasLink={true}
|
hasLink={true}
|
||||||
size={'M'}
|
size={'M'}
|
||||||
|
@ -75,24 +76,26 @@ export const AuthorBadge = (props: Props) => {
|
||||||
<div class={styles.name}>
|
<div class={styles.name}>
|
||||||
<span>{props.author.name}</span>
|
<span>{props.author.name}</span>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
<Show when={!props.nameOnly}>
|
||||||
fallback={
|
<Switch
|
||||||
<div class={styles.bio}>
|
fallback={
|
||||||
{t('Registered since {date}', { date: formatDate(new Date(props.author.createdAt)) })}
|
<div class={styles.bio}>
|
||||||
</div>
|
{t('Registered since {date}', { date: formatDate(new Date(props.author.createdAt)) })}
|
||||||
}
|
</div>
|
||||||
>
|
}
|
||||||
<Match when={props.author.bio}>
|
>
|
||||||
<div class={clsx('text-truncate', styles.bio)} innerHTML={props.author.bio} />
|
<Match when={props.author.bio}>
|
||||||
</Match>
|
<div class={clsx('text-truncate', styles.bio)} innerHTML={props.author.bio} />
|
||||||
<Match when={props.author?.stat && props.author?.stat.shouts > 0}>
|
</Match>
|
||||||
<div class={styles.bio}>
|
<Match when={props.author?.stat && props.author?.stat.shouts > 0}>
|
||||||
{t('PublicationsWithCount', { count: props.author.stat?.shouts ?? 0 })}
|
<div class={styles.bio}>
|
||||||
</div>
|
{t('PublicationsWithCount', { count: props.author.stat?.shouts ?? 0 })}
|
||||||
</Match>
|
</div>
|
||||||
</Switch>
|
</Match>
|
||||||
|
</Switch>
|
||||||
|
</Show>
|
||||||
</a>
|
</a>
|
||||||
<Show when={props.author.slug !== session()?.user.slug}>
|
<Show when={props.author.slug !== session()?.user.slug && !props.nameOnly}>
|
||||||
<div class={styles.actions}>
|
<div class={styles.actions}>
|
||||||
<Show
|
<Show
|
||||||
when={!props.minimizeSubscribeButton}
|
when={!props.minimizeSubscribeButton}
|
||||||
|
|
|
@ -55,7 +55,7 @@ export const Userpic = (props: Props) => {
|
||||||
condition={props.hasLink}
|
condition={props.hasLink}
|
||||||
wrapper={(children) => <a href={`/author/${props.slug}`}>{children}</a>}
|
wrapper={(children) => <a href={`/author/${props.slug}`}>{children}</a>}
|
||||||
>
|
>
|
||||||
<Show when={props.userpic} fallback={<div class={styles.letters}>{letters()}</div>}>
|
<Show keyed={true} when={props.userpic} fallback={<div class={styles.letters}>{letters()}</div>}>
|
||||||
<Image src={props.userpic} width={avatarSize()} height={avatarSize()} alt={props.name} />
|
<Image src={props.userpic} width={avatarSize()} height={avatarSize()} alt={props.name} />
|
||||||
</Show>
|
</Show>
|
||||||
</ConditionalWrapper>
|
</ConditionalWrapper>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { createEffect, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
import { createEffect, createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
||||||
import { Portal } from 'solid-js/web'
|
import { Portal } from 'solid-js/web'
|
||||||
import {
|
import {
|
||||||
createEditorTransaction,
|
createEditorTransaction,
|
||||||
|
@ -53,6 +53,7 @@ type Props = {
|
||||||
onlyBubbleControls?: boolean
|
onlyBubbleControls?: boolean
|
||||||
controlsAlwaysVisible?: boolean
|
controlsAlwaysVisible?: boolean
|
||||||
autoFocus?: boolean
|
autoFocus?: boolean
|
||||||
|
isCancelButtonVisible: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MAX_DESCRIPTION_LIMIT = 400
|
export const MAX_DESCRIPTION_LIMIT = 400
|
||||||
|
@ -61,6 +62,7 @@ const SimplifiedEditor = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const [counter, setCounter] = createSignal<number>()
|
const [counter, setCounter] = createSignal<number>()
|
||||||
|
|
||||||
|
const isCancelButtonVisible = createMemo(() => props.isCancelButtonVisible !== false)
|
||||||
const wrapperEditorElRef: {
|
const wrapperEditorElRef: {
|
||||||
current: HTMLElement
|
current: HTMLElement
|
||||||
} = {
|
} = {
|
||||||
|
@ -327,7 +329,9 @@ const SimplifiedEditor = (props: Props) => {
|
||||||
</div>
|
</div>
|
||||||
<Show when={!props.onChange}>
|
<Show when={!props.onChange}>
|
||||||
<div class={styles.buttons}>
|
<div class={styles.buttons}>
|
||||||
<Button value={t('Cancel')} variant="secondary" onClick={handleClear} />
|
<Show when={isCancelButtonVisible()}>
|
||||||
|
<Button value={t('Cancel')} variant="secondary" onClick={handleClear} />
|
||||||
|
</Show>
|
||||||
<Button
|
<Button
|
||||||
value={props.submitButtonText ?? t('Send')}
|
value={props.submitButtonText ?? t('Send')}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
|
|
|
@ -5,6 +5,7 @@ import GroupDialogAvatar from './GroupDialogAvatar'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
import styles from './DialogCard.module.scss'
|
import styles from './DialogCard.module.scss'
|
||||||
import { useLocalize } from '../../context/localize'
|
import { useLocalize } from '../../context/localize'
|
||||||
|
import { AuthorBadge } from '../Author/AuthorBadge'
|
||||||
|
|
||||||
type DialogProps = {
|
type DialogProps = {
|
||||||
online?: boolean
|
online?: boolean
|
||||||
|
@ -40,27 +41,41 @@ const DialogCard = (props: DialogProps) => {
|
||||||
})}
|
})}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
>
|
>
|
||||||
<div class={styles.avatar}>
|
<Switch
|
||||||
<Switch fallback={<DialogAvatar name={props.members[0].slug} url={props.members[0].userpic} />}>
|
fallback={
|
||||||
<Match when={props.members.length >= 3}>
|
<Show
|
||||||
|
when={props.isChatHeader}
|
||||||
|
fallback={
|
||||||
|
<div class={styles.avatar}>
|
||||||
|
<DialogAvatar name={props.members[0].slug} url={props.members[0].userpic} />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<AuthorBadge nameOnly={true} author={props.members[0]} />
|
||||||
|
</Show>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Match when={props.members.length >= 3}>
|
||||||
|
<div class={styles.avatar}>
|
||||||
<GroupDialogAvatar users={props.members} />
|
<GroupDialogAvatar users={props.members} />
|
||||||
</Match>
|
</div>
|
||||||
</Switch>
|
</Match>
|
||||||
</div>
|
</Switch>
|
||||||
<div class={styles.row}>
|
|
||||||
<div class={styles.name}>
|
|
||||||
{companions()?.length > 1 ? t('Group Chat') : companions()[0]?.name}
|
|
||||||
</div>
|
|
||||||
<div class={styles.message}>
|
|
||||||
<Switch>
|
|
||||||
<Match when={props.message && !props.isChatHeader}>
|
|
||||||
<div innerHTML={props.message} />
|
|
||||||
</Match>
|
|
||||||
<Match when={props.isChatHeader && companions().length > 1}>{names()}</Match>
|
|
||||||
</Switch>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Show when={!props.isChatHeader}>
|
<Show when={!props.isChatHeader}>
|
||||||
|
<div class={styles.row}>
|
||||||
|
<div class={styles.name}>
|
||||||
|
{companions()?.length > 1 ? t('Group Chat') : companions()[0]?.name}
|
||||||
|
</div>
|
||||||
|
<div class={styles.message}>
|
||||||
|
<Switch>
|
||||||
|
<Match when={props.message}>
|
||||||
|
<div innerHTML={props.message} />
|
||||||
|
</Match>
|
||||||
|
<Match when={props.isChatHeader && companions().length > 1}>{names()}</Match>
|
||||||
|
</Switch>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class={styles.activity}>
|
<div class={styles.activity}>
|
||||||
<Show when={props.lastUpdate}>
|
<Show when={props.lastUpdate}>
|
||||||
<div class={styles.time}>{formatTime(new Date(props.lastUpdate * 1000))}</div>
|
<div class={styles.time}>{formatTime(new Date(props.lastUpdate * 1000))}</div>
|
||||||
|
|
|
@ -266,6 +266,7 @@ export const InboxView = () => {
|
||||||
<SimplifiedEditor
|
<SimplifiedEditor
|
||||||
smallHeight={true}
|
smallHeight={true}
|
||||||
imageEnabled={true}
|
imageEnabled={true}
|
||||||
|
isCancelButtonVisible={false}
|
||||||
placeholder={t('Write message')}
|
placeholder={t('Write message')}
|
||||||
setClear={isClear()}
|
setClear={isClear()}
|
||||||
onSubmit={(message) => handleSubmit(message)}
|
onSubmit={(message) => handleSubmit(message)}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { splitProps } from 'solid-js'
|
import { createMemo, splitProps } from 'solid-js'
|
||||||
import type { JSX } from 'solid-js'
|
import type { JSX } from 'solid-js'
|
||||||
import { getImageUrl } from '../../../utils/getImageUrl'
|
import { getImageUrl } from '../../../utils/getImageUrl'
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@ type Props = JSX.ImgHTMLAttributes<HTMLImageElement> & {
|
||||||
|
|
||||||
export const Image = (props: Props) => {
|
export const Image = (props: Props) => {
|
||||||
const [local, others] = splitProps(props, ['src', 'alt'])
|
const [local, others] = splitProps(props, ['src', 'alt'])
|
||||||
|
|
||||||
const src = getImageUrl(local.src, { width: others.width })
|
const src = getImageUrl(local.src, { width: others.width })
|
||||||
|
|
||||||
return <img src={src} alt={local.alt} {...others} />
|
return <img src={src} alt={local.alt} {...others} />
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user