diff --git a/components/Card/DesktopCard/DesktopCard.tsx b/components/Card/DesktopCard/index.tsx similarity index 51% rename from components/Card/DesktopCard/DesktopCard.tsx rename to components/Card/DesktopCard/index.tsx index d2751952..2bb3612a 100644 --- a/components/Card/DesktopCard/DesktopCard.tsx +++ b/components/Card/DesktopCard/index.tsx @@ -1,17 +1,14 @@ -import React from 'react'; -import { Card } from 'components/Card/Card'; +import React, { ReactNode } from 'react'; 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; + children: ReactNode; closePopup: () => void; } -export function DesktopCard({ contentConfig, popupId, popupType, closePopup }: Props) { +export function DesktopCard({ popupId, children, closePopup }: Props) { if (!popupId) { return <>; } @@ -21,7 +18,7 @@ export function DesktopCard({ contentConfig, popupId, popupType, closePopup }: P
- + {children} ); } 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/CardActions.tsx b/components/Card/components/CardActions.tsx new file mode 100644 index 00000000..ea6c5a27 --- /dev/null +++ b/components/Card/components/CardActions.tsx @@ -0,0 +1,54 @@ +import React, { useMemo } from 'react'; +import { Button, ButtonSize, ButtonType, Icon, IconType } from 'ekb'; +import { useCopyHref } from 'shared/helpers/useCopyHref'; + +type Props = { + coordinates?: [number, number] | number[]; +}; + +const COPY_RESET_TIMEOUT = 2000; + +export function CardActions({ coordinates }: Props) { + 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 && ( + + )} + + + ); +} 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/components/Sources/Sources.tsx b/components/Card/components/Sources/Sources.tsx index 812c60ed..5f2a3551 100644 --- a/components/Card/components/Sources/Sources.tsx +++ b/components/Card/components/Sources/Sources.tsx @@ -1,17 +1,15 @@ import React from 'react'; import { Link, LinkSize } from 'ekb'; -import { SourceInfo } from 'types/Sources.types'; import styles from './Sources.module.css'; -export function Sources({ sources }: { sources: SourceInfo[] }) { +export function Sources({ sources }: { sources: { name: string; link: string }[] }) { return (
-

Источники

    - {sources.map(({ link, name, data }) => { + {sources.map(({ link, name }) => { return (
  • - + {name}
  • 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/components/Card/Card.tsx b/components/Card/index.tsx similarity index 99% rename from components/Card/Card.tsx rename to components/Card/index.tsx index cdbdbe84..d93f158c 100644 --- a/components/Card/Card.tsx +++ b/components/Card/index.tsx @@ -25,7 +25,6 @@ export function Card({ contentConfig, popupId, popupType }: Props) { } setLoading(true); - const requestFunction = contentConfig[popupType].oneItemRequest; const data = await requestFunction(popupId); diff --git a/components/Filters/FilterGrid.tsx b/components/Filters/FilterGrid.tsx new file mode 100644 index 00000000..2396f632 --- /dev/null +++ b/components/Filters/FilterGrid.tsx @@ -0,0 +1,53 @@ +import React, { ComponentProps, useCallback, useEffect, useState } from 'react'; +import { Checkbox, ListGrid, ListGridItem } from 'ekb'; + +export type IFilterGridItem = Partial> & { + type: string; + color?: string; +}; + +interface Props { + selectedByDefault?: string[]; + items?: IFilterGridItem[]; + onChange?: (state: string[]) => void; +} + +export function FilterGrid({ items, onChange, selectedByDefault = [] }: Props) { + const [selected, setSelected] = useState(selectedByDefault); + + const toggle = useCallback( + (type: string) => { + if (selected.includes(type)) { + setSelected(selected.filter((s) => s !== type)); + } else { + setSelected(selected.concat(type)); + } + }, + [selected], + ); + + useEffect(() => { + onChange?.(selected); + }, [onChange, selected]); + + return ( + + {items.map(({ type, subTitle, description, color }) => ( + toggle(type)} + /> + } + > + {type} + + ))} + + ); +} 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 index 6221a34b..d3d2f81e 100644 --- a/constants/colors.ts +++ b/constants/colors.ts @@ -1,7 +1 @@ -import { MapItemType } from 'types/Content.types'; - -export const MARKER_COLOR = { - [MapItemType.DTP]: '#05B506', -}; - export const DEFAULT_BULDING_COLOR_NORMAL = '#0c1021'; 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/App/App.tsx b/features/App/App.tsx index 663fe805..2c29bb26 100644 --- a/features/App/App.tsx +++ b/features/App/App.tsx @@ -8,7 +8,6 @@ import { Copyright } from 'features/Copyright/Copyright'; import { MapContextProvider } from 'features/Map/providers/MapProvider'; import { Footer } from 'components/Footer/Footer'; import { Map } from 'features/Map/Map'; -import { FILTERS_CONFIG } from './Filters.config'; import { Sidebars } from './Sidebars'; export default function App() { @@ -19,7 +18,7 @@ export default function App() { - +