mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
#23 added labs layout
This commit is contained in:
parent
8316b46efe
commit
18ec220a4e
14 changed files with 135 additions and 65 deletions
|
@ -1,42 +1,15 @@
|
|||
import React, { DetailsHTMLAttributes, FC, useEffect, useRef } from 'react';
|
||||
import styles from './styles.module.scss';
|
||||
import React, { DetailsHTMLAttributes, FC } from 'react';
|
||||
import StickyBox from 'react-sticky-box/dist/esnext';
|
||||
|
||||
import ResizeSensor from 'resize-sensor';
|
||||
(window as any).ResizeSensor = ResizeSensor;
|
||||
|
||||
import StickySidebar from 'sticky-sidebar';
|
||||
(window as any).StickySidebar = StickySidebar;
|
||||
|
||||
import classnames from 'classnames';
|
||||
|
||||
interface IProps extends DetailsHTMLAttributes<HTMLDivElement> {}
|
||||
|
||||
const Sticky: FC<IProps> = ({ children }) => {
|
||||
const ref = useRef(null);
|
||||
const sb = useRef<StickySidebar>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current) return;
|
||||
|
||||
sb.current = new StickySidebar(ref.current, {
|
||||
resizeSensor: true,
|
||||
topSpacing: 72,
|
||||
bottomSpacing: 10,
|
||||
});
|
||||
|
||||
return () => sb.current?.destroy();
|
||||
}, [ref.current, sb.current, children]);
|
||||
|
||||
if (sb) {
|
||||
sb.current?.updateSticky();
|
||||
}
|
||||
interface IProps extends DetailsHTMLAttributes<HTMLDivElement> {
|
||||
offsetTop?: number;
|
||||
}
|
||||
|
||||
const Sticky: FC<IProps> = ({ children, offsetTop = 65 }) => {
|
||||
return (
|
||||
<div className={classnames(styles.wrap, 'sidebar_container')}>
|
||||
<div className="sidebar" ref={ref}>
|
||||
<div className={classnames(styles.sticky, 'sidebar__inner')}>{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
<StickyBox offsetTop={offsetTop} offsetBottom={10}>
|
||||
{children}
|
||||
</StickyBox>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
@import "src/styles/variables";
|
||||
|
||||
.wrap {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
|
||||
:global(.sidebar) {
|
||||
will-change: min-height;
|
||||
}
|
||||
|
||||
:global(.sidebar__inner) {
|
||||
transform: translate(0, 0); /* For browsers don't support translate3d. */
|
||||
transform: translate3d(0, 0, 0);
|
||||
will-change: position, transform;
|
||||
}
|
||||
}
|
|
@ -82,6 +82,15 @@ const HeaderUnconnected: FC<IProps> = memo(
|
|||
<Filler />
|
||||
|
||||
<div className={styles.plugs}>
|
||||
{is_user && (
|
||||
<Link
|
||||
className={classNames(styles.item, { [styles.is_active]: pathname === URLS.BASE })}
|
||||
to={URLS.LAB}
|
||||
>
|
||||
ЛАБ
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<Link
|
||||
className={classNames(styles.item, { [styles.is_active]: pathname === URLS.BASE })}
|
||||
to={URLS.BASE}
|
||||
|
@ -122,9 +131,6 @@ const HeaderUnconnected: FC<IProps> = memo(
|
|||
}
|
||||
);
|
||||
|
||||
const Header = connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(HeaderUnconnected);
|
||||
const Header = connect(mapStateToProps, mapDispatchToProps)(HeaderUnconnected);
|
||||
|
||||
export { Header };
|
||||
|
|
|
@ -4,14 +4,12 @@ import { UPLOAD_TYPES } from '~/redux/uploads/constants';
|
|||
import { AudioPlayer } from '~/components/media/AudioPlayer';
|
||||
import styles from './styles.module.scss';
|
||||
import { INodeComponentProps } from '~/redux/node/constants';
|
||||
import { useNodeAudios } from '~/utils/hooks/node/useNodeAudios';
|
||||
|
||||
interface IProps extends INodeComponentProps {}
|
||||
|
||||
const NodeAudioBlock: FC<IProps> = ({ node }) => {
|
||||
const audios = useMemo(
|
||||
() => node.files.filter(file => file && file.type === UPLOAD_TYPES.AUDIO),
|
||||
[node.files]
|
||||
);
|
||||
const audios = useNodeAudios(node);
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
|
|
|
@ -6,14 +6,12 @@ import { path } from 'ramda';
|
|||
import { getURL } from '~/utils/dom';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
import { INodeComponentProps } from '~/redux/node/constants';
|
||||
import { useNodeImages } from '~/utils/hooks/node/useNodeImages';
|
||||
|
||||
interface IProps extends INodeComponentProps {}
|
||||
|
||||
const NodeAudioImageBlock: FC<IProps> = ({ node }) => {
|
||||
const images = useMemo(
|
||||
() => node.files.filter(file => file && file.type === UPLOAD_TYPES.IMAGE),
|
||||
[node.files]
|
||||
);
|
||||
const images = useNodeImages(node);
|
||||
|
||||
if (images.length === 0) return null;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue