generated from dream-aim-deliver/dad-ui-kit-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Research context card and list research context
- Loading branch information
Showing
3 changed files
with
193 additions
and
15 deletions.
There are no files selected for viewing
39 changes: 38 additions & 1 deletion
39
lib/components/research-context/list-research-context-layout.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 |
---|---|---|
@@ -1,5 +1,42 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { | ||
ResearchContextCard, | ||
ResearchContextCardProps, | ||
} from "./research-context-card"; | ||
|
||
export interface ListResearchContextCardProps { | ||
items: ResearchContextCardProps[]; | ||
} | ||
|
||
export const ListResearchContextLayout = (props: { | ||
children: React.ReactNode; | ||
}) => { | ||
return <div className="w-full h-full flex">{props.children}</div>; | ||
return ( | ||
<div | ||
className=" | ||
grid | ||
gap-6 | ||
grid-cols-1 | ||
sm:grid-cols-2 | ||
lg:grid-cols-3 | ||
w-full | ||
p-4 | ||
" | ||
> | ||
{props.children} | ||
</div> | ||
); | ||
}; | ||
|
||
export const ListResearchContextCard = ({ | ||
items, | ||
}: ListResearchContextCardProps) => { | ||
return ( | ||
<ListResearchContextLayout> | ||
{items.map((item) => ( | ||
<ResearchContextCard key={item.id} {...item} /> | ||
))} | ||
</ListResearchContextLayout> | ||
); | ||
}; |
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
97 changes: 97 additions & 0 deletions
97
stories/components/research-context/ResearchContext.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,97 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { ResearchContextCard } from "@/components/research-context/research-context-card"; | ||
import { ListResearchContextCard } from "@/components/research-context/list-research-context-layout"; | ||
|
||
const handleNavigateToSourcesPage = (id: number) => { | ||
alert(`Navigate to sources for item ${id}`); | ||
}; | ||
|
||
const handleNavigateToListConversationPage = (id: number) => { | ||
alert(`Navigate to conversations for item ${id}`); | ||
}; | ||
|
||
// Single card | ||
const singleCardProps = { | ||
id: 1, | ||
title: "Research Context 1", | ||
description: "This is a sample description for research context 1.", | ||
callbacks: { | ||
onNavigateToSourcesPage: handleNavigateToSourcesPage, | ||
onNavigateToListConversationPage: handleNavigateToListConversationPage, | ||
}, | ||
}; | ||
|
||
// List of cards | ||
const listOfCardsProps = [ | ||
{ | ||
id: 1, | ||
title: "Research Context 1", | ||
description: "This is a sample description for research context 1.", | ||
callbacks: { | ||
onNavigateToSourcesPage: handleNavigateToSourcesPage, | ||
onNavigateToListConversationPage: handleNavigateToListConversationPage, | ||
}, | ||
}, | ||
{ | ||
id: 2, | ||
title: "Research Context 2", | ||
description: "This is a sample description for research context 2.", | ||
callbacks: { | ||
onNavigateToSourcesPage: handleNavigateToSourcesPage, | ||
onNavigateToListConversationPage: handleNavigateToListConversationPage, | ||
}, | ||
}, | ||
{ | ||
id: 3, | ||
title: "Research Context 3", | ||
description: "This is a sample description for research context 3.", | ||
callbacks: { | ||
onNavigateToSourcesPage: handleNavigateToSourcesPage, | ||
onNavigateToListConversationPage: handleNavigateToListConversationPage, | ||
}, | ||
}, | ||
{ | ||
id: 4, | ||
title: "Research Context 4", | ||
description: "This is a sample description for research context 3.", | ||
callbacks: { | ||
onNavigateToSourcesPage: handleNavigateToSourcesPage, | ||
onNavigateToListConversationPage: handleNavigateToListConversationPage, | ||
}, | ||
}, | ||
{ | ||
id: 5, | ||
title: "Research Context 5", | ||
description: "This is a sample description for research context 3.", | ||
callbacks: { | ||
onNavigateToSourcesPage: handleNavigateToSourcesPage, | ||
onNavigateToListConversationPage: handleNavigateToListConversationPage, | ||
}, | ||
}, | ||
{ | ||
id: 6, | ||
title: "Research Context 6", | ||
description: "This is a sample description for research context 3.", | ||
callbacks: { | ||
onNavigateToSourcesPage: handleNavigateToSourcesPage, | ||
onNavigateToListConversationPage: handleNavigateToListConversationPage, | ||
}, | ||
}, | ||
]; | ||
|
||
const meta = { | ||
title: "Components/ResearchContextCard", | ||
component: ResearchContextCard, | ||
tags: ["autodocs"], | ||
} satisfies Meta<typeof ResearchContextCard>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const SingleCard: Story = { | ||
args: singleCardProps, | ||
}; | ||
|
||
export const ListOfCards = { | ||
render: () => <ListResearchContextCard items={listOfCardsProps} />, | ||
}; |