mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
moved editor to separate reducer
This commit is contained in:
parent
e950d98b73
commit
87670770b0
38 changed files with 1425 additions and 1069 deletions
|
@ -1,4 +1,3 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
|
||||
import { EditorPanel } from '~/components/panels/EditorPanel';
|
||||
|
@ -9,8 +8,7 @@ import { bindActionCreators } from 'redux';
|
|||
|
||||
import { hot } from 'react-hot-loader';
|
||||
import { Renderer } from '~/components/renderer/Renderer';
|
||||
import { hideRenderer, setDialogActive } from '~/redux/user/actions';
|
||||
import { Cursor } from '~/components/Cursor';
|
||||
import { editorHideRenderer, editorSetDialogActive } from '~/redux/editor/actions';
|
||||
import { LeftDialog } from '~/containers/LeftDialog';
|
||||
import { TopLeftPanel } from '~/components/panels/TopLeftPanel';
|
||||
import { TopRightPanel } from '~/components/panels/TopRightPanel';
|
||||
|
@ -19,18 +17,19 @@ import { IStickerPack } from '~/constants/stickers';
|
|||
import { IDialogs } from '~/constants/dialogs';
|
||||
|
||||
import { Map } from '~/containers/map/Map';
|
||||
import { IRootReducer } from '~/redux/user';
|
||||
import { IEditorState } from '~/redux/editor';
|
||||
import { IState } from '~/redux/store';
|
||||
|
||||
type Props = {
|
||||
sticker: string;
|
||||
renderer_active: boolean;
|
||||
|
||||
mode: IRootReducer['mode'];
|
||||
mode: IEditorState['mode'];
|
||||
dialog: keyof IDialogs;
|
||||
dialog_active: boolean;
|
||||
set: keyof IStickerPack;
|
||||
hideRenderer: typeof hideRenderer;
|
||||
setDialogActive: typeof setDialogActive;
|
||||
editorHideRenderer: typeof editorHideRenderer;
|
||||
editorSetDialogActive: typeof editorSetDialogActive;
|
||||
};
|
||||
|
||||
const Component = (props: Props) => (
|
||||
|
@ -45,26 +44,26 @@ const Component = (props: Props) => (
|
|||
<LeftDialog
|
||||
dialog={props.dialog}
|
||||
dialog_active={props.dialog_active}
|
||||
setDialogActive={props.setDialogActive}
|
||||
editorSetDialogActive={props.editorSetDialogActive}
|
||||
/>
|
||||
|
||||
<LogoPreview />
|
||||
|
||||
<Map />
|
||||
|
||||
{props.renderer_active && <Renderer onClick={props.hideRenderer} />}
|
||||
{props.renderer_active && <Renderer onClick={props.editorHideRenderer} />}
|
||||
</div>
|
||||
);
|
||||
|
||||
const mapStateToProps = ({
|
||||
user: {
|
||||
editor: {
|
||||
mode,
|
||||
dialog,
|
||||
dialog_active,
|
||||
renderer,
|
||||
activeSticker: { sticker = null, set = null },
|
||||
},
|
||||
}) => ({
|
||||
}: IState) => ({
|
||||
renderer_active: renderer.renderer_active,
|
||||
mode,
|
||||
dialog,
|
||||
|
@ -74,5 +73,5 @@ const mapStateToProps = ({
|
|||
});
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators({ hideRenderer, setDialogActive }, dispatch);
|
||||
bindActionCreators({ editorHideRenderer, editorSetDialogActive }, dispatch);
|
||||
export const App = connect(mapStateToProps, mapDispatchToProps)(hot(module)(Component));
|
||||
|
|
|
@ -4,12 +4,12 @@ import classnames from 'classnames';
|
|||
import { AppInfoDialog } from '~/components/dialogs/AppInfoDialog';
|
||||
import { Icon } from '~/components/panels/Icon';
|
||||
import { MapListDialog } from '~/components/dialogs/MapListDialog';
|
||||
import * as USER_ACTIONS from '~/redux/user/actions';
|
||||
import * as EDITOR_ACTIONS from '~/redux/editor/actions';
|
||||
|
||||
interface Props {
|
||||
dialog: keyof IDialogs;
|
||||
dialog_active: Boolean;
|
||||
setDialogActive: typeof USER_ACTIONS.setDialogActive;
|
||||
editorSetDialogActive: typeof EDITOR_ACTIONS.editorSetDialogActive;
|
||||
}
|
||||
|
||||
const LEFT_DIALOGS = {
|
||||
|
@ -17,7 +17,7 @@ const LEFT_DIALOGS = {
|
|||
[DIALOGS.APP_INFO]: AppInfoDialog,
|
||||
};
|
||||
|
||||
const LeftDialog = ({ dialog, dialog_active, setDialogActive }: Props) => (
|
||||
const LeftDialog = ({ dialog, dialog_active, editorSetDialogActive }: Props) => (
|
||||
<React.Fragment>
|
||||
{Object.keys(LEFT_DIALOGS).map(item => (
|
||||
<div
|
||||
|
@ -26,11 +26,11 @@ const LeftDialog = ({ dialog, dialog_active, setDialogActive }: Props) => (
|
|||
>
|
||||
{dialog && LEFT_DIALOGS[item] && createElement(LEFT_DIALOGS[item], {})}
|
||||
|
||||
<div className="dialog-close-button desktop-only" onClick={() => setDialogActive(false)}>
|
||||
<div className="dialog-close-button desktop-only" onClick={() => editorSetDialogActive(false)}>
|
||||
<Icon icon="icon-cancel-1" />
|
||||
</div>
|
||||
|
||||
<div className="dialog-close-button mobile-only" onClick={() => setDialogActive(false)}>
|
||||
<div className="dialog-close-button mobile-only" onClick={() => editorSetDialogActive(false)}>
|
||||
<Icon icon="icon-chevron-down" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,15 +12,15 @@ import * as MAP_ACTIONS from "~/redux/map/actions";
|
|||
import { Route } from "~/containers/map/Route";
|
||||
import { TileLayer } from "~/containers/map/TileLayer";
|
||||
import { Stickers } from "~/containers/map/Stickers";
|
||||
import { selectUserEditing } from '~/redux/user/selectors'
|
||||
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { selectEditorEditing } from "~/redux/editor/selectors";
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
provider: selectMapProvider(state),
|
||||
route: selectMapRoute(state),
|
||||
stickers: selectMapStickers(state),
|
||||
editing: selectUserEditing(state),
|
||||
editing: selectEditorEditing(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue