diff --git a/ui/src/components/Comment/index.tsx b/ui/src/components/Comment/index.tsx index 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/hooks/useTagModal/index.tsx b/ui/src/hooks/useTagModal/index.tsx index 4a24870a..f1b80af7 100644 --- a/ui/src/hooks/useTagModal/index.tsx +++ b/ui/src/hooks/useTagModal/index.tsx @@ -95,13 +95,13 @@ const useTagModal = (props: IProps = {}) => { isInvalid: true, errorMsg: t('form.fields.slug_name.msg.range'), }; - } else if (/[^a-z0-9+#\-.]/.test(slugName.value)) { - bol = false; - formData.slugName = { - value: slugName.value, - isInvalid: true, - errorMsg: t('form.fields.slug_name.msg.character'), - }; + // } else if (/[^a-z0-9+#\-.]/.test(slugName.value)) { + // bol = false; + // formData.slugName = { + // value: slugName.value, + // isInvalid: true, + // errorMsg: t('form.fields.slug_name.msg.character'), + // }; } else { formData.slugName = { value: slugName.value, @@ -217,7 +217,9 @@ const useTagModal = (props: IProps = {}) => { isInvalid={formData.slugName.isInvalid} /> - {t('form.fields.slug_name.desc')} + + {t('form.fields.slug_name.msg.range')} + {formData.slugName.errorMsg} diff --git a/ui/src/index.scss b/ui/src/index.scss index 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.tsx index 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 = ({ }, 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.tsx index 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.ts index 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,