-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add PostEvent #872
Open
dani-moreno
wants to merge
7
commits into
main
Choose a base branch
from
add-postevent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add PostEvent #872
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ef6890e
Add PostEvent
dani-moreno bb3e38a
style fixes
dani-moreno 7b5f597
style fix
dani-moreno 7116f38
fixes
dani-moreno 73fc6a5
Date
dani-moreno 4989c7d
DateAvatar update
dani-moreno d85ea2b
Celebration update
dani-moreno 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 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 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 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 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
56 changes: 56 additions & 0 deletions
56
lib/experimental/Information/Communities/Post/PostEvent/index.stories.tsx
This file contains 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,56 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { PostEvent } from "." | ||
|
||
const meta: Meta<typeof PostEvent> = { | ||
component: PostEvent, | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof PostEvent> | ||
|
||
// Fixed date for the example stories | ||
const eventDate = new Date(2024, 11, 13, 20, 0) | ||
|
||
export const Default: Story = { | ||
decorators: [ | ||
(Story) => ( | ||
<div className="max-w-96"> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
args: { | ||
title: "End of the Year Dinner!", | ||
place: "Poble Espanyol", | ||
imageUrl: "https://cataas.com/cat", | ||
date: eventDate, | ||
}, | ||
} | ||
|
||
export const NoImage: Story = { | ||
decorators: [ | ||
(Story) => ( | ||
<div className="max-w-96"> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
args: { | ||
title: "End of the Year Dinner!", | ||
place: "Poble Espanyol", | ||
date: eventDate, | ||
}, | ||
} | ||
|
||
export const Skeleton: Story = { | ||
decorators: [ | ||
(Story) => ( | ||
<div className="max-w-96"> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
args: {}, | ||
render: () => <PostEvent.Skeleton />, | ||
} |
70 changes: 70 additions & 0 deletions
70
lib/experimental/Information/Communities/Post/PostEvent/index.tsx
This file contains 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,70 @@ | ||
import { DateAvatar } from "@/experimental/Information/Avatars/DateAvatar" | ||
import { formatTime } from "@/lib/date" | ||
import { withSkeleton } from "@/lib/skeleton" | ||
import { Skeleton } from "@/ui/skeleton" | ||
|
||
type PostEventProps = { | ||
title: string | ||
imageUrl?: string | ||
place: string | ||
date: Date | ||
} | ||
|
||
export const BasePostEvent = ({ | ||
title, | ||
imageUrl, | ||
place, | ||
date, | ||
}: PostEventProps) => { | ||
return ( | ||
<div className="flex w-full flex-col gap-1 rounded-xl border border-solid border-f1-border-secondary bg-f1-background-inverse-secondary p-1 shadow"> | ||
{imageUrl && ( | ||
<div className="relative aspect-video w-full"> | ||
<img | ||
src={imageUrl} | ||
role="presentation" | ||
loading="lazy" | ||
className="aspect-video h-full w-full rounded-md object-cover" | ||
/> | ||
<Skeleton className="absolute inset-0 h-full w-full rounded-md" /> | ||
</div> | ||
)} | ||
<div className="flex h-full flex-row gap-3 p-2"> | ||
<div className="w-1 shrink-0 self-stretch rounded-full bg-f1-background-accent-bold" /> | ||
<div className="flex min-w-0 grow flex-col"> | ||
<span className="truncate font-medium text-f1-foreground"> | ||
{title} | ||
</span> | ||
<span className="flex min-w-0 flex-row gap-1 text-f1-foreground-secondary"> | ||
{formatTime(date)} · <span className="truncate">{place}</span> | ||
</span> | ||
</div> | ||
<div className="shrink-0"> | ||
<DateAvatar date={date} /> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export const PostEventSkeleton = () => ( | ||
<div | ||
className="flex w-full flex-col gap-1 rounded-xl border border-solid border-f1-border-secondary bg-f1-background-inverse-secondary p-1" | ||
role="status" | ||
aria-busy="true" | ||
aria-live="polite" | ||
> | ||
<div> | ||
<Skeleton className="aspect-video h-full w-full rounded-lg" /> | ||
</div> | ||
<div className="flex h-full flex-row gap-3 p-2"> | ||
<Skeleton className="w-1 shrink-0 self-stretch rounded-full" /> | ||
<div className="flex grow flex-col gap-1.5 py-1"> | ||
<Skeleton className="mt-px h-3 w-1/2" /> | ||
<Skeleton className="mb-px h-3 w-1/4" /> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
|
||
export const PostEvent = withSkeleton(BasePostEvent, PostEventSkeleton) |
This file contains 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,13 @@ | ||
import { format } from "date-fns" | ||
|
||
export function formatTime(date: Date) { | ||
return format(date, "HH:mm") | ||
} | ||
|
||
export function formatMonth(date: Date) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should better name this something like |
||
return format(date, "MMM") | ||
} | ||
|
||
export function getDayOfMonth(date: Date) { | ||
return date.getDate() | ||
} |
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.
We should use
p
which is a localized version of the time to use 12h or 24h version when necessary