Skip to content

Commit

Permalink
Search Results page updates (github#34498)
Browse files Browse the repository at this point in the history
  • Loading branch information
gracepark authored Feb 7, 2023
1 parent 98dab85 commit dbf220f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion components/rest/RestOperation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { LinkIconHeading } from 'components/article/LinkIconHeading'
import { Link } from 'components/Link'
import { useTranslation } from 'components/hooks/useTranslation'
import { RestPreviewNotice } from './RestPreviewNotice'
import styles from './RestOperation.module.scss'
import { ParameterTable } from 'components/parameter-table/ParameterTable'
import { RestCodeSamples } from './RestCodeSamples'
import { RestStatusCodes } from './RestStatusCodes'
import { Operation } from './types'

import styles from './RestOperation.module.scss'

type Props = {
operation: Operation
}
Expand Down
8 changes: 8 additions & 0 deletions components/search/SearchResults.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.search_result {
mark {
background-color: transparent;
font-weight: bold;
}

word-wrap: break-word;
}
11 changes: 7 additions & 4 deletions components/search/SearchResults.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Box, Pagination, Text } from '@primer/react'
import { SearchIcon } from '@primer/octicons-react'
import { useRouter } from 'next/router'
import cx from 'classnames'

import type { SearchResultsT, SearchResultHitT } from './types'
import { useTranslation } from 'components/hooks/useTranslation'
import { Link } from 'components/Link'
import { useQuery } from 'components/hooks/useQuery'
import { sendEvent, EventType } from 'components/lib/events'

import styles from './SearchResults.module.scss'

type Props = {
results: SearchResultsT
query: string
Expand All @@ -22,8 +25,8 @@ export function SearchResults({ results, query }: Props) {
<div>
<Text>
{results.meta.found.value === 1
? t('one_result_found')
: t('found_results').replace('{n}', results.meta.found.value.toLocaleString())}
? t('one_result')
: t('n_results').replace('{n}', results.meta.found.value.toLocaleString())}
</Text>
<br />
<SearchResultHits hits={results.hits} query={query} />
Expand Down Expand Up @@ -57,7 +60,7 @@ function NoSearchResults() {
<div className="d-flex flex-items-center flex-column my-6 border rounded-2">
<div className="d-flex flex-items-center flex-column p-4">
<SearchIcon size={24} />
<Text className="f2 mt-3">{t('found_results').replace('{n}', 0)}</Text>
<Text className="f2 mt-3">{t('n_results').replace('{n}', 0)}</Text>
</div>
</div>
)
Expand All @@ -80,7 +83,7 @@ function SearchResultHit({
hit.highlights.title && hit.highlights.title.length > 0 ? hit.highlights.title[0] : hit.title

return (
<div className="my-6" data-testid="search-result">
<div className={cx('my-6', styles.search_result)} data-testid="search-result">
<p className="text-normal f5 color-fg-muted" style={{ wordSpacing: 2 }}>
{hit.breadcrumbs.length > 1 && (
<>
Expand Down
5 changes: 2 additions & 3 deletions data/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ release_notes:
search:
need_help: Need help?
placeholder: Search GitHub Docs
no_results: No results found
search_results_for: Search results for
no_content: No content
matches_found: Results found
matches_displayed: Matches displayed
search_error: An error occurred trying to perform the search.
description: Enter a search term to find it in the GitHub Documentation.
label: Search GitHub Docs
found_results: Found {n} results
one_result_found: Found 1 result
n_results: '{n} results'
one_result: 1 result
homepage:
explore_by_product: Explore by product
version_picker: Version
Expand Down
5 changes: 2 additions & 3 deletions tests/fixtures/data/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ release_notes:
search:
need_help: Need help?
placeholder: Search GitHub Docs
no_results: No results found
search_results_for: Search results for
no_content: No content
matches_found: Results found
matches_displayed: Matches displayed
search_error: An error occurred trying to perform the search.
description: Enter a search term to find it in the GitHub Documentation.
label: Search GitHub Docs
found_results: Found {n} results
one_result_found: Found 1 result
n_results: '{n} results'
one_result: 1 result
homepage:
explore_by_product: Explore by product
version_picker: Version
Expand Down

0 comments on commit dbf220f

Please sign in to comment.