UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
156 lines (155 loc) 6.35 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.PenbarBrushSettings = 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 PenbarBrushSettings = class PenbarBrushSettings extends lit_1.LitElement { handleStrokeWidthChanged(e) { const strokeWidth = parseInt(e.target.value); this.api.setAppState({ penbarBrush: Object.assign(Object.assign({}, this.api.getAppState().penbarBrush), { strokeWidth }), }); this.api.record(); } handleStrokeColorChanged(e) { e.stopPropagation(); const strokeColor = e.target.selected[0]; this.api.setAppState({ penbarBrush: Object.assign(Object.assign({}, this.api.getAppState().penbarBrush), { stroke: strokeColor }), }); } handleStampIntervalChanged(e) { const stampInterval = parseFloat(e.target.value); this.api.setAppState({ penbarBrush: Object.assign(Object.assign({}, this.api.getAppState().penbarBrush), { stampInterval }), }); this.api.record(); } handleStampNoiseFactorChanged(e) { const stampNoiseFactor = parseFloat(e.target.value); this.api.setAppState({ penbarBrush: Object.assign(Object.assign({}, this.api.getAppState().penbarBrush), { stampNoiseFactor }), }); this.api.record(); } handleStampRotationFactorChanged(e) { const stampRotationFactor = parseFloat(e.target.value); this.api.setAppState({ penbarBrush: Object.assign(Object.assign({}, this.api.getAppState().penbarBrush), { stampRotationFactor }), }); this.api.record(); } handleStampChanged(e) { const stamp = e.target.value; this.api.setAppState({ penbarBrush: Object.assign(Object.assign({}, this.api.getAppState().penbarBrush), { stamp }), }); this.api.record(); } render() { const { penbarBrush, theme } = this.appState; return (0, lit_1.html) `<h4 style="margin: 0; margin-bottom: 8px;"> ${(0, localize_1.msg)((0, localize_1.str) `Brush 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=${[penbarBrush.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"> <sp-picker style="width: 100%; margin-bottom: 4px; margin-top: 4px;" label=${(0, localize_1.msg)((0, localize_1.str) `Stamp`)} value=${penbarBrush.stamp} @change=${this.handleStampChanged} id="font-family" > ${penbarBrush.stamps.map((stamp) => (0, lit_1.html) `<sp-menu-item value=${stamp.src} style="display: flex; align-items: center; gap: 4px;"> <img src=${stamp.src} style="width: 20px; height: 20px;" /> <span>${stamp.name}</span> </sp-menu-item>`)} </sp-picker> </div> <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="80" min="0" value=${penbarBrush.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;"> <sp-slider style="flex: 1;" size="s" label=${(0, localize_1.msg)((0, localize_1.str) `Stamp interval`)} max="1" min="0.1" value=${penbarBrush.stampInterval} step="0.1" editable @change=${this.handleStampIntervalChanged} ></sp-slider> </div> <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) `Stamp noise factor`)} max="1" min="0.1" value=${penbarBrush.stampNoiseFactor} step="0.1" editable @change=${this.handleStampNoiseFactorChanged} ></sp-slider> </div> <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) `Stamp rotation factor`)} max="1" min="0.1" value=${penbarBrush.stampRotationFactor} step="0.1" editable @change=${this.handleStampRotationFactorChanged} ></sp-slider> </div>`; } }; exports.PenbarBrushSettings = PenbarBrushSettings; __decorate([ (0, context_1.consume)({ context: context_2.appStateContext, subscribe: true }) ], PenbarBrushSettings.prototype, "appState", void 0); __decorate([ (0, context_1.consume)({ context: context_2.apiContext, subscribe: true }) ], PenbarBrushSettings.prototype, "api", void 0); exports.PenbarBrushSettings = PenbarBrushSettings = __decorate([ (0, decorators_js_1.customElement)('ic-spectrum-penbar-brush-settings'), (0, localize_1.localized)() ], PenbarBrushSettings); //# sourceMappingURL=penbar-brush-settings.js.map