mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 06:07:06 +01:00
f5e86d0351
* fix error with color variable - fix rebase * clean list search & fuse threshold decreased * update search-icon , fix tests * nice to have highlighting text & cleaning * unit test on settings & search input ui up on expanded view * fix color variable in alert scss * setting search input padding right up * fix dom warning * util/search test added & Dom element warning fix * renaming files * fix color text in settings search * settings search highlight text refacto & fix ui * fix settings-search test & renaming * Fix styling on search field for edge cases, update components and e2e E2E tests update for search feature Update components from class to functional component # Fix storybook for search box Fix styling Fix unit tests fix: remove z-index Fix unit tests Co-authored-by: amerkadicE <amer.kadic@endava.com>
102 lines
3.3 KiB
JavaScript
102 lines
3.3 KiB
JavaScript
import React, { useContext, useEffect } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classnames from 'classnames';
|
|
import { highlightSearchedText } from '../../../helpers/utils/settings-search';
|
|
import { I18nContext } from '../../../contexts/i18n';
|
|
|
|
export default function SettingsSearchList({ results, onClickSetting }) {
|
|
const t = useContext(I18nContext);
|
|
|
|
useEffect(() => {
|
|
results.forEach((_, i) => {
|
|
highlightSearchedText(i);
|
|
});
|
|
}, [results]);
|
|
|
|
return (
|
|
<div className="settings-page__header__search__list">
|
|
{Array(5)
|
|
.fill(undefined)
|
|
.map((_, i) => {
|
|
const { image, tab, section } = results[i] || {};
|
|
|
|
return (
|
|
Boolean(image || tab || section) && (
|
|
<div key={`settings_${i}`}>
|
|
<div
|
|
key={`res_${i}`}
|
|
className="settings-page__header__search__list__item"
|
|
onClick={() => onClickSetting(results[i])}
|
|
>
|
|
<img
|
|
className="settings-page__header__search__list__item__icon"
|
|
src={`./images/${image}`}
|
|
/>
|
|
|
|
<span
|
|
id={`menu-tab_${i}`}
|
|
className={classnames(
|
|
'settings-page__header__search__list__item__tab',
|
|
{
|
|
'settings-page__header__search__list__item__tab-multiple-lines':
|
|
tab === t('securityAndPrivacy'),
|
|
},
|
|
)}
|
|
>
|
|
{tab}
|
|
</span>
|
|
<div className="settings-page__header__search__list__item__caret" />
|
|
<span
|
|
id={`menu-section_${i}`}
|
|
className={classnames(
|
|
'settings-page__header__search__list__item__section',
|
|
{
|
|
'settings-page__header__search__list__item__section-multiple-lines':
|
|
tab === t('securityAndPrivacy') ||
|
|
tab === t('alerts'),
|
|
},
|
|
)}
|
|
>
|
|
{section}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
)
|
|
);
|
|
})}
|
|
{results.length === 0 && (
|
|
<div
|
|
className="settings-page__header__search__list__item"
|
|
style={{ cursor: 'auto', display: 'flex' }}
|
|
>
|
|
<span className="settings-page__header__search__list__item__no-matching">
|
|
{t('settingsSearchMatchingNotFound')}
|
|
</span>
|
|
</div>
|
|
)}
|
|
<div
|
|
className="settings-page__header__search__list__item"
|
|
style={{ cursor: 'auto', display: 'flex' }}
|
|
>
|
|
<span className="settings-page__header__search__list__item__request">
|
|
{t('missingSetting')}
|
|
</span>
|
|
<a
|
|
href="https://community.metamask.io/c/feature-requests-ideas/13"
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
key="need-help-link"
|
|
className="settings-page__header__search__list__item__link"
|
|
>
|
|
{t('missingSettingRequest')}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
SettingsSearchList.propTypes = {
|
|
results: PropTypes.array,
|
|
onClickSetting: PropTypes.func,
|
|
};
|