Skip to content

Commit bf49301

Browse files
DrewDrew
authored andcommitted
styling: make code block scrollable instead of wrapping code
1 parent a9e7268 commit bf49301

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

frontends/chat/src/components/Atoms/AfMessage.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export const AfMessage = (props: AfMessageProps) => {
165165
orientation={screenWidth() > 768 ? "horizontal" : "vertical"}
166166
sizes={sizes()}
167167
onSizesChange={(sizes) => setSizes(sizes)}
168+
class="max-w-full"
168169
classList={{
169170
"self-start": props.role == "assistant",
170171
"self-end": props.role == "user",
@@ -174,7 +175,7 @@ export const AfMessage = (props: AfMessageProps) => {
174175
minSize={0.1}
175176
ref={setLeftColumnRef}
176177
classList={{
177-
"dark:text-white self-start group grow shadow-sm w-full h-full rounded border dark:border-neutral-700 md:px-6 px-4 py-4 flex items-start":
178+
"dark:text-white self-start group grow shadow-sm max-w-full overflow-hidden h-full rounded border dark:border-neutral-700 md:px-6 px-4 py-4 flex items-start":
178179
true,
179180
"bg-neutral-200 border-neutral-300 dark:bg-neutral-700/70":
180181
props.role === "assistant",
@@ -183,7 +184,7 @@ export const AfMessage = (props: AfMessageProps) => {
183184
"md:mr-16": props.role === "assistant" && metadata().length <= 0,
184185
}}
185186
>
186-
<div class="flex w-full items-center gap-4 self-start text-black dark:text-neutral-100 md:flex-row">
187+
<div class="flex w-full items-center gap-4 self-start text-wrap text-black dark:text-neutral-100 md:flex-row">
187188
<div class="mt-1 self-start">
188189
{props.role === "user" ? (
189190
<BiSolidUserRectangle class="fill-current" />
@@ -194,7 +195,7 @@ export const AfMessage = (props: AfMessageProps) => {
194195
<div
195196
classList={{
196197
"w-full": true,
197-
"flex gap-y-8 items-start lg:gap-4 flex-col-reverse lg:flex-row":
198+
"flex overflow-hidden gap-y-8 items-start lg:gap-4 flex-col-reverse lg:flex-row":
198199
!!chunkMetadatas(),
199200
}}
200201
>
@@ -245,7 +246,7 @@ export const AfMessage = (props: AfMessageProps) => {
245246
<SolidMarkdown
246247
remarkPlugins={[remarkBreaks, remarkGfm]}
247248
rehypePlugins={[rehypeSanitize]}
248-
class="w-full select-text space-y-2"
249+
class="w-full max-w-[full] select-text space-y-2 overflow-hidden"
249250
components={{
250251
h1: (props) => {
251252
return (
@@ -305,7 +306,7 @@ export const AfMessage = (props: AfMessageProps) => {
305306
});
306307

307308
return (
308-
<div class="relative w-full text-wrap rounded-lg bg-gray-100 px-4 py-2 dark:bg-neutral-700">
309+
<div class="relative w-full rounded-lg bg-gray-100 px-4 py-2 dark:bg-neutral-700">
309310
<button
310311
class="absolute right-2 top-2 p-1 text-xs hover:text-fuchsia-500 dark:text-white dark:hover:text-fuchsia-500"
311312
onClick={() => {
@@ -331,7 +332,9 @@ export const AfMessage = (props: AfMessageProps) => {
331332
</Switch>
332333
</button>
333334

334-
<code ref={setCodeBlock}>{props.children}</code>
335+
<div class="overflow-x-auto">
336+
<code ref={setCodeBlock}>{props.children}</code>
337+
</div>
335338
</div>
336339
);
337340
},

frontends/chat/src/components/Layouts/MainLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const MainLayout = (props: LayoutProps) => {
290290
<>
291291
<div class="relative flex w-full flex-col justify-between">
292292
<div
293-
class="flex flex-col items-stretch gap-6 px-4 pb-32 pt-4"
293+
class="flex max-w-full flex-col items-stretch gap-6 overflow-hidden px-4 pb-32 pt-4"
294294
id="topic-messages"
295295
>
296296
<For each={messages()}>

0 commit comments

Comments
 (0)