mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-26 23:14:19 +00:00
27 lines
817 B
JavaScript
27 lines
817 B
JavaScript
import React, { useContext, useState } from "react"
|
|
import Style from "./ButtonToggleBeforeAfter.module.css"
|
|
import classNames from "classnames"
|
|
import Button from "../base/Button"
|
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
|
|
|
|
|
export default function ButtonToggleBeforeAfter({ onUpdate, className, ...props }) {
|
|
const [value, setValue] = useState(false)
|
|
const { strings } = useContext(ContextLanguage)
|
|
|
|
const onButtonClick = () => {
|
|
onUpdate(!value)
|
|
setValue(value => !value)
|
|
}
|
|
|
|
return (
|
|
<Button
|
|
color={"Grey"}
|
|
className={classNames(Style.ButtonToggleBeforeAfter, className)}
|
|
onClick={onButtonClick}
|
|
{...props}
|
|
>
|
|
{value ? strings.timeBefore : strings.timeAfter}
|
|
</Button>
|
|
)
|
|
}
|