mirror of
				https://github.com/BookStackApp/BookStack.git
				synced 2025-11-04 13:31:45 +03:00 
			
		
		
		
	Adds dynamic and fixed (out of DOM order) positioning with location adjustment depending on space. Also adds smarter hiding to prevent disappearing when mouse leaves but within the same space as the toggle.
		
			
				
	
	
		
			33 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import {EditorContainerUiElement, EditorUiElement} from "../core";
 | 
						|
import {el} from "../../../utils/dom";
 | 
						|
import {EditorButton} from "../buttons";
 | 
						|
import {EditorDropdownButton} from "./dropdown-button";
 | 
						|
import caretDownIcon from "@icons/caret-down-large.svg";
 | 
						|
 | 
						|
export class EditorButtonWithMenu extends EditorContainerUiElement {
 | 
						|
    protected button: EditorButton;
 | 
						|
    protected dropdownButton: EditorDropdownButton;
 | 
						|
 | 
						|
    constructor(button: EditorButton, menuItems: EditorUiElement[]) {
 | 
						|
        super([button]);
 | 
						|
 | 
						|
        this.button = button;
 | 
						|
        this.dropdownButton = new EditorDropdownButton({
 | 
						|
            button: {label: 'Menu', icon: caretDownIcon},
 | 
						|
            showOnHover: false,
 | 
						|
            direction: 'vertical',
 | 
						|
            showAside: false,
 | 
						|
        }, menuItems);
 | 
						|
        this.addChildren(this.dropdownButton);
 | 
						|
    }
 | 
						|
 | 
						|
    buildDOM(): HTMLElement {
 | 
						|
        return el('div', {
 | 
						|
            class: 'editor-button-with-menu-container',
 | 
						|
        }, [
 | 
						|
            this.button.getDOMElement(),
 | 
						|
            this.dropdownButton.getDOMElement()
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
}
 |