From 73d8d1ef2773531e39a4a1e5d0d29a9285ea2402 Mon Sep 17 00:00:00 2001 From: Ilya Y <75578537+ilya-bkv@users.noreply.github.com> Date: Wed, 1 Nov 2023 19:10:19 +0300 Subject: [PATCH] Follow topic btn (#291) * Follow topic btn --- src/components/Topic/Full.module.scss | 18 +++++++---- src/components/Topic/Full.tsx | 32 ++++++++++--------- .../_shared/Button/Button.module.scss | 4 +-- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/components/Topic/Full.module.scss b/src/components/Topic/Full.module.scss index 3cf0420e..5f8a049c 100644 --- a/src/components/Topic/Full.module.scss +++ b/src/components/Topic/Full.module.scss @@ -15,16 +15,22 @@ .topicActions { margin-top: 2.8rem; - button, - a { - background: #000; + .write { + display: inline-flex; + align-items: center; + justify-content: center; + height: 40px; + min-width: 64px; + font-size: 17px; + padding: 8px 16px; + + background: var(--background-color-invert); + color: var(--default-color-invert); border: none; + font-weight: 500; border-radius: 2px; - color: #fff; cursor: pointer; - font-size: 100%; margin: 0 1.2rem 1em; - padding: 0.8rem 1.6rem; white-space: nowrap; } } diff --git a/src/components/Topic/Full.tsx b/src/components/Topic/Full.tsx index 0c512497..9ce2a389 100644 --- a/src/components/Topic/Full.tsx +++ b/src/components/Topic/Full.tsx @@ -7,6 +7,7 @@ import { follow, unfollow } from '../../stores/zine/common' import { clsx } from 'clsx' import { useSession } from '../../context/session' import { useLocalize } from '../../context/localize' +import { Button } from '../_shared/Button' type Props = { topic: Topic @@ -15,7 +16,7 @@ type Props = { export const FullTopic = (props: Props) => { const { subscriptions, - actions: { requireAuthentication } + actions: { requireAuthentication, loadSubscriptions } } = useSession() const { t } = useLocalize() @@ -24,13 +25,12 @@ export const FullTopic = (props: Props) => { subscriptions().topics.some((topic) => topic.slug === props.topic?.slug) ) - const handleSubscribe = (isFollowed: boolean) => { - requireAuthentication(() => { - if (isFollowed) { - unfollow({ what: FollowingEntity.Topic, slug: props.topic.slug }) - } else { - follow({ what: FollowingEntity.Topic, slug: props.topic.slug }) - } + const handleSubscribe = (really: boolean) => { + requireAuthentication(async () => { + await (really + ? follow({ what: FollowingEntity.Topic, slug: props.topic.slug }) + : unfollow({ what: FollowingEntity.Topic, slug: props.topic.slug })) + loadSubscriptions() }, 'follow') } @@ -40,16 +40,18 @@ export const FullTopic = (props: Props) => {

{props.topic.body}

- + +
{props.topic.title} diff --git a/src/components/_shared/Button/Button.module.scss b/src/components/_shared/Button/Button.module.scss index 51498b5f..6f9ca1af 100644 --- a/src/components/_shared/Button/Button.module.scss +++ b/src/components/_shared/Button/Button.module.scss @@ -8,8 +8,8 @@ white-space: nowrap; &.primary { - background: #000; - color: #fff; + background: var(--background-color-invert); + color: var(--default-color-invert); &:hover { color: #ccc;