diff --git a/src/api/utils/DoElementsOverlap.ts b/src/api/utils/DoElementsOverlap.ts new file mode 100644 index 00000000..f28b0c86 --- /dev/null +++ b/src/api/utils/DoElementsOverlap.ts @@ -0,0 +1,10 @@ +export const DoElementsOverlap = (a: HTMLElement, b: HTMLElement) => +{ + const rectA = a.getBoundingClientRect(); + const rectB = b.getBoundingClientRect(); + + const ox = Math.abs(rectA.x - rectB.x) < (rectA.x < rectB.x ? rectB.width : rectA.width); + const oy = Math.abs(rectA.y - rectB.y) < (rectA.y < rectB.y ? rectB.height : rectA.height); + + return (ox && oy); +} diff --git a/src/api/utils/index.ts b/src/api/utils/index.ts index 398758cb..c63244a6 100644 --- a/src/api/utils/index.ts +++ b/src/api/utils/index.ts @@ -1,5 +1,6 @@ export * from './CloneObject'; export * from './ColorUtils'; +export * from './DoElementsOverlap'; export * from './LocalizeBadgeDescription'; export * from './LocalizeBageName'; export * from './LocalizeFormattedNumber'; diff --git a/src/common/layout/LayoutFurniIconImageView.tsx b/src/common/layout/LayoutFurniIconImageView.tsx new file mode 100644 index 00000000..c961d66f --- /dev/null +++ b/src/common/layout/LayoutFurniIconImageView.tsx @@ -0,0 +1,35 @@ +import { FC } from 'react'; +import { LayoutImage, LayoutImageProps } from '.'; +import { GetRoomEngine } from '../../api'; +import { ProductTypeEnum } from '../../components/catalog/common/ProductTypeEnum'; + +interface LayoutFurniIconImageViewProps extends LayoutImageProps +{ + productType: string; + productClassId: number; + extraData?: string; +} + +export const LayoutFurniIconImageView: FC = props => +{ + const { productType = 's', productClassId = -1, extraData = '', ...rest } = props; + + const getImageIconUrl = () => + { + let imageUrl: string = null; + + switch(productType.toLocaleLowerCase()) + { + case ProductTypeEnum.FLOOR: + imageUrl = GetRoomEngine().getFurnitureFloorIconUrl(productClassId); + break; + case ProductTypeEnum.WALL: + imageUrl = GetRoomEngine().getFurnitureWallIconUrl(productClassId, extraData); + break; + } + + return imageUrl; + } + + return ; +} diff --git a/src/common/layout/index.ts b/src/common/layout/index.ts index 1d7beea2..a7bdd15c 100644 --- a/src/common/layout/index.ts +++ b/src/common/layout/index.ts @@ -2,6 +2,7 @@ export * from './LayoutAvatarImageView'; export * from './LayoutBackgroundImage'; export * from './LayoutBadgeImageView'; export * from './LayoutCurrencyIcon'; +export * from './LayoutFurniIconImageView'; export * from './LayoutFurniImageView'; export * from './LayoutGiftTagView'; export * from './LayoutGridItem';