Skip to content

Commit

Permalink
add feeback color
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryHengZJ committed Apr 26, 2024
1 parent dc58e2b commit 5f0b759
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 19 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ You can also customize chatbot with different configuration
textColor: '#303235',
sendButtonColor: '#3B81F6',
},
feedback: {
color: '#303235',
},
},
},
});
Expand Down
3 changes: 2 additions & 1 deletion dist/components/Bot.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BotMessageTheme, TextInputTheme, UserMessageTheme } from '@/features/bubble/types';
import { BotMessageTheme, TextInputTheme, UserMessageTheme, FeedbackTheme } from '@/features/bubble/types';
export type FileEvent<T = EventTarget> = {
target: T;
};
Expand Down Expand Up @@ -40,6 +40,7 @@ export type BotProps = {
botMessage?: BotMessageTheme;
userMessage?: UserMessageTheme;
textInput?: TextInputTheme;
feedback?: FeedbackTheme;
poweredByTextColor?: string;
badgeBackgroundColor?: string;
bubbleBackgroundColor?: string;
Expand Down
2 changes: 1 addition & 1 deletion dist/components/Bot.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/components/bubbles/BotBubble.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Props = {
textColor?: string;
chatFeedbackStatus?: boolean;
fontSize?: number;
feedbackColor?: string;
};
export declare const BotBubble: (props: Props) => import("solid-js").JSX.Element;
export {};
Expand Down
2 changes: 1 addition & 1 deletion dist/components/bubbles/BotBubble.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/components/buttons/FeedbackButtons.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JSX } from 'solid-js';
type RatingButtonProps = {
sendButtonColor?: string;
feedbackColor?: string;
isDisabled?: boolean;
isLoading?: boolean;
disableIcon?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion dist/components/buttons/FeedbackButtons.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/features/bubble/components/Bubble.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/features/bubble/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export type BotMessageTheme = {
showAvatar?: boolean;
avatarSrc?: string;
};
export type FeedbackTheme = {
color?: string;
};
export type ChatWindowTheme = {
showTitle?: boolean;
title?: string;
Expand All @@ -36,6 +39,7 @@ export type ChatWindowTheme = {
userMessage?: UserMessageTheme;
botMessage?: BotMessageTheme;
textInput?: TextInputTheme;
feedback?: FeedbackTheme;
poweredByTextColor?: string;
};
export type ButtonTheme = {
Expand Down
2 changes: 1 addition & 1 deletion dist/features/bubble/types.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/features/full/components/Full.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/web.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/components/Bot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BotBubble } from './bubbles/BotBubble';
import { LoadingBubble } from './bubbles/LoadingBubble';
import { SourceBubble } from './bubbles/SourceBubble';
import { StarterPromptBubble } from './bubbles/StarterPromptBubble';
import { BotMessageTheme, TextInputTheme, UserMessageTheme } from '@/features/bubble/types';
import { BotMessageTheme, TextInputTheme, UserMessageTheme, FeedbackTheme } from '@/features/bubble/types';
import { Badge } from './Badge';
import socketIOClient from 'socket.io-client';
import { Popup } from '@/features/popup';
Expand Down Expand Up @@ -67,6 +67,7 @@ export type BotProps = {
botMessage?: BotMessageTheme;
userMessage?: UserMessageTheme;
textInput?: TextInputTheme;
feedback?: FeedbackTheme;
poweredByTextColor?: string;
badgeBackgroundColor?: string;
bubbleBackgroundColor?: string;
Expand Down Expand Up @@ -848,6 +849,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
apiHost={props.apiHost}
backgroundColor={props.botMessage?.backgroundColor}
textColor={props.botMessage?.textColor}
feedbackColor={props.feedback?.color}
showAvatar={props.botMessage?.showAvatar}
avatarSrc={props.botMessage?.avatarSrc}
chatFeedbackStatus={chatFeedbackStatus()}
Expand Down
12 changes: 9 additions & 3 deletions src/components/bubbles/BotBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = {
textColor?: string;
chatFeedbackStatus?: boolean;
fontSize?: number;
feedbackColor?: string;
};

const defaultBackgroundColor = '#f7f8ff';
Expand Down Expand Up @@ -175,12 +176,17 @@ export const BotBubble = (props: Props) => {
{props.chatFeedbackStatus && props.message.messageId && (
<>
<div class="flex items-center px-2">
<CopyToClipboardButton onClick={() => copyMessageToClipboard()} />
<CopyToClipboardButton feedbackColor={props.feedbackColor} onClick={() => copyMessageToClipboard()} />
{rating() === '' || rating() === 'THUMBS_UP' ? (
<ThumbsUpButton isDisabled={rating() === 'THUMBS_UP'} rating={rating()} onClick={onThumbsUpClick} />
<ThumbsUpButton feedbackColor={props.feedbackColor} isDisabled={rating() === 'THUMBS_UP'} rating={rating()} onClick={onThumbsUpClick} />
) : null}
{rating() === '' || rating() === 'THUMBS_DOWN' ? (
<ThumbsDownButton isDisabled={rating() === 'THUMBS_DOWN'} rating={rating()} onClick={onThumbsDownClick} />
<ThumbsDownButton
feedbackColor={props.feedbackColor}
isDisabled={rating() === 'THUMBS_DOWN'}
rating={rating()}
onClick={onThumbsDownClick}
/>
) : null}
</div>
<Show when={showFeedbackContentDialog()}>
Expand Down
10 changes: 6 additions & 4 deletions src/components/buttons/FeedbackButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { Spinner } from './SendButton';
import { ClipboardIcon, ThumbsDownIcon, ThumbsUpIcon } from '../icons';

type RatingButtonProps = {
sendButtonColor?: string;
feedbackColor?: string;
isDisabled?: boolean;
isLoading?: boolean;
disableIcon?: boolean;
rating?: string;
} & JSX.ButtonHTMLAttributes<HTMLButtonElement>;

const defaultFeedbackColor = '#3B81F6';

export const CopyToClipboardButton = (props: RatingButtonProps) => {
return (
<button
Expand All @@ -23,7 +25,7 @@ export const CopyToClipboardButton = (props: RatingButtonProps) => {
title="Copy to clipboard"
>
<Show when={!props.isLoading} fallback={<Spinner class="text-white" />}>
<ClipboardIcon color={props.sendButtonColor} class={'send-icon flex ' + (props.disableIcon ? 'hidden' : '')} />
<ClipboardIcon color={props.feedbackColor ?? defaultFeedbackColor} class={'send-icon flex ' + (props.disableIcon ? 'hidden' : '')} />
</Show>
</button>
);
Expand All @@ -43,7 +45,7 @@ export const ThumbsUpButton = (props: RatingButtonProps) => {
title="Thumbs Up"
>
<Show when={!props.isLoading} fallback={<Spinner class="text-white" />}>
<ThumbsUpIcon color={props.sendButtonColor} class={'send-icon flex ' + (props.disableIcon ? 'hidden' : '')} />
<ThumbsUpIcon color={props.feedbackColor ?? defaultFeedbackColor} class={'send-icon flex ' + (props.disableIcon ? 'hidden' : '')} />
</Show>
</button>
);
Expand All @@ -63,7 +65,7 @@ export const ThumbsDownButton = (props: RatingButtonProps) => {
title="Thumbs Down"
>
<Show when={!props.isLoading} fallback={<Spinner class="text-white" />}>
<ThumbsDownIcon color={props.sendButtonColor} class={'send-icon flex ' + (props.disableIcon ? 'hidden' : '')} />
<ThumbsDownIcon color={props.feedbackColor ?? defaultFeedbackColor} class={'send-icon flex ' + (props.disableIcon ? 'hidden' : '')} />
</Show>
</button>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/icons/ThumbsDownIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const ThumbsDownIcon = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => (
width="24"
height="24"
viewBox="0 0 24 24"
fill={props.color ?? 'none'}
fill="none"
stroke={props.color ?? defaultButtonColor}
stroke-width="2"
stroke-linecap="round"
Expand Down
2 changes: 1 addition & 1 deletion src/components/icons/ThumbsUpIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const ThumbsUpIcon = (props: JSX.SvgSVGAttributes<SVGSVGElement>) => (
width="24"
height="24"
viewBox="0 0 24 24"
fill={props.color ?? 'none'}
fill="none"
stroke={props.color ?? defaultButtonColor}
stroke-width="2"
stroke-linecap="round"
Expand Down
1 change: 1 addition & 0 deletions src/features/bubble/components/Bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const Bubble = (props: BubbleProps) => {
textInput={bubbleProps.theme?.chatWindow?.textInput}
botMessage={bubbleProps.theme?.chatWindow?.botMessage}
userMessage={bubbleProps.theme?.chatWindow?.userMessage}
feedback={bubbleProps.theme?.chatWindow?.feedback}
fontSize={bubbleProps.theme?.chatWindow?.fontSize}
chatflowid={props.chatflowid}
chatflowConfig={props.chatflowConfig}
Expand Down
5 changes: 5 additions & 0 deletions src/features/bubble/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export type BotMessageTheme = {
avatarSrc?: string;
};

export type FeedbackTheme = {
color?: string;
};

export type ChatWindowTheme = {
showTitle?: boolean;
title?: string;
Expand All @@ -41,6 +45,7 @@ export type ChatWindowTheme = {
userMessage?: UserMessageTheme;
botMessage?: BotMessageTheme;
textInput?: TextInputTheme;
feedback?: FeedbackTheme;
poweredByTextColor?: string;
};

Expand Down
1 change: 1 addition & 0 deletions src/features/full/components/Full.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const Full = (props: FullProps, { element }: { element: HTMLElement }) =>
textInput={props.theme?.chatWindow?.textInput}
botMessage={props.theme?.chatWindow?.botMessage}
userMessage={props.theme?.chatWindow?.userMessage}
feedback={props.theme?.chatWindow?.feedback}
fontSize={props.theme?.chatWindow?.fontSize}
chatflowid={props.chatflowid}
chatflowConfig={props.chatflowConfig}
Expand Down

0 comments on commit 5f0b759

Please sign in to comment.