diff --git a/Tray.js b/Tray.js index 59149e8..f50a0ca 100644 --- a/Tray.js +++ b/Tray.js @@ -27,6 +27,8 @@ class Tray { this.isChecked = isChecked; this.borderColor = color || Tray.colorPalette[0]; this.element = this.createElement(); + this.flexDirection = 'column'; // Add this line + this.updateAppearance(); this.updateBorderColor(); } @@ -59,9 +61,9 @@ class Tray { contextMenuButton.classList.add('tray-context-menu-button'); contextMenuButton.textContent = '⋮'; contextMenuButton.addEventListener('click', this.onContextMenuButtonClick.bind(this)); + titleContainer.appendChild(contextMenuButton); titleContainer.appendChild(checkboxContainer); titleContainer.appendChild(title); - titleContainer.appendChild(contextMenuButton); tray.addEventListener('contextmenu', this.onContextMenu.bind(this)); title.addEventListener('contextmenu', (event) => { @@ -79,6 +81,8 @@ class Tray { const content = document.createElement('div'); content.classList.add('tray-content'); + content.style.flexDirection = this.flexDirection; // Add this line + titleContainer.addEventListener('dblclick', this.onDoubleClick.bind(this)); const foldButton = document.createElement('button'); foldButton.classList.add('tray-fold-button'); @@ -98,7 +102,28 @@ class Tray { return tray; } - + toggleFlexDirection() { + this.flexDirection = this.flexDirection === 'column' ? 'row' : 'column'; + this.updateFlexDirection(); + this.updateChildrenAppearance(); // Add this line + saveToLocalStorage(); + } + + updateFlexDirection() { + const content = this.element.querySelector('.tray-content'); + content.style.flexDirection = this.flexDirection; + content.style.display = 'flex'; // Ensure flex display is set + } + + updateChildrenAppearance() { + this.children.forEach(child => { + if (this.flexDirection === 'row') { + child.element.style.width = '200px'; // Or any appropriate width + } else { + child.element.style.width = '100%'; + } + }); + } onCheckboxChange(event) { this.isChecked = event.target.checked; saveToLocalStorage(); @@ -418,19 +443,20 @@ class Tray { const menu = document.createElement('div'); menu.classList.add('context-menu'); menu.innerHTML = ` -
- - - - - -