-
Notifications
You must be signed in to change notification settings - Fork 117
featI(cloud): add changelog #2945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { faSparkle, Icon } from "@rivet-gg/icons"; | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import { useLocalStorage } from "usehooks-ts"; | ||
import { | ||
Avatar, | ||
AvatarFallback, | ||
AvatarImage, | ||
Badge, | ||
cn, | ||
Picture, | ||
PictureFallback, | ||
PictureImage, | ||
Skeleton, | ||
Slot, | ||
WithTooltip, | ||
} from "@/components"; | ||
import { changelogQueryOptions } from "@/queries/global"; | ||
import type { ChangelogItem } from "@/queries/types"; | ||
|
||
interface ChangelogEntryProps extends ChangelogItem { | ||
isNew?: boolean; | ||
} | ||
|
||
export function ChangelogEntry({ | ||
published, | ||
images, | ||
title, | ||
description, | ||
slug, | ||
authors, | ||
isNew, | ||
}: ChangelogEntryProps) { | ||
return ( | ||
<div className="py-2"> | ||
<div className="flex my-2 justify-between items-center"> | ||
<div className="flex items-center gap-2"> | ||
<div className="bg-white text-background size-8 rounded-full flex items-center justify-center"> | ||
<Icon icon={faSparkle} className="m-0" /> | ||
</div> | ||
<h4 className="font-bold text-lg text-foreground"> | ||
{isNew ? ( | ||
<span>New Update</span> | ||
) : ( | ||
<span>Latest Update</span> | ||
)} | ||
</h4> | ||
</div> | ||
<Badge variant="outline"> | ||
{new Date(published).toLocaleDateString()} | ||
</Badge> | ||
</div> | ||
|
||
<a | ||
href={`https://rivet.gg/changelog/${slug}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
className="block" | ||
> | ||
<Picture className="rounded-md border my-4 h-[200px] w-full block overflow-hidden aspect-video"> | ||
<PictureFallback> | ||
<Skeleton className="size-full" /> | ||
</PictureFallback> | ||
<PictureImage | ||
className="size-full object-cover animate-in fade-in-0 duration-300 fill-mode-forwards" | ||
src={`https://rivet.gg/${images[0].url}`} | ||
width={images[0].width} | ||
height={images[0].height} | ||
alt={"Changelog entry"} | ||
/> | ||
</Picture> | ||
|
||
<p className="font-semibold text-sm">{title}</p> | ||
|
||
<p className="text-xs mt-1 text-muted-foreground"> | ||
{description}{" "} | ||
<span className="text-right text-xs inline gap-1.5 text-foreground items-center"> | ||
Read more... | ||
</span> | ||
</p> | ||
</a> | ||
<div className="flex items-end justify-end mt-2"> | ||
<div className="flex gap-2 items-center"> | ||
<a | ||
className="flex gap-1.5 items-center flex-row-reverse text-right" | ||
href={authors[0].socials.twitter} | ||
> | ||
<Avatar className="size-8"> | ||
<AvatarFallback> | ||
{authors[0].name[0]} | ||
</AvatarFallback> | ||
<AvatarImage | ||
src={`https://rivet.gg/${authors[0].avatar.url}`} | ||
alt={authors[0].name} | ||
/> | ||
</Avatar> | ||
<div className="ml-2"> | ||
<p className="font-semibold text-sm"> | ||
{authors[0].name} | ||
</p> | ||
<p className="text-xs text-muted-foreground"> | ||
{authors[0].role} | ||
</p> | ||
</div> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
interface ChangelogProps { | ||
className?: string; | ||
children?: React.ReactNode; | ||
} | ||
|
||
export function Changelog({ className, children, ...props }: ChangelogProps) { | ||
const { data } = useSuspenseQuery(changelogQueryOptions()); | ||
|
||
const [lastChangelog, setLast] = useLocalStorage<string | null>( | ||
"rivet-lastchangelog", | ||
null, | ||
); | ||
|
||
const hasNewChangelog = !lastChangelog | ||
? data.length > 0 | ||
: data.some( | ||
(entry) => new Date(entry.published) > new Date(lastChangelog), | ||
); | ||
|
||
return ( | ||
<WithTooltip | ||
delayDuration={0} | ||
contentProps={{ collisionPadding: 8 }} | ||
onOpenChange={(isOpen) => { | ||
if (isOpen) { | ||
setLast(data[0].published); | ||
} | ||
}} | ||
trigger={ | ||
<Slot | ||
{...props} | ||
className={cn( | ||
"relative", | ||
!hasNewChangelog && "[&_[data-changelog-ping]]:hidden", | ||
className, | ||
)} | ||
> | ||
{children} | ||
</Slot> | ||
} | ||
content={<ChangelogEntry {...data[0]} isNew={hasNewChangelog} />} | ||
/> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { z } from "zod"; | ||
|
||
export const ChangelogItem = z.object({ | ||
published: z.string(), | ||
images: z.array( | ||
z.object({ url: z.string(), width: z.number(), height: z.number() }), | ||
), | ||
title: z.string(), | ||
description: z.string(), | ||
slug: z.string(), | ||
authors: z.array( | ||
z.object({ | ||
name: z.string(), | ||
role: z.string(), | ||
avatar: z.object({ url: z.string() }), | ||
socials: z.object({ | ||
twitter: z.string().optional(), | ||
github: z.string().optional(), | ||
bluesky: z.string().optional(), | ||
}), | ||
}), | ||
), | ||
}); | ||
export const Changelog = z.array(ChangelogItem); | ||
|
||
export type Changelog = z.infer<typeof Changelog>; | ||
export type ChangelogItem = z.infer<typeof ChangelogItem>; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
href
attribute referencesauthors[0].socials.twitter
directly, but according to the schema definition intypes.ts
, this property is optional. This could lead to broken links if an author doesn't have a Twitter account. Consider adding a fallback:Or implement a more robust approach that selects the first available social link from the author's socials object, with a sensible default when none exist.
Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.