@infinite-canvas-tutorial/webcomponents
Version:
WebComponents UI implementation
110 lines (107 loc) • 4.68 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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PenbarTextSettings = 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 PenbarTextSettings = class PenbarTextSettings extends lit_1.LitElement {
handleFillColorChanged(e) {
e.stopPropagation();
const fillColor = e.target.selected[0];
this.api.setAppState({
penbarText: Object.assign(Object.assign({}, this.api.getAppState().penbarText), { fill: fillColor }),
});
}
handleFontFamilyChanged(e) {
e.stopPropagation();
const fontFamily = e.target.value;
this.api.setAppState({
penbarText: Object.assign(Object.assign({}, this.api.getAppState().penbarText), { fontFamily }),
});
}
handleFontSizeChanged(e) {
e.stopPropagation();
const fontSize = e.target.value;
this.api.setAppState({
penbarText: Object.assign(Object.assign({}, this.api.getAppState().penbarText), { fontSize }),
});
}
handleFontStyleChanged(e) {
e.stopPropagation();
const fontStyle = e.target.value;
this.api.setAppState({
penbarText: Object.assign(Object.assign({}, this.api.getAppState().penbarText), { fontStyle }),
});
}
render() {
const { penbarText, theme } = this.appState;
return (0, lit_1.html) `<h4 style="margin: 0; margin-bottom: 8px;">
${(0, localize_1.msg)((0, localize_1.str) `Text settings`)}
</h4>
<sp-field-label for="font-family">Typography</sp-field-label>
<sp-picker
style="width: 100%; margin-bottom: 4px;"
label=${(0, localize_1.msg)((0, localize_1.str) `Font family`)}
value=${penbarText.fontFamily}
@change=${this.handleFontFamilyChanged}
id="font-family"
>
${penbarText.fontFamilies.map((fontFamily) => (0, lit_1.html) `<sp-menu-item
value=${fontFamily}
style="font-family: ${fontFamily};"
>${fontFamily}</sp-menu-item
>`)}
</sp-picker>
<div
class="line"
style="display: flex; align-items: center;justify-content: space-between; gap: 4px;"
>
<sp-picker
style="flex: 1;"
label=${(0, localize_1.msg)((0, localize_1.str) `Font style`)}
value=${penbarText.fontStyle}
@change=${this.handleFontStyleChanged}
id="font-style"
>
<sp-menu-item value="normal">${(0, localize_1.msg)((0, localize_1.str) `normal`)}</sp-menu-item>
<sp-menu-item value="italic">${(0, localize_1.msg)((0, localize_1.str) `italic`)}</sp-menu-item>
</sp-picker>
<sp-number-field
style="width: 80px;"
value=${penbarText.fontSize}
@change=${this.handleFontSizeChanged}
autocomplete="off"
min="0"
></sp-number-field>
</div>
<sp-field-label for="fill">${(0, localize_1.msg)((0, localize_1.str) `Fill`)}</sp-field-label>
<sp-swatch-group
id="fill"
selects="single"
.selected=${[penbarText.fill]}
@change=${this.handleFillColorChanged}
>
${theme.colors[theme.mode].swatches.map((color) => (0, lit_1.html) ` <sp-swatch color=${color} size="s"></sp-swatch> `)}
</sp-swatch-group> `;
}
};
exports.PenbarTextSettings = PenbarTextSettings;
__decorate([
(0, context_1.consume)({ context: context_2.appStateContext, subscribe: true })
], PenbarTextSettings.prototype, "appState", void 0);
__decorate([
(0, context_1.consume)({ context: context_2.apiContext, subscribe: true })
], PenbarTextSettings.prototype, "api", void 0);
exports.PenbarTextSettings = PenbarTextSettings = __decorate([
(0, decorators_js_1.customElement)('ic-spectrum-penbar-text-settings'),
(0, localize_1.localized)()
], PenbarTextSettings);
//# sourceMappingURL=penbar-text-settings.js.map