Skip to content

Commit

Permalink
Added styling and icon to enlarge image
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Wentzel committed Feb 5, 2025
1 parent 0791433 commit 8fa9f8d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions assets/js/Containers/FrevaGPT/components/ChatBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import React from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";

import { Col, Card, Modal } from "react-bootstrap";
import { Col, Card, Modal, Button } from "react-bootstrap";

import { isEmpty } from "lodash";

import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";

import { FaExpand } from "react-icons/fa";

import { replaceLinebreaks } from "../utils";

import * as constants from "../constants";
Expand All @@ -24,20 +26,36 @@ class ChatBlock extends React.Component {
this.renderUser = this.renderUser.bind(this);
this.renderError = this.renderError.bind(this);
this.renderDefault = this.renderDefault.bind(this);
this.enlargeImage = this.enlargeImage.bind(this);

this.state = {
showModal: false
}
}

enlargeImage(imageString) {
this.setState({showModal: true, image: `data:image/jpeg;base64,${imageString}`})
}

renderImage(element, index) {
return (
<Col key={`${index}-image`} md={constants.BOT_COLUMN_STYLE}>
<Col
key={`${index}-image`}
md={constants.BOT_COLUMN_STYLE}
className="border-0 border-bottom mb-3 shadow-sm card-body">
<img
className="w-100"
onClick={() => this.setState({showModal: true, image: `data:image/jpeg;base64,${element.content}`})}
onClick={() => this.enlargeImage(element.content)}
src={`data:image/jpeg;base64,${element.content}`}
/>
<div className="d-flex justify-content-end">
<Button
variant="link"
onClick={() => this.enlargeImage(element.content)}
className="d-flex align-items-center">
<FaExpand/>
</Button>
</div>
</Col>
);
}
Expand Down

0 comments on commit 8fa9f8d

Please sign in to comment.