bulmil
Version:

123 lines (122 loc) • 3.74 kB
JavaScript
import { Component, Prop, h } from '@stencil/core';
export class Dropdown {
constructor() {
/**
* The dropdown visibility
*/
this.isActive = false;
/**
* Align the dropdown to the right
*/
this.isRight = false;
/**
* Dropdown menu that appears above the dropdown button
*/
this.isUp = false;
/**
* The dropdown will show up when hovering the dropdown-trigger
*/
this.isHoverable = false;
/**
* Handle Trigger click action
*/
this.handleTriggerClick = () => {
this.isActive = !this.isActive;
};
}
render() {
return (h("div", { class: {
dropdown: true,
'is-active': this.isActive,
'is-right': this.isRight,
'is-up': this.isUp,
'is-hoverable': this.isHoverable,
} },
h("div", { onClick: this.handleTriggerClick, class: "dropdown-trigger" },
h("slot", { name: "trigger", "aria-haspopup": "true" })),
h("div", { class: "dropdown-menu", role: "menu" },
h("div", { class: "dropdown-content" },
h("slot", null)))));
}
static get is() { return "bm-dropdown"; }
static get originalStyleUrls() { return {
"$": ["dropdown.scss"]
}; }
static get styleUrls() { return {
"$": ["dropdown.css"]
}; }
static get properties() { return {
"isActive": {
"type": "boolean",
"mutable": true,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "The dropdown visibility"
},
"attribute": "is-active",
"reflect": true,
"defaultValue": "false"
},
"isRight": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Align the dropdown to the right"
},
"attribute": "is-right",
"reflect": false,
"defaultValue": "false"
},
"isUp": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "Dropdown menu that appears above the dropdown button"
},
"attribute": "is-up",
"reflect": false,
"defaultValue": "false"
},
"isHoverable": {
"type": "boolean",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "The dropdown will show up when hovering the dropdown-trigger"
},
"attribute": "is-hoverable",
"reflect": false,
"defaultValue": "false"
}
}; }
}