Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Cole/fix codeblock (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
colemccracken authored Dec 20, 2023
1 parent 70ea70c commit 816cdb7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/openassistants-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@definitive-io/openassistants-react",
"version": "0.1.3",
"version": "0.1.4",
"license": "MIT",
"module": "dist/openassistants-react.esm.js",
"main": "dist/index.js",
Expand Down
10 changes: 3 additions & 7 deletions packages/openassistants-react/src/components/chat-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ export function OpenAssistantsChatMessage({
isLoading,
...props
}: DefinitiveChatMessageProps) {
const defaultCollapsed = false; // useful for testing
const [collapsed, setCollapsed] = useState(defaultCollapsed);
const [isEditing, setIsEditing] = useState(false);
const [editedMessageContent, setEditedMessageContent] = useState<string>('');
const content = getContent(message);
Expand Down Expand Up @@ -152,9 +150,7 @@ export function OpenAssistantsChatMessage({
{!isEditing && (
<div>
<MemoizedReactMarkdown
className={`prose break-words prose-p:leading-relaxed prose-pre:p-0 ${
collapsed ? 'collapsed' : ''
}`}
className={`prose break-words prose-p:leading-relaxed prose-pre:p-0`}
remarkPlugins={[remarkGfm]}
components={{
p({ children }) {
Expand Down Expand Up @@ -184,14 +180,14 @@ export function OpenAssistantsChatMessage({
}
return (
<div>
{!collapsed && (
{
<CodeBlock
key={Math.random()}
language={(match && match[1]) || ''}
value={String(children).replace(/\n$/, '')}
{...props}
/>
)}
}
</div>
);
},
Expand Down
8 changes: 4 additions & 4 deletions packages/openassistants-react/src/components/ui/codeblock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ const CodeBlock: FC<Props> = memo(({ language, value }) => {
};

return (
<div className="codeblock relative w-full font-sans">
<div className="relative w-full font-sans bg-gray-200">
<div className="flex w-full items-center justify-between px-6 py-2 pr-4">
<span className="text-xs lowercase">{language}</span>
<span className="text-xs lowercase text-primary">{language}</span>
<div className="flex items-center space-x-1">
<Button
variant="ghost"
className="hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
className="text-primary text-xs hover:bg-gray-300 hover:text-primary"
onClick={downloadAsFile}
size="icon"
>
Expand All @@ -105,7 +105,7 @@ const CodeBlock: FC<Props> = memo(({ language, value }) => {
<Button
variant="ghost"
size="icon"
className="text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
className="text-primary text-xs hover:bg-gray-300 hover:text-primary"
onClick={onCopy}
>
{isCopied ? <IconCheck /> : <IconCopy />}
Expand Down

0 comments on commit 816cdb7

Please sign in to comment.