Skip to content

Commit e5fb7f6

Browse files
update sort button
Co-authored-by: Lucas Bergholz <[email protected]>
1 parent 5be4b46 commit e5fb7f6

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/index.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ document.addEventListener("DOMContentLoaded", function() {
5656

5757
// Add input for filtering
5858
function addInput(el, label, idx) {
59+
const container = document.createElement('div');
60+
container.setAttribute('style', 'display: flex; align-items: center;');
61+
5962
const input = document.createElement('input');
6063
input.addEventListener("change", function(e) {
6164
widget.filters[idx] = e.target.value;
@@ -68,15 +71,18 @@ document.addEventListener("DOMContentLoaded", function() {
6871
input.setAttribute('type', 'text');
6972
input.setAttribute('name', 'filter_' + label);
7073
input.setAttribute('list', 'opts_for_' + label);
71-
el.appendChild(input);
74+
75+
container.appendChild(input);
76+
addSortButton(container, idx);
77+
78+
el.appendChild(container);
7279
}
7380
const tbody = el.querySelector('tbody');
7481
const headings = Array.from(el.querySelectorAll('thead th')).map((el, idx) => {
7582
const isSuggested = el.getAttribute("data-suggest") !== null;
7683
const label = el.innerText.toLowerCase();
7784
el.appendChild(document.createElement('br'));
7885
addInput(el, label, idx);
79-
addSortButton(el, idx);
8086

8187
if (isSuggested) {
8288
setupDatalist(el, label, idx);
@@ -104,18 +110,14 @@ document.addEventListener("DOMContentLoaded", function() {
104110
}); */
105111

106112
function addSortButton(el, idx) {
107-
const button = document.createElement('button');
108113
const img = document.createElement('img');
109-
button.innerText = 'Sort';
110-
button.addEventListener("click", function() {
111-
sortTable(idx);
112-
});
113-
img.addEventListener("click", function() {
114-
sortTable(idx);
115-
});
116-
button.setAttribute('style', 'justify-content: center');
114+
img.src = "https://uxwing.com/wp-content/themes/uxwing/download/arrow-direction/up-down-arrows-icon.png"
115+
img.addEventListener("click", function() {
116+
sortTable(idx);
117+
});
118+
img.setAttribute('style', 'width: 16px; margin-left: 5px' )
117119

118-
el.appendChild(button);
120+
el.appendChild(img)
119121
}
120122

121123
let direction = false;

0 commit comments

Comments
 (0)