PluginProbe
Code Snippets / 3.10.0
Code Snippets v3.10.0
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
code-snippets / js / components / ManageMenu / SnippetsTable / SnippetsTableSearch.tsx

SnippetsTableSearch.tsx in Code Snippets 3.10.0, at js/components/ManageMenu/SnippetsTable/SnippetsTableSearch.tsx

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __, sprintf } from '@wordpress/i18n'
2 import React from 'react'
3 import { Button } from '../../common/Button'
4 import { useSnippetsFilters } from './WithSnippetsTableFilters'
5
6 export const SearchArea = () => {
7 const { searchQuery, setSearchQuery } = useSnippetsFilters()
8
9 return (
10 <search className="snippets-search-area">
11 <form
12 className="search-box"
13 aria-label={__('Search Snippets', 'code-snippets')}
14 onSubmit={event => {
15 event.preventDefault()
16 }}
17 >
18 <input
19 type="search"
20 id="snippets_search"
21 name="s"
22 value={searchQuery ?? ''}
23 aria-label={__('Search Snippets:', 'code-snippets')}
24 onChange={event => setSearchQuery(event.target.value)}
25 placeholder={__('Search snippets', 'code-snippets')}
26 />
27 </form>
28 </search>
29 )
30 }
31
32 export const SearchResultsIndicator = () => {
33 const { searchQueryText, searchLineNumber, currentTag, setSearchQuery, setCurrentTag } = useSnippetsFilters()
34
35 return searchQueryText || currentTag
36 ? <p className="snippets-search-subtitle">
37 {__('Search results', 'code-snippets')}
38
39 {/* translators: %s: search query. */}
40 {searchQueryText && sprintf(__(' for “%s”', 'code-snippets'), searchQueryText)}
41
42 {/* translators: %d: code line number. */}
43 {searchLineNumber && sprintf(__(' on line “%d”', 'code-snippets'), searchLineNumber)}
44
45 {/* translators: %s: tag name. */}
46 {currentTag && sprintf(__(' in tag “%s”', 'code-snippets'), currentTag)}
47
48 {' '}
49 <Button small className="clear-filters" onClick={() => {
50 setSearchQuery()
51 setCurrentTag()
52 }}>
53 {__('Clear Filters', 'code-snippets')}
54 </Button>
55 </p>
56 : null
57 }
58