blob: 935926f1b8834725029d05bbfdcc272b8d98ba4c [file] [log] [blame]
Adrià Vilanova Martíneze0d65f22022-11-06 18:49:35 +01001import '@material/web/button/outlined-button.js';
2
3import {html, LitElement} from 'lit';
4
5import {SHARED_MD3_STYLES} from '../../../../common/styles/md3.js';
6
7export 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}
40window.customElements.define('twpt-cr-import-button', TwptCRImportButton);