Show hint for Symbol Palette search (#4373)

GitOrigin-RevId: cfdba4f31117cc406cee06e9a97db567c65d5348
This commit is contained in:
Miguel Serrano 2021-08-03 12:02:45 +02:00 committed by Copybot
parent d2f5509fed
commit cc2861a2a3
6 changed files with 19 additions and 11 deletions

View file

@ -213,6 +213,7 @@
"no_preview_available": "",
"no_search_results": "",
"no_symbols_found": "",
"showing_symbol_search_results": "",
"normal": "",
"off": "",
"ok": "",

View file

@ -66,10 +66,13 @@ export default function SymbolPaletteContent({ handleSelect }) {
<Tabs className="symbol-palette-container">
<div className="symbol-palette">
<div className="symbol-palette-header">
<SymbolPaletteTabs
categories={categories}
disabled={input.length > 0}
/>
{input.length <= 0 ? (
<SymbolPaletteTabs categories={categories} />
) : (
<div className="symbol-palette-search-hint">
{t('showing_symbol_search_results', { search: input })}
</div>
)}
<div className="symbol-palette-header-group">
<BetaBadge
tooltip={{

View file

@ -1,15 +1,11 @@
import { TabList, Tab } from '@reach/tabs'
import PropTypes from 'prop-types'
export default function SymbolPaletteTabs({ categories, disabled }) {
export default function SymbolPaletteTabs({ categories }) {
return (
<TabList aria-label="Symbol Categories" className="symbol-palette-tab-list">
{categories.map(category => (
<Tab
key={category.id}
disabled={disabled}
className="symbol-palette-tab"
>
<Tab key={category.id} className="symbol-palette-tab">
{category.label}
</Tab>
))}
@ -23,5 +19,4 @@ SymbolPaletteTabs.propTypes = {
label: PropTypes.string.isRequired,
})
).isRequired,
disabled: PropTypes.bool,
}

View file

@ -28,6 +28,11 @@
margin-left: @margin-xs;
}
.symbol-palette-search-hint {
padding-left: @padding-xs;
margin-left: @margin-xs;
}
.symbol-palette-tab-list[data-reach-tab-list] {
background: none;
border-bottom: none;

View file

@ -1462,6 +1462,7 @@
"category_misc": "Misc",
"no_symbols_found": "No symbols found",
"find_out_more_about_latex_symbols": "Find out more about LaTeX symbols",
"showing_symbol_search_results": "Showing search results for \"__search__\"",
"search": "Search",
"also": "Also",
"add_email": "Add Email",

View file

@ -69,6 +69,9 @@ describe('symbol palette', function () {
expect(symbols).to.have.length(2)
})
// check the search hint is displayed
screen.getByText('Showing search results for "pi"')
// press Tab to select the symbols
fireEvent.keyDown(container, { key: 'Tab' })