From 2df4d9aa49e1b56c390773ea2cdc313a78a7b0c2 Mon Sep 17 00:00:00 2001 From: Noa Virellia Date: Sun, 1 Feb 2026 09:54:19 +0800 Subject: [PATCH] feat(client): event card Signed-off-by: Noa Virellia --- client/cms/package.json | 1 + client/cms/pnpm-lock.yaml | 8 +++ .../components/workbenchCards/event-card.tsx | 39 -------------- .../workbenchCards/event-card.view.tsx | 52 +++++++++++++++++++ client/cms/src/stories/event-card.stories.ts | 17 ++++-- 5 files changed, 74 insertions(+), 43 deletions(-) delete mode 100644 client/cms/src/components/workbenchCards/event-card.tsx create mode 100644 client/cms/src/components/workbenchCards/event-card.view.tsx diff --git a/client/cms/package.json b/client/cms/package.json index e6996a9..0f0db0f 100644 --- a/client/cms/package.json +++ b/client/cms/package.json @@ -53,6 +53,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "culori": "^4.0.2", + "dayjs": "^1.11.19", "immer": "^11.1.0", "lodash-es": "^4.17.22", "lucide-react": "^0.562.0", diff --git a/client/cms/pnpm-lock.yaml b/client/cms/pnpm-lock.yaml index 0117e43..f61ca18 100644 --- a/client/cms/pnpm-lock.yaml +++ b/client/cms/pnpm-lock.yaml @@ -125,6 +125,9 @@ importers: culori: specifier: ^4.0.2 version: 4.0.2 + dayjs: + specifier: ^1.11.19 + version: 1.11.19 immer: specifier: ^11.1.0 version: 11.1.3 @@ -2850,6 +2853,9 @@ packages: resolution: {integrity: sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==} engines: {node: '>=12'} + dayjs@1.11.19: + resolution: {integrity: sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==} + debug@4.4.3: resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} engines: {node: '>=6.0'} @@ -7765,6 +7771,8 @@ snapshots: d3-timer@3.0.1: {} + dayjs@1.11.19: {} + debug@4.4.3: dependencies: ms: 2.1.3 diff --git a/client/cms/src/components/workbenchCards/event-card.tsx b/client/cms/src/components/workbenchCards/event-card.tsx deleted file mode 100644 index 2820413..0000000 --- a/client/cms/src/components/workbenchCards/event-card.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { Badge } from "@/components/ui/badge" -import { Button } from "@/components/ui/button" -import { - Card, - CardAction, - CardDescription, - CardFooter, - CardHeader, - CardTitle, -} from "@/components/ui/card" -export function EventCard({ type, coverImage, eventName, description, startTime, endTime }: - { - type: 'official' | 'party', - coverImage: string, eventName: string, description: string, startTime: string, endTime: string - }) { - return ( - -
- Event cover - - - Featured - - Design systems meetup - - A practical talk on component APIs, accessibility, and shipping - faster. - - - - - - - ) -} diff --git a/client/cms/src/components/workbenchCards/event-card.view.tsx b/client/cms/src/components/workbenchCards/event-card.view.tsx new file mode 100644 index 0000000..7bb21cf --- /dev/null +++ b/client/cms/src/components/workbenchCards/event-card.view.tsx @@ -0,0 +1,52 @@ +import dayjs from 'dayjs'; +import { Calendar } from 'lucide-react'; +import { Badge } from '@/components/ui/badge'; +import { Button } from '@/components/ui/button'; +import { + Card, + CardAction, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from '@/components/ui/card'; + +export function EventCardView({ type, coverImage, eventName, description, startTime, endTime }: + { + type: 'official' | 'party'; + coverImage: string; + eventName: string; + description: string; + startTime: Date; + endTime: Date; + }) { + const startDayJs = dayjs(startTime); + const endDayJs = dayjs(endTime); + return ( + +
+ Event cover + + + {type === 'official' ? Official : Party} + + {eventName} + + + {`${startDayJs.format('YYYY/MM/DD')} - ${endDayJs.format('YYYY/MM/DD')}`} + + + {description} + + + + + + + + ); +} diff --git a/client/cms/src/stories/event-card.stories.ts b/client/cms/src/stories/event-card.stories.ts index 262abff..6a6017b 100644 --- a/client/cms/src/stories/event-card.stories.ts +++ b/client/cms/src/stories/event-card.stories.ts @@ -1,12 +1,21 @@ import type { Meta, StoryObj } from '@storybook/react-vite'; -import { EventCard } from '@/components/workbenchCards/event-card'; +import { EventCardView } from '@/components/workbenchCards/event-card.view'; const meta = { title: 'Cards/EventCard', - component: EventCard, -} satisfies Meta; + component: EventCardView, +} satisfies Meta; export default meta; type Story = StoryObj; -export const Primary: Story = {}; +export const Primary: Story = { + args: { + type: 'official', + coverImage: "https://github.com/NixOS/nixos-artwork/blob/master/wallpapers/nix-wallpaper-watersplash.png?raw=true", + eventName: 'Nix CN Conference 26.05', + description: 'Event Description', + startTime: "2026-06-13T04:00:00.000Z", + endTime: "2026-06-14T04:00:00.000Z", + }, +};