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

#23 changed toggle colors

This commit is contained in:
Fedor Katurov 2021-03-19 16:26:02 +07:00
commit dddb86c778
6 changed files with 52 additions and 32 deletions

View file

@ -2,12 +2,15 @@ import React, { FC, useCallback } from 'react';
import styles from './styles.module.scss';
import classNames from 'classnames';
type ToggleColor = 'primary' | 'secondary' | 'lab' | 'danger';
interface IProps {
value?: boolean;
handler?: (val: boolean) => void;
color?: ToggleColor;
}
const Toggle: FC<IProps> = ({ value, handler }) => {
const Toggle: FC<IProps> = ({ value, handler, color = 'primary' }) => {
const onClick = useCallback(() => {
if (!handler) {
return;
@ -19,7 +22,7 @@ const Toggle: FC<IProps> = ({ value, handler }) => {
return (
<button
type="button"
className={classNames(styles.toggle, { [styles.active]: value })}
className={classNames(styles.toggle, { [styles.active]: value }, styles[color])}
onClick={onClick}
/>
);