Skip to content

Conversation

@Lakate
Copy link
Contributor

@Lakate Lakate commented Feb 14, 2023

No description provided.

@Lakate Lakate requested review from DaffPunks and removed request for gorgeousvlad February 14, 2023 09:03
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

import Map from '../../components/Map/Map';
import MediaBase from '../../components/MediaBase/MediaBase';

export const MapBlock = (props: MapBlockProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

export const MapBlock = ({map, ...props}: MapBlockProps) => {?

type: 'string',
enum: mediaDirection,
},
mobileDirection: {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we take this props from media from its schema?

};

export const MapsContextSourceLinks = {
[MapType.Yandex]: 'https://api-maps.yandex.ru/2.1',
Copy link
Contributor

Choose a reason for hiding this comment

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

are sure that this yandex api host wouldn't have its place in production bundle? need to check


export const apiKeyIdInLS = {
[MapType.Google]: 'gmap-api-key',
[MapType.Yandex]: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should not put this key at all instead of empty value?

loading="lazy"
allowFullScreen
referrerPolicy="no-referrer-when-downgrade"
src={`${scriptSrc}?key=${apiKey}&q=${address.replace(' ', '+')}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe define func getScriptSrc?

private recalcZoomAndCenter() {
const coordsLength = this.coords.length;

if (!coordsLength) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

we try not to use one string ifs

rightTop = [Math.max(rightTop[0], point[0]), Math.max(rightTop[1], point[1])];
});

// ~30px - control button height
Copy link
Contributor

Choose a reason for hiding this comment

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

create a constant please

{mediaContent}
</Col>
<Col sizes={mediaSizes}>
<div className={b('card', {shadow: !disableShadow})}>{card}</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

card could be null should we render the Col in this case?

<LocaleContext.Provider value={locale} />,
<LocationContext.Provider value={location} />,
<MobileContext.Provider value={Boolean(isMobile)} />,
<MapsValueContext.Provider value={mapsContext} />,
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need two contexts for maps, not one?

extends MapProviderExternalProps,
Partial<MapProviderDefaultProps> {}

export class MapProvider extends React.Component<
Copy link
Contributor

Choose a reason for hiding this comment

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

we are trying to use only functional react components

@yuberdysheva
Copy link
Contributor

Is storybook maps don't rerender height between tabs. Only when we reload page
image

@Lakate Lakate force-pushed the lakate/map-block branch 3 times, most recently from 8f8e55e to f449d57 Compare February 21, 2023 13:51
@Lakate
Copy link
Contributor Author

Lakate commented Feb 21, 2023

I have changed maps:

  1. you have to pass scriptSrc to the mapsContext
  2. i created a helper file in storybook to store maps constants to use it in the stories only
    After all, i don't see any constants connected with yandex maps api in build. (the YandexMap component remained in the builded files)

import Map from '../../components/Map/Map';
import MediaBase from '../../components/MediaBase/MediaBase';

export const MapBlock = ({map, ...props}: MapBlockProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessary but we could remove return here MapBlock = ({map, ...props}: MapBlockProps)=>();

YMapsApiLoader.status = MapApiStatus.Loaded;
})
.catch(() => {
throw new Error("Can't load Yandex Maps Api");
Copy link
Contributor

Choose a reason for hiding this comment

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

we try not to throw unhandled exceptions in ui, could you provide error situation in interface and display error for this case?


#{$block} {
width: 100%;
height: 300px;
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that max-height below is also 300px, maybe we need a constant here?

@Lakate Lakate merged commit bd349bb into main Feb 28, 2023
@Lakate Lakate deleted the lakate/map-block branch February 28, 2023 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants