-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from vtex/fix/search-page-structure
Fix/search page structure
- Loading branch information
Showing
11 changed files
with
165 additions
and
135 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
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,68 @@ | ||
import { useRouter } from 'next/router' | ||
import { Box, Text } from '@vtex/brand-ui' | ||
|
||
import { MethodType } from 'utils/typings/unionTypes' | ||
|
||
import { getIcon } from 'utils/constants' | ||
import SearchCard from 'components/search-card' | ||
|
||
import { ActionType } from 'components/last-updates-card/functions' | ||
import styles from './styles' | ||
|
||
export interface SearchDataItemProps { | ||
doc: string | ||
title: string | ||
description: string | ||
filters?: string[] | ||
http?: MethodType | ||
actionType?: ActionType | ||
} | ||
|
||
const SearchResults = () => { | ||
const router = useRouter() | ||
|
||
const searchData: SearchDataItemProps[] = [ | ||
{ | ||
doc: 'API Guides', | ||
title: 'SKU Selector', | ||
description: | ||
'The SKU Selector is a product details page block responsible for displaying every SKU available for a given product.', | ||
filters: ['label', 'label', 'label'], | ||
}, | ||
{ | ||
doc: 'API Reference', | ||
title: 'GET SKU seller', | ||
http: 'POST', | ||
description: | ||
'The SKU Selector is a product details page block responsible for displaying every SKU available for a given product.', | ||
filters: ['label', 'label', 'label'], | ||
}, | ||
{ | ||
doc: 'Release Notes', | ||
title: 'SKU Selector', | ||
description: | ||
'The SKU Selector is a product details page block responsible for displaying every SKU available for a given product.', | ||
actionType: 'removed', | ||
}, | ||
] | ||
return ( | ||
<Box sx={styles.resultContainer}> | ||
<Text sx={styles.resultText}> | ||
Showing {searchData.length} results for "{router.query.keyword}" in all | ||
results | ||
</Text> | ||
<hr /> | ||
<Box> | ||
{searchData.map((result, index) => ( | ||
<SearchCard | ||
key={`${result.doc}${result.title}${index}`} | ||
Icon={getIcon(result.doc)!} | ||
{...result} | ||
/> | ||
))} | ||
</Box> | ||
</Box> | ||
) | ||
} | ||
|
||
export default SearchResults |
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,23 @@ | ||
import { SxStyleProp } from '@vtex/brand-ui' | ||
|
||
const resultContainer: SxStyleProp = { | ||
width: '720px', | ||
paddingTop: '64px', | ||
hr: { | ||
marginTop: '16px', | ||
marginBottom: '32px', | ||
borderTop: 'none', | ||
borderColor: '#DDDDDD', | ||
}, | ||
} | ||
|
||
const resultText: SxStyleProp = { | ||
mb: '16px', | ||
fontSize: '16px', | ||
lineHeight: '22px', | ||
} | ||
|
||
export default { | ||
resultContainer, | ||
resultText, | ||
} |
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
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
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
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
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
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
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,32 @@ | ||
import { createContext, Dispatch, SetStateAction, useState } from 'react' | ||
import type { DocumentationTitle, UpdatesTitle } from 'utils/typings/unionTypes' | ||
|
||
type FilterType = DocumentationTitle | UpdatesTitle | '' | ||
|
||
type SearchContextType = { | ||
filterSelectedSection: FilterType | ||
changeFilterSelectedSection: Dispatch<SetStateAction<FilterType>> | ||
} | ||
|
||
export const SearchContext = createContext<SearchContextType>({ | ||
filterSelectedSection: '', | ||
changeFilterSelectedSection: () => undefined, | ||
}) | ||
|
||
const SearchContextProvider: React.FC = ({ children }) => { | ||
const [filterSelectedSection, changeFilterSelectedSection] = | ||
useState<FilterType>('') | ||
|
||
return ( | ||
<SearchContext.Provider | ||
value={{ | ||
filterSelectedSection, | ||
changeFilterSelectedSection, | ||
}} | ||
> | ||
{children} | ||
</SearchContext.Provider> | ||
) | ||
} | ||
|
||
export default SearchContextProvider |
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 |
---|---|---|
|
@@ -414,9 +414,14 @@ | |
dependencies: | ||
"glob" "7.1.7" | ||
|
||
"@next/[email protected]": | ||
"integrity" "sha512-aBvcbMwuanDH4EMrL2TthNJy+4nP59Bimn8egqv6GHMVj0a44cU6Au4PjOhLNqEh9l+IpRGBqMTzec94UdC5xg==" | ||
"resolved" "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.1.0.tgz" | ||
"@next/[email protected]": | ||
"integrity" "sha512-OKO4R/digvrVuweSw/uBM4nSdyzsBV5EwkUeeG4KVpkIZEe64ZwRpnFB65bC6hGwxIBnTv5NMSnJ+0K/WmG78A==" | ||
"resolved" "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.1.0.tgz" | ||
"version" "12.1.0" | ||
|
||
"@next/[email protected]": | ||
"integrity" "sha512-JohhgAHZvOD3rQY7tlp7NlmvtvYHBYgY0x5ZCecUT6eCCcl9lv6iV3nfu82ErkxNk1H893fqH0FUpznZ/H3pSw==" | ||
"resolved" "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.1.0.tgz" | ||
"version" "12.1.0" | ||
|
||
"@nodelib/[email protected]": | ||
|