Skip to content

Commit

Permalink
embeds support
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl committed Jul 26, 2024
1 parent 32dae2b commit 7893337
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ theme via Tailwind.
- Code Highlighting
- Tables
- JSON
- Embeds
- File Uploads
- Animations
- Conversation Pagination
Expand Down
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"reablocks": "^8.4.3",
"react-markdown": "^9.0.1",
"reakeys": "^2.0.3",
"remark-gfm": "^4.0.0"
"remark-gfm": "^4.0.0",
"remark-youtube": "^1.3.2"
},
"devDependencies": {
"@storybook/addon-docs": "^8.2.6",
Expand Down
3 changes: 2 additions & 1 deletion src/SessionMessages/SessionMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ThumbUpIcon from '@/assets/thumbs-up.svg?react';
import RefreshIcon from '@/assets/refresh.svg?react';
import { PluggableList } from 'react-markdown/lib';
import { Markdown } from '@/Markdown';
import remarkYoutube from 'remark-youtube';

export interface SessionMessageProps {
/**
Expand Down Expand Up @@ -67,7 +68,7 @@ export const SessionMessage: FC<SessionMessageProps> = ({
onDownvote,
onRefresh
}) => {
const { theme, remarkPlugins = [remarkGfm] } = useContext(SessionsContext);
const { theme, remarkPlugins = [remarkGfm, remarkYoutube] } = useContext(SessionsContext);

const handleCopy = (text: string) => {
navigator.clipboard
Expand Down
80 changes: 80 additions & 0 deletions stories/Demos.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,86 @@ export const CustomComponents = () => {
);
};

export const Embeds = () => {
const fakeSessionsWithEmbeds: Session[] = [
{
id: '1',
title: 'Session with Embeds',
createdAt: new Date(),
updatedAt: new Date(),
conversations: [
{
id: '1',
question: 'Can you show me a video about React?',
response: `
## Watch this video
https://youtu.be/enTFE2c68FQ
https://www.youtube.com/watch?v=enTFE2c68FQ
These links showcase a video about React basics. You can click on either link to watch the video.`,
createdAt: new Date(),
updatedAt: new Date()
},
{
id: '2',
question: 'Do you have another video recommendation?',
response: `
Certainly! Here's another great video about web development:
## Check out this tutorial
https://www.youtube.com/watch?v=dQw4w9WgXcQ
This video covers some interesting web development concepts.`,
createdAt: new Date(),
updatedAt: new Date()
}
]
}
];

return (
<div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
padding: 20,
margin: 20,
background: '#02020F',
borderRadius: 5
}}
>
<Sessions
sessions={fakeSessionsWithEmbeds}
viewType="console"
onDeleteSession={() => alert('delete!')}
>
<SessionsList>
<NewSessionButton />
<SessionGroups>
{groups =>
groups.map(({ heading, sessions }) => (
<SessionsGroup heading={heading} key={heading}>
{sessions.map(s => <SessionListItem key={s.id} session={s} />)}
</SessionsGroup>
))
}
</SessionGroups>
</SessionsList>
<div className="flex-1 h-full flex flex-col">
<SessionMessages />
<SessionInput />
</div>
</Sessions>
</div>
);
};

// export const NewSessionContent = () => {
// return (
// <div style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, padding: 20, margin: 20, background: '#02020F', borderRadius: 5 }}>
Expand Down

0 comments on commit 7893337

Please sign in to comment.