Skip to content

Commit

Permalink
Fix prettier code format issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jsdalton committed Jun 1, 2023
1 parent cddb1b4 commit 02f5e0e
Show file tree
Hide file tree
Showing 17 changed files with 784 additions and 785 deletions.
6 changes: 2 additions & 4 deletions apps/salesforce-commerce-cloud/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ const App = () => {
}, [sdk.location]);

return (
<QueryClientProvider client={queryClient}>
{ Component && <Component /> }
</QueryClientProvider>
)
<QueryClientProvider client={queryClient}>{Component && <Component />}</QueryClientProvider>
);
};

export default App;
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) => {
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;
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ import React from 'react';

import { Flex, Text } from '@contentful/f36-components';

const ProductPreview = (props:{product: any}) => {
const descriptionLength = 178
const { product } = props
const ProductPreview = (props: { product: any }) => {
const descriptionLength = 178;
const { product } = props;

let description = "Description"
let description = 'Description';
if (product.shortDescription.default) {
description = product.shortDescription.default.markup.length > descriptionLength ?
`${product.shortDescription.default.markup.substring(0, descriptionLength)}...` :
product.shortDescription.default.markup
description =
product.shortDescription.default.markup.length > descriptionLength
? `${product.shortDescription.default.markup.substring(0, descriptionLength)}...`
: product.shortDescription.default.markup;
}

return (
<>
{product.image.absUrl &&
{product.image.absUrl && (
<img src={product.image.absUrl} alt={product.image.alt.default} height="75" width="75" />
}
)}
<Flex flexDirection="column" marginLeft="spacingS">
<Text as="div" fontWeight="fontWeightDemiBold">{product.name.default} (ID: {product.id})</Text>
<Text as="div">
{description}
</Text>
</Flex>
<Text as="div" fontWeight="fontWeightDemiBold">
{product.name.default} (ID: {product.id})
</Text>
<Text as="div">{description}</Text>
</Flex>
</>
);
}
};

export default ProductPreview
export default ProductPreview;
Loading

0 comments on commit 02f5e0e

Please sign in to comment.