Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mainpage widget with map #71

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading