-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft: feat: show match context #396
- Loading branch information
Showing
3 changed files
with
114 additions
and
1 deletion.
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
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,78 @@ | ||
import React, { useState } from "react"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faLightbulb } from "@fortawesome/free-solid-svg-icons"; | ||
|
||
const ActionShowMatchContext = (props) => { | ||
const [showModal, setShowModal] = useState(false); | ||
|
||
const modalHeader = ( | ||
<div className="modal-header d-flex justify-content-between"> | ||
<h6 className="modal-title">Match context</h6> | ||
<button | ||
type="button" | ||
className="close " | ||
onClick={() => setShowModal(false)} | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
); | ||
|
||
const tableRows = Object.entries(props.context).map( | ||
(contextItem, index) => ( | ||
<tr key={index}> | ||
<th scope="row fit-content"> | ||
<span className="badge rounded-pill bg-primary ms-1 mt-1"> | ||
{contextItem[0]} | ||
</span> | ||
</th> | ||
<th scope="row">{contextItem[1]}</th> | ||
</tr> | ||
) | ||
); | ||
|
||
const modalBody = ( | ||
<div className="modal-body modal-table"> | ||
{!props.context ? ( | ||
"No context available" | ||
) : ( | ||
<table className="table"> | ||
<tbody>{tableRows}</tbody> | ||
</table> | ||
)} | ||
</div> | ||
); | ||
|
||
return ( | ||
<> | ||
<button | ||
title="Show match context" | ||
className="text-secondary" | ||
style={{ border: 0, background: 0 }} | ||
onClick={() => setShowModal(!showModal)} | ||
> | ||
<FontAwesomeIcon icon={faLightbulb} size="sm" /> | ||
</button> | ||
<div className="modal-container"> | ||
<div | ||
className="modal modal-block" | ||
style={{ | ||
display: showModal ? "block" : "none", | ||
blockSize: "fit-content", | ||
width: "fit-content", | ||
position: "center", | ||
}} | ||
> | ||
<div className="modal-dialog"> | ||
<div className="modal-content"> | ||
{modalHeader} | ||
{modalBody} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default ActionShowMatchContext; |
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