2022-04-06 16:37:23 +02:00
|
|
|
import React from "react";
|
|
|
|
import {useTheme} from "../../hooks/themeHook";
|
|
|
|
import {FontAwesomeIcon as Fa} from "@fortawesome/react-fontawesome";
|
|
|
|
import {faCloudMoon, faPalette} from "@fortawesome/free-solid-svg-icons";
|
|
|
|
import {colorEnumToBgClass} from "../../util/colors";
|
|
|
|
import {Modal} from "react-bootstrap-v5";
|
|
|
|
import {useTranslation} from "react-i18next";
|
|
|
|
|
|
|
|
const ColorSelectorButton = ({color, setColor, disabled}) =>
|
|
|
|
<button className={"btn color-chooser " + colorEnumToBgClass(color)}
|
|
|
|
id={"choose-" + color}
|
|
|
|
disabled={disabled}
|
|
|
|
onClick={() => setColor(color)}
|
|
|
|
>
|
|
|
|
<Fa icon={faPalette}/>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
const ColorSelectorModal = () => {
|
|
|
|
const {t} = useTranslation();
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal id="colorChooserModal"
|
|
|
|
aria-labelledby="colorChooserModalLabel"
|
|
|
|
show={theme.colorChooserOpen}
|
|
|
|
onHide={theme.toggleColorChooser}>
|
2022-08-18 17:27:11 +02:00
|
|
|
<Modal.Header className="bg-white">
|
2022-04-06 16:37:23 +02:00
|
|
|
<Modal.Title id="colorChooserModalLabel">
|
|
|
|
<Fa icon={faPalette}/> {t('html.label.themeSelect')}
|
|
|
|
</Modal.Title>
|
|
|
|
<button aria-label="Close" className="btn-close" onClick={theme.toggleColorChooser}/>
|
|
|
|
</Modal.Header>
|
|
|
|
<Modal.Body style={{padding: "0.5rem 0 0.5rem 0.5rem"}}>
|
|
|
|
{theme.themeColors.map((color, i) =>
|
|
|
|
<ColorSelectorButton
|
|
|
|
key={i}
|
|
|
|
color={color.name}
|
|
|
|
setColor={theme.setColor}
|
|
|
|
disabled={theme.nightModeEnabled}
|
|
|
|
/>)}
|
|
|
|
</Modal.Body>
|
|
|
|
<Modal.Footer>
|
|
|
|
<button className="btn" id="night-mode-toggle" type="button" onClick={theme.toggleNightMode}>
|
|
|
|
<Fa icon={faCloudMoon}/> {t('html.button.nightMode')}
|
|
|
|
</button>
|
|
|
|
<button className="btn bg-plan" type="button" onClick={theme.toggleColorChooser}>OK</button>
|
|
|
|
</Modal.Footer>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ColorSelectorModal;
|