UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
91 lines 3.95 kB
"use strict"; 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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PenbarPencilSettings = void 0; const lit_1 = require("lit"); const decorators_js_1 = require("lit/decorators.js"); const context_1 = require("@lit/context"); const context_2 = require("../context"); const localize_1 = require("@lit/localize"); let PenbarPencilSettings = class PenbarPencilSettings extends lit_1.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 (0, lit_1.html) `<h4 style="margin: 0; margin-bottom: 8px;"> ${(0, localize_1.msg)((0, localize_1.str) `Pencil settings`)} </h4> <sp-field-label for="stroke">${(0, localize_1.msg)((0, localize_1.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) => (0, lit_1.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=${(0, localize_1.msg)((0, localize_1.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=${(0, localize_1.msg)((0, localize_1.str) `Freehand`)} .checked=${penbarPencil.freehand} @change=${this.handleFreehandChanged} >${(0, localize_1.msg)((0, localize_1.str) `Freehand`)}</sp-switch > </div>`; } }; exports.PenbarPencilSettings = PenbarPencilSettings; __decorate([ (0, context_1.consume)({ context: context_2.appStateContext, subscribe: true }) ], PenbarPencilSettings.prototype, "appState", void 0); __decorate([ (0, context_1.consume)({ context: context_2.apiContext, subscribe: true }) ], PenbarPencilSettings.prototype, "api", void 0); exports.PenbarPencilSettings = PenbarPencilSettings = __decorate([ (0, decorators_js_1.customElement)('ic-spectrum-penbar-pencil-settings'), (0, localize_1.localized)() ], PenbarPencilSettings); //# sourceMappingURL=penbar-pencil-settings.js.map