class ActionEntry extends HTMLElement{
    constructor(title, actionCallback, hideMenuCallback){
        super();
        this.title = title;
        this.actionCallback = actionCallback;
        this.hideMenuCallback = hideMenuCallback;
    }

    performActionCallback(){
        this.hideMenuCallback();
        this.actionCallback()
    }

    connectedCallback(){
        this.render();
        this.getElementsByClassName("action-entry-title")[0].onclick = () => {this.performActionCallback();};
        this.getElementsByTagName("img")[0].onclick = () => {this.performActionCallback();};
    }

    render(){
        this.innerHTML = `
        <link rel="stylesheet" href="components/action_entry/action_entry.css">
        <div class="action-entry">
            <span class="action-entry-title">${this.title}</span>
            <img src="res/arrow.png" class="action-entry-arrow">     
        </div>
        `;
    }
}

customElements.define("sea-action-entry", ActionEntry);