2021-05-18 00:04:06 +00:00
|
|
|
import React, { useContext, useState } 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
|
|
|
|
|
|
|
|
|
|
|
export default function ButtonToggleBeforeAfter({ onUpdate, className, ...props }) {
|
|
|
|
const [value, setValue] = useState(false)
|
2021-05-18 00:48:34 +00:00
|
|
|
const { strings } = useContext(ContextLanguage)
|
2021-04-30 14:37:28 +00:00
|
|
|
|
|
|
|
const onButtonClick = () => {
|
|
|
|
onUpdate(!value)
|
|
|
|
setValue(value => !value)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
color={"Grey"}
|
|
|
|
className={classNames(Style.ButtonToggleBeforeAfter, className)}
|
|
|
|
onClick={onButtonClick}
|
|
|
|
{...props}
|
|
|
|
>
|
2021-05-18 00:04:06 +00:00
|
|
|
{value ? strings.timeBefore : strings.timeAfter}
|
2021-04-30 14:37:28 +00:00
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}
|