2021-05-21 17:52:56 +00:00
|
|
|
import React, { useContext } from "react"
|
2021-04-30 14:37:28 +00:00
|
|
|
import Style from "./ButtonToggleBeforeAfter.module.css"
|
|
|
|
import classNames from "classnames"
|
|
|
|
import Button from "../base/Button"
|
2021-05-18 00:04:06 +00:00
|
|
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
2021-04-30 14:37:28 +00:00
|
|
|
|
|
|
|
|
2021-05-23 03:03:41 +00:00
|
|
|
/**
|
|
|
|
* A {@link Button} allowing the user to select between **Before** and **After**.
|
|
|
|
*
|
|
|
|
* @param isBefore - The current value of the button.
|
|
|
|
* @param setBefore - Function to set the current value of the button.
|
|
|
|
* @param className - Additional class(es) to append to the button.
|
|
|
|
* @param props - Additional props to pass to the button.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-21 17:52:56 +00:00
|
|
|
export default function ButtonToggleBeforeAfter({ isBefore, setBefore, className, ...props }) {
|
2021-05-18 00:48:34 +00:00
|
|
|
const { strings } = useContext(ContextLanguage)
|
2021-04-30 14:37:28 +00:00
|
|
|
|
|
|
|
const onButtonClick = () => {
|
2021-05-21 17:52:56 +00:00
|
|
|
setBefore(a => !a)
|
2021-04-30 14:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
color={"Grey"}
|
|
|
|
className={classNames(Style.ButtonToggleBeforeAfter, className)}
|
|
|
|
onClick={onButtonClick}
|
|
|
|
{...props}
|
|
|
|
>
|
2021-05-21 17:52:56 +00:00
|
|
|
{isBefore ? strings.timeBefore : strings.timeAfter}
|
2021-04-30 14:37:28 +00:00
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}
|