-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit of Salesforce Commerce Cloud app. #3633
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
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; |
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) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel it would be good to destructure the props here for consistency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel it would be good to destructure the props here for consistency |
||
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) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it would be good to destructure the props here for consistency