mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +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');
|
||||
|
||||
this.icon = new DomMarker({
|
||||
element,
|
||||
className: 'location-marker',
|
||||
});
|
||||
this.icon = new DomMarker({ element, className: 'location-marker' });
|
||||
|
||||
this.mark = null;
|
||||
this.map = editor.map.map;
|
||||
|
@ -64,8 +61,10 @@ export class UserLocation extends React.Component {
|
|||
|
||||
render() {
|
||||
return (
|
||||
<div onClick={this.centerMapOnLocation}>
|
||||
<Icon icon="icon-locate" size={30} />
|
||||
<div className="status-bar square pointer pointer">
|
||||
<div onClick={this.centerMapOnLocation}>
|
||||
<Icon icon="icon-locate" size={30} />
|
||||
</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
|
||||
import React from 'react';
|
||||
import { toHours } from '$utils/format';
|
||||
import { Icon } from '$components/panels/Icon';
|
||||
import { UserLocation } from '$components/UserLocation';
|
||||
import { connect } from 'react-redux';
|
||||
import { DistanceBar } from '$components/panels/DistanceBar';
|
||||
|
||||
type Props = {
|
||||
distance: number,
|
||||
estimated: number,
|
||||
};
|
||||
|
||||
const Component = ({ distance, estimated }: Props) => (
|
||||
export const TopLeftPanel = () => (
|
||||
<div className="status-panel top left">
|
||||
<div className="status-bar square pointer pointer">
|
||||
<UserLocation />
|
||||
</div>
|
||||
|
||||
<div className="status-bar padded desktop-only">
|
||||
{distance} км
|
||||
<Icon icon="icon-cycle" size={32} />
|
||||
{
|
||||
<span>{toHours(estimated)}</span>
|
||||
}
|
||||
</div>
|
||||
<UserLocation />
|
||||
<DistanceBar />
|
||||
</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