Skip to content

Commit 32e3fa1

Browse files
committed
feat: intro new visitor map layer style which fit on black and light theme
1 parent 213f366 commit 32e3fa1

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/client/components/website/WebsiteVisitorMap/VisitorLeafletMap.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import React, { useMemo } from 'react';
22
import { AppRouterOutput } from '../../../api/trpc';
33
import { MapContainer, CircleMarker, Popup, TileLayer } from 'react-leaflet';
44
import { mapCenter } from './utils';
5+
import { useTranslation } from '@i18next-toolkit/react';
6+
import { useTheme } from '@/store/settings';
57
import 'leaflet/dist/leaflet.css';
68
import './VisitorLeafletMap.css';
7-
import { useTranslation } from '@i18next-toolkit/react';
89

910
export const UserDataPoint: React.FC<{
1011
pointRadius?: number;
@@ -40,6 +41,7 @@ UserDataPoint.displayName = 'UserDataPoint';
4041
export const VisitorLeafletMap: React.FC<{
4142
data: AppRouterOutput['website']['geoStats'];
4243
}> = React.memo((props) => {
44+
const theme = useTheme();
4345
const pointRadius = useMemo(() => {
4446
if (props.data.length > 20000) {
4547
return 1;
@@ -65,7 +67,13 @@ export const VisitorLeafletMap: React.FC<{
6567
maxZoom={10}
6668
scrollWheelZoom={true}
6769
>
68-
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
70+
{/* <TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" /> */}
71+
72+
{theme === 'light' ? (
73+
<TileLayer url="https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png" />
74+
) : (
75+
<TileLayer url="https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png" />
76+
)}
6977

7078
{props.data.map((item) => (
7179
<UserDataPoint

0 commit comments

Comments
 (0)