Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added matching categories to the search results of ElementsPanel for better accessibility. #264

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added Matching Categories in search results of ElementsPanel for bett…
…er accessibility
Chandrachur67 committed Jan 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 14d59643281c9d71d926f172e75a524ee3f3e191
52 changes: 52 additions & 0 deletions src/components/Panels/ElementsPanel/ElementsPanel.vue
Original file line number Diff line number Diff line change
@@ -42,6 +42,46 @@
<img :src="element.imgURL" :alt="element.name" />
</div>
</div>
<v-expansion-panels
v-if="elementInput && searchCategories().length"
id="menu"
class="accordion"
variant="accordion"
>
<v-expansion-panel
v-for="category in searchCategories()"
:key="category[0]"
>
<v-expansion-panel-title>
{{
$t(
'simulator.panel_body.circuit_elements.expansion_panel_title.' +
category[0]
)
}}
</v-expansion-panel-title>
<v-expansion-panel-text eager>
<div class="panel customScroll">
<div
v-for="element in category[1]"
:id="element.name"
:key="element"
:title="element.label"
class="icon logixModules"
@click="createElement(element.name)"
@mousedown="createElement(element.name)"
@mouseover="getTooltipText(element.name)"
@mouseleave="tooltipText = 'null'"
>
<img
:src="element.imgURL"
:alt="element.name"
/>
</div>
</div>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
<div
v-if="elementInput && !searchElements().length"
class="search-results"
@@ -163,6 +203,18 @@ function searchElements() {
return finalResult
}

function searchCategories() {
const result = panelData.filter((category) => {
const categoryName = category[0];
const categoryNameWords = categoryName.split(' ');

return categoryNameWords.some((word) =>
word.toLowerCase().startsWith(elementInput.value.toLowerCase())
);
})
return result;
}

function createElement(elementName) {
if (simulationArea.lastSelected && simulationArea.lastSelected.newElement)
simulationArea.lastSelected.delete()