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

added flow display controls overlay

This commit is contained in:
Fedor Katurov 2021-10-13 16:14:37 +07:00
parent c8204a41a2
commit 5fef4bc804
14 changed files with 327 additions and 116 deletions

View file

@ -1,16 +1,17 @@
import React, { FC, useCallback } from 'react';
import styles from './styles.module.scss';
import classNames from 'classnames';
import { ButtonProps, DivProps } from '~/utils/types';
type ToggleColor = 'primary' | 'secondary' | 'lab' | 'danger';
type ToggleColor = 'primary' | 'secondary' | 'lab' | 'danger' | 'white';
interface IProps {
type IProps = Omit<ButtonProps, 'value' | 'color'> & {
value?: boolean;
handler?: (val: boolean) => void;
color?: ToggleColor;
}
};
const Toggle: FC<IProps> = ({ value, handler, color = 'primary' }) => {
const Toggle: FC<IProps> = ({ value, handler, color = 'primary', ...rest }) => {
const onClick = useCallback(() => {
if (!handler) {
return;
@ -21,8 +22,14 @@ const Toggle: FC<IProps> = ({ value, handler, color = 'primary' }) => {
return (
<button
{...rest}
type="button"
className={classNames(styles.toggle, { [styles.active]: value }, styles[color])}
className={classNames(
styles.toggle,
{ [styles.active]: value },
styles[color],
rest.className
)}
onClick={onClick}
/>
);

View file

@ -12,6 +12,19 @@
cursor: pointer;
position: relative;
&.white {
box-shadow: inset white 0 0 0 2px;
&::after {
width: 14px;
height: 14px;
top: 5px;
left: 5px;
background: none;
box-shadow: inset white 0 0 0 2px;
}
}
&::after {
content: ' ';
position: absolute;
@ -26,7 +39,6 @@
}
&.active {
&::after {
transform: translate(24px, 0);
background-color: white;
@ -47,5 +59,9 @@
&.danger {
background-color: $red;
}
&.monochrome {
background-color: white;
}
}
}