From 5a476872f8d2b9393b4390a52734c1a0bd6024c2 Mon Sep 17 00:00:00 2001 From: Kuizuo Date: Thu, 28 Dec 2023 00:42:13 +0800 Subject: [PATCH] feat: optimize tag style --- src/css/custom.scss | 23 ++++++++ src/theme/BlogPostGridItems/index.tsx | 4 +- src/theme/BlogPostItem/Footer/index.tsx | 47 ++++------------ .../BlogPostItem/Footer/styles.module.scss | 4 +- .../BlogPostItem/Header/Authors/index.tsx | 7 +-- src/theme/BlogPostItem/Header/Info/index.tsx | 56 ++++++++++++------- .../Header/Info/styles.module.css | 38 ++++++++++++- src/theme/Tag/index.tsx | 11 +++- .../{styles.module.css => styles.module.scss} | 16 ++---- 9 files changed, 124 insertions(+), 82 deletions(-) rename src/theme/Tag/{styles.module.css => styles.module.scss} (79%) diff --git a/src/css/custom.scss b/src/css/custom.scss index 69b81221..02e0146c 100644 --- a/src/css/custom.scss +++ b/src/css/custom.scss @@ -278,3 +278,26 @@ div[class^='announcementBar_'] { .gsc-comments textarea { background: var(--content-background-color); } + +.tag { + &:hover { + color: currentColor !important; + } + + &::after { + content: ''; + position: absolute; + bottom: 0; + left: 0; + width: 0; + height: 2px; + background: var(--ifm-color-primary); + visibility: hidden; + transition: all 0.3s linear; + } + + &:hover::after { + visibility: visible; + width: 100%; + } +} diff --git a/src/theme/BlogPostGridItems/index.tsx b/src/theme/BlogPostGridItems/index.tsx index 9dd611d0..30013c98 100644 --- a/src/theme/BlogPostGridItems/index.tsx +++ b/src/theme/BlogPostGridItems/index.tsx @@ -61,9 +61,7 @@ export default function BlogPostGridItems({ items }: BlogPostItemsProps): JSX.El label={label} permalink={tagPermalink} key={tagPermalink} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - className={styles.tag} + className={'tag'} /> ) diff --git a/src/theme/BlogPostItem/Footer/index.tsx b/src/theme/BlogPostItem/Footer/index.tsx index dbba50f9..5371b0ef 100644 --- a/src/theme/BlogPostItem/Footer/index.tsx +++ b/src/theme/BlogPostItem/Footer/index.tsx @@ -12,16 +12,8 @@ import styles from './styles.module.scss' export default function BlogPostItemFooter(): JSX.Element | null { const { metadata, isBlogPostPage } = useBlogPost() - const { - tags, - title, - editUrl, - hasTruncateMarker, - date, - formattedDate, - readingTime, - authors, - } = metadata + const { tags, title, editUrl, hasTruncateMarker, date, formattedDate, readingTime, authors } = + metadata // A post is truncated if it's in the "list view" and it has a truncate marker const truncatedPost = !isBlogPostPage && hasTruncateMarker @@ -37,7 +29,7 @@ export default function BlogPostItemFooter(): JSX.Element | null {
{/* {authorsExists && ( <> - + {authors.map(a => ( @@ -49,36 +41,26 @@ export default function BlogPostItemFooter(): JSX.Element | null { )} */} {date && ( <> - -