mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
top panels code cleanup
This commit is contained in:
parent
eae5a893fc
commit
3e16ad4e37
3 changed files with 44 additions and 41 deletions
|
@ -10,10 +10,7 @@ export class UserLocation extends React.Component {
|
||||||
|
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('div');
|
||||||
|
|
||||||
this.icon = new DomMarker({
|
this.icon = new DomMarker({ element, className: 'location-marker' });
|
||||||
element,
|
|
||||||
className: 'location-marker',
|
|
||||||
});
|
|
||||||
|
|
||||||
this.mark = null;
|
this.mark = null;
|
||||||
this.map = editor.map.map;
|
this.map = editor.map.map;
|
||||||
|
@ -64,9 +61,11 @@ export class UserLocation extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
<div className="status-bar square pointer pointer">
|
||||||
<div onClick={this.centerMapOnLocation}>
|
<div onClick={this.centerMapOnLocation}>
|
||||||
<Icon icon="icon-locate" size={30} />
|
<Icon icon="icon-locate" size={30} />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
35
src/components/panels/DistanceBar.jsx
Normal file
35
src/components/panels/DistanceBar.jsx
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// flow
|
||||||
|
import React from 'react';
|
||||||
|
import { toHours } from '$utils/format';
|
||||||
|
import { Icon } from '$components/panels/Icon';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
distance: number,
|
||||||
|
estimated: number,
|
||||||
|
};
|
||||||
|
|
||||||
|
const Component = ({ distance, estimated }: Props) => (
|
||||||
|
<div className="status-bar padded desktop-only">
|
||||||
|
{distance} км
|
||||||
|
<Icon icon="icon-cycle" size={32} />
|
||||||
|
{
|
||||||
|
<span>{toHours(estimated)}</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
function mapStateToProps(state) {
|
||||||
|
const {
|
||||||
|
user: { distance, estimated },
|
||||||
|
} = state;
|
||||||
|
|
||||||
|
return { distance, estimated };
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapDispatchToProps = () => ({ });
|
||||||
|
|
||||||
|
export const DistanceBar = connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(Component);
|
|
@ -1,42 +1,11 @@
|
||||||
// flow
|
// flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { toHours } from '$utils/format';
|
|
||||||
import { Icon } from '$components/panels/Icon';
|
|
||||||
import { UserLocation } from '$components/UserLocation';
|
import { UserLocation } from '$components/UserLocation';
|
||||||
import { connect } from 'react-redux';
|
import { DistanceBar } from '$components/panels/DistanceBar';
|
||||||
|
|
||||||
type Props = {
|
export const TopLeftPanel = () => (
|
||||||
distance: number,
|
|
||||||
estimated: number,
|
|
||||||
};
|
|
||||||
|
|
||||||
const Component = ({ distance, estimated }: Props) => (
|
|
||||||
<div className="status-panel top left">
|
<div className="status-panel top left">
|
||||||
<div className="status-bar square pointer pointer">
|
|
||||||
<UserLocation />
|
<UserLocation />
|
||||||
</div>
|
<DistanceBar />
|
||||||
|
|
||||||
<div className="status-bar padded desktop-only">
|
|
||||||
{distance} км
|
|
||||||
<Icon icon="icon-cycle" size={32} />
|
|
||||||
{
|
|
||||||
<span>{toHours(estimated)}</span>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
|
||||||
const {
|
|
||||||
user: { distance, estimated },
|
|
||||||
} = state;
|
|
||||||
|
|
||||||
return { distance, estimated };
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapDispatchToProps = () => ({ });
|
|
||||||
|
|
||||||
export const TopLeftPanel = connect(
|
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(Component);
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue