A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat(Question): add bgFadeOut for some anchor
haitao(lj)f4da6c2345f1
diff --git a/ui/src/components/Comment/index.tsx b/ui/src/components/Comment/index.tsxindex 028c84bf..1c3191aa 100644--- a/ui/src/components/Comment/index.tsx+++ b/ui/src/components/Comment/index.tsx@@ -10,7 +10,7 @@ import { marked } from 'marked';import * as Types from '@/common/interface';import { Modal } from '@/components';import { usePageUsers, useReportModal } from '@/hooks';-import { matchedUsers, parseUserInfo, scrollTop } from '@/utils';+import { matchedUsers, parseUserInfo, scrollTop, bgFadeOut } from '@/utils';import { tryNormalLogged } from '@/utils/guard';import {useQueryComments,@@ -44,6 +44,7 @@ const Comment = ({ objectId, mode, commentId }) => {if (pageIndex === 0 && co.comment_id === commentId) {setTimeout(() => {scrollTop(el);+ bgFadeOut(el);}, 100);}}, []);diff --git a/ui/src/index.scss b/ui/src/index.scssindex b4ceeaaa..32197219 100644--- a/ui/src/index.scss+++ b/ui/src/index.scss@@ -283,3 +283,11 @@ a {.pre-line {white-space: pre-wrap;}++@keyframes bg-fade-out {+ 0%, 25% {background-color: var(--bs-highlight-bg)}+ 100% { background-color: transparent }+}+.bg-fade-out {+ animation: 2s ease 1s bg-fade-out;+}diff --git a/ui/src/pages/Questions/Detail/components/Answer/index.tsx b/ui/src/pages/Questions/Detail/components/Answer/index.tsxindex 43412747..feff0574 100644--- a/ui/src/pages/Questions/Detail/components/Answer/index.tsx+++ b/ui/src/pages/Questions/Detail/components/Answer/index.tsx@@ -12,7 +12,7 @@ import {FormatTime,htmlRender,} from '@/components';-import { scrollTop } from '@/utils';+import { scrollTop, bgFadeOut } from '@/utils';import { AnswerItem } from '@/common/interface';import { acceptanceAnswer } from '@/services';@@ -61,6 +61,7 @@ const Index: FC<Props> = ({}, 100);}htmlRender(answerRef.current.querySelector('.fmt'));+ bgFadeOut(answerRef.current);}, [data.id, answerRef.current]);if (!data?.id) {return null;diff --git a/ui/src/pages/Questions/Detail/index.tsx b/ui/src/pages/Questions/Detail/index.tsxindex 91bf6a87..2899af71 100644--- a/ui/src/pages/Questions/Detail/index.tsx+++ b/ui/src/pages/Questions/Detail/index.tsx@@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next';import Pattern from '@/common/pattern';import { Pagination } from '@/components';import { loggedUserInfoStore, toastStore } from '@/stores';-import { scrollTop } from '@/utils';+import { scrollTop, bgFadeOut } from '@/utils';import { usePageTags, usePageUsers } from '@/hooks';import type {ListResult,@@ -35,7 +35,9 @@ const Index = () => {const navigate = useNavigate();const { t } = useTranslation('translation');const { qid = '', slugPermalink = '' } = useParams();- // Compatible with Permalink+ /**+ * Note: Compatible with Permalink+ */let { aid = '' } = useParams();if (!aid && Pattern.isAnswerId.test(slugPermalink)) {aid = slugPermalink;@@ -77,6 +79,7 @@ const Index = () => {// scroll into view;const element = document.getElementById('answerHeader');scrollTop(element);+ bgFadeOut(element);}res.list.forEach((item) => {diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.tsindex 1ff6b2eb..e3e53652 100644--- a/ui/src/utils/common.ts+++ b/ui/src/utils/common.ts@@ -36,6 +36,15 @@ function scrollTop(element) {});}+const bgFadeOut = (el) => {+ if (el && !el.classList.contains('bg-fade-out')) {+ el.classList.add('bg-fade-out');+ setTimeout(() => {+ el.classList.remove('bg-fade-out');+ }, 3200);+ }+};+/*** Extract user info from markdown* @param markdown string@@ -209,6 +218,7 @@ export {thousandthDivision,formatCount,scrollTop,+ bgFadeOut,matchedUsers,parseUserInfo,formatUptime,