UNPKG

holakit

Version:

Yet another design-driven UI component set.

1 lines 3.82 kB
{"moduleFile":{"sourceFilePath":"/Users/laosb/Documents/SoftwareProj/holakit/packages/core/src/components/hola-button/hola-button.tsx","localImports":[],"externalImports":["@stencil/core"],"potentialCmpRefs":[],"cmpMeta":{"tagNameMeta":"hola-button","stylesMeta":{"$":{"externalStyles":[{"absolutePath":"/Users/laosb/Documents/SoftwareProj/holakit/packages/core/src/components/hola-button/hola-button.css","cmpRelativePath":"hola-button.css","originalComponentPath":"hola-button.css"}]}},"assetsDirsMeta":[],"hostMeta":{},"dependencies":[],"jsdoc":{"name":"HolaButton","tags":[],"documentation":"","type":"typeof HolaButton"},"encapsulationMeta":1,"componentClass":"HolaButton","membersMeta":{"el":{"memberType":64},"href":{"memberType":1,"attribName":"href","attribType":{"text":"string","optional":false,"typeReferences":{}},"reflectToAttrib":false,"propType":2,"jsdoc":{"name":"href","tags":[],"documentation":"When you need this to be a link, specify this as a url.","type":"string"}},"type":{"memberType":1,"attribName":"type","attribType":{"text":"string","optional":false,"typeReferences":{}},"reflectToAttrib":false,"propType":2,"jsdoc":{"name":"type","tags":[],"documentation":"The type of button when this element acts as <button>.","type":"string"}},"submit":{"memberType":1,"attribName":"submit","attribType":{"text":"boolean","optional":false,"typeReferences":{}},"reflectToAttrib":false,"propType":4,"jsdoc":{"name":"submit","tags":[],"documentation":"Add this if you want this acts like a form submit.","type":"boolean"}}},"eventsMeta":[],"listenersMeta":[]},"hasSlot":true,"hasSvg":false,"jsFilePath":"/Users/laosb/Documents/SoftwareProj/holakit/packages/core/src/components/hola-button/hola-button.js"},"jsText":"export class HolaButton {\r\n constructor() {\r\n /**\r\n * When you need this to be a link, specify this as a url.\r\n */\r\n this.href = '#';\r\n /**\r\n * The type of button when this element acts as <button>.\r\n */\r\n this.type = 'button';\r\n /**\r\n * Add this if you want this acts like a form submit.\r\n */\r\n this.submit = false;\r\n }\r\n onClick(event) {\r\n // To make form events work, this method is stole from\r\n // https://github.com/ionic-team/ionic/blob/0fec72255bb99611cfe67ea70152400ec7f8b762/core/src/components/button/button.tsx#L118-L139\r\n const form = this.el.closest('form');\r\n if (form) {\r\n event.preventDefault();\r\n if (this.submit)\r\n return form.submit();\r\n const fakeButton = document.createElement('button');\r\n fakeButton.type = this.type;\r\n fakeButton.style.display = 'none';\r\n form.appendChild(fakeButton);\r\n fakeButton.click();\r\n fakeButton.remove();\r\n }\r\n }\r\n render() {\r\n if (this.href)\r\n h(\"a\", { href: this.href, class: \"button\" },\r\n h(\"slot\", null));\r\n return h(\"button\", { onClick: this.onClick, type: this.type, class: \"button\" },\r\n h(\"slot\", null));\r\n }\r\n static get is() { return \"hola-button\"; }\r\n static get encapsulation() { return \"shadow\"; }\r\n static get properties() { return {\r\n \"el\": {\r\n \"elementRef\": true\r\n },\r\n \"href\": {\r\n \"type\": String,\r\n \"attr\": \"href\"\r\n },\r\n \"submit\": {\r\n \"type\": Boolean,\r\n \"attr\": \"submit\"\r\n },\r\n \"type\": {\r\n \"type\": String,\r\n \"attr\": \"type\"\r\n }\r\n }; }\r\n static get style() { return \"/**style-placeholder:hola-button:**/\"; }\r\n}\r\n"}