-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
784 additions
and
785 deletions.
There are no files selected for viewing
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
31 changes: 16 additions & 15 deletions
31
apps/salesforce-commerce-cloud/src/components/dialog/CategoryPreview.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,25 +1,26 @@ | ||
import React from 'react' | ||
import React from 'react'; | ||
|
||
import { Text, Flex } from '@contentful/f36-components' | ||
import { Text, Flex } from '@contentful/f36-components'; | ||
|
||
const CategoryPreview = (props:{category: any}) => { | ||
const { category } = props | ||
const catalogInfo = category.paths.find((path:any) => category.catalogId === path.id) | ||
const CategoryPreview = (props: { category: any }) => { | ||
const { category } = props; | ||
const catalogInfo = category.paths.find((path: any) => category.catalogId === path.id); | ||
|
||
return ( | ||
<> | ||
<Flex flexDirection="column" marginLeft="spacingS"> | ||
<Text as="div"> | ||
<Text as="span" fontWeight="fontWeightDemiBold">{category.name?.default}</Text> (Catalog: {catalogInfo?.name?.default ? catalogInfo.name.default : category.catalogId}) | ||
<Text as="div"> | ||
<Text as="span" fontWeight="fontWeightDemiBold"> | ||
{category.name?.default} | ||
</Text>{' '} | ||
(Catalog: {catalogInfo?.name?.default ? catalogInfo.name.default : category.catalogId}) | ||
</Text> | ||
{category.pageDescription?.default && | ||
<Text as="div"> | ||
{category.pageDescription.default} | ||
</Text> | ||
} | ||
</Flex> | ||
{category.pageDescription?.default && ( | ||
<Text as="div">{category.pageDescription.default}</Text> | ||
)} | ||
</Flex> | ||
</> | ||
); | ||
} | ||
}; | ||
|
||
export default CategoryPreview | ||
export default CategoryPreview; |
141 changes: 77 additions & 64 deletions
141
apps/salesforce-commerce-cloud/src/components/dialog/CategorySearchResults.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,70 +1,83 @@ | ||
import React from 'react' | ||
import { css } from '@emotion/react' | ||
import React from 'react'; | ||
import { css } from '@emotion/react'; | ||
|
||
import tokens from '@contentful/f36-tokens' | ||
import { Box, Card, Flex, Text } from '@contentful/f36-components' | ||
import { TagsIcon } from '@contentful/f36-icons' | ||
|
||
import { SearchResultsProps, SearchResultProps, height, stickyHeaderBreakpoint, headerHeight } from './SearchPicker' | ||
import tokens from '@contentful/f36-tokens'; | ||
import { Box, Card, Flex, Text } from '@contentful/f36-components'; | ||
import { TagsIcon } from '@contentful/f36-icons'; | ||
|
||
const CategorySearchResults = (props:SearchResultsProps) => { | ||
const resultsWrapperStyle = css` | ||
max-height: ${height}px; | ||
padding: ${tokens.spacingL}; | ||
padding-bottom: 0; | ||
@media screen and (min-height: ${stickyHeaderBreakpoint}px;) { | ||
padding-top: ${tokens.spacingL + headerHeight}px; | ||
} | ||
` | ||
|
||
return ( | ||
<Box as="section" css={resultsWrapperStyle} > | ||
{props.searchResults.map((result) => ( | ||
<CategorySearchResult | ||
key={`${result.catalogId}:${result.id}`} | ||
fieldType={props.fieldType} | ||
onItemSelect={props.onItemSelect} | ||
selected={props.selectedItems} | ||
result={result} | ||
/> | ||
))} | ||
</Box> | ||
) | ||
} | ||
|
||
const CategorySearchResult = (props:SearchResultProps) => { | ||
const { result, fieldType, onItemSelect, selected } = props | ||
const resultId = fieldType === 'product' ? result.id : `${result.catalogId}:${result.id}` | ||
|
||
const categoryStyle = css` | ||
margin-left: ${tokens.spacingXs} | ||
` | ||
import { | ||
SearchResultsProps, | ||
SearchResultProps, | ||
height, | ||
stickyHeaderBreakpoint, | ||
headerHeight, | ||
} from './SearchPicker'; | ||
|
||
return ( | ||
<Card | ||
id={resultId} | ||
padding="none" | ||
marginBottom="spacingS" | ||
onClick={() => onItemSelect(resultId)} | ||
isSelected={selected?.includes(resultId)} | ||
> | ||
<Flex flexDirection="column"> | ||
<Flex alignItems="center" padding="spacingXs"> | ||
<TagsIcon /> | ||
<Flex flexDirection="column" marginLeft="spacingS"> | ||
<Text as="div" fontWeight="fontWeightDemiBold" fontSize='fontSizeM'> | ||
{result.name.default} | ||
</Text> | ||
<Text as="div" fontWeight="fontWeightMedium" fontSize='fontSizeS' fontColor='gray600'> | ||
ID: {result.id} | ||
<Box as="span" css={css`margin-left: ${tokens.spacingXs};`}>|</Box> | ||
<Box as="span" css={categoryStyle}>Catalog: {result.name?.default ? result.name.default : result.catalogId}</Box> | ||
</Text> | ||
</Flex> | ||
const CategorySearchResults = (props: SearchResultsProps) => { | ||
const resultsWrapperStyle = css` | ||
max-height: ${height}px; | ||
padding: ${tokens.spacingL}; | ||
padding-bottom: 0; | ||
@media screen and (min-height: ${stickyHeaderBreakpoint}px;) { | ||
padding-top: ${tokens.spacingL + headerHeight}px; | ||
} | ||
`; | ||
|
||
return ( | ||
<Box as="section" css={resultsWrapperStyle}> | ||
{props.searchResults.map((result) => ( | ||
<CategorySearchResult | ||
key={`${result.catalogId}:${result.id}`} | ||
fieldType={props.fieldType} | ||
onItemSelect={props.onItemSelect} | ||
selected={props.selectedItems} | ||
result={result} | ||
/> | ||
))} | ||
</Box> | ||
); | ||
}; | ||
|
||
const CategorySearchResult = (props: SearchResultProps) => { | ||
const { result, fieldType, onItemSelect, selected } = props; | ||
const resultId = fieldType === 'product' ? result.id : `${result.catalogId}:${result.id}`; | ||
|
||
const categoryStyle = css` | ||
margin-left: ${tokens.spacingXs}; | ||
`; | ||
|
||
return ( | ||
<Card | ||
id={resultId} | ||
padding="none" | ||
marginBottom="spacingS" | ||
onClick={() => onItemSelect(resultId)} | ||
isSelected={selected?.includes(resultId)}> | ||
<Flex flexDirection="column"> | ||
<Flex alignItems="center" padding="spacingXs"> | ||
<TagsIcon /> | ||
<Flex flexDirection="column" marginLeft="spacingS"> | ||
<Text as="div" fontWeight="fontWeightDemiBold" fontSize="fontSizeM"> | ||
{result.name.default} | ||
</Text> | ||
<Text as="div" fontWeight="fontWeightMedium" fontSize="fontSizeS" fontColor="gray600"> | ||
ID: {result.id} | ||
<Box | ||
as="span" | ||
css={css` | ||
margin-left: ${tokens.spacingXs}; | ||
`}> | ||
| | ||
</Box> | ||
<Box as="span" css={categoryStyle}> | ||
Catalog: {result.name?.default ? result.name.default : result.catalogId} | ||
</Box> | ||
</Text> | ||
</Flex> | ||
</Flex> | ||
</Card> | ||
) | ||
} | ||
</Flex> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default CategorySearchResults | ||
export default CategorySearchResults; |
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
Oops, something went wrong.