panels: fixed them

This commit is contained in:
muerwre 2018-12-07 14:32:35 +07:00
parent d248b679ed
commit b8ba50517b
13 changed files with 171 additions and 182 deletions

View file

@ -1,13 +1,12 @@
import React from 'react'; import React from 'react';
import { MODES } from '$constants/modes'; import { MODES } from '$constants/modes';
import { editor } from '$modules/Editor';
import { Icon } from '$components/panels/Icon'; import { Icon } from '$components/panels/Icon';
type Props = { type Props = {
stopEditing: Function, stopEditing: Function,
setMode: Function, setMode: Function,
setEditing: Function, width: Number,
}; };
export class CancelDialog extends React.Component<Props, void> { export class CancelDialog extends React.Component<Props, void> {
@ -23,7 +22,10 @@ export class CancelDialog extends React.Component<Props, void> {
}; };
render() { render() {
const { width } = this.props;
return ( return (
<div className="control-dialog" style={{ width }}>
<div className="helper cancel-helper"> <div className="helper cancel-helper">
<div className="helper__text danger"> <div className="helper__text danger">
<Icon icon="icon-cancel-1" /> <Icon icon="icon-cancel-1" />
@ -39,6 +41,7 @@ export class CancelDialog extends React.Component<Props, void> {
</div> </div>
</div> </div>
</div> </div>
</div>
); );
} }
} }

View file

@ -9,6 +9,7 @@ type Props = {
} }
export const LogoDialog = ({ logo, setLogo }: Props) => ( export const LogoDialog = ({ logo, setLogo }: Props) => (
<div className="control-dialog top">
<div className="helper logo-helper"> <div className="helper logo-helper">
<div className="helper-back"> <div className="helper-back">
<Icon icon="icon-logo" size={200} /> <Icon icon="icon-logo" size={200} />
@ -25,4 +26,5 @@ export const LogoDialog = ({ logo, setLogo }: Props) => (
)) ))
} }
</div> </div>
</div>
); );

View file

@ -17,7 +17,7 @@ export class ProviderDialog extends React.Component<Props, void> {
const { provider, setProvider } = this.props; const { provider, setProvider } = this.props;
return ( return (
<React.Fragment> <div className="control-dialog top right control-dialog-provider">
<div className="helper provider-helper"> <div className="helper provider-helper">
{ {
Object.keys(PROVIDERS).map(item => ( Object.keys(PROVIDERS).map(item => (
@ -39,16 +39,7 @@ export class ProviderDialog extends React.Component<Props, void> {
)) ))
} }
</div> </div>
<div className="helper">
<div className="helper__text">
<Icon icon="icon-map-1" />
<div className="big upper">ВЫБЕРИТЕ СТИЛЬ КАРТЫ</div>
</div> </div>
<div className="helper__buttons button-group" onClick={this.closeDialog}>
<Icon icon="icon-cancel-1" />
</div>
</div>
</React.Fragment>
); );
} }
} }

View file

@ -5,6 +5,7 @@ type Props = {
routerCancel: Function, routerCancel: Function,
routerSubmit: Function, routerSubmit: Function,
routerPoints: Number, routerPoints: Number,
width: Number,
} }
const noPoints = ({ routerCancel }: Props) => ( const noPoints = ({ routerCancel }: Props) => (
@ -54,8 +55,8 @@ const draggablePoints = ({ routerCancel, routerSubmit }: Props) => (
</div> </div>
); );
export const RouterDialog = ({ routerPoints, routerCancel, routerSubmit }: Props) => ( export const RouterDialog = ({ routerPoints, routerCancel, routerSubmit, width }: Props) => (
<div> <div className="control-dialog" style={{ width }}>
{!routerPoints && noPoints({ routerCancel })} {!routerPoints && noPoints({ routerCancel })}
{routerPoints === 1 && firstPoint({ routerCancel })} {routerPoints === 1 && firstPoint({ routerCancel })}
{routerPoints >= 2 && draggablePoints({ routerCancel, routerSubmit })} {routerPoints >= 2 && draggablePoints({ routerCancel, routerSubmit })}

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { getUrlData, pushPath } from '$utils/history'; import { getUrlData } from '$utils/history';
import { toTranslit } from '$utils/format'; import { toTranslit } from '$utils/format';
import { TIPS } from '$constants/tips'; import { TIPS } from '$constants/tips';
import { MODES } from '$constants/modes'; import { MODES } from '$constants/modes';
@ -11,7 +11,8 @@ type Props = {
save_error: String, save_error: String,
save_finished: Boolean, save_finished: Boolean,
save_overwriting: Boolean, save_overwriting: Boolean,
save_processing: Boolean,
width: Number,
setMode: Function, setMode: Function,
sendSaveRequest: Function, sendSaveRequest: Function,
@ -59,10 +60,11 @@ export class SaveDialog extends React.Component<Props, State> {
render() { render() {
const { title } = this.state; const { title } = this.state;
const { save_error, save_finished, save_overwriting } = this.props; const { save_error, save_finished, save_overwriting, width } = this.props;
const { host } = getUrlData(); const { host } = getUrlData();
return ( return (
<div className="control-dialog" style={{ width }}>
<div className="helper save-helper"> <div className="helper save-helper">
<div className="save-title"> <div className="save-title">
<div className="save-title-input"> <div className="save-title-input">
@ -101,8 +103,7 @@ export class SaveDialog extends React.Component<Props, State> {
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
); );
} }

View file

@ -4,10 +4,12 @@ import React from 'react';
import { STICKERS } from '$constants/stickers'; import { STICKERS } from '$constants/stickers';
type Props = { type Props = {
setActiveSticker: Function setActiveSticker: Function,
width: Number,
}; };
export const StickersDialog = ({ setActiveSticker }: Props) => ( export const StickersDialog = ({ setActiveSticker, width }: Props) => (
<div className="control-dialog" style={{ width }}>
<div className="helper stickers-helper"> <div className="helper stickers-helper">
{ {
Object.keys(STICKERS).map(set => ( Object.keys(STICKERS).map(set => (
@ -32,4 +34,5 @@ export const StickersDialog = ({ setActiveSticker }: Props) => (
)) ))
} }
</div> </div>
</div>
); );

View file

@ -6,11 +6,14 @@ type Props = {
clearStickers: Function, clearStickers: Function,
clearAll: Function, clearAll: Function,
clearCancel: Function, clearCancel: Function,
width: Number,
} }
export const TrashDialog = ({ export const TrashDialog = ({
clearPoly, clearStickers, clearAll, clearCancel clearPoly, clearStickers, clearAll, clearCancel, width,
}: Props) => ( }: Props) => (
<div className="control-dialog" style={{ width }}>
<div className="helper trash-helper"> <div className="helper trash-helper">
<div className="helper__text danger"> <div className="helper__text danger">
<Icon icon="icon-trash-4" /> <Icon icon="icon-trash-4" />
@ -33,4 +36,5 @@ export const TrashDialog = ({
</div> </div>
</div> </div>
</div> </div>
</div>
); );

View file

@ -34,42 +34,24 @@ type Props = {
width: Number, width: Number,
} }
const DIALOG_CONTENTS = {
[MODES.ROUTER]: RouterDialog,
[MODES.STICKERS]: StickersDialog,
[MODES.TRASH]: TrashDialog,
[MODES.LOGO]: LogoDialog,
[MODES.SAVE]: SaveDialog,
[MODES.CONFIRM_CANCEL]: CancelDialog,
[MODES.PROVIDER]: ProviderDialog,
};
export const Component = (props: Props) => { export const Component = (props: Props) => {
const { const {
mode, activeSticker, width mode
} = props; } = props;
const showDialog = (
mode === MODES.ROUTER
|| (mode === MODES.STICKERS && !activeSticker.set)
|| mode === MODES.TRASH
|| mode === MODES.LOGO
|| mode === MODES.SAVE
|| mode === MODES.CONFIRM_CANCEL
|| mode === MODES.PROVIDER
);
const dialogIsSmall = (
mode === MODES.LOGO
);
return ( return (
showDialog && (mode && DIALOG_CONTENTS[mode] && React.createElement(DIALOG_CONTENTS[mode], { ...props }))
<div || <div>null</div>
id="control-dialog"
style={{
width: dialogIsSmall ? 201 : width,
right: dialogIsSmall ? 217 : 10,
}}
>
{ mode === MODES.ROUTER && <RouterDialog {...props} /> }
{ mode === MODES.STICKERS && <StickersDialog {...props} /> }
{ mode === MODES.TRASH && <TrashDialog {...props} /> }
{ mode === MODES.LOGO && <LogoDialog {...props} /> }
{ mode === MODES.SAVE && <SaveDialog {...props} /> }
{ mode === MODES.CONFIRM_CANCEL && <CancelDialog {...props} /> }
{ mode === MODES.PROVIDER && <ProviderDialog {...props} /> }
</div>
); );
}; };

View file

@ -75,16 +75,16 @@ class Component extends React.PureComponent<Props, void> {
</div> </div>
<div className="status-panel top right"> <div className="status-panel top right">
<div className="status-bar pointer top-control padded"> <div className="status-bar pointer top-control padded" onClick={this.startProviderMode}>
<Icon icon="icon-map-1" size={24} /> <Icon icon="icon-map-1" size={24} />
<div className="status-bar-sep" /> <div className="status-bar-sep" />
{(provider && PROVIDERS[provider] && PROVIDERS[provider].name) || '...'} <span>{(provider && PROVIDERS[provider] && PROVIDERS[provider].name) || '...'}</span>
</div> </div>
<div className="status-bar pointer top-control padded"> <div className="status-bar pointer top-control padded" onClick={this.startLogoMode}>
<Icon icon="icon-logo-3" size={24} /> <Icon icon="icon-logo-3" size={24} />
<div className="status-bar-sep" /> <div className="status-bar-sep" />
{(logo && LOGOS[logo] && LOGOS[logo][0]) || '...'} <span>{(logo && LOGOS[logo] && LOGOS[logo][0]) || '...'}</span>
</div> </div>
</div> </div>
@ -122,24 +122,10 @@ class Component extends React.PureComponent<Props, void> {
</button> </button>
<button <button
className={classnames({ active: mode === MODES.TRASH })} className={classnames({ active: false })}
onClick={this.props.takeAShot} onClick={this.props.takeAShot}
> >
<Icon icon="icon-shot-3" /> <Icon icon="icon-shot-2" />
</button>
<button
className={classnames({ active: mode === MODES.PROVIDER })}
onClick={this.startProviderMode}
>
<Icon icon="icon-map-1" />
</button>
<button
className={classnames({ active: mode === MODES.LOGO })}
onClick={this.startLogoMode}
>
<Icon icon="icon-logo-3" />
</button> </button>
</div> </div>
@ -157,7 +143,6 @@ class Component extends React.PureComponent<Props, void> {
className={classnames({ primary: changed, disabled: !changed })} className={classnames({ primary: changed, disabled: !changed })}
onClick={this.startSaveMode} onClick={this.startSaveMode}
> >
<span>СХОРОНИТЬ</span>
<Icon icon="icon-check-1" /> <Icon icon="icon-check-1" />
</button> </button>
</div> </div>

View file

@ -1,5 +1,5 @@
export const LOGOS = { export const LOGOS = {
default: ['Без логотипа', null, 'bottom-right'], default: ['Без лого', null, 'bottom-right'],
nvs: ['НВС', 'http://map.vault48.org/misc/lgo.png', 'bottom-right'], nvs: ['НВС', 'http://map.vault48.org/misc/lgo.png', 'bottom-right'],
pinmix: ['Пин-Микс', 'http://map.vault48.org/misc/pin-mix.png', 'top-right'], pinmix: ['Пин-Микс', 'http://map.vault48.org/misc/pin-mix.png', 'top-right'],
jolly: ['Пин-Микс + JW', 'http://map.vault48.org/misc/jw.png', 'top-right'], jolly: ['Пин-Микс + JW', 'http://map.vault48.org/misc/jw.png', 'top-right'],

View file

@ -11,10 +11,10 @@
todo map search todo map search
todo map lazy loading todo map lazy loading
todo map preview on save
todo tooltips todo tooltips
todo better poly editor https://github.com/SupriyaSudhindra/leaflet-editable-polyline todo better poly editor https://github.com/SupriyaSudhindra/leaflet-editable-polyline
todo network operations notify todo network operations notify
todo delayed notify (delay(2000).then(showLoadingMsg)) todo delayed notify (delay(2000).then(showLoadingMsg))
todo network error notifications todo network error notifications
@ -24,6 +24,7 @@
todo better loader screen todo better loader screen
todo network errors handling on startup todo network errors handling on startup
todo map preview on save
*/ */
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';

View file

@ -263,7 +263,7 @@ export class Editor {
setInitialData = () => { setInitialData = () => {
const { path } = getUrlData(); const { path } = getUrlData();
const { id } = this.getUser(); const { id } = this.getUser();
const { route, stickers } = this.dumpData(); const { route, stickers, provider } = this.dumpData();
this.initialData = { this.initialData = {
version: 2, version: 2,
@ -273,6 +273,7 @@ export class Editor {
path, path,
route, route,
stickers, stickers,
provider,
}; };
}; };
@ -321,6 +322,7 @@ export class Editor {
dumpData = () => ({ dumpData = () => ({
route: this.poly.dumpData(), route: this.poly.dumpData(),
stickers: this.stickers.dumpData(), stickers: this.stickers.dumpData(),
provider: this.provider,
}); });
setProvider = provider => { setProvider = provider => {

View file

@ -153,7 +153,7 @@
background: #222222; background: #222222;
} }
#control-dialog { .control-dialog {
background: rgba(30, 30, 30, 0.95); background: rgba(30, 30, 30, 0.95);
position: absolute; position: absolute;
right: 10px; right: 10px;
@ -164,6 +164,15 @@
box-sizing: border-box; box-sizing: border-box;
// padding-bottom: 48px; // padding-bottom: 48px;
box-shadow: inset rgba(255, 255, 255, 0.05) 1px 1px; box-shadow: inset rgba(255, 255, 255, 0.05) 1px 1px;
&.top {
bottom: auto;
top: 52px;
}
}
.control-dialog-provider {
width: 500px;
} }
.helper { .helper {
@ -284,7 +293,6 @@
grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr 1fr;
grid-column-gap: 10px; grid-column-gap: 10px;
grid-row-gap: 10px; grid-row-gap: 10px;
padding-bottom: 0;
.provider-helper-thumb { .provider-helper-thumb {
height: 100px; height: 100px;
@ -351,6 +359,15 @@
justify-content: center; justify-content: center;
box-shadow: @bar_shadow; box-shadow: @bar_shadow;
span {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 1;
text-transform: uppercase;
font-size: 0.9em;
}
&.square { &.square {
width: 32px; width: 32px;
} }
@ -360,11 +377,8 @@
} }
&.top-control { &.top-control {
width: 120px; width: 150px;
justify-content: flex-start; justify-content: flex-start;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
svg { svg {