Fix/hydration (#315)

hydration fix

---------

Co-authored-by: Igor Lobanov <igor.lobanov@onetwotrip.com>
This commit is contained in:
Ilya Y 2023-11-14 10:47:22 +03:00 committed by GitHub
parent 3f3bd798e6
commit 37a8805b8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 30 deletions

View File

@ -64,18 +64,7 @@ export const AuthorBadge = (props: Props) => {
return isSubscribing() ? t('subscribing...') : t('Subscribe')
})
const unsubscribeValue = createMemo(() => {
if (props.iconButtons) {
return <Icon name="author-unsubscribe" class={stylesButton.icon} />
}
return (
<>
<span class={styles.actionButtonLabel}>{t('Following')}</span>
<span class={styles.actionButtonLabelHovered}>{t('Unfollow')}</span>
</>
)
})
const unsubscribeValue = () => {}
return (
<div class={clsx(styles.AuthorBadge, { [styles.nameOnly]: props.nameOnly })}>
@ -142,7 +131,19 @@ export const AuthorBadge = (props: Props) => {
<Button
variant={props.iconButtons ? 'secondary' : 'bordered'}
size="M"
value={unsubscribeValue()}
value={
<Show
when={props.iconButtons}
fallback={
<>
<span class={styles.actionButtonLabel}>{t('Following')}</span>
<span class={styles.actionButtonLabelHovered}>{t('Unfollow')}</span>
</>
}
>
<Icon name="author-unsubscribe" class={stylesButton.icon} />
</Show>
}
onClick={() => handleSubscribe(false)}
isSubscribeButton={true}
class={clsx(styles.actionButton, {

View File

@ -528,9 +528,8 @@ export const Header = (props: Props) => {
</ul>
</div>
</nav>
<ShowOnlyOnClient>
<Snackbar />
</ShowOnlyOnClient>
<Snackbar />
</div>
</header>
)

View File

@ -4,6 +4,7 @@ import styles from './Snackbar.module.scss'
import { Transition } from 'solid-transition-group'
import { clsx } from 'clsx'
import { Icon } from '../_shared/Icon'
import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient'
export const Snackbar = () => {
const { snackbarMessage } = useSnackbar()
@ -15,20 +16,22 @@ export const Snackbar = () => {
[styles.success]: snackbarMessage()?.type === 'success'
})}
>
<Transition
enterClass={styles.enter}
exitToClass={styles.exitTo}
onExit={(el, done) => setTimeout(() => done(), 300)}
>
<Show when={snackbarMessage()}>
<div class={styles.content}>
<Show when={snackbarMessage()?.type === 'success'}>
<Icon name="check-success" class={styles.icon} />
</Show>
{snackbarMessage().body}
</div>
</Show>
</Transition>
<ShowOnlyOnClient>
<Transition
enterClass={styles.enter}
exitToClass={styles.exitTo}
onExit={(el, done) => setTimeout(() => done(), 300)}
>
<Show when={snackbarMessage()}>
<div class={styles.content}>
<Show when={snackbarMessage()?.type === 'success'}>
<Icon name="check-success" class={styles.icon} />
</Show>
{snackbarMessage().body}
</div>
</Show>
</Transition>
</ShowOnlyOnClient>
</div>
)
}