From 5637c55b7f8f812d01b213ddb1d3174ab26939fa Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 6 Oct 2024 01:15:13 +0200 Subject: [PATCH 1/2] [icons] Try sync index addition --- .../components/material-icons/SearchIcons.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/data/material/components/material-icons/SearchIcons.js b/docs/data/material/components/material-icons/SearchIcons.js index 945dcc038ff325..9fbd70f2488031 100644 --- a/docs/data/material/components/material-icons/SearchIcons.js +++ b/docs/data/material/components/material-icons/SearchIcons.js @@ -518,29 +518,31 @@ const searchIndex = new FlexSearchIndex({ tokenize: 'full', }); +const nameCleanRegex = /(Outlined|TwoTone|Rounded|Sharp)$/; + const allIconsMap = {}; const allIcons = Object.keys(mui) .sort() .map((importName) => { let theme; - if (importName.includes('Outlined')) { + if (importName.endsWith('Outlined')) { theme = 'Outlined'; - } else if (importName.includes('TwoTone')) { + } else if (importName.endsWith('TwoTone')) { theme = 'Two tone'; - } else if (importName.includes('Rounded')) { + } else if (importName.endsWith('Rounded')) { theme = 'Rounded'; - } else if (importName.includes('Sharp')) { + } else if (importName.endsWith('Sharp')) { theme = 'Sharp'; } else { theme = 'Filled'; } - const name = importName.replace(/(Outlined|TwoTone|Rounded|Sharp)$/, ''); + const name = importName.replace(nameCleanRegex, ''); let searchable = name; if (synonyms[searchable]) { searchable += ` ${synonyms[searchable]}`; } - searchIndex.addAsync(importName, searchable); + searchIndex.add(importName, searchable); const icon = { importName, From c5b480f193c82daf68d0d977347fd543bbb59a83 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 6 Oct 2024 20:54:17 +0200 Subject: [PATCH 2/2] jan's feedback --- .../components/material-icons/SearchIcons.js | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/docs/data/material/components/material-icons/SearchIcons.js b/docs/data/material/components/material-icons/SearchIcons.js index 9fbd70f2488031..4e252ebcca769c 100644 --- a/docs/data/material/components/material-icons/SearchIcons.js +++ b/docs/data/material/components/material-icons/SearchIcons.js @@ -518,26 +518,20 @@ const searchIndex = new FlexSearchIndex({ tokenize: 'full', }); -const nameCleanRegex = /(Outlined|TwoTone|Rounded|Sharp)$/; - const allIconsMap = {}; const allIcons = Object.keys(mui) .sort() .map((importName) => { - let theme; - if (importName.endsWith('Outlined')) { - theme = 'Outlined'; - } else if (importName.endsWith('TwoTone')) { - theme = 'Two tone'; - } else if (importName.endsWith('Rounded')) { - theme = 'Rounded'; - } else if (importName.endsWith('Sharp')) { - theme = 'Sharp'; - } else { - theme = 'Filled'; + let theme = 'Filled'; + let name = importName; + + for (const currentTheme of ['Outlined', 'Rounded', 'TwoTone', 'Sharp']) { + if (importName.endsWith(currentTheme)) { + theme = currentTheme === 'TwoTone' ? 'Two tone' : currentTheme; + name = importName.slice(0, -currentTheme.length); + break; + } } - - const name = importName.replace(nameCleanRegex, ''); let searchable = name; if (synonyms[searchable]) { searchable += ` ${synonyms[searchable]}`;