mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
returned fluid lab
This commit is contained in:
parent
8ff18dfd10
commit
2e4cb24cf4
4 changed files with 41 additions and 37 deletions
|
@ -1,4 +1,5 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
import Masonry from 'react-masonry-css';
|
||||||
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { LabNode } from '~/components/lab/LabNode';
|
import { LabNode } from '~/components/lab/LabNode';
|
||||||
|
@ -8,6 +9,11 @@ import { values } from 'ramda';
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {}
|
||||||
|
|
||||||
|
const breakpointCols = {
|
||||||
|
default: 2,
|
||||||
|
1280: 1,
|
||||||
|
};
|
||||||
|
|
||||||
const getRandomNodeType = () =>
|
const getRandomNodeType = () =>
|
||||||
values(NODE_TYPES)[Math.floor(Math.random() * values(NODE_TYPES).length)];
|
values(NODE_TYPES)[Math.floor(Math.random() * values(NODE_TYPES).length)];
|
||||||
|
|
||||||
|
@ -26,17 +32,30 @@ const LabGrid: FC<IProps> = () => {
|
||||||
|
|
||||||
if (is_loading) {
|
if (is_loading) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<Masonry
|
||||||
|
className={styles.wrap}
|
||||||
|
breakpointCols={breakpointCols}
|
||||||
|
columnClassName={styles.column}
|
||||||
|
>
|
||||||
<LoadingNode />
|
<LoadingNode />
|
||||||
<LoadingNode />
|
<LoadingNode />
|
||||||
<LoadingNode />
|
<LoadingNode />
|
||||||
<LoadingNode />
|
<LoadingNode />
|
||||||
</div>
|
<LoadingNode />
|
||||||
|
<LoadingNode />
|
||||||
|
<LoadingNode />
|
||||||
|
<LoadingNode />
|
||||||
|
<LoadingNode />
|
||||||
|
</Masonry>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<Masonry
|
||||||
|
className={styles.wrap}
|
||||||
|
breakpointCols={breakpointCols}
|
||||||
|
columnClassName={styles.column}
|
||||||
|
>
|
||||||
{nodes.map(node => (
|
{nodes.map(node => (
|
||||||
<LabNode
|
<LabNode
|
||||||
node={node.node}
|
node={node.node}
|
||||||
|
@ -45,7 +64,7 @@ const LabGrid: FC<IProps> = () => {
|
||||||
commentCount={node.comment_count}
|
commentCount={node.comment_count}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</Masonry>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
@import "~/styles/variables.scss";
|
@import "~/styles/variables.scss";
|
||||||
|
|
||||||
.wrap {
|
div.wrap {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-auto-flow: row;
|
width: 100%;
|
||||||
grid-auto-rows: auto;
|
margin-right: 0;
|
||||||
grid-row-gap: $gap * 2;
|
}
|
||||||
|
|
||||||
|
.column {
|
||||||
|
background-clip: padding-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0 $gap / 2;
|
||||||
|
|
||||||
|
& > div {
|
||||||
|
margin-bottom: $gap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,20 +18,9 @@ import classNames from 'classnames';
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {}
|
||||||
|
|
||||||
enum Layout {
|
|
||||||
Fluid = 'fluid',
|
|
||||||
Default = 'default',
|
|
||||||
}
|
|
||||||
|
|
||||||
const LabLayout: FC<IProps> = () => {
|
const LabLayout: FC<IProps> = () => {
|
||||||
const { is_loading } = useShallowSelect(selectLabList);
|
const { is_loading } = useShallowSelect(selectLabList);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [layout, setLayout] = usePersistedState('lab_layout', Layout.Default);
|
|
||||||
|
|
||||||
const isFluid = layout === Layout.Fluid;
|
|
||||||
const toggleLayout = useCallback(() => {
|
|
||||||
setLayout(isFluid ? Layout.Default : Layout.Fluid);
|
|
||||||
}, [setLayout, isFluid]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(labGetList());
|
dispatch(labGetList());
|
||||||
|
@ -39,8 +28,8 @@ const LabLayout: FC<IProps> = () => {
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Container>
|
||||||
<div className={classNames(styles.container, { [styles.fluid]: isFluid })}>
|
<div className={styles.container}>
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<Group className={styles.content}>
|
<Group className={styles.content}>
|
||||||
<LabHead isLoading={is_loading} />
|
<LabHead isLoading={is_loading} />
|
||||||
|
@ -56,7 +45,7 @@ const LabLayout: FC<IProps> = () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SidebarRouter prefix="/lab" isLab />
|
<SidebarRouter prefix="/lab" isLab />
|
||||||
</div>
|
</Container>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,15 @@
|
||||||
@import "~/styles/variables.scss";
|
@import "~/styles/variables.scss";
|
||||||
|
|
||||||
@mixin fluid {
|
|
||||||
@media(min-width: $content_width) {
|
|
||||||
.fluid & {
|
|
||||||
@content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 3fr 1fr;
|
grid-template-columns: 3fr 1fr;
|
||||||
column-gap: $gap;
|
column-gap: $gap/2;
|
||||||
|
|
||||||
@include tablet {
|
@include tablet {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
grid-auto-flow: row;
|
grid-auto-flow: row;
|
||||||
padding: 0 $gap / 2;
|
padding: 0 $gap / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@include fluid {
|
|
||||||
grid-template-columns: 3fr $cell;
|
|
||||||
padding: 0 $gap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue