-
Notifications
You must be signed in to change notification settings - Fork 22
feat: add Map-block #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Map-block #149
Conversation
|
Preview is ready. |
bdaad72 to
f611e03
Compare
src/blocks/Map/Map.tsx
Outdated
| import Map from '../../components/Map/Map'; | ||
| import MediaBase from '../../components/MediaBase/MediaBase'; | ||
|
|
||
| export const MapBlock = (props: MapBlockProps) => { |
There was a problem hiding this comment.
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) => {?
src/blocks/Map/schema.ts
Outdated
| type: 'string', | ||
| enum: mediaDirection, | ||
| }, | ||
| mobileDirection: { |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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]: '', |
There was a problem hiding this comment.
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?
src/components/Map/GoogleMap.tsx
Outdated
| loading="lazy" | ||
| allowFullScreen | ||
| referrerPolicy="no-referrer-when-downgrade" | ||
| src={`${scriptSrc}?key=${apiKey}&q=${address.replace(' ', '+')}`} |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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} />, |
There was a problem hiding this comment.
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< |
There was a problem hiding this comment.
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
8f8e55e to
f449d57
Compare
|
I have changed maps:
|
src/blocks/Map/Map.tsx
Outdated
| import Map from '../../components/Map/Map'; | ||
| import MediaBase from '../../components/MediaBase/MediaBase'; | ||
|
|
||
| export const MapBlock = ({map, ...props}: MapBlockProps) => { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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?
7c98557 to
c33a807
Compare
|
|
||
| #{$block} { | ||
| width: 100%; | ||
| height: 300px; |
There was a problem hiding this comment.
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?
f753822 to
13874f7
Compare

No description provided.