mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46: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 };
|
35
src/components/input/Toggle/styles.module.scss
Normal file
35
src/components/input/Toggle/styles.module.scss
Normal file
|
@ -0,0 +1,35 @@
|
|||
@import "~/styles/variables.scss";
|
||||
|
||||
.toggle {
|
||||
height: 24px;
|
||||
width: 48px;
|
||||
border-radius: 12px;
|
||||
background-color: transparentize(white, 0.9);
|
||||
display: flex;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
left: 3px;
|
||||
top: 3px;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
border-radius: 11px;
|
||||
background-color: darken(white, 50%);
|
||||
transform: translate(0, 0);
|
||||
transition: transform 0.25s, color 0.25s, background-color;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: $wisegreen;
|
||||
|
||||
&::after {
|
||||
transform: translate(24px, 0);
|
||||
background-color: white;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue