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

#23 changed promoted button appearance

This commit is contained in:
Fedor Katurov 2021-03-17 17:26:22 +07:00
parent 82aeb7f147
commit 32aaa3f794
7 changed files with 86 additions and 83 deletions

View file

@ -1,7 +1,8 @@
import React, { FC, useCallback, useEffect, useRef } from 'react';
import React, { FC, useCallback } from 'react';
import { IEditorComponentProps } from '~/redux/node/types';
import { usePopper } from 'react-popper';
import { Button } from '~/components/input/Button';
import { Icon } from '~/components/input/Icon';
import styles from './styles.module.scss';
interface IProps extends IEditorComponentProps {}
@ -17,9 +18,8 @@ const EditorPublicSwitch: FC<IProps> = ({ data, setData }) => {
return (
<Button
color={data.is_promoted ? 'primary' : 'secondary'}
color={data.is_promoted ? 'primary' : 'lab'}
type="button"
iconLeft={data.is_promoted ? 'waves' : 'lab'}
size="giant"
label={
data.is_promoted
@ -27,8 +27,17 @@ const EditorPublicSwitch: FC<IProps> = ({ data, setData }) => {
: 'Видно только сотрудникам в лаборатории'
}
onClick={onChange}
className={styles.button}
round
/>
>
{data.is_promoted ? (
<Icon icon="waves" size={24} />
) : (
<div className={styles.lab_wrapper}>
<Icon icon="lab" size={24} />
</div>
)}
</Button>
);
};

View file

@ -1,63 +1,63 @@
@import "src/styles/variables";
.wrap {
@include outer_shadow();
@include editor_round_button();
transition: all 0.5s;
fill: $content_bg;
background-color: $olive;
&.promoted {
background-color: lighten($content_bg, 4%);
fill: $red;
@keyframes move_1 {
0% {
transform: scale(0) translate(0, 0);
opacity: 0;
}
&:hover {
50% {
transform: scale(1) translate(5px, -5px);
opacity: 1;
}
.tooltip {
opacity: 1;
100% {
transform: scale(1.2) translate(-5px, -10px);
opacity: 0;
}
}
@keyframes move_2 {
0% {
transform: scale(0) translate(0, 0);
opacity: 0;
}
50% {
transform: scale(1) translate(-5px, -5px);
opacity: 1;
}
100% {
transform: scale(1.6) translate(5px, -10px);
opacity: 0;
}
}
.button {
}
.lab_wrapper {
position: relative;
bottom: -2px;
.button:hover & {
&:before,&:after {
content: ' ';
position: absolute;
top: 1px;
left: 10px;
width: 2px;
height: 2px;
box-shadow: white 0 0 0 2px;
border-radius: 4px;
animation: move_1 0.5s infinite linear;
}
&:after {
animation: move_2 0.5s -0.25s infinite linear;
}
}
input {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
opacity: 0;
z-index: 1;
cursor: pointer;
}
}
.icon {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
}
.tooltip {
border-radius: 2px;
background: darken($content_bg, 6%);
padding: $gap;
position: absolute;
font: $font_12_semibold;
bottom: 100%;
right: 0;
transform: translate(0, -$gap);
text-align: center;
touch-action: none;
pointer-events: none;
opacity: 0;
width: 100px;
user-select: none;
transition: all 0.1s;
}