@infinite-canvas-tutorial/webcomponents
Version:
WebComponents UI implementation
69 lines (68 loc) • 2.53 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { html, css, LitElement } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { consume } from '@lit/context';
import { apiContext, appStateContext } from '../context';
let FillActionButton = class FillActionButton extends LitElement {
handleFillChanged(e) {
const { type, value } = e.detail;
this.api.updateNode(this.node, {
fill: type === 'solid'
? value.startsWith('#')
? value
: `#${value}`
: value,
});
this.api.record();
}
render() {
if (!this.node) {
return html ``;
}
const { fill } = this.node;
return html `<sp-action-button quiet size="m" id="fill">
<ic-spectrum-fill-icon
value=${fill}
.node=${this.node}
slot="icon"
></ic-spectrum-fill-icon>
<sp-tooltip self-managed placement="bottom"> Fill </sp-tooltip>
</sp-action-button>
<sp-overlay trigger="fill@click" placement="bottom" type="auto">
<sp-popover dialog>
<ic-spectrum-color-picker
value=${fill}
@color-change=${this.handleFillChanged}
></ic-spectrum-color-picker>
</sp-popover>
</sp-overlay>`;
}
};
FillActionButton.styles = css `
ic-spectrum-fill-icon {
width: 30px;
height: 30px;
}
sp-popover {
padding: 0;
}
`;
__decorate([
consume({ context: appStateContext, subscribe: true })
], FillActionButton.prototype, "appState", void 0);
__decorate([
consume({ context: apiContext, subscribe: true })
], FillActionButton.prototype, "api", void 0);
__decorate([
property()
], FillActionButton.prototype, "node", void 0);
FillActionButton = __decorate([
customElement('ic-spectrum-fill-action-button')
], FillActionButton);
export { FillActionButton };
//# sourceMappingURL=fill-action-button.js.map