Skip to content

The Open Standard for Generative UI

add theme variables for chat (#49)

abhithesys27bad3dec73a
diff --git a/js/packages/react-ui/package.json b/js/packages/react-ui/package.json
index 837764969..e23bf1d0d 100644
--- a/js/packages/react-ui/package.json
+++ b/js/packages/react-ui/package.json
@@ -2,7 +2,7 @@
"type": "module",
"name": "@crayonai/react-ui",
"license": "MIT",
- "version": "0.5.2",
+ "version": "0.5.3",
"description": "Component library for Generative UI SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
diff --git a/js/packages/react-ui/src/components/Shell/shell.scss b/js/packages/react-ui/src/components/Shell/shell.scss
index 5a63110b8..f38656dee 100644
--- a/js/packages/react-ui/src/components/Shell/shell.scss
+++ b/js/packages/react-ui/src/components/Shell/shell.scss
@@ -12,7 +12,7 @@
padding: cssUtils.$spacing-m;
overflow: hidden;
- background: cssUtils.$bg-fill;
+ background: cssUtils.$chat-container-bg;
box-sizing: border-box;
& * {
box-sizing: border-box;
diff --git a/js/packages/react-ui/src/components/Shell/sidebar.scss b/js/packages/react-ui/src/components/Shell/sidebar.scss
index ba3dc1cef..eced8d448 100644
--- a/js/packages/react-ui/src/components/Shell/sidebar.scss
+++ b/js/packages/react-ui/src/components/Shell/sidebar.scss
@@ -6,7 +6,7 @@ $sidebar-mobile-width: 294px;
$sidebar-mobile-padding: cssUtils.$spacing-l;
.crayon-shell-sidebar-container {
- background: cssUtils.$bg-fill;
+ background: cssUtils.$bg-container;
border: 1px solid cssUtils.$stroke-default;
height: 100%;
width: $sidebar-width;
diff --git a/js/packages/react-ui/src/components/Shell/thread.scss b/js/packages/react-ui/src/components/Shell/thread.scss
index 60e359f3f..64fb9323e 100644
--- a/js/packages/react-ui/src/components/Shell/thread.scss
+++ b/js/packages/react-ui/src/components/Shell/thread.scss
@@ -35,6 +35,10 @@ $center-align-spacing: calc(32px + cssUtils.$spacing-s);
padding-right: $center-align-spacing;
overflow: hidden;
+ // override theme variables so that other crayon components don't depend on chat colors
+ --crayon-primary-text: #{cssUtils.$chat-assistant-response-text};
+ --crayon-container-fills: #{cssUtils.$chat-assistant-response-bg};
+
.crayon-shell-container--mobile & {
padding: 0;
}
@@ -50,6 +54,7 @@ $center-align-spacing: calc(32px + cssUtils.$spacing-s);
&__text {
@include cssUtils.typography(primary, default);
+ color: cssUtils.$chat-assistant-response-text;
&:first-child {
margin-top: cssUtils.$spacing-xs;
}
@@ -74,8 +79,8 @@ $center-align-spacing: calc(32px + cssUtils.$spacing-s);
&__content {
@include cssUtils.typography(primary, default);
padding: cssUtils.$spacing-m cssUtils.$spacing-l;
- background-color: cssUtils.$bg-brand-el;
- color: cssUtils.$primary-text;
+ background-color: cssUtils.$chat-user-response-bg;
+ color: cssUtils.$chat-user-response-text;
border-radius: cssUtils.$rounded-2xl;
overflow-wrap: break-word;
max-width: 100%;
diff --git a/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx b/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
index 8c34b69b0..ee5924b4b 100644
--- a/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
+++ b/js/packages/react-ui/src/components/ThemeProvider/ThemeProvider.tsx
@@ -309,6 +309,12 @@ export const ThemeProvider = ({
--crayon-shadow-xl: ${theme.shadowXl};
--crayon-shadow-2xl: ${theme.shadow2xl};
--crayon-shadow-3xl: ${theme.shadow3xl};
+
+ --crayon-chat-container-bg: ${theme.chatContainerBg || theme.backgroundFills};
+ --crayon-chat-assistant-response-bg: ${theme.chatAssistantResponseBg || theme.containerFills};
+ --crayon-chat-assistant-response-text: ${theme.chatAssistantResponseText || theme.primaryText};
+ --crayon-chat-user-response-bg: ${theme.chatUserResponseBg || theme.brandElFills};
+ --crayon-chat-user-response-text: ${theme.chatUserResponseText || theme.brandText};
}
`}</style>
{children}
diff --git a/js/packages/react-ui/src/components/ThemeProvider/types.ts b/js/packages/react-ui/src/components/ThemeProvider/types.ts
index 3d1d9b1a8..6f46fc4c0 100644
--- a/js/packages/react-ui/src/components/ThemeProvider/types.ts
+++ b/js/packages/react-ui/src/components/ThemeProvider/types.ts
@@ -30,6 +30,13 @@ export interface ColorTheme {
successText?: string;
linkText?: string;
infoText?: string;
+
+ // chat colors
+ chatContainerBg?: string;
+ chatAssistantResponseBg?: string;
+ chatAssistantResponseText?: string;
+ chatUserResponseBg?: string;
+ chatUserResponseText?: string;
}
// Layout-related theme properties
diff --git a/js/packages/react-ui/src/cssUtils.scss b/js/packages/react-ui/src/cssUtils.scss
index 3fa75354c..4bdb69966 100644
--- a/js/packages/react-ui/src/cssUtils.scss
+++ b/js/packages/react-ui/src/cssUtils.scss
@@ -67,6 +67,14 @@ $shadow-xl: var(--crayon-shadow-xl);
$shadow-2xl: var(--crayon-shadow-2xl);
$shadow-3xl: var(--crayon-shadow-3xl);
+// Crayon Chat Colors
+
+$chat-container-bg: var(--crayon-chat-container-bg);
+$chat-assistant-response-bg: var(--crayon-chat-assistant-response-bg);
+$chat-assistant-response-text: var(--crayon-chat-assistant-response-text);
+$chat-user-response-bg: var(--crayon-chat-user-response-bg);
+$chat-user-response-text: var(--crayon-chat-user-response-text);
+
@function typography($font-name) {
@return (font: var(--#{$font-name}), letter-spacing: var(--#{$font-name}-letter-spacing));
}