Add components

This commit is contained in:
Bill 2022-03-24 02:55:48 -04:00
parent d8e7d9f714
commit f8ae1842a3
4 changed files with 47 additions and 0 deletions

View File

@ -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);
}

View File

@ -1,5 +1,6 @@
export * from './CloneObject'; export * from './CloneObject';
export * from './ColorUtils'; export * from './ColorUtils';
export * from './DoElementsOverlap';
export * from './LocalizeBadgeDescription'; export * from './LocalizeBadgeDescription';
export * from './LocalizeBageName'; export * from './LocalizeBageName';
export * from './LocalizeFormattedNumber'; export * from './LocalizeFormattedNumber';

View File

@ -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<LayoutFurniIconImageViewProps> = 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 <LayoutImage imageUrl={ getImageIconUrl() } className='furni-image' { ...rest } />;
}

View File

@ -2,6 +2,7 @@ export * from './LayoutAvatarImageView';
export * from './LayoutBackgroundImage'; export * from './LayoutBackgroundImage';
export * from './LayoutBadgeImageView'; export * from './LayoutBadgeImageView';
export * from './LayoutCurrencyIcon'; export * from './LayoutCurrencyIcon';
export * from './LayoutFurniIconImageView';
export * from './LayoutFurniImageView'; export * from './LayoutFurniImageView';
export * from './LayoutGiftTagView'; export * from './LayoutGiftTagView';
export * from './LayoutGridItem'; export * from './LayoutGridItem';