Skip to content

Commit

Permalink
feat(plasma-temple): product - export by platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
kvpolyanskiy committed Apr 11, 2022
1 parent 07f15fd commit 19ee15f
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import React from 'react';
import { detectDevice, DeviceKind } from '@sberdevices/plasma-ui/utils';

import { DeviceComponent } from '../../../DeviceComponent/DeviceComponent';

import { ExpandableProductDetailsCommon, ExpandableProductDetailsProps } from './ExpandableProductDetails@common';
import { ExpandableProductDetailsMobile } from './ExpandableProductDetails@mobile';

const mapDeviceToExpandableProductDetails: Record<DeviceKind, React.FC<ExpandableProductDetailsProps>> = {
sberBox: ExpandableProductDetailsCommon,
sberPortal: ExpandableProductDetailsCommon,
mobile: ExpandableProductDetailsMobile,
};

/**
* Компонент для отображения деталей (характеристик) товара
* с возможность по умолчанию скрывать часть характеристик
* Актуален для устройств с пультом и SberPortal
*/
export const ExpandableProductDetails = mapDeviceToExpandableProductDetails[detectDevice()];
export const ExpandableProductDetails: React.FC<ExpandableProductDetailsProps> = (props) => (
<DeviceComponent
sberbox={ExpandableProductDetailsCommon}
sberportal={ExpandableProductDetailsCommon}
mobile={ExpandableProductDetailsMobile}
props={props}
/>
);
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React from 'react';
import { detectDevice, DeviceKind } from '@sberdevices/plasma-ui/utils';

import { DeviceComponent } from '../../DeviceComponent/DeviceComponent';

import { ProductInfoCommon, ProductInfoProps } from './ProductInfo@common';
import { ProductInfoMobile } from './ProductInfo@mobile';

const mapDeviceToProductInfo: Record<DeviceKind, React.FC<ProductInfoProps>> = {
sberBox: ProductInfoCommon,
sberPortal: ProductInfoCommon,
mobile: ProductInfoMobile,
};

/**
* Компонент для отображения информации (описания) о товаре
* Актуален для устройств с пультом и SberPortal
*/
export const ProductInfo = mapDeviceToProductInfo[detectDevice()];
export const ProductInfo: React.FC<ProductInfoProps> = (props) => (
<DeviceComponent
sberbox={ProductInfoCommon}
sberportal={ProductInfoCommon}
mobile={ProductInfoMobile}
props={props}
/>
);
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
import React from 'react';
import { detectDevice } from '@sberdevices/plasma-ui/utils';
import styled, { css } from 'styled-components';
import { Col, mediaQuery, Price, Row } from '@sberdevices/plasma-ui';
import { accent, headline2, headline3, primary } from '@sberdevices/plasma-tokens';

import { DeviceFamily } from '../../../types';

import { ProductPriceSberBox } from './ProductPrice@sberbox';
import { ProductPriceSberPortal } from './ProductPrice@sberportal';
import { ProductPriceProps } from './types';

const mapDeviceToProductPrice: Record<DeviceFamily, React.FC<ProductPriceProps>> = {
sberBox: ProductPriceSberBox,
sberPortal: ProductPriceSberPortal,
mobile: ProductPriceSberPortal,
};
const StyledPrice = styled(Price)<{ old?: boolean }>`
${headline2}
${mediaQuery(
'M',
2,
)(css`
${headline3}
`)}
${mediaQuery(
'S',
1,
)(css`
${headline3}
`)}
color: ${accent};
${({ old }) =>
old &&
css`
color: ${primary};
opacity: 0.28;
text-decoration: line-through;
`}
`;

/** Компонент для отображения цены на странице товара */
export const ProductPrice = mapDeviceToProductPrice[detectDevice()];
export const ProductPrice: React.FC<ProductPriceProps> = ({ price, oldPrice, className, ...rest }) => {
if (!price) {
return null;
}

return (
<Row className={className}>
<Col>
<StyledPrice {...rest}>{price}</StyledPrice>
</Col>
{oldPrice && (
<Col>
<StyledPrice {...rest} old>
{oldPrice}
</StyledPrice>
</Col>
)}
</Row>
);
};

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions packages/plasma-temple/src/components/Product/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './ProductImageSlider/ProductImageSlider';
export * from './ProductInfo/ProductInfo';
export * from './ProductRecommendations/ProductRecommendations';
export * from './ProductVariationSwitcher/ProductVariationSwitcher';
export * from './types';
11 changes: 11 additions & 0 deletions packages/plasma-temple/src/components/Product/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export { ProductMobile as Product } from './Product@mobile';
export { ProductActionButton } from './ProductActionButton/ProductActionButton';
export { ProductDetails } from './ProductDetails/ProductDetails';
export { ExpandableProductDetailsMobile as ExpandableProductDetails } from './ProductDetails/ExpandableProductDetails/ExpandableProductDetails@mobile';
export { ProductImage } from './ProductImage/ProductImage';
export { ProductImageSlider } from './ProductImageSlider/ProductImageSlider';
export { ProductInfoMobile as ProductInfo } from './ProductInfo/ProductInfo@mobile';
export { ProductPrice } from './ProductPrice/ProductPrice';
export { ProductTitle } from './ProductTitle/ProductTitle';
export { ProductRecommendations } from './ProductRecommendations/ProductRecommendations';
export { ProductVariationSwitcher } from './ProductVariationSwitcher/ProductVariationSwitcher';
10 changes: 10 additions & 0 deletions packages/plasma-temple/src/components/Product/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export { ProductCommon as Product } from './Product@common';
export { ProductActionButton } from './ProductActionButton/ProductActionButton';
export { ProductDetails } from './ProductDetails/ProductDetails';
export { ExpandableProductDetailsCommon as ExpandableProductDetails } from './ProductDetails/ExpandableProductDetails/ExpandableProductDetails@common';
export { ProductImage } from './ProductImage/ProductImage';
export { ProductInfoCommon as ProductInfo } from './ProductInfo/ProductInfo@common';
export { ProductPrice } from './ProductPrice/ProductPrice';
export { ProductTitle } from './ProductTitle/ProductTitle';
export { ProductRecommendations } from './ProductRecommendations/ProductRecommendations';
export { ProductVariationSwitcher } from './ProductVariationSwitcher/ProductVariationSwitcher';
10 changes: 10 additions & 0 deletions packages/plasma-temple/src/components/Product/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export { ProductCommon as Product } from './Product@common';
export { ProductActionButton } from './ProductActionButton/ProductActionButton';
export { ProductDetails } from './ProductDetails/ProductDetails';
export { ExpandableProductDetailsCommon as ExpandableProductDetails } from './ProductDetails/ExpandableProductDetails/ExpandableProductDetails@common';
export { ProductImage } from './ProductImage/ProductImage';
export { ProductInfoCommon as ProductInfo } from './ProductInfo/ProductInfo@common';
export { ProductPrice } from './ProductPrice/ProductPrice';
export { ProductTitle } from './ProductTitle/ProductTitle';
export { ProductRecommendations } from './ProductRecommendations/ProductRecommendations';
export { ProductVariationSwitcher } from './ProductVariationSwitcher/ProductVariationSwitcher';
1 change: 1 addition & 0 deletions packages/plasma-temple/src/components/[email protected]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { StateLayoutMobile as StateLayout } from './StateLayout/StateLayout@mobile';
export * from './Product/index@mobile';
1 change: 1 addition & 0 deletions packages/plasma-temple/src/components/[email protected]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { StateLayoutSberBox as StateLayout } from './StateLayout/StateLayout@sberbox';
export * from './Product/index@sberbox';
1 change: 1 addition & 0 deletions packages/plasma-temple/src/components/[email protected]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { StateLayoutSberPortal as StateLayout } from './StateLayout/StateLayout@sberportal';
export * from './Product/index@sberportal';

0 comments on commit 19ee15f

Please sign in to comment.