mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
#23 fixed submit button appearance for lab
This commit is contained in:
parent
998a2e305a
commit
ede5dfe17f
15 changed files with 82 additions and 44 deletions
|
@ -1,28 +1,37 @@
|
||||||
import React, { FC, useCallback } from 'react';
|
import React, { FC, useCallback } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
import * as NODE_ACTIONS from '~/redux/node/actions';
|
import { nodeCreate } from '~/redux/node/actions';
|
||||||
import { DIALOGS } from '~/redux/modal/constants';
|
|
||||||
|
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { NODE_TYPES } from '~/redux/node/constants';
|
import { NODE_TYPES } from '~/redux/node/constants';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
const mapStateToProps = null;
|
interface Props {
|
||||||
const mapDispatchToProps = {
|
isLab?: boolean;
|
||||||
nodeCreate: NODE_ACTIONS.nodeCreate,
|
}
|
||||||
// showDialog: MODAL_ACTIONS.modalShowDialog,
|
|
||||||
};
|
|
||||||
|
|
||||||
type IProps = typeof mapDispatchToProps & {};
|
const SubmitBar: FC<Props> = ({ isLab }) => {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const SubmitBarUnconnected: FC<IProps> = ({ nodeCreate }) => {
|
const onOpenImageEditor = useCallback(() => dispatch(nodeCreate(NODE_TYPES.IMAGE, isLab)), [
|
||||||
const onOpenImageEditor = useCallback(() => nodeCreate(NODE_TYPES.IMAGE), [nodeCreate]);
|
dispatch,
|
||||||
const onOpenTextEditor = useCallback(() => nodeCreate(NODE_TYPES.TEXT), [nodeCreate]);
|
]);
|
||||||
const onOpenVideoEditor = useCallback(() => nodeCreate(NODE_TYPES.VIDEO), [nodeCreate]);
|
|
||||||
const onOpenAudioEditor = useCallback(() => nodeCreate(NODE_TYPES.AUDIO), [nodeCreate]);
|
const onOpenTextEditor = useCallback(() => dispatch(nodeCreate(NODE_TYPES.TEXT, isLab)), [
|
||||||
|
dispatch,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const onOpenVideoEditor = useCallback(() => dispatch(nodeCreate(NODE_TYPES.VIDEO, isLab)), [
|
||||||
|
dispatch,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const onOpenAudioEditor = useCallback(() => dispatch(nodeCreate(NODE_TYPES.AUDIO, isLab)), [
|
||||||
|
dispatch,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<div className={classNames(styles.wrap, { [styles.lab]: isLab })}>
|
||||||
<div className={styles.panel}>
|
<div className={styles.panel}>
|
||||||
<div onClick={onOpenImageEditor}>
|
<div onClick={onOpenImageEditor}>
|
||||||
<Icon icon="image" />
|
<Icon icon="image" />
|
||||||
|
@ -48,9 +57,4 @@ const SubmitBarUnconnected: FC<IProps> = ({ nodeCreate }) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const SubmitBar = connect(
|
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(SubmitBarUnconnected);
|
|
||||||
|
|
||||||
export { SubmitBar };
|
export { SubmitBar };
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
@import "src/styles/variables";
|
@import "src/styles/variables";
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
right: -($bar_height + $gap);
|
bottom: 0;
|
||||||
|
right: 50%;
|
||||||
|
transform: translate($content_width / 2 + $bar_height + $gap, 0);
|
||||||
|
z-index: 4;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.panel {
|
.panel {
|
||||||
|
@ -11,9 +14,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: $content_width + ($bar_height + $gap) * 2) {
|
@media (max-width: $content_width + ($bar_height + $gap) * 2) {
|
||||||
position: relative;
|
|
||||||
right: 0;
|
right: 0;
|
||||||
margin-left: $gap;
|
transform: translate(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +36,10 @@
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.lab & {
|
||||||
|
background: $blue_gradient;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.panel {
|
.panel {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { PlayerBar } from '~/components/bars/PlayerBar';
|
import { PlayerBar } from '~/components/bars/PlayerBar';
|
||||||
import { SubmitBar } from '~/components/bars/SubmitBar';
|
|
||||||
import { selectUser } from '~/redux/auth/selectors';
|
import { selectUser } from '~/redux/auth/selectors';
|
||||||
import { pick } from 'ramda';
|
import { pick } from 'ramda';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
@ -14,8 +13,6 @@ const BottomContainerUnconnected: FC<IProps> = ({ is_user }) => (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<PlayerBar />
|
<PlayerBar />
|
||||||
|
|
||||||
{is_user && <SubmitBar />}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
import { URLS } from '~/constants/urls';
|
import { URLS } from '~/constants/urls';
|
||||||
import { FlowLayout } from '~/containers/flow/FlowLayout';
|
import { FlowLayout } from '~/layouts/FlowLayout';
|
||||||
import { NodeLayout } from '~/containers/node/NodeLayout';
|
import { NodeLayout } from '~/layouts/NodeLayout';
|
||||||
import { BorisLayout } from '~/containers/node/BorisLayout';
|
import { BorisLayout } from '~/layouts/BorisLayout';
|
||||||
import { ErrorNotFound } from '~/containers/pages/ErrorNotFound';
|
import { ErrorNotFound } from '~/containers/pages/ErrorNotFound';
|
||||||
import { ProfilePage } from '~/containers/profile/ProfilePage';
|
import { ProfilePage } from '~/containers/profile/ProfilePage';
|
||||||
import { Redirect, Route, Switch, useLocation } from 'react-router';
|
import { Redirect, Route, Switch, useLocation } from 'react-router';
|
||||||
import { LabLayout } from '~/containers/lab/LabLayout';
|
import { LabLayout } from '~/layouts/LabLayout';
|
||||||
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
||||||
import { selectAuthUser } from '~/redux/auth/selectors';
|
import { selectAuthUser } from '~/redux/auth/selectors';
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,30 @@
|
||||||
import React, { FC } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
import { Route, Switch } from 'react-router';
|
import { Route, Switch } from 'react-router';
|
||||||
import { TagSidebar } from '~/containers/sidebars/TagSidebar';
|
import { TagSidebar } from '~/containers/sidebars/TagSidebar';
|
||||||
import { ProfileSidebar } from '~/containers/sidebars/ProfileSidebar';
|
import { ProfileSidebar } from '~/containers/sidebars/ProfileSidebar';
|
||||||
|
import { Authorized } from '~/components/containers/Authorized';
|
||||||
|
import { SubmitBar } from '~/components/bars/SubmitBar';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
prefix?: string;
|
prefix?: string;
|
||||||
|
isLab?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SidebarRouter: FC<IProps> = ({ prefix = '' }) => (
|
const SidebarRouter: FC<IProps> = ({ prefix = '', isLab }) => {
|
||||||
<Switch>
|
return createPortal(
|
||||||
<Route path={`${prefix}/tag/:tag`} component={TagSidebar} />
|
<>
|
||||||
<Route path={`${prefix}/~:username`} component={ProfileSidebar} />
|
<Switch>
|
||||||
</Switch>
|
<Route path={`${prefix}/tag/:tag`} component={TagSidebar} />
|
||||||
);
|
<Route path={`${prefix}/~:username`} component={ProfileSidebar} />
|
||||||
|
</Switch>
|
||||||
|
|
||||||
|
<Authorized>
|
||||||
|
<SubmitBar isLab={isLab} />
|
||||||
|
</Authorized>
|
||||||
|
</>,
|
||||||
|
document.body
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export { SidebarRouter };
|
export { SidebarRouter };
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { Container } from '~/containers/main/Container';
|
||||||
import StickyBox from 'react-sticky-box/dist/esnext';
|
import StickyBox from 'react-sticky-box/dist/esnext';
|
||||||
import { BorisComments } from '~/components/boris/BorisComments';
|
import { BorisComments } from '~/components/boris/BorisComments';
|
||||||
import { URLS } from '~/constants/urls';
|
import { URLS } from '~/constants/urls';
|
||||||
import { Route, Switch, Link } from 'react-router-dom';
|
import { Route, Switch } from 'react-router-dom';
|
||||||
import { BorisUIDemo } from '~/components/boris/BorisUIDemo';
|
import { BorisUIDemo } from '~/components/boris/BorisUIDemo';
|
||||||
import { BorisSuperpowers } from '~/components/boris/BorisSuperpowers';
|
import { BorisSuperpowers } from '~/components/boris/BorisSuperpowers';
|
||||||
import { Superpower } from '~/components/boris/Superpower';
|
import { Superpower } from '~/components/boris/Superpower';
|
||||||
|
@ -25,6 +25,7 @@ import { Tabs } from '~/components/dialogs/Tabs';
|
||||||
import { Tab } from '~/components/dialogs/Tab';
|
import { Tab } from '~/components/dialogs/Tab';
|
||||||
import { useHistory, useLocation } from 'react-router';
|
import { useHistory, useLocation } from 'react-router';
|
||||||
import { Card } from '~/components/containers/Card';
|
import { Card } from '~/components/containers/Card';
|
||||||
|
import { SidebarRouter } from '~/containers/main/SidebarRouter';
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
|
|
||||||
|
@ -144,6 +145,8 @@ const BorisLayout: FC<IProps> = () => {
|
||||||
</Group>
|
</Group>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SidebarRouter prefix="/" />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
};
|
};
|
|
@ -1,4 +1,4 @@
|
||||||
@import "src/styles/variables";
|
@import "~/styles/variables";
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: 50% 0 no-repeat url('../../../sprites/boris_bg.svg');
|
background: 50% 0 no-repeat url('../../sprites/boris_bg.svg');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import styles from './styles.module.scss';
|
||||||
import { IState } from '~/redux/store';
|
import { IState } from '~/redux/store';
|
||||||
import { FlowStamp } from '~/components/flow/FlowStamp';
|
import { FlowStamp } from '~/components/flow/FlowStamp';
|
||||||
import { Container } from '~/containers/main/Container';
|
import { Container } from '~/containers/main/Container';
|
||||||
|
import { SidebarRouter } from '~/containers/main/SidebarRouter';
|
||||||
|
|
||||||
const mapStateToProps = (state: IState) => ({
|
const mapStateToProps = (state: IState) => ({
|
||||||
flow: pick(['nodes', 'heroes', 'recent', 'updated', 'is_loading', 'search'], selectFlow(state)),
|
flow: pick(['nodes', 'heroes', 'recent', 'updated', 'is_loading', 'search'], selectFlow(state)),
|
||||||
|
@ -85,6 +86,8 @@ const FlowLayoutUnconnected: FC<IProps> = ({
|
||||||
onChangeCellView={flowSetCellView}
|
onChangeCellView={flowSetCellView}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SidebarRouter prefix="/" />
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
};
|
};
|
|
@ -16,6 +16,7 @@ import { Filler } from '~/components/containers/Filler';
|
||||||
import { LabStats } from '~/containers/lab/LabStats';
|
import { LabStats } from '~/containers/lab/LabStats';
|
||||||
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
|
||||||
import { selectLabList, selectLabListNodes, selectLabStatsLoading } from '~/redux/lab/selectors';
|
import { selectLabList, selectLabListNodes, selectLabStatsLoading } from '~/redux/lab/selectors';
|
||||||
|
import { SidebarRouter } from '~/containers/main/SidebarRouter';
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {}
|
||||||
|
|
||||||
|
@ -44,6 +45,8 @@ const LabLayout: FC<IProps> = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
|
|
||||||
|
<SidebarRouter prefix="/lab" isLab />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
|
@ -87,9 +87,10 @@ export const nodeSetTags = (tags: ITag[]) => ({
|
||||||
tags,
|
tags,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const nodeCreate = (node_type: INode['type']) => ({
|
export const nodeCreate = (node_type: INode['type'], isLab?: boolean) => ({
|
||||||
type: NODE_ACTIONS.CREATE,
|
type: NODE_ACTIONS.CREATE,
|
||||||
node_type,
|
node_type,
|
||||||
|
isLab,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const nodeEdit = (id: INode['id']) => ({
|
export const nodeEdit = (id: INode['id']) => ({
|
||||||
|
|
|
@ -227,10 +227,18 @@ function* onUpdateTags({ id, tags }: ReturnType<typeof nodeUpdateTags>) {
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function* onCreateSaga({ node_type: type }: ReturnType<typeof nodeCreate>) {
|
function* onCreateSaga({ node_type: type, isLab }: ReturnType<typeof nodeCreate>) {
|
||||||
if (!type || !has(type, NODE_EDITOR_DIALOGS)) return;
|
if (!type || !has(type, NODE_EDITOR_DIALOGS)) return;
|
||||||
|
|
||||||
yield put(nodeSetEditor({ ...EMPTY_NODE, ...(NODE_EDITOR_DATA[type] || {}), type }));
|
yield put(
|
||||||
|
nodeSetEditor({
|
||||||
|
...EMPTY_NODE,
|
||||||
|
...(NODE_EDITOR_DATA[type] || {}),
|
||||||
|
type,
|
||||||
|
is_promoted: !isLab,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
yield put(modalShowDialog(NODE_EDITOR_DIALOGS[type]));
|
yield put(modalShowDialog(NODE_EDITOR_DIALOGS[type]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue