switching between modes :-)

This commit is contained in:
muerwre 2018-08-31 16:52:31 +07:00
parent 293f3cd7b9
commit f85911861a
4 changed files with 51 additions and 24 deletions

View file

@ -23,9 +23,13 @@ export class EditorPanel extends React.PureComponent {
startSaveMode = () => this.props.editor.changeMode(MODES.SAVE); startSaveMode = () => this.props.editor.changeMode(MODES.SAVE);
stopEditing = () => this.props.editor.stopEditing();
startEditing = () => this.props.editor.startEditing();
render() { render() {
const { const {
mode, routerPoints, editor, totalDistance, estimateTime, activeSticker, logo, user mode, routerPoints, editor, totalDistance, estimateTime, activeSticker, logo, user, editing,
} = this.props; } = this.props;
return ( return (
@ -42,7 +46,7 @@ export class EditorPanel extends React.PureComponent {
<LogoPreview logo={logo} /> <LogoPreview logo={logo} />
<div className="panel right"> <div className={classnames('panel right', { active: editing })}>
<div className="control-dist"> <div className="control-dist">
{totalDistance} км {totalDistance} км
<Icon icon="icon-cycle" size={32} /> <Icon icon="icon-cycle" size={32} />
@ -96,9 +100,20 @@ export class EditorPanel extends React.PureComponent {
> >
<Icon icon="icon-logo" /> <Icon icon="icon-logo" />
</button> </button>
</div>
<div className="control-sep" />
<div className="control-bar">
<button <button
className="highlighted" className="highlighted"
onClick={this.stopEditing}
>
<span>ОТМЕНА</span>
</button>
<button
className="primary"
onClick={this.startSaveMode} onClick={this.startSaveMode}
> >
<span>СХОРОНИТЬ</span> <span>СХОРОНИТЬ</span>
@ -107,6 +122,17 @@ export class EditorPanel extends React.PureComponent {
</div> </div>
</div> </div>
<div className={classnames('panel right', { active: !editing })}>
<div className="control-bar">
<button className="success" onClick={this.startEditing}>
<Icon icon="icon-router" />
<span>
РЕДАКТОРОВАТЬ
</span>
</button>
</div>
</div>
</div> </div>
); );
} }

View file

@ -62,7 +62,7 @@ export class UserPanel extends React.PureComponent {
return ( return (
<div> <div>
<div className="panel"> <div className="panel active">
<div className="user-panel"> <div className="user-panel">
{ {
!user || user.role === ROLES.guest !user || user.role === ROLES.guest
@ -74,26 +74,6 @@ export class UserPanel extends React.PureComponent {
<UserMenu user={user} userLogout={userLogout} /> <UserMenu user={user} userLogout={userLogout} />
} }
</div> </div>
<div className="control-sep" />
<div className="control-bar">
{
editing
?
<button>
<span>
РЕДАКТОР
</span>
</button>
: <button>
<span>
ПРОСМОТР
</span>
</button>
}
</div>
</div> </div>
</div> </div>
); );

View file

@ -175,7 +175,6 @@ export class App extends React.Component {
<UserPanel <UserPanel
editor={editor} editor={editor}
editing={editing}
user={user} user={user}
setUser={this.setUser} setUser={this.setUser}
userLogout={this.userLogout} userLogout={this.userLogout}
@ -190,6 +189,7 @@ export class App extends React.Component {
activeSticker={activeSticker} activeSticker={activeSticker}
logo={logo} logo={logo}
user={user} user={user}
editing={editing}
/> />
</div> </div>
); );

View file

@ -3,6 +3,8 @@
border-radius: 3px; border-radius: 3px;
display: flex; display: flex;
box-shadow: @bar_shadow; box-shadow: @bar_shadow;
} }
.control-dist { .control-dist {
@ -36,6 +38,12 @@
color: white; color: white;
display: flex; display: flex;
align-items: center; align-items: center;
transform: translateY(100px);
transition: transform 500ms;
&.active {
transform: translateY(0);
}
&.right { &.right {
left: auto; left: auto;
@ -66,6 +74,10 @@
margin-left: 8px; margin-left: 8px;
} }
&:first-child {
border-radius: 4px 0 0 4px;
}
&:last-child { &:last-child {
border-radius: 0 4px 4px 0; border-radius: 0 4px 4px 0;
} }
@ -78,10 +90,19 @@
} }
&.highlighted { &.highlighted {
background: #555555;
}
&.primary {
background: linear-gradient(150deg, @blue_primary, @blue_secondary) 50% 50% no-repeat; background: linear-gradient(150deg, @blue_primary, @blue_secondary) 50% 50% no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
} }
&.success {
background: linear-gradient(150deg, @green_primary, @green_secondary) 50% 50% no-repeat;
background-size: 100% 100%;
}
svg { svg {
fill: white; fill: white;
stroke: white; stroke: white;