Adrià Vilanova MartÃnez | e0d65f2 | 2022-11-06 18:49:35 +0100 | [diff] [blame] | 1 | import '@material/web/button/outlined-button.js'; |
| 2 | |
| 3 | import {html, LitElement} from 'lit'; |
| 4 | |
| 5 | import {SHARED_MD3_STYLES} from '../../../../common/styles/md3.js'; |
| 6 | |
| 7 | export default class TwptCRImportButton extends LitElement { |
| 8 | static properties = { |
| 9 | cannedResponseId: {type: String}, |
| 10 | selected: {type: Boolean}, |
| 11 | }; |
| 12 | |
| 13 | static styles = [ |
| 14 | SHARED_MD3_STYLES, |
| 15 | ]; |
| 16 | |
| 17 | render() { |
| 18 | const icon = this.selected ? 'done' : 'post_add'; |
| 19 | const label = this.selected ? 'Selected' : 'Select'; |
| 20 | |
| 21 | return html` |
| 22 | <md-outlined-button |
| 23 | icon=${icon} |
| 24 | label=${label} |
| 25 | ?disabled=${this.selected} |
| 26 | @click=${this._importCR}> |
| 27 | </md-outlined-button> |
| 28 | `; |
| 29 | } |
| 30 | |
| 31 | _importCR() { |
| 32 | window.opener?.postMessage?.( |
| 33 | { |
| 34 | action: 'importCannedResponse', |
| 35 | cannedResponseId: this.cannedResponseId, |
| 36 | }, |
| 37 | '*'); |
| 38 | } |
| 39 | } |
| 40 | window.customElements.define('twpt-cr-import-button', TwptCRImportButton); |