Skip to content

Commit

Permalink
fix : Add Hover Effect to FileMessage Component (#845)
Browse files Browse the repository at this point in the history
* feat: Enhance FileMessage component with hover effect based on theme

* fixed linting
  • Loading branch information
AyushKumar123456789 authored Jan 27, 2025
1 parent 08724e7 commit dd4195a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/react/src/views/FileMessage/FileMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback, memo } from 'react';
import React, { useState, useCallback, memo, useContext } from 'react';
import PropTypes from 'prop-types';
import {
Box,
Expand All @@ -9,6 +9,9 @@ import {
useToastBarDispatch,
useComponentOverrides,
appendClassNames,
useTheme,
lighten,
darken,
} from '@embeddedchat/ui-elements';
import FilePreviewContainer from './FilePreviewContainer';
import FileBodyContainer from '../Message/MessageBodyContainer';
Expand All @@ -26,6 +29,19 @@ const FileMessage = ({ fileMessage }) => {
const { RCInstance } = useRCContext();
const messages = useMessageStore((state) => state.messages);

const theme = useTheme();
const { mode } = theme;
const messageStyles = styles.message;

const hoverStyle = {
'&:hover': {
backgroundColor:
mode === 'light'
? darken(theme.theme.colors.background, 0.03)
: lighten(theme.theme.colors.background, 1),
},
};

const [fileToDelete, setFileToDelete] = useState({});

const downloadFile = useCallback((url, title) => {
Expand Down Expand Up @@ -69,7 +85,7 @@ const FileMessage = ({ fileMessage }) => {
<Box
className={appendClassNames('ec-file', classNames)}
style={styleOverrides}
css={styles.message}
css={[messageStyles, hoverStyle]}
>
<FilePreviewContainer file={fileMessage} />
<FileBodyContainer style={{ width: '75%' }}>
Expand Down

0 comments on commit dd4195a

Please sign in to comment.