mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 19:41:02 +08:00
fix: improve Tag component by making it entire component clickable (#598)
Update Tag component structure/styles and make the entire component clickable
This commit is contained in:
+13
-14
@@ -1,36 +1,35 @@
|
|||||||
---
|
---
|
||||||
import IconHash from "@/assets/icons/IconHash.svg";
|
import IconHash from "@/assets/icons/IconHash.svg";
|
||||||
|
|
||||||
export interface Props {
|
type Props = {
|
||||||
tag: string;
|
tag: string;
|
||||||
tagName: string;
|
tagName: string;
|
||||||
size?: "sm" | "lg";
|
size?: "sm" | "lg";
|
||||||
}
|
};
|
||||||
|
|
||||||
const { tag, tagName, size = "sm" } = Astro.props;
|
const { tag, tagName, size = "lg" } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<li
|
<li>
|
||||||
class:list={[
|
|
||||||
"group inline-block group-hover:cursor-pointer",
|
|
||||||
size === "sm" ? "my-1 underline-offset-4" : "mx-1 my-3 underline-offset-8",
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<a
|
<a
|
||||||
href={`/tags/${tag}/`}
|
href={`/tags/${tag}/`}
|
||||||
transition:name={tag}
|
transition:name={tag}
|
||||||
class:list={[
|
class:list={[
|
||||||
"relative pe-2 text-lg underline decoration-dashed group-hover:-top-0.5 group-hover:text-accent focus-visible:p-1 focus-visible:no-underline",
|
"flex items-center gap-0.5",
|
||||||
|
"border-b-2 border-dashed border-foreground",
|
||||||
|
"hover:-mt-0.5 hover:border-accent hover:text-accent",
|
||||||
|
"focus-visible:border-none focus-visible:text-accent",
|
||||||
{ "text-sm": size === "sm" },
|
{ "text-sm": size === "sm" },
|
||||||
|
{ "text-lg": size === "lg" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<IconHash
|
<IconHash
|
||||||
class:list={[
|
class:list={[
|
||||||
"inline-block opacity-80",
|
"opacity-80",
|
||||||
{ "-me-3.5 size-4": size === "sm" },
|
{ "size-5": size === "lg" },
|
||||||
{ "-me-5 size-6": size === "lg" },
|
{ "size-4": size === "sm" },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<span>{tagName}</span>
|
{tagName}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ import IconChevronLeft from "@/assets/icons/IconChevronLeft.svg";
|
|||||||
import IconChevronRight from "@/assets/icons/IconChevronRight.svg";
|
import IconChevronRight from "@/assets/icons/IconChevronRight.svg";
|
||||||
import { SITE } from "@/config";
|
import { SITE } from "@/config";
|
||||||
|
|
||||||
export interface Props {
|
type Props = {
|
||||||
post: CollectionEntry<"blog">;
|
post: CollectionEntry<"blog">;
|
||||||
posts: CollectionEntry<"blog">[];
|
posts: CollectionEntry<"blog">[];
|
||||||
}
|
};
|
||||||
|
|
||||||
const { post, posts } = Astro.props;
|
const { post, posts } = Astro.props;
|
||||||
|
|
||||||
@@ -118,8 +118,8 @@ const nextPost =
|
|||||||
|
|
||||||
<EditPost class="sm:hidden" {hideEditPost} {post} />
|
<EditPost class="sm:hidden" {hideEditPost} {post} />
|
||||||
|
|
||||||
<ul class="mt-4 mb-8 sm:my-8">
|
<ul class="mt-4 mb-8 flex flex-wrap gap-4 sm:my-8">
|
||||||
{tags.map(tag => <Tag tag={slugifyStr(tag)} tagName={tag} />)}
|
{tags.map(tag => <Tag tag={slugifyStr(tag)} tagName={tag} size="sm" />)}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<BackToTopButton />
|
<BackToTopButton />
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ let tags = getUniqueTags(posts);
|
|||||||
<Layout title={`Tags | ${SITE.title}`}>
|
<Layout title={`Tags | ${SITE.title}`}>
|
||||||
<Header />
|
<Header />
|
||||||
<Main pageTitle="Tags" pageDesc="All the tags used in posts.">
|
<Main pageTitle="Tags" pageDesc="All the tags used in posts.">
|
||||||
<ul>
|
<ul class="flex flex-wrap gap-6">
|
||||||
{tags.map(({ tag, tagName }) => <Tag {tag} {tagName} size="lg" />)}
|
{tags.map(({ tag, tagName }) => <Tag {tag} {tagName} />)}
|
||||||
</ul>
|
</ul>
|
||||||
</Main>
|
</Main>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
Reference in New Issue
Block a user