UNPKG

@infinite-canvas-tutorial/webcomponents

Version:
107 lines (104 loc) 4.23 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 PenbarTextSettings = class PenbarTextSettings extends 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 html `<h4 style="margin: 0; margin-bottom: 8px;"> ${msg(str `Text settings`)} </h4> <sp-field-label for="font-family">Typography</sp-field-label> <sp-picker style="width: 100%; margin-bottom: 4px;" label=${msg(str `Font family`)} value=${penbarText.fontFamily} @change=${this.handleFontFamilyChanged} id="font-family" > ${penbarText.fontFamilies.map((fontFamily) => 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=${msg(str `Font style`)} value=${penbarText.fontStyle} @change=${this.handleFontStyleChanged} id="font-style" > <sp-menu-item value="normal">${msg(str `normal`)}</sp-menu-item> <sp-menu-item value="italic">${msg(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">${msg(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) => html ` <sp-swatch color=${color} size="s"></sp-swatch> `)} </sp-swatch-group> `; } }; __decorate([ consume({ context: appStateContext, subscribe: true }) ], PenbarTextSettings.prototype, "appState", void 0); __decorate([ consume({ context: apiContext, subscribe: true }) ], PenbarTextSettings.prototype, "api", void 0); PenbarTextSettings = __decorate([ customElement('ic-spectrum-penbar-text-settings'), localized() ], PenbarTextSettings); export { PenbarTextSettings }; //# sourceMappingURL=penbar-text-settings.js.map