From 5eb3568baf241d253bda9719b86770cd353f196c Mon Sep 17 00:00:00 2001 From: Anton Akhatov Date: Mon, 1 Jan 2024 11:33:16 +0000 Subject: [PATCH] refactor store --- .eslintrc.json | 13 +- components/Card/Card.tsx | 53 - components/Card/DesktopCard/DesktopCard.tsx | 27 - components/Card/MobileCard.tsx | 18 - .../ConstructionInfo/ConstructionInfo.tsx | 38 - .../Card/components/Header/Header.module.css | 29 - components/Card/components/Header/Header.tsx | 62 - .../components/Section/Section.module.css | 11 - .../Card/components/Section/Section.tsx | 7 - components/Card/index.ts | 2 - .../UI => components}/Close/Close.module.css | 0 {shared/UI => components}/Close/Close.tsx | 0 {shared/UI => components}/Close/index.ts | 0 .../DesktopCard/DesktopCard.module.css | 0 components/DesktopCard/index.tsx | 24 + components/Filters/Filters.tsx | 63 - components/Filters/index.ts | 1 - constants/colors.ts | 7 - constants/map.ts | 1 - constants/sources.ts | 49 - features/About/AboutProjectModal.tsx | 2 +- features/{App => }/App.tsx | 11 +- features/App/Content.config.ts | 39 - features/App/Filters.config.tsx | 68 - features/Buildings/BuildingSource.tsx | 156 - .../CardContent/CardContent.module.css | 14 - .../Buildings/CardContent/CardContent.tsx | 200 - features/Buildings/Filter/HouseBaseFilter.tsx | 29 - features/Buildings/Houses.constants.ts | 43 - features/Buildings/houseBase.ts | 39 +- features/Copyright/Copyright.tsx | 14 +- .../DownloadButton/DownloadButton.module.css | 0 .../DownloadButton/DownloadButton.tsx | 4 +- .../FeedbackButton/FeedbackButton.tsx | 10 +- .../HealthProgress/HealthProgress.module.css | 0 .../HealthProgress/HealthProgress.tsx | 26 +- .../CustomCardContent}/Info/Info.module.css | 0 .../CustomCardContent}/Info/Info.tsx | 0 .../CustomCardContent}/Info/Info.types.ts | 0 .../OKNInfo/OKNInfo.module.css | 0 .../OKNInfo/OKNInfo.tsx | 14 +- .../CustomCardContent/OKNInfo/SvgOknIcon.tsx | 2 +- .../Participant/Participant.module.css | 0 .../Participants/Participant/Participant.tsx | 5 +- .../Participants/Participants.module.css | 13 +- .../Participants/Participants.tsx | 108 + .../Participants/Participants.types.ts | 48 + features/CustomCardContent/overrideCard.tsx | 100 + .../FacadeFilter.tsx | 0 .../QuarterFilter.tsx | 15 - .../DTP/CardContent/CardContent.module.css | 14 - features/DTP/CardContent/CardContent.tsx | 120 - .../components/Participants/Participants.tsx | 109 - .../Participants/Participants.types.ts | 12 - features/DTP/DTP.constants.ts | 51 - features/DTP/DtpSource.tsx | 111 - features/DTP/Filter/DTPFilter.module.css | 22 - features/DTP/Filter/DTPFilter.state.ts | 37 - features/DTP/Filter/DTPFilter.tsx | 211 - features/DTP/Filter/DTPFilter.types.ts | 13 - features/DTP/dtp.ts | 105 - features/DTP/types.ts | 14 - .../DesignCode/CardContent/CardContent.tsx | 49 - features/DesignCode/DesignCode.constants.ts | 17 - features/DesignCode/DesignCodeSource.tsx | 73 - .../Filter/DesignCodeFilter.state.ts | 17 - .../DesignCode/Filter/DesignCodeFilter.tsx | 55 - .../Filter/DesignCodeFilter.types.ts | 7 - features/DesignCode/designCode.ts | 31 - features/DesignCode/designCodeObject.ts | 28 - features/Facade/CardContent/Facade.module.css | 12 - features/Facade/CardContent/Facade.tsx | 18 - features/Facade/FacadeSource.tsx | 61 - features/HouseAge/HouseAgeFilter.tsx | 42 - features/HouseFloor/HouseFloorFilter.tsx | 42 - .../HouseWearTear/HouseWearTearFilter.tsx | 41 - features/Lines/CardContent/CardContent.tsx | 30 - features/Lines/Filter/LinesFilter.state.ts | 17 - features/Lines/Filter/LinesFilter.tsx | 63 - features/Lines/Filter/LinesFilter.types.ts | 8 - features/Lines/Lines.constants.ts | 16 - features/Lines/LinesSource.tsx | 70 - features/Lines/lineType.ts | 18 - features/Lines/lines.ts | 16 - .../OKN/CardContent/CardContent.module.css | 35 - features/OKN/CardContent/CardContent.tsx | 79 - features/OKN/CardContent/index.ts | 1 - features/OKN/Filter/OknFilter.state.ts | 43 - features/OKN/Filter/OknFilter.tsx | 129 - features/OKN/Okn.constants.ts | 30 - features/OKN/OknSource.tsx | 140 - features/OKN/okn.ts | 19 - features/OKN/oknConstants.ts | 11 - features/OKN/oknObject.ts | 30 - .../CardContent/CardContent.module.css | 30 - features/Quarter/CardContent/CardContent.tsx | 60 - features/Quarter/QuarterSource.tsx | 57 - features/Quarter/quarter.ts | 11 - features/Quarter/quarterObject.ts | 6 - {features/Map => map}/Map.tsx | 28 +- map/components/MapLoader.tsx | 16 + {features/App => map/components}/Sidebars.tsx | 41 +- map/constants.ts | 2 + map/filters/FilterBuildingRange.tsx | 37 + map/filters/FilterGrid.tsx | 53 + .../Filters => map/filters}/FilterLoader.tsx | 0 map/filters/MapFilter.tsx | 86 + .../filters}/RangeBaseFilter.tsx | 2 +- .../Map => map}/helpers/colorLuminance.ts | 0 .../Map => map}/helpers/getFeatureState.ts | 0 map/helpers/getLayerProps.ts | 61 + map/helpers/getStringFromStringOrArray.ts | 13 + map/helpers/groupByProperty.tsx | 25 + map/helpers/setBuildingStyle.ts | 123 + map/helpers/useClickableBuilding.tsx | 34 + map/helpers/useLoadGeoJSON.ts | 37 + .../Map => map}/helpers/useMapObjectState.ts | 0 .../Map => map}/helpers/useOpenMapItem.tsx | 13 +- map/layers/ClickableLayer.tsx | 36 + map/layers/Layers.tsx | 77 + .../layers/MarkersLayer.module.css | 0 map/layers/MarkersLayer.tsx | 82 + map/sources/Card/BaseCard.tsx | 175 + map/sources/Card/BuildingCard.tsx | 78 + map/sources/Card/FeatureCard.tsx | 30 + map/sources/Card/components/CardActions.tsx | 54 + .../components/Sources/Sources.module.css | 0 .../Card/components/Sources/Sources.tsx | 8 +- map/sources/Card/index.tsx | 34 + .../providers => map/state}/MapProvider.tsx | 25 +- map/state/dataSlice/dataLayers.ts | 62 + .../state/dataSlice}/selectors.ts | 2 +- .../Map/providers => map/state}/usePopup.ts | 25 +- map/types.ts | 100 + map/visualLayers/BuildingRangeVisualLayer.tsx | 40 + map/visualLayers/BuldingsIdsVisualLayer.tsx | 30 + map/visualLayers/VisualisationLayer.tsx | 98 + package.json | 7 +- pages/_document.tsx | 4 +- pages/api/dtp.ts | 10 +- pages/index.tsx | 2 +- pnpm-lock.yaml | 16 +- public/administrativeDistricts.json | 23197 ++++++++++++++++ public/okn-meta.json | 12 - shared/UI/Icons/Auto.tsx | 21 - shared/UI/Icons/Bike.tsx | 21 - shared/UI/Icons/BrokenHeart.tsx | 47 - shared/UI/Icons/Bycicle.tsx | 21 - shared/UI/Icons/Children.tsx | 21 - shared/UI/Icons/Copy.tsx | 34 - shared/UI/Icons/Download.tsx | 20 - shared/UI/Icons/DownloadIcon.tsx | 17 - shared/UI/Icons/Edit.tsx | 26 - shared/UI/Icons/External.tsx | 12 - shared/UI/Icons/Heart.tsx | 35 - shared/UI/Icons/Icons.constants.ts | 30 - shared/UI/Icons/Icons.types.ts | 17 - shared/UI/Icons/Link.tsx | 21 - shared/UI/Icons/Pdf.tsx | 38 - shared/UI/Icons/Pedestrian.tsx | 21 - shared/UI/Icons/PublicTransport.tsx | 21 - shared/UI/Icons/index.tsx | 14 - shared/helpers/getYearNameByValue.ts | 6 + shared/helpers/hash.ts | 4 +- state/config.ts | 795 + state/features/dataLayers.ts | 36 - state/index.ts | 2 +- state/state.ts | 37 +- types/Content.types.ts | 16 - types/Filters.types.ts | 28 - types/ObjectsBase.types.ts | 11 - types/Sources.types.ts | 19 - 172 files changed, 25813 insertions(+), 3949 deletions(-) delete mode 100644 components/Card/Card.tsx delete mode 100644 components/Card/DesktopCard/DesktopCard.tsx delete mode 100644 components/Card/MobileCard.tsx delete mode 100644 components/Card/components/ConstructionInfo/ConstructionInfo.tsx delete mode 100644 components/Card/components/Header/Header.module.css delete mode 100644 components/Card/components/Header/Header.tsx delete mode 100644 components/Card/components/Section/Section.module.css delete mode 100644 components/Card/components/Section/Section.tsx delete mode 100644 components/Card/index.ts rename {shared/UI => components}/Close/Close.module.css (100%) rename {shared/UI => components}/Close/Close.tsx (100%) rename {shared/UI => components}/Close/index.ts (100%) rename components/{Card => }/DesktopCard/DesktopCard.module.css (100%) create mode 100644 components/DesktopCard/index.tsx delete mode 100644 components/Filters/Filters.tsx delete mode 100644 components/Filters/index.ts delete mode 100644 constants/colors.ts delete mode 100644 constants/sources.ts rename features/{App => }/App.tsx (73%) delete mode 100644 features/App/Content.config.ts delete mode 100644 features/App/Filters.config.tsx delete mode 100644 features/Buildings/BuildingSource.tsx delete mode 100644 features/Buildings/CardContent/CardContent.module.css delete mode 100644 features/Buildings/CardContent/CardContent.tsx delete mode 100644 features/Buildings/Filter/HouseBaseFilter.tsx delete mode 100644 features/Buildings/Houses.constants.ts rename {shared/UI => features/CustomCardContent}/DownloadButton/DownloadButton.module.css (100%) rename {shared/UI => features/CustomCardContent}/DownloadButton/DownloadButton.tsx (84%) rename features/{ => CustomCardContent}/FeedbackButton/FeedbackButton.tsx (68%) rename features/{HouseWearTear => CustomCardContent}/HealthProgress/HealthProgress.module.css (100%) rename features/{HouseWearTear => CustomCardContent}/HealthProgress/HealthProgress.tsx (57%) rename {components/Card/components => features/CustomCardContent}/Info/Info.module.css (100%) rename {components/Card/components => features/CustomCardContent}/Info/Info.tsx (100%) rename {components/Card/components => features/CustomCardContent}/Info/Info.types.ts (100%) rename features/{OKN/CardContent/components => CustomCardContent}/OKNInfo/OKNInfo.module.css (100%) rename features/{OKN/CardContent/components => CustomCardContent}/OKNInfo/OKNInfo.tsx (73%) rename shared/UI/Icons/OKN.tsx => features/CustomCardContent/OKNInfo/SvgOknIcon.tsx (99%) rename features/{DTP/CardContent/components => CustomCardContent}/Participants/Participant/Participant.module.css (100%) rename features/{DTP/CardContent/components => CustomCardContent}/Participants/Participant/Participant.tsx (94%) rename features/{DTP/CardContent/components => CustomCardContent}/Participants/Participants.module.css (81%) create mode 100644 features/CustomCardContent/Participants/Participants.tsx create mode 100644 features/CustomCardContent/Participants/Participants.types.ts create mode 100644 features/CustomCardContent/overrideCard.tsx rename features/{Facade/Filter => CustomFilterContent}/FacadeFilter.tsx (100%) rename features/{Quarter/Filter => CustomFilterContent}/QuarterFilter.tsx (80%) delete mode 100644 features/DTP/CardContent/CardContent.module.css delete mode 100644 features/DTP/CardContent/CardContent.tsx delete mode 100644 features/DTP/CardContent/components/Participants/Participants.tsx delete mode 100644 features/DTP/CardContent/components/Participants/Participants.types.ts delete mode 100644 features/DTP/DTP.constants.ts delete mode 100644 features/DTP/DtpSource.tsx delete mode 100644 features/DTP/Filter/DTPFilter.module.css delete mode 100644 features/DTP/Filter/DTPFilter.state.ts delete mode 100644 features/DTP/Filter/DTPFilter.tsx delete mode 100644 features/DTP/Filter/DTPFilter.types.ts delete mode 100644 features/DTP/dtp.ts delete mode 100644 features/DTP/types.ts delete mode 100644 features/DesignCode/CardContent/CardContent.tsx delete mode 100644 features/DesignCode/DesignCode.constants.ts delete mode 100644 features/DesignCode/DesignCodeSource.tsx delete mode 100644 features/DesignCode/Filter/DesignCodeFilter.state.ts delete mode 100644 features/DesignCode/Filter/DesignCodeFilter.tsx delete mode 100644 features/DesignCode/Filter/DesignCodeFilter.types.ts delete mode 100644 features/DesignCode/designCode.ts delete mode 100644 features/DesignCode/designCodeObject.ts delete mode 100644 features/Facade/CardContent/Facade.module.css delete mode 100644 features/Facade/CardContent/Facade.tsx delete mode 100644 features/Facade/FacadeSource.tsx delete mode 100644 features/HouseAge/HouseAgeFilter.tsx delete mode 100644 features/HouseFloor/HouseFloorFilter.tsx delete mode 100644 features/HouseWearTear/HouseWearTearFilter.tsx delete mode 100644 features/Lines/CardContent/CardContent.tsx delete mode 100644 features/Lines/Filter/LinesFilter.state.ts delete mode 100644 features/Lines/Filter/LinesFilter.tsx delete mode 100644 features/Lines/Filter/LinesFilter.types.ts delete mode 100644 features/Lines/Lines.constants.ts delete mode 100644 features/Lines/LinesSource.tsx delete mode 100644 features/Lines/lineType.ts delete mode 100644 features/Lines/lines.ts delete mode 100644 features/OKN/CardContent/CardContent.module.css delete mode 100644 features/OKN/CardContent/CardContent.tsx delete mode 100644 features/OKN/CardContent/index.ts delete mode 100644 features/OKN/Filter/OknFilter.state.ts delete mode 100644 features/OKN/Filter/OknFilter.tsx delete mode 100644 features/OKN/Okn.constants.ts delete mode 100644 features/OKN/OknSource.tsx delete mode 100644 features/OKN/okn.ts delete mode 100644 features/OKN/oknConstants.ts delete mode 100644 features/OKN/oknObject.ts delete mode 100644 features/Quarter/CardContent/CardContent.module.css delete mode 100644 features/Quarter/CardContent/CardContent.tsx delete mode 100644 features/Quarter/QuarterSource.tsx delete mode 100644 features/Quarter/quarter.ts delete mode 100644 features/Quarter/quarterObject.ts rename {features/Map => map}/Map.tsx (62%) create mode 100644 map/components/MapLoader.tsx rename {features/App => map/components}/Sidebars.tsx (54%) create mode 100644 map/constants.ts create mode 100644 map/filters/FilterBuildingRange.tsx create mode 100644 map/filters/FilterGrid.tsx rename {components/Filters => map/filters}/FilterLoader.tsx (100%) create mode 100644 map/filters/MapFilter.tsx rename {components => map/filters}/RangeBaseFilter.tsx (95%) rename {features/Map => map}/helpers/colorLuminance.ts (100%) rename {features/Map => map}/helpers/getFeatureState.ts (100%) create mode 100644 map/helpers/getLayerProps.ts create mode 100644 map/helpers/getStringFromStringOrArray.ts create mode 100644 map/helpers/groupByProperty.tsx create mode 100644 map/helpers/setBuildingStyle.ts create mode 100644 map/helpers/useClickableBuilding.tsx create mode 100644 map/helpers/useLoadGeoJSON.ts rename {features/Map => map}/helpers/useMapObjectState.ts (100%) rename {features/Map => map}/helpers/useOpenMapItem.tsx (58%) create mode 100644 map/layers/ClickableLayer.tsx create mode 100644 map/layers/Layers.tsx rename features/DesignCode/DesignCodeMarker.module.css => map/layers/MarkersLayer.module.css (100%) create mode 100644 map/layers/MarkersLayer.tsx create mode 100644 map/sources/Card/BaseCard.tsx create mode 100644 map/sources/Card/BuildingCard.tsx create mode 100644 map/sources/Card/FeatureCard.tsx create mode 100644 map/sources/Card/components/CardActions.tsx rename {components => map/sources}/Card/components/Sources/Sources.module.css (100%) rename {components => map/sources}/Card/components/Sources/Sources.tsx (61%) create mode 100644 map/sources/Card/index.tsx rename {features/Map/providers => map/state}/MapProvider.tsx (58%) create mode 100644 map/state/dataSlice/dataLayers.ts rename {state/features => map/state/dataSlice}/selectors.ts (61%) rename {features/Map/providers => map/state}/usePopup.ts (63%) create mode 100644 map/types.ts create mode 100644 map/visualLayers/BuildingRangeVisualLayer.tsx create mode 100644 map/visualLayers/BuldingsIdsVisualLayer.tsx create mode 100644 map/visualLayers/VisualisationLayer.tsx create mode 100644 public/administrativeDistricts.json delete mode 100644 public/okn-meta.json delete mode 100644 shared/UI/Icons/Auto.tsx delete mode 100644 shared/UI/Icons/Bike.tsx delete mode 100644 shared/UI/Icons/BrokenHeart.tsx delete mode 100644 shared/UI/Icons/Bycicle.tsx delete mode 100644 shared/UI/Icons/Children.tsx delete mode 100644 shared/UI/Icons/Copy.tsx delete mode 100644 shared/UI/Icons/Download.tsx delete mode 100644 shared/UI/Icons/DownloadIcon.tsx delete mode 100644 shared/UI/Icons/Edit.tsx delete mode 100644 shared/UI/Icons/External.tsx delete mode 100644 shared/UI/Icons/Heart.tsx delete mode 100644 shared/UI/Icons/Icons.constants.ts delete mode 100644 shared/UI/Icons/Icons.types.ts delete mode 100644 shared/UI/Icons/Link.tsx delete mode 100644 shared/UI/Icons/Pdf.tsx delete mode 100644 shared/UI/Icons/Pedestrian.tsx delete mode 100644 shared/UI/Icons/PublicTransport.tsx delete mode 100644 shared/UI/Icons/index.tsx create mode 100644 state/config.ts delete mode 100644 state/features/dataLayers.ts delete mode 100644 types/Content.types.ts delete mode 100644 types/Filters.types.ts delete mode 100644 types/ObjectsBase.types.ts delete mode 100644 types/Sources.types.ts diff --git a/.eslintrc.json b/.eslintrc.json index 2a634d3b..e04b8bdb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,15 +12,16 @@ "project": "./tsconfig.json" }, "rules": { + "react-hooks/exhaustive-deps": "error", + "@next/next/no-img-element": "off", // TODO: remove this rule "@typescript-eslint/no-explicit-any": "off", // TODO: remove this rule "@typescript-eslint/ban-ts-comment": "off", - // TODO: remove this rule + "jsx-a11y/click-events-have-key-events": "off", - // TODO: remove this rule "jsx-a11y/no-static-element-interactions": "off", "no-irregular-whitespace": "off", @@ -57,6 +58,14 @@ { "from": "./state", "target": "./components" }, { "from": "./constants", "target": "./components" }, { "from": "./features", "target": "./components" } + + // { "from": "./constants", "target": "./map" }, + // { "from": "./state", "target": "./map" }, + // { "from": "./styles", "target": "./map" }, + // { "from": "./shared", "target": "./map" }, + // { "from": "./pages", "target": "./map" }, + // { "from": "./features", "target": "./map" }, + // { "from": "./components", "target": "./map" } ] } ] diff --git a/components/Card/Card.tsx b/components/Card/Card.tsx deleted file mode 100644 index cdbdbe84..00000000 --- a/components/Card/Card.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import React, { useEffect, useMemo, useState } from 'react'; -import styled from 'styled-components'; -import { AnimatedLogo } from 'ekb'; -import { ContentConfig, MapItemType } from 'types/Content.types'; - -interface Props { - contentConfig: ContentConfig; - popupId?: string; - popupType: MapItemType | null; -} - -const CardLoaderContainer = styled.div` - position: relative; - height: 600px; -`; - -export function Card({ contentConfig, popupId, popupType }: Props) { - const [popupData, setPopupData] = useState(); - const [loading, setLoading] = useState(false); - - useEffect(() => { - async function fetchData() { - if (!popupId || !popupType) { - return; - } - - setLoading(true); - - const requestFunction = contentConfig[popupType].oneItemRequest; - - const data = await requestFunction(popupId); - - setPopupData(data); - setLoading(false); - } - - fetchData(); - }, [contentConfig, popupId, popupType]); - - const CardContent = useMemo(() => { - setLoading(true); - - return contentConfig[popupType]?.cardContent || (() => null); - }, [contentConfig, popupType]); - - return loading ? ( - - - - ) : ( - - ); -} diff --git a/components/Card/DesktopCard/DesktopCard.tsx b/components/Card/DesktopCard/DesktopCard.tsx deleted file mode 100644 index d2751952..00000000 --- a/components/Card/DesktopCard/DesktopCard.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import { Card } from 'components/Card/Card'; -import { Close } from 'shared/UI/Close'; -import { ContentConfig, MapItemType } from 'types/Content.types'; -import styles from './DesktopCard.module.css'; - -interface Props { - contentConfig: ContentConfig; - popupId?: string; - popupType: MapItemType | null; - closePopup: () => void; -} - -export function DesktopCard({ contentConfig, popupId, popupType, closePopup }: Props) { - if (!popupId) { - return <>; - } - - return ( -
-
- -
- -
- ); -} diff --git a/components/Card/MobileCard.tsx b/components/Card/MobileCard.tsx deleted file mode 100644 index 52ea9413..00000000 --- a/components/Card/MobileCard.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { SheetModal } from 'ekb'; -import { Card } from 'components/Card/Card'; -import { ContentConfig, MapItemType } from 'types/Content.types'; - -interface Props { - contentConfig: ContentConfig; - popupId?: string; - popupType: MapItemType | null; - closePopup: () => void; -} - -export function MobileCard({ contentConfig, popupId, popupType, closePopup }: Props) { - return ( - - - - ); -} diff --git a/components/Card/components/ConstructionInfo/ConstructionInfo.tsx b/components/Card/components/ConstructionInfo/ConstructionInfo.tsx deleted file mode 100644 index d45cf49e..00000000 --- a/components/Card/components/ConstructionInfo/ConstructionInfo.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React, { useMemo } from 'react'; -import { getYearNameByValue } from 'shared/helpers/getYearNameByValue'; -import { Info } from 'components/Card/components/Info/Info'; - -const YEAR_RE = /\d{4}/; - -type ConstructionInfoProps = { - date: string; -}; - -export function ConstructionInfo({ date }: ConstructionInfoProps) { - const constructionDateInfo = useMemo(() => { - const result = [ - { - name: 'Когда построили', - text: date, - }, - ]; - - const constructionYearMatch = date.match(YEAR_RE); - - if (constructionYearMatch) { - const constructionYear = Number(constructionYearMatch[0]); - const age = new Date().getFullYear() - Number(constructionYear); - - result.push({ - name: 'Возраст здания', - text: `${String(age)} ${getYearNameByValue(age)}`, - }); - } - - return result; - }, [date]); - - return ( - - ); -} diff --git a/components/Card/components/Header/Header.module.css b/components/Card/components/Header/Header.module.css deleted file mode 100644 index c443ba4c..00000000 --- a/components/Card/components/Header/Header.module.css +++ /dev/null @@ -1,29 +0,0 @@ -.header { - display: flex; - flex-wrap: wrap; - column-gap: 4px; -} - -.header__title { - margin: 12px 0 0; - font-size: 30px; - font-weight: 500; - line-height: 1; -} - -.header__description { - margin: 4px 0 0; - font-size: 14px; - font-weight: 400; - line-height: 20px; -} - -@media screen and (width >= 1150px) { - .header__title { - font-size: 32px; - } - - .header__description { - font-size: 16px; - } -} diff --git a/components/Card/components/Header/Header.tsx b/components/Card/components/Header/Header.tsx deleted file mode 100644 index d63477e6..00000000 --- a/components/Card/components/Header/Header.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React, { useMemo } from 'react'; -import { Button, ButtonSize, ButtonType } from 'ekb'; -import { Icon } from 'shared/UI/Icons'; -import { IconType } from 'shared/UI/Icons/Icons.types'; -import { useCopyHref } from 'shared/helpers/useCopyHref'; -import styles from './Header.module.css'; - -export type HeaderProps = { - coordinates?: [number, number] | number[]; - title?: string; - description?: string; -}; - -const COPY_RESET_TIMEOUT = 2000; - -export function Header({ coordinates, title, description }: HeaderProps) { - const { isCopied: isLinkCopied, onCopy: onCopyLink } = useCopyHref( - window.location.href, - COPY_RESET_TIMEOUT, - ); - - const coordsString = useMemo(() => { - if (!coordinates) { - return null; - } - - const coords = Array.isArray(coordinates[0]) ? coordinates[0] : coordinates; - - return `${coords[0]?.toFixed(6)}, ${coords[1]?.toFixed(6)}`; - }, [coordinates]); - const { isCopied: isCoordsCopied, onCopy: onCopyCoords } = useCopyHref( - coordsString, - COPY_RESET_TIMEOUT, - ); - - return ( - <> -
- {coordsString && ( - - )} - -
-

{title}

- {description &&

{description}

} - - ); -} diff --git a/components/Card/components/Section/Section.module.css b/components/Card/components/Section/Section.module.css deleted file mode 100644 index a47616fe..00000000 --- a/components/Card/components/Section/Section.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.block { - margin-top: 16px; - padding-top: 16px; - border-top: 1px solid rgba(256, 256, 256, 0.16); -} - -.block_inline { - display: flex; - flex-wrap: wrap; - gap: 8px; -} diff --git a/components/Card/components/Section/Section.tsx b/components/Card/components/Section/Section.tsx deleted file mode 100644 index 7c82e9cf..00000000 --- a/components/Card/components/Section/Section.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -import styles from './Section.module.css'; - -export function Section({ children }: React.PropsWithChildren) { - return
{children}
; -} diff --git a/components/Card/index.ts b/components/Card/index.ts deleted file mode 100644 index 984b6544..00000000 --- a/components/Card/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { DesktopCard } from './DesktopCard/DesktopCard'; -export { MobileCard } from './MobileCard'; diff --git a/shared/UI/Close/Close.module.css b/components/Close/Close.module.css similarity index 100% rename from shared/UI/Close/Close.module.css rename to components/Close/Close.module.css diff --git a/shared/UI/Close/Close.tsx b/components/Close/Close.tsx similarity index 100% rename from shared/UI/Close/Close.tsx rename to components/Close/Close.tsx diff --git a/shared/UI/Close/index.ts b/components/Close/index.ts similarity index 100% rename from shared/UI/Close/index.ts rename to components/Close/index.ts diff --git a/components/Card/DesktopCard/DesktopCard.module.css b/components/DesktopCard/DesktopCard.module.css similarity index 100% rename from components/Card/DesktopCard/DesktopCard.module.css rename to components/DesktopCard/DesktopCard.module.css diff --git a/components/DesktopCard/index.tsx b/components/DesktopCard/index.tsx new file mode 100644 index 00000000..a4a1b717 --- /dev/null +++ b/components/DesktopCard/index.tsx @@ -0,0 +1,24 @@ +import React, { ReactNode } from 'react'; +import { Close } from 'components/Close'; +import styles from './DesktopCard.module.css'; + +interface Props { + popupHash?: string; + children: ReactNode; + closePopup: () => void; +} + +export function DesktopCard({ popupHash, children, closePopup }: Props) { + if (!popupHash) { + return <>; + } + + return ( +
+
+ +
+ {children} +
+ ); +} diff --git a/components/Filters/Filters.tsx b/components/Filters/Filters.tsx deleted file mode 100644 index 854f1374..00000000 --- a/components/Filters/Filters.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React from 'react'; -import styled from 'styled-components'; -import { Accordion, AccordionItem, Link, LinkSize } from 'ekb'; -import { FilterConfigItem, FilterType } from 'types/Filters.types'; - -interface Props { - filters: Record; - activeFilter: FilterType; - onToggleClick: (type: FilterType) => void; -} - -const Notice = styled.div` - margin-top: 12px; - padding: 12px 16px; - background: #3a4155; - color: #9c9ea8; - font-size: 14px; - border-radius: 4px; -`; - -export function Filters({ filters, activeFilter, onToggleClick }: Props) { - return ( - - {(Object.entries(filters) as [FilterType, FilterConfigItem][]).map( - ([type, { component, title, isVerified }], idx) => { - const id = `id:${type}-${idx}`; - const isActive = type === activeFilter; - const toggle = () => onToggleClick(type); - - return ( - - {component && ( - <> - {isActive ? component : null} - {!isVerified && ( - - Данные берутся из публичных источников - и содержат неточности.{' '} - - Оставьте фидбек - -  — помогите улучшить карту. - - )} - - )} - - ); - }, - )} - - ); -} diff --git a/components/Filters/index.ts b/components/Filters/index.ts deleted file mode 100644 index 194f6207..00000000 --- a/components/Filters/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Filters } from './Filters'; diff --git a/constants/colors.ts b/constants/colors.ts deleted file mode 100644 index 6221a34b..00000000 --- a/constants/colors.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { MapItemType } from 'types/Content.types'; - -export const MARKER_COLOR = { - [MapItemType.DTP]: '#05B506', -}; - -export const DEFAULT_BULDING_COLOR_NORMAL = '#0c1021'; diff --git a/constants/map.ts b/constants/map.ts index 89bb642d..bdeb3b86 100644 --- a/constants/map.ts +++ b/constants/map.ts @@ -1,4 +1,3 @@ export const MIN_ZOOM = 11; export const MAX_ZOOM = 20; -export const BUILDING_LAYER_ID = 'building'; export const CENTER_COORDS: [number, number] = [60.605, 56.838011]; diff --git a/constants/sources.ts b/constants/sources.ts deleted file mode 100644 index 32c45a35..00000000 --- a/constants/sources.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { SourceType, SourcesConfig } from 'types/Sources.types'; - -export const SOURCES_BY_TYPE: SourcesConfig = { - [SourceType.osm]: { - name: 'OpenStreetMap', - link: 'https://www.openstreetmap.org/', - data: null, - }, - [SourceType.okn]: { - name: 'Объекты культурного наследия Свердловской области', - link: 'https://okn.midural.ru/kategorii/obekty-kulturnogo-naslediya-sverdlovskoy-oblasti', - data: null, - }, - [SourceType.howoldthishouse]: { - name: 'Карта возраста домов', - link: 'https://how-old-is-this.house/', - data: 'https://how-old-is-this.house/dataset?p=h-ekb', - }, - [SourceType.domaekb]: { - name: 'Жилые дома Екатеринбурга', - link: 'https://domaekb.ru', - data: null, - }, - [SourceType.mingkh]: { - name: 'МинЖКХ', - link: 'https://mingkh.ru', - data: null, - }, - [SourceType.ekaterinburgdesign]: { - name: 'Дизайн-код Ектеринбурга', - link: 'https://ekaterinburg.design', - data: 'https://ekaterinburg.design', - }, - [SourceType.dtp]: { - name: 'Карта ДТП', - link: 'https://dtp-stat.ru/', - data: 'https://dtp-stat.ru/opendata', - }, - [SourceType.ekb_quarter]: { - name: 'екатеринбург.рф', - link: 'https://екатеринбург.рф/справка/квартальные', - data: null, - }, - [SourceType.design_objects_map]: { - name: 'Карта объектов «Дизайн-кода»', - link: 'https://map.ekaterinburg.design', - data: 'https://map.ekaterinburg.design', - }, -}; diff --git a/features/About/AboutProjectModal.tsx b/features/About/AboutProjectModal.tsx index 5f364fad..5a414906 100644 --- a/features/About/AboutProjectModal.tsx +++ b/features/About/AboutProjectModal.tsx @@ -1,7 +1,7 @@ import React, { useContext, useEffect } from 'react'; import { AboutProjectContent } from 'features/About/AboutProjectContent'; import { AboutProjectContext } from 'features/About/AboutProjectProvider'; -import { Close } from 'shared/UI/Close'; +import { Close } from 'components/Close'; import styles from './AboutProjectModal.module.css'; export function AboutProjectModal() { diff --git a/features/App/App.tsx b/features/App.tsx similarity index 73% rename from features/App/App.tsx rename to features/App.tsx index 663fe805..0c97f841 100644 --- a/features/App/App.tsx +++ b/features/App.tsx @@ -5,21 +5,20 @@ import { store } from 'state'; import { AboutProjectIcons } from 'features/About/AboutProjectIcons/AboutProjectIcons'; import { AboutProjectProvider } from 'features/About/AboutProjectProvider'; import { Copyright } from 'features/Copyright/Copyright'; -import { MapContextProvider } from 'features/Map/providers/MapProvider'; +import { MapContextProvider } from 'map/state/MapProvider'; import { Footer } from 'components/Footer/Footer'; -import { Map } from 'features/Map/Map'; -import { FILTERS_CONFIG } from './Filters.config'; -import { Sidebars } from './Sidebars'; +import { Map } from 'map/Map'; +import { Sidebars } from 'map/components/Sidebars'; export default function App() { return ( - + - +