Skip to content

Commit

Permalink
Merge pull request #623 from krabbi/fix_lists_in_converastion
Browse files Browse the repository at this point in the history
[FE]: Fix render lists in conversation
  • Loading branch information
dartpain authored Oct 19, 2023
2 parents 3039c97 + f9e6751 commit 4ed6580
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
11 changes: 11 additions & 0 deletions frontend/src/conversation/ConversationBubble.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.list p {
display: inline;
}

.list li:not(:first-child) {
margin-top: 1em;
}

.list li > .list {
margin-top: 1em;
}
35 changes: 18 additions & 17 deletions frontend/src/conversation/ConversationBubble.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { forwardRef, useState } from 'react';
import Avatar from '../Avatar';
import { FEEDBACK, MESSAGE_TYPE } from './conversationModels';
import classes from './ConversationBubble.module.css';
import Alert from './../assets/alert.svg';
import { ReactComponent as Like } from './../assets/like.svg';
import { ReactComponent as Dislike } from './../assets/dislike.svg';
Expand Down Expand Up @@ -40,16 +41,6 @@ const ConversationBubble = forwardRef<
}, 2000);
};

const List = ({
ordered,
children,
}: {
ordered?: boolean;
children: React.ReactNode;
}) => {
const Tag = ordered ? 'ol' : 'ul';
return <Tag className="list-inside list-disc">{children}</Tag>;
};
let bubble;

if (type === 'QUESTION') {
Expand Down Expand Up @@ -104,11 +95,23 @@ const ConversationBubble = forwardRef<
</code>
);
},
ul({ node, children }) {
return <List>{children}</List>;
ul({ children }) {
return (
<ul
className={`list-inside list-disc whitespace-normal pl-4 ${classes.list}`}
>
{children}
</ul>
);
},
ol({ node, children }) {
return <List ordered>{children}</List>;
ol({ children }) {
return (
<ol
className={`list-inside list-decimal whitespace-normal pl-4 ${classes.list}`}
>
{children}
</ol>
);
},
}}
>
Expand All @@ -118,9 +121,7 @@ const ConversationBubble = forwardRef<
<>
<span className="mt-3 h-px w-full bg-[#DEDEDE]"></span>
<div className="mt-3 flex w-full flex-row flex-wrap items-center justify-start gap-2">
<div className="py-1 text-base font-semibold">
Sources:
</div>
<div className="py-1 text-base font-semibold">Sources:</div>
<div className="flex flex-row flex-wrap items-center justify-start gap-2">
{sources?.map((source, index) => (
<div
Expand Down

2 comments on commit 4ed6580

@vercel
Copy link

@vercel vercel bot commented on 4ed6580 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nextra-docsgpt – ./docs

nextra-docsgpt.vercel.app
nextra-docsgpt-arc53.vercel.app
docs.docsgpt.co.uk
nextra-docsgpt-git-main-arc53.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4ed6580 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs-gpt – ./frontend

docs-gpt-brown.vercel.app
docs-gpt-git-main-arc53.vercel.app
docs-gpt-arc53.vercel.app

Please sign in to comment.