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_preview_available": "",
"no_search_results": "", "no_search_results": "",
"no_symbols_found": "", "no_symbols_found": "",
"showing_symbol_search_results": "",
"normal": "", "normal": "",
"off": "", "off": "",
"ok": "", "ok": "",

View file

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

View file

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

View file

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

View file

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

View file

@ -69,6 +69,9 @@ describe('symbol palette', function () {
expect(symbols).to.have.length(2) 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 // press Tab to select the symbols
fireEvent.keyDown(container, { key: 'Tab' }) fireEvent.keyDown(container, { key: 'Tab' })