Skip to content

Commit

Permalink
refactor store
Browse files Browse the repository at this point in the history
  • Loading branch information
gcor committed Jan 2, 2024
1 parent b1baa8b commit 7c1168b
Show file tree
Hide file tree
Showing 112 changed files with 1,478 additions and 2,287 deletions.
Original file line number Diff line number Diff line change
@@ -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 <></>;
}
Expand All @@ -21,7 +18,7 @@ export function DesktopCard({ contentConfig, popupId, popupType, closePopup }: P
<div className={styles.DesktopCard__header}>
<Close close={closePopup} />
</div>
<Card popupId={popupId} popupType={popupType} contentConfig={contentConfig} />
{children}
</div>
);
}
18 changes: 0 additions & 18 deletions components/Card/MobileCard.tsx

This file was deleted.

54 changes: 54 additions & 0 deletions components/Card/components/CardActions.tsx
Original file line number Diff line number Diff line change
@@ -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 && (
<Button
type={ButtonType.DEFAULT}
size={ButtonSize.SMALL}
onClick={onCopyCoords}
postfix={<Icon type={IconType.Copy} />}
>
{isCoordsCopied ? 'Скопировано' : coordsString}
</Button>
)}
<Button
type={ButtonType.DEFAULT}
size={ButtonSize.SMALL}
onClick={onCopyLink}
postfix={<Icon type={IconType.Link} />}
>
{isLinkCopied ? 'Скопировано' : 'Ссылка на объект'}
</Button>
</>
);
}
38 changes: 0 additions & 38 deletions components/Card/components/ConstructionInfo/ConstructionInfo.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions components/Card/components/Header/Header.module.css

This file was deleted.

62 changes: 0 additions & 62 deletions components/Card/components/Header/Header.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions components/Card/components/Section/Section.module.css

This file was deleted.

7 changes: 0 additions & 7 deletions components/Card/components/Section/Section.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion components/Card/components/Sources/Sources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './Sources.module.css';
export function Sources({ sources }: { sources: SourceInfo[] }) {
return (
<div className={styles.sources}>
<h3 className={styles.sources__title}>Источники</h3>
{/* <h3 className={styles.sources__title}>Источники</h3> */}
<ul className={styles.sources__list}>
{sources.map(({ link, name, data }) => {
return (
Expand Down
2 changes: 0 additions & 2 deletions components/Card/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion components/Card/Card.tsx → components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export function Card({ contentConfig, popupId, popupType }: Props) {
}

setLoading(true);

const requestFunction = contentConfig[popupType].oneItemRequest;

const data = await requestFunction(popupId);
Expand Down
53 changes: 53 additions & 0 deletions components/Filters/FilterGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { ComponentProps, useCallback, useEffect, useState } from 'react';
import { Checkbox, ListGrid, ListGridItem } from 'ekb';

export type IFilterGridItem = Partial<ComponentProps<typeof ListGridItem>> & {
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<string[]>(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 (
<ListGrid>
{items.map(({ type, subTitle, description, color }) => (
<ListGridItem
key={type}
subTitle={subTitle}
description={description}
prefix={
<Checkbox
isSelected={selected.includes(type)}
activeColor={color}
toggle={() => toggle(type)}
/>
}
>
{type}
</ListGridItem>
))}
</ListGrid>
);
}
1 change: 0 additions & 1 deletion components/Filters/index.ts

This file was deleted.

12 changes: 6 additions & 6 deletions features/App/Content.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { designCode } from 'features/DesignCode/designCode';
import { dtp } from 'features/DTP/dtp';
import { okn } from 'features/OKN/okn';
import { lines } from 'features/Lines/lines';
import { LinesCardContent } from 'features/Lines/CardContent/CardContent';
import { QuarterCardContent } from 'features/Quarter/CardContent/CardContent';
import { LinesCardContent } from 'features/Lines/LinesCardContent';
import { QuarterCardContent } from 'features/Quarter/QuarterCardContent';
import { quarter } from 'features/Quarter/quarter';
import { DesignCodeCardContent } from 'features/DesignCode/CardContent/CardContent';
import { DTPCardContent } from 'features/DTP/CardContent/CardContent';
import { HousesCardContent } from 'features/Buildings/CardContent/CardContent';
import { OKNCardContent } from 'features/OKN/CardContent';
import { DesignCodeCardContent } from 'features/DesignCode/DesignCodeCard';
import { DTPCardContent } from 'features/DTP/DtpCardContent';
import { HousesCardContent } from 'features/Buildings/BuildingCard';
import { OKNCardContent } from 'features/OKN/OknCardContent';

export const CONTENTS_CONFIG: ContentConfig = {
[MapItemType.Houses]: {
Expand Down
8 changes: 2 additions & 6 deletions features/App/Filters.config.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { DTPFilter } from 'features/DTP/Filter/DTPFilter';
import { DesignCodeFilter } from 'features/DesignCode/Filter/DesignCodeFilter';
import { HouseAgeFilter } from 'features/HouseAge/HouseAgeFilter';
import { HouseFloorFilter } from 'features/HouseFloor/HouseFloorFilter';
import { HouseWearTearFilter } from 'features/HouseWearTear/HouseWearTearFilter';
import { LinesFilter } from 'features/Lines/Filter/LinesFilter';
import { OknFilter } from 'features/OKN/Filter/OknFilter';
import { QuarterFilter } from 'features/Quarter/Filter/QuarterFilter';
import { QuarterFilter } from 'features/Quarter/QuarterFilter';
import { SOURCES_BY_TYPE } from 'constants/sources';
import { SourceType } from 'types/Sources.types';
import { FilterConfig, FilterType } from 'types/Filters.types';
import { FacadeFilter } from 'features/Facade/Filter/FacadeFilter';
import { FacadeFilter } from 'features/Facade/FacadeFilter';

export const FILTERS_CONFIG: FilterConfig = {
[FilterType.HouseAge]: {
Expand Down Expand Up @@ -38,7 +36,6 @@ export const FILTERS_CONFIG: FilterConfig = {
},
[FilterType.DesignCode]: {
title: '«Дизайн-код Екатеринбурга»',
component: <DesignCodeFilter />,
source: [SOURCES_BY_TYPE[SourceType.design_objects_map]],
isVerified: true,
},
Expand All @@ -50,7 +47,6 @@ export const FILTERS_CONFIG: FilterConfig = {
},
[FilterType.Line]: {
title: 'Туристические маршруты',
component: <LinesFilter />,
isVerified: true,
},
[FilterType.Quarter]: {
Expand Down
Loading

1 comment on commit 7c1168b

@ekbdev
Copy link

@ekbdev ekbdev commented on 7c1168b Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for map ready!

✅ Preview
https://map-7owrwzll3-ekbdev.vercel.app
https://ekbdev-map-refactor3.vercel.app

Built with commit 7c1168b.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.