1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

#23 added superpowers switch

This commit is contained in:
Fedor Katurov 2021-03-19 14:15:04 +07:00
parent e38090c755
commit 756840f173
16 changed files with 178 additions and 25 deletions

View file

@ -0,0 +1,28 @@
import React, { FC, useCallback } from 'react';
import styles from './styles.module.scss';
import classNames from 'classnames';
interface IProps {
value?: boolean;
handler?: (val: boolean) => void;
}
const Toggle: FC<IProps> = ({ value, handler }) => {
const onClick = useCallback(() => {
if (!handler) {
return;
}
handler(!value);
}, [value, handler]);
return (
<button
type="button"
className={classNames(styles.toggle, { [styles.active]: value })}
onClick={onClick}
/>
);
};
export { Toggle };