Skip to content

Commit

Permalink
Merge pull request #104 from ekaterinburgdev/feature/kvartalnye
Browse files Browse the repository at this point in the history
Feature/kvartalnye
  • Loading branch information
GrigoriiPrudnikov authored Nov 7, 2023
2 parents b10f7c6 + 06ffff7 commit 8b7acd3
Show file tree
Hide file tree
Showing 39 changed files with 6,335 additions and 18,867 deletions.
8 changes: 5 additions & 3 deletions components/Layers/DesignCode/CardContent/CardContent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';

import { Section } from 'components/UI/Card/components/Section/Section';
import { Header } from 'components/UI/Card/components/Header/Header';
import { Label } from 'components/UI/Card/components/Label/Label';
import { Section } from 'components/UI/Card/components/Section/Section';

import { DESIGN_MAP_HOST } from 'components/Layers/DesignCode/designCode';
import styles from 'styles/CardContent.module.css';
import { Sources } from 'components/UI/Card/components/Sources/Sources';
import { DESIGN_CODE_MARKER_COLOR_BY_TYPE } from '../MapData/MapData.constants';

import { DesignCodeObject } from '../designCodeObject';
Expand Down Expand Up @@ -44,6 +43,9 @@ export function DesignCodeCardContent({ placemark }: { placemark?: DesignCodeObj
);
})}
</Section>
<Section>
<Sources sources={['ekaterinburgdesign']} />
</Section>
</div>
) : null;
}
26 changes: 16 additions & 10 deletions components/Layers/Filters.config.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { DTPFilter } from 'components/Layers/DTP/Filter/DTPFilter';
import { DesignCodeFilter } from 'components/Layers/DesignCode/Filter/DesignCodeFilter';
import { HouseAgeFilter } from 'components/Layers/Houses/Filter/Age/HouseAgeFilter';
import { HouseFloorFilter } from 'components/Layers/Houses/Filter/Floor/HouseFloorFilter';
import { HouseWearTearFilter } from 'components/Layers/Houses/Filter/WearTear/HouseWearTearFilter';
import { DesignCodeFilter } from 'components/Layers/DesignCode/Filter/DesignCodeFilter';
import { OknFilter } from 'components/Layers/OKN/Filter/Okn/OknFilter';
import { LinesFilter } from 'components/Layers/Lines/Filter/LinesFilter';
import { DTPFilter } from 'components/Layers/DTP/Filter/DTPFilter';
import { OknFilter } from 'components/Layers/OKN/Filter/Okn/OknFilter';
import { QuarterFilter } from 'components/Layers/Quarter/Filter/QuarterFilter';
import { SOURCES_BY_TYPE } from 'constants/sources';
import { FilterConfig, FilterType } from '../../types/Filters.types';

Expand All @@ -14,42 +14,48 @@ export const FILTERS_CONFIG: FilterConfig = {
[FilterType.HouseAge]: {
title: 'Возраст домов',
component: <HouseAgeFilter />,
source: SOURCES_BY_TYPE.howoldthishouse,
source: [SOURCES_BY_TYPE.howoldthishouse],
isVerified: false,
},
[FilterType.HouseFloor]: {
title: 'Этажность домов',
component: <HouseFloorFilter />,
source: SOURCES_BY_TYPE.howoldthishouse,
source: [SOURCES_BY_TYPE.mingkh, SOURCES_BY_TYPE.domaekb],
isVerified: false,
},
[FilterType.HouseWearTear]: {
title: 'Степень износа домов',
component: <HouseWearTearFilter />,
source: SOURCES_BY_TYPE.howoldthishouse,
source: [SOURCES_BY_TYPE.mingkh, SOURCES_BY_TYPE.domaekb],
isVerified: false,
},
[FilterType.OKN]: {
title: 'Объекты культурного наследия',
component: <OknFilter />,
source: SOURCES_BY_TYPE.okn,
source: [SOURCES_BY_TYPE.okn],
isVerified: false,
},
[FilterType.DesignCode]: {
title: '«Дизайн-код Екатеринбурга»',
component: <DesignCodeFilter />,
source: SOURCES_BY_TYPE.ekaterinburgdesign,
source: [SOURCES_BY_TYPE.ekaterinburgdesign],
isVerified: true,
},
[FilterType.DTP]: {
title: 'ДТП',
component: <DTPFilter />,
source: SOURCES_BY_TYPE.dtp,
source: [SOURCES_BY_TYPE.dtp],
isVerified: true,
},
[FilterType.Line]: {
title: 'Туристические маршруты',
component: <LinesFilter />,
isVerified: true,
},
[FilterType.Quarter]: {
title: 'Квартальные',
component: <QuarterFilter />,
source: [SOURCES_BY_TYPE.ekb_quarter],
isVerified: true,
},
};
2 changes: 1 addition & 1 deletion components/Layers/Houses/CardContent/CardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export function HousesCardContent() {
</Section>
)}
<Section>
<Sources sources={['howoldthishouse', 'mingkh', 'domaekb']} />
<Sources sources={['osm', 'howoldthishouse', 'mingkh', 'domaekb']} />
</Section>
<Section>
<EditObjectButtonLink address={placemark?.attributes.Address} />
Expand Down
30 changes: 30 additions & 0 deletions components/Layers/Quarter/CardContent/CardContent.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.popup {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
padding: 16px 8px 16px 16px;
}

.mainLink {
color: inherit;
font-size: inherit;
line-height: inherit;
}

.description {
margin-top: 8px;
position: relative;
svg {
position: relative;
top: 2px;
left: 2px;
path {
fill: #000;
}
}
a {
border-radius: 8px;
font-size: 16px;
width: 100%;
text-align: center;
}
}
69 changes: 69 additions & 0 deletions components/Layers/Quarter/CardContent/CardContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { QuarterObject } from 'components/Layers/Quarter/quarterObject';
import { Button, ButtonSize, ButtonType } from 'components/UI/Button/Button';
import { Header } from 'components/UI/Card/components/Header/Header';
import { Info } from 'components/UI/Card/components/Info/Info';
import { Section } from 'components/UI/Card/components/Section/Section';
import sectionStyles from 'components/UI/Card/components/Section/Section.module.css';
import { Sources } from 'components/UI/Card/components/Sources/Sources';
import { EditObjectButtonLink } from 'components/UI/EditObjectButtonLink/EditObjectButtonLink';
import { Icon } from 'components/UI/Icons';
import { IconType } from 'components/UI/Icons/Icons.types';
import styles from './CardContent.module.css';

type QuarterCardContentProps = {
placemark?: QuarterObject;
};

export function QuarterCardContent({ placemark }: QuarterCardContentProps) {
if (!placemark) return null;

return (
<div className={styles.popup}>
<Header title={placemark.quarterTitle} />

<div className={styles.description}>
{/* <a href={placemark.url} target="_blank" rel="noreferrer">
Посмотреть телефон и почту квартального&nbsp;
<Icon type={IconType.External} color="#000" />
</a> */}
<Button
size={ButtonSize.SMALL}
onClick={() => {}}
link={placemark.url}
type={ButtonType.YELLOW}
>
Посмотреть телефон и почту квартального&nbsp;
<Icon type={IconType.External} color="#000" />
</Button>
</div>

<Section>
<Info
nameColor="#9baac3"
infos={[
{
name: 'Район',
text: placemark.districtTitle,
},
// {
// name: 'Границы квартала',
// text: placemark.quarterDescription,
// },
]}
/>
</Section>

<Section>
<Sources sources={['ekb_quarter']} />
</Section>
<Section>
<div className={sectionStyles.block_inline}>
<EditObjectButtonLink
text="Дополнить или поправить"
address={placemark?.quarterTitle}
/>
</div>
</Section>
</div>
);
}
22 changes: 22 additions & 0 deletions components/Layers/Quarter/Filter/QuarterFilter.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.wrapper {
font-size: 16px;
line-height: 21px;

p {
margin: 16px 0 0 0;
&:first-child {
margin-top: 0;
}
}

ul {
list-style-type: '— ';
margin: 0;
padding: 0;
padding-left: 16px;
}

li {
padding: 0;
}
}
42 changes: 42 additions & 0 deletions components/Layers/Quarter/Filter/QuarterFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { setFilter } from 'state/features/dataLayers';
import { FilterType } from 'types/Filters.types';
import { Link } from 'components/UI/Card/components/Link/Link';
import styles from './QuarterFilter.module.css';

export function QuarterFilter() {
const dispatch = useDispatch();

useEffect(() => {
dispatch(
setFilter({
activeFilter: FilterType.Quarter,
activeFilterParams: {},
}),
);
});

return (
<div className={styles.wrapper}>
<p>
Квартальный 🙋 — это человек, который следит за&nbsp;порядком на придомовых
территориях, детских площадках, парковках, мусорках, объектах торговли и&nbsp;т. д.
</p>
<p>На что можно пожаловаться квартальному:</p>
<ul>
<li>общие вопросы благоустройства;</li>
<li>незаконная торговля, парковки и постройки;</li>
<li>вывески и незаконная реклама;</li>
<li>самовольные ограничения;</li>
<li>сломанные детские площадки.</li>
</ul>
<p>
<Link
href="https://екатеринбург.рф/справка/квартальные/"
text="Подробнее о квартальных"
/>
</p>
</div>
);
}
10 changes: 10 additions & 0 deletions components/Layers/Quarter/quarter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import quarterObjects from 'public/quarter_inspectors.json';
import { QuarterObject } from './quarterObject';

export const quarter = {
getObject(quarterId: string): Promise<QuarterObject> {
return Promise.resolve(
quarterObjects.features.find((f) => f.properties.id === quarterId).properties as unknown as QuarterObject,
);
},
};
6 changes: 6 additions & 0 deletions components/Layers/Quarter/quarterObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface QuarterObject {
districtTitle: string;
quarterTitle: string;
quarterDescription: string;
url: string;
}
6 changes: 6 additions & 0 deletions components/Layers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { okn } from 'components/Layers/OKN/okn';

import { lines } from 'components/Layers/Lines/lines';
import { LinesCardContent } from 'components/Layers/Lines/CardContent/CardContent';
import { QuarterCardContent } from 'components/Layers/Quarter/CardContent/CardContent';
import { quarter } from 'components/Layers/Quarter/quarter';
import { DesignCodeCardContent } from './DesignCode/CardContent/CardContent';
import { DTPCardContent } from './DTP/CardContent/CardContent';
import { HousesCardContent } from './Houses/CardContent/CardContent';
Expand Down Expand Up @@ -39,4 +41,8 @@ export const MODEL_CONFIG = {
cardContent: LinesCardContent,
requests: { oneItemRequest: lines.getObject },
},
[MapItemType.Quarter]: {
cardContent: QuarterCardContent,
requests: { oneItemRequest: quarter.getObject },
},
} as const;
2 changes: 2 additions & 0 deletions components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { OknSource } from './layers/OknSource';
import { DtpSource } from './layers/DtpSource';
import { LinesSource } from './layers/LinesSource';
import { DesignCodeSource } from './layers/DesignCodeSource';
import { QuarterSource } from './layers/QuarterSource';
import { MapContext } from './providers/MapProvider';

import 'maplibre-gl/dist/maplibre-gl.css';
Expand All @@ -24,6 +25,7 @@ function MapLayers() {
<DtpSource />
<LinesSource />
<DesignCodeSource />
<QuarterSource />
</>
);
}
Expand Down
73 changes: 73 additions & 0 deletions components/Map/layers/QuarterSource.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useEffect } from 'react';
import { FillLayer, Layer, LineLayer, Source, useMap } from 'react-map-gl';
import { useSelector } from 'react-redux';
import { activeFilterSelector } from 'state/features/selectors';
import { FilterType } from 'types/Filters.types';
import { getLayerStyle } from 'components/Map/helpers/getFeatureState';
import { MapItemType } from 'types/map-item';
import { usePopup } from 'components/Map/providers/usePopup';
import useMapObjectState from '../providers/useMapObjectState';
import { colorLuminance } from '../helpers/colorLuminance';

const QUARTER_LAYER_ID = 'ekb-quarter-inspectors-layer';
const QUARTER_SOURCE_ID = 'ekb-quarter-inspectors-source';

export function QuarterSource() {
const ekbMap = useMap();
const { openPopup } = usePopup();
const activeFilter = useSelector(activeFilterSelector);

useMapObjectState(QUARTER_LAYER_ID);

useEffect(() => {
const map = ekbMap.current;

const handlePointClick = (e) => {
const item = e.target.queryRenderedFeatures(e.point)[0];

openPopup(item?.properties?.id, MapItemType.Quarter);
};

map.on('click', QUARTER_LAYER_ID, handlePointClick);

return () => {
map.off('click', QUARTER_LAYER_ID, handlePointClick);
};
}, [ekbMap, openPopup]);

const layerStyle: FillLayer = {
type: 'fill',
id: QUARTER_LAYER_ID,
source: QUARTER_SOURCE_ID,
paint: {
'fill-color': getLayerStyle<string>({
initial: '#9AADCC',
hover: colorLuminance('#9AADCC', 0.2),
active: colorLuminance('#9AADCC', 0.4),
}),
'fill-opacity': 0.6,
},
};

const layerStrokeStyle: LineLayer = {
id: `${QUARTER_LAYER_ID}-outline`,
type: 'line',
source: QUARTER_SOURCE_ID,
paint: {
'line-color': '#000',
'line-opacity': 0.5,
'line-width': 1.5,
},
};

if (activeFilter !== FilterType.Quarter) {
return null;
}

return (
<Source type="geojson" data="./quarter_inspectors.json" id={QUARTER_SOURCE_ID} generateId>
<Layer {...layerStyle} />
<Layer {...layerStrokeStyle} />
</Source>
);
}
Loading

0 comments on commit 8b7acd3

Please sign in to comment.