From 429115a9b98cada6ba09ee5f4beeeb444820dc75 Mon Sep 17 00:00:00 2001 From: Jeff Sieu Date: Sun, 6 Nov 2022 15:22:59 +0800 Subject: [PATCH] [questions][ui] improve mobile back navigation --- .../questions/layout/BackButtonLayout.tsx | 30 ++ .../answer/[answerId]/[answerSlug]/index.tsx | 129 ++++---- .../[questionId]/[questionSlug]/index.tsx | 298 +++++++++--------- 3 files changed, 231 insertions(+), 226 deletions(-) create mode 100644 apps/portal/src/components/questions/layout/BackButtonLayout.tsx diff --git a/apps/portal/src/components/questions/layout/BackButtonLayout.tsx b/apps/portal/src/components/questions/layout/BackButtonLayout.tsx new file mode 100644 index 00000000..e12ecad5 --- /dev/null +++ b/apps/portal/src/components/questions/layout/BackButtonLayout.tsx @@ -0,0 +1,30 @@ +import type { PropsWithChildren } from 'react'; +import { ArrowSmallLeftIcon } from '@heroicons/react/24/outline'; +import { Button } from '@tih/ui'; + +export type BackButtonLayoutProps = PropsWithChildren<{ + href: string; +}>; + +export default function BackButtonLayout({ + href, + children, +}: BackButtonLayoutProps) { + return ( +
+
+
+
+ {children} +
+
+ ); +} diff --git a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx index 73fd6065..a03accdd 100644 --- a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx +++ b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/answer/[answerId]/[answerSlug]/index.tsx @@ -2,12 +2,12 @@ import Head from 'next/head'; import { useRouter } from 'next/router'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; -import { ArrowSmallLeftIcon } from '@heroicons/react/24/outline'; import { Button, TextArea } from '@tih/ui'; import AnswerCommentListItem from '~/components/questions/AnswerCommentListItem'; import FullAnswerCard from '~/components/questions/card/FullAnswerCard'; import FullScreenSpinner from '~/components/questions/FullScreenSpinner'; +import BackButtonLayout from '~/components/questions/layout/BackButtonLayout'; import PaginationLoadMoreButton from '~/components/questions/PaginationLoadMoreButton'; import SortOptionsSelect from '~/components/questions/SortOptionsSelect'; @@ -104,83 +104,72 @@ export default function QuestionPage() { {answer.content} - {APP_TITLE} -
-
-