Files
5chan/src/components/SettingsModal.jsx
T

52 lines
1.3 KiB
React
Raw Normal View History

2023-03-15 15:25:09 +01:00
import React from "react";
2023-04-09 08:37:29 +02:00
import { StyledModal } from "./styled/SettingsModal.styled";
2023-03-15 15:25:09 +01:00
import { Link, useLocation, useNavigate } from "react-router-dom";
import Modal from "react-modal";
2023-04-08 13:27:17 +02:00
import useGeneralStore from "../hooks/stores/useGeneralStore";
2023-03-15 15:25:09 +01:00
const customOverlayStyles = {
overlay: {
backgroundColor: 'rgba(0,0,0,.25)'
}
};
const SettingsModal = ({ isOpen, closeModal }) => {
2023-04-08 13:27:17 +02:00
const selectedStyle = useGeneralStore(state => state.selectedStyle);
2023-03-15 15:25:09 +01:00
const navigate = useNavigate();
const location = useLocation();
const handleCloseModal = () => {
closeModal();
if (location.pathname === "/settings") {
navigate(-1, { replace: true });
} else {
navigate("/settings", { state: { from: location } });
}
};
return (
<StyledModal
isOpen={isOpen}
onRequestClose={closeModal}
contentLabel="Settings"
style={customOverlayStyles}
selectedStyle={selectedStyle}
>
<div className="panel">
<div className="panel-header">
Settings
<Link to="" onClick={handleCloseModal}>
<span className="icon" title="close" />
</Link>
</div>
<h4>Plebbit Options</h4>
<p>Coming soon...</p>
</div>
</StyledModal>
);
}
Modal.setAppElement("#root");
export default SettingsModal;