Skip to content

Commit

Permalink
Add mainpage widget with map (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashachabin authored Jul 21, 2023
1 parent 6b4a200 commit 7b62716
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
23 changes: 23 additions & 0 deletions client/components/MainPage/Card/CardDynamic/CardMap.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.CardMap {
}

.CardMap,
.CardMap__Widget,
.CardMap__NonClick {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}

.CardMap__Widget {
z-index: -1;
overflow: hidden;
pointer-events: none;
}

.CardMap__Widget * {
pointer-events: none;
}
21 changes: 21 additions & 0 deletions client/components/MainPage/Card/CardDynamic/CardMap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import classNames from 'classnames/bind';

import { Map as MapComponent } from 'components/Map';

import styles from './CardMap.module.css';

const cn = classNames.bind(styles);

export function CardMap() {
return (
<div className={cn(styles.CardMap)}>
<div className={cn(styles.CardMap__Widget)}>
<MapComponent
zoom={16}
showControls={false}
/>
</div>
<div className={cn(styles.CardMap__NonClick)}></div>
</div>
)
}
3 changes: 3 additions & 0 deletions client/components/MainPage/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MainPageTypes } from './MainPage.types';
import { Card } from './Card/Card';
import { CardTrafficJams } from './Card/CardDynamic/CardTrafficJams';
import { CardTransportA11y } from './Card/CardDynamic/CardTransportA11y';
import { CardMap } from './Card/CardDynamic/CardMap';

import Logo from './Logo.svg';

Expand All @@ -21,6 +22,8 @@ export function MainPage({ cards, cardsDynamicData, marqueeItems }: MainPageType
return <CardTransportA11y {...cardsDynamicData.a11yTransportCounters} />
case 'traffic-jams':
return <CardTrafficJams score={cardsDynamicData.trafficJams} />
case 'map':
return <CardMap />
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.Map {
width: 100vw;
width: 100%;
height: 100%;
}
10 changes: 6 additions & 4 deletions client/components/Map/MainContainer/MapMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'leaflet/dist/leaflet.css';

const cn = classNames.bind(styles);

function MapMainContainer() {
function MapMainContainer({ zoom = 16, showControls = true }) {
const position: [number, number] = COORDS_EKATERINBURG;

const [sidebar, setSidebar] = useState<React.ReactElement>(null);
Expand All @@ -39,16 +39,18 @@ function MapMainContainer() {
center={position}
attributionControl={null}
zoomControl={false}
zoom={16}
zoom={zoom}
zoomDelta={0.6}
scrollWheelZoom
doubleClickZoom={false}
className={cn(styles.Map)}
>
<TileLayer url="https://tiles.ekaterinburg.io/styles/basic-white/{z}/{x}/{y}@2x.png" />

<MapLocation />
<MapZoomControl position="bottomright" />
{showControls && <>
<MapLocation />
<MapZoomControl position="bottomright" />
</>}

<MapTransport />

Expand Down

0 comments on commit 7b62716

Please sign in to comment.