UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
88 lines 3.54 kB
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, LitElement } from 'lit'; import { customElement } from 'lit/decorators.js'; import { consume } from '@lit/context'; import { apiContext, appStateContext } from '../context'; import { localized, msg, str } from '@lit/localize'; let PenbarPencilSettings = class PenbarPencilSettings extends LitElement { handleStrokeWidthChanged(e) { const strokeWidth = parseInt(e.target.value); this.api.setAppState({ penbarPencil: Object.assign(Object.assign({}, this.api.getAppState().penbarPencil), { strokeWidth }), }); this.api.record(); } handleStrokeColorChanged(e) { e.stopPropagation(); const strokeColor = e.target.selected[0]; this.api.setAppState({ penbarPencil: Object.assign(Object.assign({}, this.api.getAppState().penbarPencil), { stroke: strokeColor }), }); } handleFreehandChanged(e) { const freehand = e.target.checked; this.api.setAppState({ penbarPencil: Object.assign(Object.assign({}, this.api.getAppState().penbarPencil), { freehand }), }); } render() { const { penbarPencil, theme } = this.appState; return html `<h4 style="margin: 0; margin-bottom: 8px;"> ${msg(str `Pencil settings`)} </h4> <sp-field-label for="stroke">${msg(str `Stroke`)}</sp-field-label> <sp-swatch-group id="stroke" selects="single" .selected=${[penbarPencil.stroke]} @change=${this.handleStrokeColorChanged} > ${theme.colors[theme.mode].swatches.map((color) => html ` <sp-swatch color=${color} size="s"></sp-swatch> `)} </sp-swatch-group> <div class="line" style="display: flex; align-items: center;"> <sp-slider style="flex: 1;" size="s" label=${msg(str `Stroke width`)} max="100" min="0" value=${penbarPencil.strokeWidth} step="1" editable format-options='{ "style": "unit", "unit": "px" }' @change=${this.handleStrokeWidthChanged} ></sp-slider> </div> <div class="line" style="display: flex; align-items: center;justify-content: space-between;" > <sp-switch label=${msg(str `Freehand`)} .checked=${penbarPencil.freehand} @change=${this.handleFreehandChanged} >${msg(str `Freehand`)}</sp-switch > </div>`; } }; __decorate([ consume({ context: appStateContext, subscribe: true }) ], PenbarPencilSettings.prototype, "appState", void 0); __decorate([ consume({ context: apiContext, subscribe: true }) ], PenbarPencilSettings.prototype, "api", void 0); PenbarPencilSettings = __decorate([ customElement('ic-spectrum-penbar-pencil-settings'), localized() ], PenbarPencilSettings); export { PenbarPencilSettings }; //# sourceMappingURL=penbar-pencil-settings.js.map