From 6871b1a146379e0aad1ddc3f663dd34b4e02f3af Mon Sep 17 00:00:00 2001 From: kvakazyambra Date: Sun, 18 Jun 2023 21:02:11 +0300 Subject: [PATCH] Added snackbars to subscription and copy link in the share popup --- public/locales/en/translation.json | 2 ++ public/locales/ru/translation.json | 2 ++ src/components/Article/SharePopup.tsx | 6 ++++++ src/components/Discours/Subscribe.tsx | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 4aa8a024..8ec92dcd 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -52,6 +52,7 @@ "Cooperate": "Cooperate", "Copy": "Copy", "Copy link": "Copy link", + "Link copied": "Link copied", "Corrections history": "Corrections history", "Create Chat": "Create Chat", "Create Group": "Create a group", @@ -245,6 +246,7 @@ "Terms of use": "Site rules", "Text checking": "Text checking", "Thank you": "Thank you", + "Thank you for subscribing": "Thank you for subscribing", "This comment has not yet been rated": "This comment has not yet been rated", "This email is already taken. If it's you": "This email is already taken. If it's you", "This functionality is currently not available, we would like to work on this issue. Use the download link.": "This functionality is currently not available, we would like to work on this issue. Use the download link.", diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index b153ab42..eead45a2 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -55,6 +55,7 @@ "Cooperate": "Соучаствовать", "Copy": "Скопировать", "Copy link": "Скопировать ссылку", + "Link copied": "Ссылка скопирована", "Corrections history": "История правок", "Create Chat": "Создать чат", "Create Group": "Создать группу", @@ -259,6 +260,7 @@ "Terms of use": "Правила сайта", "Text checking": "Проверка текста", "Thank you": "Благодарности", + "Thank you for subscribing": "Спасибо, что подписались на рассылку", "This comment has not yet been rated": "Этот комментарий еще пока никто не оценил", "This email is already taken. If it's you": "Такой email уже зарегистрирован. Если это вы", "This functionality is currently not available, we would like to work on this issue. Use the download link.": "В данный момент этот функционал недоступен, мы работаем над этой проблемой. Воспользуйтесь загрузкой по ссылке.", diff --git a/src/components/Article/SharePopup.tsx b/src/components/Article/SharePopup.tsx index f7d5d4e6..d4da06e5 100644 --- a/src/components/Article/SharePopup.tsx +++ b/src/components/Article/SharePopup.tsx @@ -6,6 +6,7 @@ import type { PopupProps } from '../_shared/Popup' import { Popup } from '../_shared/Popup' import { useLocalize } from '../../context/localize' import { createEffect, createSignal } from 'solid-js' +import { useSnackbar } from '../../context/snackbar' type SharePopupProps = { title: string @@ -24,6 +25,9 @@ export const getShareUrl = (params: { pathname?: string } = {}) => { export const SharePopup = (props: SharePopupProps) => { const { t } = useLocalize() const [isVisible, setIsVisible] = createSignal(false) + const { + actions: { showSnackbar } + } = useSnackbar() createEffect(() => { if (props.isVisible) { @@ -36,8 +40,10 @@ export const SharePopup = (props: SharePopupProps) => { url: props.shareUrl, description: props.description })) + const copyLink = async () => { await navigator.clipboard.writeText(props.shareUrl) + showSnackbar({ body: t('Link copied') }) } return ( diff --git a/src/components/Discours/Subscribe.tsx b/src/components/Discours/Subscribe.tsx index 32a9e5c8..0d794589 100644 --- a/src/components/Discours/Subscribe.tsx +++ b/src/components/Discours/Subscribe.tsx @@ -5,6 +5,7 @@ import { isValidEmail } from '../../utils/validators' import { Button } from '../_shared/Button' import styles from './Subscribe.module.scss' +import { useSnackbar } from '../../context/snackbar' export default () => { const { t } = useLocalize() @@ -12,6 +13,9 @@ export default () => { const [title, setTitle] = createSignal('') const [email, setEmail] = createSignal('') const [emailError, setEmailError] = createSignal(null) + const { + actions: { showSnackbar } + } = useSnackbar() const validate = (): boolean => { if (!email()) { @@ -52,6 +56,7 @@ export default () => { if (response.ok) { setTitle(t('You are subscribed')) + showSnackbar({ body: t('Thank you for subscribing') }) } else { if (response.status === 400) { setEmailError(t('Please check your email address'))