Skip to content

Commit d193f9b

Browse files
committed
set text white only to code with pre
1 parent f9e2c8b commit d193f9b

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed

dist/components/bubbles/BotBubble.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/components/bubbles/GuestBubble.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/bubbles/BotBubble.tsx

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,24 @@ export const BotBubble = (props: Props) => {
5858
if (el) {
5959
el.innerHTML = Marked.parse(props.message.message);
6060

61-
// Apply textColor to all links, headings, and other markdown elements except code blocks
61+
// Apply textColor to all links, headings, and other markdown elements except code
6262
const textColor = props.textColor ?? defaultTextColor;
6363
el.querySelectorAll('a, h1, h2, h3, h4, h5, h6, strong, em, blockquote, li').forEach((element) => {
6464
(element as HTMLElement).style.color = textColor;
6565
});
6666

67-
// Always set code blocks text to white
68-
el.querySelectorAll('pre, code').forEach((element) => {
67+
// Code blocks (with pre) get white text
68+
el.querySelectorAll('pre').forEach((element) => {
6969
(element as HTMLElement).style.color = '#FFFFFF';
70+
// Also ensure any code elements inside pre have white text
71+
element.querySelectorAll('code').forEach((codeElement) => {
72+
(codeElement as HTMLElement).style.color = '#FFFFFF';
73+
});
74+
});
75+
76+
// Inline code (not in pre) gets green text
77+
el.querySelectorAll('code:not(pre code)').forEach((element) => {
78+
(element as HTMLElement).style.color = '#4CAF50'; // Green color
7079
});
7180

7281
// Set target="_blank" for links
@@ -277,9 +286,18 @@ export const BotBubble = (props: Props) => {
277286
(element as HTMLElement).style.color = textColor;
278287
});
279288

280-
// Always set code blocks text to white
281-
el.querySelectorAll('pre, code').forEach((element) => {
289+
// Code blocks (with pre) get white text
290+
el.querySelectorAll('pre').forEach((element) => {
282291
(element as HTMLElement).style.color = '#FFFFFF';
292+
// Also ensure any code elements inside pre have white text
293+
element.querySelectorAll('code').forEach((codeElement) => {
294+
(codeElement as HTMLElement).style.color = '#FFFFFF';
295+
});
296+
});
297+
298+
// Inline code (not in pre) gets green text
299+
el.querySelectorAll('code:not(pre code)').forEach((element) => {
300+
(element as HTMLElement).style.color = '#4CAF50'; // Green color
283301
});
284302

285303
el.querySelectorAll('a').forEach((link) => {

src/components/bubbles/GuestBubble.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,18 @@ export const GuestBubble = (props: Props) => {
3535
(element as HTMLElement).style.color = textColor;
3636
});
3737

38-
// Always set code blocks text to white
39-
el.querySelectorAll('pre, code').forEach((element) => {
38+
// Code blocks (with pre) get white text
39+
el.querySelectorAll('pre').forEach((element) => {
4040
(element as HTMLElement).style.color = '#FFFFFF';
41+
// Also ensure any code elements inside pre have white text
42+
element.querySelectorAll('code').forEach((codeElement) => {
43+
(codeElement as HTMLElement).style.color = '#FFFFFF';
44+
});
45+
});
46+
47+
// Inline code (not in pre) gets green text
48+
el.querySelectorAll('code:not(pre code)').forEach((element) => {
49+
(element as HTMLElement).style.color = '#4CAF50'; // Green color
4150
});
4251

4352
// Set target="_blank" for links

0 commit comments

Comments
 (0)