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:
parent
e38090c755
commit
756840f173
16 changed files with 178 additions and 25 deletions
28
src/components/input/Toggle/index.tsx
Normal file
28
src/components/input/Toggle/index.tsx
Normal 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 };
|
Loading…
Add table
Add a link
Reference in a new issue