Skip to content

Commit

Permalink
refactor store
Browse files Browse the repository at this point in the history
  • Loading branch information
gcor committed Jan 3, 2024
1 parent b1baa8b commit 5e3a40f
Show file tree
Hide file tree
Showing 127 changed files with 2,012 additions and 2,925 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.

8 changes: 3 additions & 5 deletions components/Card/components/Sources/Sources.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className={styles.sources}>
<h3 className={styles.sources__title}>Источники</h3>
<ul className={styles.sources__list}>
{sources.map(({ link, name, data }) => {
{sources.map(({ link, name }) => {
return (
<li key={link} className={styles.sources__listItem}>
<Link href={data || link} size={LinkSize.SMALL}>
<Link href={link} size={LinkSize.SMALL}>
{name}
</Link>
</li>
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.

6 changes: 0 additions & 6 deletions constants/colors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import { MapItemType } from 'types/Content.types';

export const MARKER_COLOR = {
[MapItemType.DTP]: '#05B506',
};

export const DEFAULT_BULDING_COLOR_NORMAL = '#0c1021';
Loading

1 comment on commit 5e3a40f

@ekbdev
Copy link

@ekbdev ekbdev commented on 5e3a40f Jan 3, 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-7v2dn9srg-ekbdev.vercel.app
https://ekbdev-map-refactor3.vercel.app

Built with commit 5e3a40f.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.