Skip to content

Commit

Permalink
adjust filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinter69 committed Aug 17, 2023
1 parent 2b4eb1b commit 90cf77f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
29 changes: 17 additions & 12 deletions war/src/main/js/components/dropdowns/hetero-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,20 @@ function generateButtons() {
};
menuItems.push(item);
}
let menu = Utils.generateDropdownItems(menuItems, true);
createFilter(menu);
instance.setContent(menu);
const menuContainer = document.createElement("div");
const menu = Utils.generateDropdownItems(menuItems, true);
menuContainer.appendChild(createFilter(menu));
menuContainer.appendChild(menu);
instance.setContent(menuContainer);
});
},
);
}

function createFilter(menu) {
const filterInput = document.createElement("input");
filterInput.classList.add("jenkins-input");
filterInput.setAttribute("placeholder", "Filter");
filterInput.setAttribute("spellcheck", "false");
filterInput.setAttribute("type", "search");
const filterInput = createElementFromHtml(`
<input class="jenkins-dropdown__filter-input" placeholder="Filter" spellcheck="false" type="search"/>
`);

filterInput.addEventListener("input", (event) =>
applyFilterKeyword(menu, event.currentTarget),
Expand All @@ -222,9 +222,15 @@ function createFilter(menu) {
}
});

const filterContainer = document.createElement("div");
const filterContainer = createElementFromHtml(`
<div class="jenkins-dropdown__filter">
<div class="jenkins-dropdown__item__icon">
${Symbols.FUNNEL}
</div>
</div>
`);
filterContainer.appendChild(filterInput);
menu.insertBefore(filterContainer, menu.firstChild);
return filterContainer;
}

function applyFilterKeyword(menu, filterInput) {
Expand All @@ -234,7 +240,7 @@ function applyFilterKeyword(menu, filterInput) {
);
for (let item of items) {
let match = item.innerText.toLowerCase().includes(filterKeyword);
item.style.display = match ? "inline-flex" : "NONE";
item.style.display = match ? "inline-flex" : "none";
}
}

Expand All @@ -243,7 +249,6 @@ function generateDropDown(button, callback) {
button,
Object.assign({}, Templates.dropdown(), {
appendTo: undefined,
offset: [0, 5],
onCreate(instance) {
if (instance.loaded) {
return;
Expand Down
1 change: 1 addition & 0 deletions war/src/main/js/util/symbols.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions war/src/main/scss/modules/dropdowns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
$dropdown-padding: 0.4rem;

.tippy-box[data-theme~="dropdown"] {
padding: $dropdown-padding;
border-radius: 15px;
box-shadow: var(--dropdown-box-shadow);
outline: none !important;
Expand Down Expand Up @@ -39,13 +38,38 @@ $dropdown-padding: 0.4rem;
}

.jenkins-dropdown {
display: contents;
display: flex;
flex-direction: column;
padding: $dropdown-padding;

&--compact {
> .jenkins-dropdown__item,
> .jenkins-dropdown__disabled {
padding: 0 0.6rem;
min-height: 24px !important;
min-height: 30px !important;
}
}

&__filter {
display: flex;
align-items: center;
gap: 5px;
padding: 0.6rem 1rem;
border-bottom: 1px solid var(--input-border);

&-input {
&:focus {
outline: none;
}

width: 100%;
border: none;
color: var(--text-color-secondary);
background-color: unset;
}

svg {
margin-top: 2px;
}
}

Expand Down

0 comments on commit 90cf77f

Please sign in to comment.