-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* propose message box * added hyperlink capability * minor tweaks --------- Co-authored-by: Radha <[email protected]>
- Loading branch information
1 parent
efb5c54
commit cc5e55e
Showing
3 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* src/css/messageBox.css */ | ||
|
||
.message-box { | ||
position: fixed; | ||
bottom: 20px; | ||
right: 10px; | ||
background-color: hwb(0 80% 2%); | ||
z-index: 1000; /* Set a high z-index value */ | ||
border: 1px solid #ccc; | ||
border-radius: 10px; | ||
padding: 20px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
max-width: 270px; /* Adjust width as needed */ | ||
} | ||
|
||
.close-button { | ||
position: absolute; | ||
top: 5px; | ||
right: 5px; | ||
background: none; | ||
border: none; | ||
cursor: pointer; | ||
} | ||
|
||
.messageContent { | ||
margin-top: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { useState } from 'react'; | ||
|
||
const MessageBox = ({ message }) => { | ||
const [isOpen, setIsOpen] = useState(true); | ||
|
||
const handleClose = () => { | ||
setIsOpen(false); | ||
}; | ||
|
||
// Function to convert markdown links to HTML links | ||
const renderMarkdownLinks = (text) => { | ||
return text.replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2">$1</a>'); | ||
}; | ||
|
||
return ( | ||
<> | ||
{isOpen && ( | ||
<div className="message-box"> | ||
<button className="close-button" onClick={handleClose}> | ||
✖ {/* Unicode character for "x" */} | ||
</button> | ||
<div | ||
className="message-content" | ||
dangerouslySetInnerHTML={{ __html: renderMarkdownLinks(message) }} // Render HTML content | ||
></div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default MessageBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters