@plteam/chat-ui
Version:
CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript
26 lines (25 loc) • 1.38 kB
JavaScript
import * as React from 'react';
import Tooltip from '@mui/material/Tooltip';
import { useChatSlots } from '../../../core/ChatSlotsContext';
import { materialDesignSysPalette } from '../../../../utils/materialDesign/palette';
const MessageFeedbackButton = ({ type, activeType, onClick, tooltip }) => {
const { coreSlots, slots } = useChatSlots();
const isActive = type === activeType;
const icon = {
like: {
active: React.createElement(slots.messageLikeFilledIcon, null),
default: React.createElement(slots.messageLikeOutlinedIcon, null),
},
dislike: {
active: React.createElement(slots.messageDislikeFilledIcon, null),
default: React.createElement(slots.messageDislikeOutlinedIcon, null),
},
};
return (React.createElement(Tooltip, { title: tooltip },
React.createElement(coreSlots.iconButton, { size: 'small', sx: {
color: isActive ? materialDesignSysPalette.primary : undefined,
backgroundColor: isActive ? materialDesignSysPalette.primaryContainer : undefined,
':hover': { backgroundColor: isActive ? materialDesignSysPalette.primaryFixedDim : undefined },
}, onClick: () => onClick(type) }, icon[type][isActive ? 'active' : 'default'])));
};
export default MessageFeedbackButton;