Skip to content

Commit

Permalink
move dropdown if outside of viewport (#228)
Browse files Browse the repository at this point in the history
Co-authored-by: Timo Huber <[email protected]>
  • Loading branch information
timohuber and timohuber authored Oct 17, 2023
1 parent 98617f2 commit c7e2d91
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
18 changes: 10 additions & 8 deletions resources/admin.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { initRoleSearchForm } from "./admin/role-search.js"
import { initFilterForm } from "./admin/filter.js"
import { initRichTextEditor } from "./admin/richTextEditor.js"
import { initCopyClipboard } from "./admin/copyClipboard.js";
import { initButtonList } from "./admin/buttonList.js"
import { initCalendar } from './admin/calendar'
import { initCopyClipboard } from "./admin/copyClipboard.js";
import { initFilterForm } from "./admin/filter.js"
import { initPrint } from "./admin/print"
import { initRichTextEditor } from "./admin/richTextEditor.js"
import { initRoleSearchForm } from "./admin/role-search.js"

initRoleSearchForm();
initFilterForm();
initRichTextEditor();
initCopyClipboard();
initButtonList()
initCalendar();
initCopyClipboard();
initFilterForm();
initPrint();
initRichTextEditor();
initRoleSearchForm();

window['pool-tool'] = {
initRichTextEditor
Expand Down
19 changes: 19 additions & 0 deletions resources/admin/buttonList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

const dropdownWidth = 200;

export const initButtonList = () => {
const els = document.querySelectorAll(".button-list");

els.forEach(el => {
const dropdown = el.querySelector(".dropdown")
if (!dropdown) {
return
}

var rect = el.getBoundingClientRect();
const windowWidth = window.innerWidth || document.documentElement.clientWidth;
if (rect.right + dropdownWidth >= windowWidth) {
el.classList.add("left")
}
})
}
7 changes: 7 additions & 0 deletions resources/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,10 @@ table.simple {
.cursor-default {
cursor: default;
}

// Button dropdown
.button-list.left .dropdown {
right: auto;
left: 0;
transform: translateX(-100%);
}

0 comments on commit c7e2d91

Please sign in to comment.