-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plasma-temple): product - export by platforms
- Loading branch information
1 parent
07f15fd
commit 19ee15f
Showing
13 changed files
with
104 additions
and
89 deletions.
There are no files selected for viewing
19 changes: 10 additions & 9 deletions
19
...c/components/Product/ProductDetails/ExpandableProductDetails/ExpandableProductDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
/> | ||
); |
19 changes: 10 additions & 9 deletions
19
packages/plasma-temple/src/components/Product/ProductInfo/ProductInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
/> | ||
); |
60 changes: 49 additions & 11 deletions
60
packages/plasma-temple/src/components/Product/ProductPrice/ProductPrice.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
38 changes: 0 additions & 38 deletions
38
packages/plasma-temple/src/components/Product/ProductPrice/[email protected]
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/plasma-temple/src/components/Product/ProductPrice/[email protected]
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/plasma-temple/src/components/Product/ProductPrice/[email protected]
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/plasma-temple/src/components/Product/[email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
packages/plasma-temple/src/components/Product/[email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
10
packages/plasma-temple/src/components/Product/[email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |