mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 08:50:51 +01:00
Add components
This commit is contained in:
parent
d8e7d9f714
commit
f8ae1842a3
10
src/api/utils/DoElementsOverlap.ts
Normal file
10
src/api/utils/DoElementsOverlap.ts
Normal 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);
|
||||||
|
}
|
@ -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';
|
||||||
|
35
src/common/layout/LayoutFurniIconImageView.tsx
Normal file
35
src/common/layout/LayoutFurniIconImageView.tsx
Normal 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 } />;
|
||||||
|
}
|
@ -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';
|
||||||
|
Loading…
Reference in New Issue
Block a user