mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
replaced div with button
This commit is contained in:
parent
44bbc4cd4c
commit
40af254e5c
3 changed files with 19 additions and 16 deletions
|
@ -1,9 +1,7 @@
|
||||||
import React, { FC, useCallback, useEffect, useRef } from 'react';
|
import React, { FC, useCallback, useEffect, useRef } from 'react';
|
||||||
import styles from './styles.module.scss';
|
|
||||||
import { Icon } from '~/components/input/Icon';
|
|
||||||
import { IEditorComponentProps } from '~/redux/node/types';
|
import { IEditorComponentProps } from '~/redux/node/types';
|
||||||
import classNames from 'classnames';
|
|
||||||
import { usePopper } from 'react-popper';
|
import { usePopper } from 'react-popper';
|
||||||
|
import { Button } from '~/components/input/Button';
|
||||||
|
|
||||||
interface IProps extends IEditorComponentProps {}
|
interface IProps extends IEditorComponentProps {}
|
||||||
|
|
||||||
|
@ -29,20 +27,19 @@ const EditorPublicSwitch: FC<IProps> = ({ data, setData }) => {
|
||||||
useEffect(() => console.log(pop), [pop]);
|
useEffect(() => console.log(pop), [pop]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<Button
|
||||||
className={classNames(styles.wrap, { [styles.promoted]: data.is_promoted })}
|
color={data.is_promoted ? 'primary' : 'secondary'}
|
||||||
onClick={onChange}
|
type="button"
|
||||||
>
|
iconLeft={data.is_promoted ? 'waves' : 'lab'}
|
||||||
<div className={styles.tooltip} ref={tooltip}>
|
size="giant"
|
||||||
{data.is_promoted
|
label={
|
||||||
|
data.is_promoted
|
||||||
? 'Доступно всем на главной странице'
|
? 'Доступно всем на главной странице'
|
||||||
: 'Видно только сотрудникам в лаборатории'}
|
: 'Видно только сотрудникам в лаборатории'
|
||||||
</div>
|
}
|
||||||
|
onClick={onChange}
|
||||||
<div className={styles.icon}>
|
round
|
||||||
{data.is_promoted ? <Icon size={24} icon="waves" /> : <Icon size={24} icon="lab" />}
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ type IButtonProps = DetailedHTMLProps<
|
||||||
stretchy?: boolean;
|
stretchy?: boolean;
|
||||||
iconOnly?: boolean;
|
iconOnly?: boolean;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
round?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Button: FC<IButtonProps> = memo(
|
const Button: FC<IButtonProps> = memo(
|
||||||
|
@ -48,6 +49,7 @@ const Button: FC<IButtonProps> = memo(
|
||||||
iconOnly,
|
iconOnly,
|
||||||
label,
|
label,
|
||||||
ref,
|
ref,
|
||||||
|
round,
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
const tooltip = useRef<HTMLSpanElement | null>(null);
|
const tooltip = useRef<HTMLSpanElement | null>(null);
|
||||||
|
@ -75,6 +77,7 @@ const Button: FC<IButtonProps> = memo(
|
||||||
icon: ((iconLeft || iconRight) && !title && !children) || iconOnly,
|
icon: ((iconLeft || iconRight) && !title && !children) || iconOnly,
|
||||||
has_icon_left: !!iconLeft,
|
has_icon_left: !!iconLeft,
|
||||||
has_icon_right: !!iconRight,
|
has_icon_right: !!iconRight,
|
||||||
|
round,
|
||||||
}),
|
}),
|
||||||
...props,
|
...props,
|
||||||
},
|
},
|
||||||
|
|
|
@ -202,14 +202,17 @@
|
||||||
.normal {
|
.normal {
|
||||||
height: 38px;
|
height: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.big {
|
.big {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.giant {
|
.giant {
|
||||||
height: 50px;
|
height: 50px;
|
||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.disabled {
|
.disabled {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue