Skip to content

Commit

Permalink
refactor(details): ♻️ Pass only viewTransitionName
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJiahao committed Jan 25, 2025
1 parent 7dbdf09 commit 693396e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/molecules/BlogHeader.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const id = getUUID(title);
<header flex="~ col" gap-lg>
<CoverImage image={image} alt="" viewTransitionName=`image-${id}` />
<div px-4 lg:px-8>
<Details {title} {...props} />
<Details {title} viewTransitionName={`title-${id}`} {...props} />
<div flex="~ row" gap-4>
<DateComponent {date} viewTransitionName={`date-${id}`} />

Expand Down
13 changes: 4 additions & 9 deletions src/components/molecules/Details.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import parse from "html-react-parser";
import type { HTMLAttributes } from "react";
import { getUUID } from "utils/getUUID";
import type { AnimatedElement } from "interfaces/AnimatedElement";
import { renderMarkdown } from "utils/renderMarkdown";
interface DetailsProps extends HTMLAttributes<HTMLDivElement> {
interface DetailsProps extends AnimatedElement {
title: string;
description?: string;
}

const Details = ({ title, description }: DetailsProps) => (
const Details = ({ title, description, viewTransitionName }: DetailsProps) => (
<div text="secondary xl" flex="~ col" gap-sm>
<h1
text="primary 3xl"
font-bold
style={{ viewTransitionName: `title-${getUUID(title)}` }}
>
<h1 text="primary 3xl" font-bold style={{ viewTransitionName }}>
{title}
</h1>

Expand Down
6 changes: 5 additions & 1 deletion src/components/molecules/ImageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const ImageCard = ({ title, url, image, date, ...props }: ImageCardProps) => {
viewTransitionName={`image-${id}`}
/>
<div p-4 lg:p-8 flex="~ col" gap-4>
<Details title={title} {...props} />
<Details
title={title}
viewTransitionName={`title-${id}`}
{...props}
/>

{date && (
<DateComponent
Expand Down

0 comments on commit 693396e

Please sign in to comment.