import { LitElement, html, property, customElement, query, css, CSSResult } from 'lit-element';
import { InkingToolbarButtonStyles } from './inking-toolbar-button-styles';
import { InkingToolbar } from "./inking-toolbar";
import * as Colors from "./colors";
@customElement('inking-toolbar-pen')
export class InkingToolbarPen extends LitElement {
@property({type: InkingToolbar}) private toolbar: InkingToolbar;
@query("button") private toolButton: HTMLButtonElement;
@property({type: CSSResult}) private toolColor = Colors.black.toString();
render() {
return html`
`;
}
constructor() {
super();
}
firstUpdated() {
// find parent inking toolbar
this.toolbar = this.shadowRoot.host.parentElement;
if (this.toolbar) {
// add this tool component to its parent toolbar
this.toolbar.addToolbarButton(this, "inking-toolbar-pen");
// update state of tool button for accessbility
let toolName = this.toolbar.getCurrentToolName();
this.toolbar.addEventListener("tool-changed", () => {
toolName = this.toolbar.getCurrentToolName();
this.toolButton.setAttribute("tabindex", toolName && toolName === "pen" ? "0" : "-1");
this.toolButton.setAttribute("aria-pressed", toolName && toolName === "pen" ? "0" : "-1");
}, false);
// update tool icon with chosen color
this.toolbar.addEventListener("color-changed", () => {
if (this.toolbar.getCurrentToolName() === "pen" )
this.toolColor = this.toolbar.getCurrentStrokeColor();
});
}
}
static get styles() {
return [
InkingToolbarButtonStyles
]
}
}
@customElement('inking-toolbar-pencil')
export class InkingToolbarPencil extends LitElement {
@property({type: InkingToolbar}) private toolbar: InkingToolbar;
@query("button") private toolButton: HTMLButtonElement;
@property({type: CSSResult}) private toolColor = Colors.black.toString();
render() {
return html`
`;
}
constructor() {
super();
}
firstUpdated() {
// find parent inking toolbar
this.toolbar = this.shadowRoot.host.parentElement;
if (this.toolbar) {
// add this tool component to its parent toolbar
this.toolbar.addToolbarButton(this, "inking-toolbar-pencil");
// update state of tool button for accessbility
let toolName = this.toolbar.getCurrentToolName();
this.toolbar.addEventListener("tool-changed", () => {
toolName = this.toolbar.getCurrentToolName();
this.toolButton.setAttribute("tabindex", toolName && toolName === "pencil" ? "0" : "-1");
this.toolButton.setAttribute("aria-pressed", toolName && toolName === "pencil" ? "0" : "-1");
}, false);
// update tool icon with chosen color
this.toolbar.addEventListener("color-changed", () => {
if (this.toolbar.getCurrentToolName() === "pencil" )
this.toolColor = this.toolbar.getCurrentStrokeColor();
});
}
}
static get styles() {
return [
InkingToolbarButtonStyles
]
}
}
@customElement('inking-toolbar-highlighter')
export class InkingToolbarHighlighter extends LitElement {
@property({type: InkingToolbar}) private toolbar: InkingToolbar;
@query("button") private toolButton: HTMLButtonElement;
@property({type: CSSResult}) private toolColor = Colors.yellow.toString();
render() {
return html`
`;
}
constructor() {
super();
}
firstUpdated() {
// find parent inking toolbar
this.toolbar = this.shadowRoot.host.parentElement;
if (this.toolbar) {
// add this tool component to its parent toolbar
this.toolbar.addToolbarButton(this, "inking-toolbar-highlighter");
// update state of tool button for accessbility
let toolName = this.toolbar.getCurrentToolName();
this.toolbar.addEventListener("tool-changed", () => {
toolName = this.toolbar.getCurrentToolName();
this.toolButton.setAttribute("tabindex", toolName && toolName === "highlighter" ? "0" : "-1");
this.toolButton.setAttribute("aria-pressed", toolName && toolName === "highlighter" ? "0" : "-1");
}, false);
// update tool icon with chosen color
this.toolbar.addEventListener("color-changed", () => {
if (this.toolbar.getCurrentToolName() === "highlighter" )
this.toolColor = this.toolbar.getCurrentStrokeColor();
});
}
}
static get styles() {
return [
InkingToolbarButtonStyles
]
}
}
@customElement('inking-toolbar-eraser')
export class InkingToolbarEraser extends LitElement {
@property({type: InkingToolbar}) private toolbar: InkingToolbar;
@query("button") private toolButton: HTMLButtonElement;
@property({type: CSSResult}) private toolColor = Colors.white.toString();
render() {
return html`
`;
}
constructor() {
super();
}
firstUpdated() {
// find parent inking toolbar
this.toolbar = this.shadowRoot.host.parentElement;
if (this.toolbar) {
// add this tool component to its parent toolbar
this.toolbar.addToolbarButton(this, "inking-toolbar-eraser");
// update state of tool button for accessbility
let toolName = this.toolbar.getCurrentToolName();
this.toolbar.addEventListener("tool-changed", () => {
toolName = this.toolbar.getCurrentToolName();
this.toolButton.setAttribute("tabindex", toolName && toolName === "eraser" ? "0" : "-1");
this.toolButton.setAttribute("aria-pressed", toolName && toolName === "eraser" ? "0" : "-1");
}, false);
// update tool icon with chosen color
this.toolbar.addEventListener("color-changed", () => {
if (this.toolbar.getCurrentToolName() === "eraser" )
this.toolColor = this.toolbar.getCurrentStrokeColor();
});
}
}
static get styles() {
return [
InkingToolbarButtonStyles
]
}
}
@customElement('inking-toolbar-copy')
export class InkingToolbarCopy extends LitElement {
@property({type: InkingToolbar}) private toolbar: InkingToolbar;
@query("button") private toolButton: HTMLButtonElement;
render() {
return html`
`;
}
constructor() {
super();
}
firstUpdated() {
// find parent inking toolbar
this.toolbar = this.shadowRoot.host.parentElement;
if (this.toolbar) {
// add this tool component to its parent toolbar
this.toolbar.addToolbarButton(this, "inking-toolbar-copy");
// update state of tool button for accessbility
let toolName = this.toolbar.getCurrentToolName();
this.toolbar.addEventListener("tool-changed", () => {
toolName = this.toolbar.getCurrentToolName();
this.toolButton.setAttribute("tabindex", toolName && toolName === "copy" ? "0" : "-1");
this.toolButton.setAttribute("aria-pressed", toolName && toolName === "copy" ? "0" : "-1");
}, false);
}
}
static get styles() {
return [
InkingToolbarButtonStyles
]
}
}
@customElement('inking-toolbar-save')
export class InkingToolbarSave extends LitElement {
@property({type: InkingToolbar}) private toolbar: InkingToolbar;
@query("button") private toolButton: HTMLButtonElement;
render() {
return html`
`;
}
constructor() {
super();
}
firstUpdated() {
// find parent inking toolbar
this.toolbar = this.shadowRoot.host.parentElement;
if (this.toolbar) {
// add this tool component to its parent toolbar
this.toolbar.addToolbarButton(this, "inking-toolbar-save");
// update state of tool button for accessbility
let toolName = this.toolbar.getCurrentToolName();
this.toolbar.addEventListener("tool-changed", () => {
toolName = this.toolbar.getCurrentToolName();
this.toolButton.setAttribute("tabindex", toolName && toolName === "save" ? "0" : "-1");
this.toolButton.setAttribute("aria-pressed", toolName && toolName === "save" ? "0" : "-1");
}, false);
}
}
static get styles() {
return [
InkingToolbarButtonStyles
]
}
}
@customElement('inking-toolbar-more')
export class InkingToolbarMore extends LitElement {
@property({type: InkingToolbar}) private toolbar: InkingToolbar;
@query("button") private toolButton: HTMLButtonElement;
render() {
return html`
`;
}
constructor() {
super();
}
firstUpdated() {
// find parent inking toolbar
this.toolbar = this.shadowRoot.host.parentElement;
if (this.toolbar) {
// add this tool component to its parent toolbar
this.toolbar.addToolbarButton(this, "inking-toolbar-more");
// update state of tool button for accessbility
let toolName = this.toolbar.getCurrentToolName();
this.toolbar.addEventListener("tool-changed", () => {
toolName = this.toolbar.getCurrentToolName();
this.toolButton.setAttribute("tabindex", toolName && toolName === "more" ? "0" : "-1");
this.toolButton.setAttribute("aria-pressed", toolName && toolName === "more" ? "0" : "-1");
}, false);
}
}
static get styles() {
return [
InkingToolbarButtonStyles
]
}
}